Merge "applypatch: Remove the 'st' field from FileContents." am: 9203e77e7d
am: 710712f235
Change-Id: I7c51478f551994a5f8914757890a216b663901da
This commit is contained in:
@@ -58,12 +58,13 @@ int LoadFileContents(const char* filename, FileContents* file) {
|
|||||||
return LoadPartitionContents(filename, file);
|
return LoadPartitionContents(filename, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stat(filename, &file->st) == -1) {
|
struct stat sb;
|
||||||
|
if (stat(filename, &sb) == -1) {
|
||||||
printf("failed to stat \"%s\": %s\n", filename, strerror(errno));
|
printf("failed to stat \"%s\": %s\n", filename, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<unsigned char> data(file->st.st_size);
|
std::vector<unsigned char> data(sb.st_size);
|
||||||
unique_file f(ota_fopen(filename, "rb"));
|
unique_file f(ota_fopen(filename, "rb"));
|
||||||
if (!f) {
|
if (!f) {
|
||||||
printf("failed to open \"%s\": %s\n", filename, strerror(errno));
|
printf("failed to open \"%s\": %s\n", filename, strerror(errno));
|
||||||
@@ -180,10 +181,6 @@ static int LoadPartitionContents(const std::string& filename, FileContents* file
|
|||||||
|
|
||||||
buffer.resize(buffer_size);
|
buffer.resize(buffer_size);
|
||||||
file->data = std::move(buffer);
|
file->data = std::move(buffer);
|
||||||
// Fake some stat() info.
|
|
||||||
file->st.st_mode = 0644;
|
|
||||||
file->st.st_uid = 0;
|
|
||||||
file->st.st_gid = 0;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -212,15 +209,6 @@ int SaveFileContents(const char* filename, const FileContents* file) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chmod(filename, file->st.st_mode) != 0) {
|
|
||||||
printf("chmod of \"%s\" failed: %s\n", filename, strerror(errno));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (chown(filename, file->st.st_uid, file->st.st_gid) != 0) {
|
|
||||||
printf("chown of \"%s\" failed: %s\n", filename, strerror(errno));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
#define _APPLYPATCH_H
|
#define _APPLYPATCH_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <sys/stat.h>
|
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@@ -33,7 +32,6 @@ struct Value;
|
|||||||
struct FileContents {
|
struct FileContents {
|
||||||
uint8_t sha1[SHA_DIGEST_LENGTH];
|
uint8_t sha1[SHA_DIGEST_LENGTH];
|
||||||
std::vector<unsigned char> data;
|
std::vector<unsigned char> data;
|
||||||
struct stat st;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// When there isn't enough room on the target filesystem to hold the patched version of the file,
|
// When there isn't enough room on the target filesystem to hold the patched version of the file,
|
||||||
|
|||||||
Reference in New Issue
Block a user