aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--applypatch/applypatch.cpp18
-rw-r--r--applypatch/include/applypatch/applypatch.h2
2 files changed, 3 insertions, 17 deletions
diff --git a/applypatch/applypatch.cpp b/applypatch/applypatch.cpp
index 41a72eb1..04b964b1 100644
--- a/applypatch/applypatch.cpp
+++ b/applypatch/applypatch.cpp
@@ -58,12 +58,13 @@ int LoadFileContents(const char* filename, FileContents* file) {
58 return LoadPartitionContents(filename, file); 58 return LoadPartitionContents(filename, file);
59 } 59 }
60 60
61 if (stat(filename, &file->st) == -1) { 61 struct stat sb;
62 if (stat(filename, &sb) == -1) {
62 printf("failed to stat \"%s\": %s\n", filename, strerror(errno)); 63 printf("failed to stat \"%s\": %s\n", filename, strerror(errno));
63 return -1; 64 return -1;
64 } 65 }
65 66
66 std::vector<unsigned char> data(file->st.st_size); 67 std::vector<unsigned char> data(sb.st_size);
67 unique_file f(ota_fopen(filename, "rb")); 68 unique_file f(ota_fopen(filename, "rb"));
68 if (!f) { 69 if (!f) {
69 printf("failed to open \"%s\": %s\n", filename, strerror(errno)); 70 printf("failed to open \"%s\": %s\n", filename, strerror(errno));
@@ -180,10 +181,6 @@ static int LoadPartitionContents(const std::string& filename, FileContents* file
180 181
181 buffer.resize(buffer_size); 182 buffer.resize(buffer_size);
182 file->data = std::move(buffer); 183 file->data = std::move(buffer);
183 // Fake some stat() info.
184 file->st.st_mode = 0644;
185 file->st.st_uid = 0;
186 file->st.st_gid = 0;
187 184
188 return 0; 185 return 0;
189} 186}
@@ -212,15 +209,6 @@ int SaveFileContents(const char* filename, const FileContents* file) {
212 return -1; 209 return -1;
213 } 210 }
214 211
215 if (chmod(filename, file->st.st_mode) != 0) {
216 printf("chmod of \"%s\" failed: %s\n", filename, strerror(errno));
217 return -1;
218 }
219 if (chown(filename, file->st.st_uid, file->st.st_gid) != 0) {
220 printf("chown of \"%s\" failed: %s\n", filename, strerror(errno));
221 return -1;
222 }
223
224 return 0; 212 return 0;
225} 213}
226 214
diff --git a/applypatch/include/applypatch/applypatch.h b/applypatch/include/applypatch/applypatch.h
index 6d7ffd78..c8ad9150 100644
--- a/applypatch/include/applypatch/applypatch.h
+++ b/applypatch/include/applypatch/applypatch.h
@@ -18,7 +18,6 @@
18#define _APPLYPATCH_H 18#define _APPLYPATCH_H
19 19
20#include <stdint.h> 20#include <stdint.h>
21#include <sys/stat.h>
22 21
23#include <functional> 22#include <functional>
24#include <memory> 23#include <memory>
@@ -33,7 +32,6 @@ struct Value;
33struct FileContents { 32struct FileContents {
34 uint8_t sha1[SHA_DIGEST_LENGTH]; 33 uint8_t sha1[SHA_DIGEST_LENGTH];
35 std::vector<unsigned char> data; 34 std::vector<unsigned char> data;
36 struct stat st;
37}; 35};
38 36
39// When there isn't enough room on the target filesystem to hold the patched version of the file, 37// When there isn't enough room on the target filesystem to hold the patched version of the file,