aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTao Bao2017-07-23 02:01:02 -0500
committerTao Bao2017-07-27 12:33:07 -0500
commitac3d1edca0ea91a192c3a9d52efbc439702e9cae (patch)
tree8c7457049a412ddd565103f8d48557adadf17f0c /recovery.cpp
parent231c627a5527b92ae3d043e454e949cdfc4f38ea (diff)
downloadplatform-bootable-recovery-ac3d1edca0ea91a192c3a9d52efbc439702e9cae.tar.gz
platform-bootable-recovery-ac3d1edca0ea91a192c3a9d52efbc439702e9cae.tar.xz
platform-bootable-recovery-ac3d1edca0ea91a192c3a9d52efbc439702e9cae.zip
otautil: Clean up dirCreateHierarchy().
- Changed to std::string based implementation (mostly moved from the former make_parents() in updater/install.cpp); - Removed the timestamp parameter, which is only neeed by file-based OTA; - Changed the type of mode from int to mode_t; - Renamed dirCreateHierarchy() to mkdir_recursively(). Test: recovery_unit_test passes. Test: No external user of dirCreateHierarchy() in code search. Change-Id: I71f8c4b29bab625513bbc3af6d0d1ecdc3a2719a
Diffstat (limited to 'recovery.cpp')
-rw-r--r--recovery.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/recovery.cpp b/recovery.cpp
index 8f3e9bde..233e5624 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -178,19 +178,19 @@ struct selabel_handle* sehandle;
178 * 7b. the user reboots (pulling the battery, etc) into the main system 178 * 7b. the user reboots (pulling the battery, etc) into the main system
179 */ 179 */
180 180
181// open a given path, mounting partitions as necessary 181// Open a given path, mounting partitions as necessary.
182FILE* fopen_path(const char *path, const char *mode) { 182FILE* fopen_path(const char* path, const char* mode) {
183 if (ensure_path_mounted(path) != 0) { 183 if (ensure_path_mounted(path) != 0) {
184 LOG(ERROR) << "Can't mount " << path; 184 LOG(ERROR) << "Can't mount " << path;
185 return NULL; 185 return nullptr;
186 } 186 }
187
188 // When writing, try to create the containing directory, if necessary.
189 // Use generous permissions, the system (init.rc) will reset them.
190 if (strchr("wa", mode[0])) dirCreateHierarchy(path, 0777, NULL, 1, sehandle);
191 187
192 FILE *fp = fopen(path, mode); 188 // When writing, try to create the containing directory, if necessary. Use generous permissions,
193 return fp; 189 // the system (init.rc) will reset them.
190 if (strchr("wa", mode[0])) {
191 mkdir_recursively(path, 0777, true, sehandle);
192 }
193 return fopen(path, mode);
194} 194}
195 195
196// close a file, log an error if the error indicator is set 196// close a file, log an error if the error indicator is set
@@ -593,7 +593,7 @@ static bool erase_volume(const char* volume) {
593 if (is_cache) { 593 if (is_cache) {
594 // Re-create the log dir and write back the log entries. 594 // Re-create the log dir and write back the log entries.
595 if (ensure_path_mounted(CACHE_LOG_DIR) == 0 && 595 if (ensure_path_mounted(CACHE_LOG_DIR) == 0 &&
596 dirCreateHierarchy(CACHE_LOG_DIR, 0777, nullptr, false, sehandle) == 0) { 596 mkdir_recursively(CACHE_LOG_DIR, 0777, false, sehandle) == 0) {
597 for (const auto& log : log_files) { 597 for (const auto& log : log_files) {
598 if (!android::base::WriteStringToFile(log.data, log.name, log.sb.st_mode, log.sb.st_uid, 598 if (!android::base::WriteStringToFile(log.data, log.name, log.sb.st_mode, log.sb.st_uid,
599 log.sb.st_gid)) { 599 log.sb.st_gid)) {