aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTao Bao2017-07-30 19:15:43 -0500
committerandroid-build-merger2017-07-30 19:15:43 -0500
commit5507c3d63ca44dfc5d57165a5e0370fb9995ddfe (patch)
tree7ed09e43bbafe166fc70f706f7c1ee70d297255f /recovery.cpp
parent6f3053522989f01ab8c294317f35ebbadbb4b11e (diff)
parent610712101bb1618629cb7c5dd1570b71b9aaa5ab (diff)
downloadplatform-bootable-recovery-5507c3d63ca44dfc5d57165a5e0370fb9995ddfe.tar.gz
platform-bootable-recovery-5507c3d63ca44dfc5d57165a5e0370fb9995ddfe.tar.xz
platform-bootable-recovery-5507c3d63ca44dfc5d57165a5e0370fb9995ddfe.zip
Merge "otautil: Clean up dirCreateHierarchy()."
am: 610712101b Change-Id: I95350c4b2aab36dd89ea7813f2eb63d407b5f8ac
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 8f08c53f..9abb9341 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -179,19 +179,19 @@ struct selabel_handle* sehandle;
179 * 7b. the user reboots (pulling the battery, etc) into the main system 179 * 7b. the user reboots (pulling the battery, etc) into the main system
180 */ 180 */
181 181
182// open a given path, mounting partitions as necessary 182// Open a given path, mounting partitions as necessary.
183FILE* fopen_path(const char *path, const char *mode) { 183FILE* fopen_path(const char* path, const char* mode) {
184 if (ensure_path_mounted(path) != 0) { 184 if (ensure_path_mounted(path) != 0) {
185 LOG(ERROR) << "Can't mount " << path; 185 LOG(ERROR) << "Can't mount " << path;
186 return NULL; 186 return nullptr;
187 } 187 }
188
189 // When writing, try to create the containing directory, if necessary.
190 // Use generous permissions, the system (init.rc) will reset them.
191 if (strchr("wa", mode[0])) dirCreateHierarchy(path, 0777, NULL, 1, sehandle);
192 188
193 FILE *fp = fopen(path, mode); 189 // When writing, try to create the containing directory, if necessary. Use generous permissions,
194 return fp; 190 // the system (init.rc) will reset them.
191 if (strchr("wa", mode[0])) {
192 mkdir_recursively(path, 0777, true, sehandle);
193 }
194 return fopen(path, mode);
195} 195}
196 196
197// close a file, log an error if the error indicator is set 197// close a file, log an error if the error indicator is set
@@ -594,7 +594,7 @@ static bool erase_volume(const char* volume) {
594 if (is_cache) { 594 if (is_cache) {
595 // Re-create the log dir and write back the log entries. 595 // Re-create the log dir and write back the log entries.
596 if (ensure_path_mounted(CACHE_LOG_DIR) == 0 && 596 if (ensure_path_mounted(CACHE_LOG_DIR) == 0 &&
597 dirCreateHierarchy(CACHE_LOG_DIR, 0777, nullptr, false, sehandle) == 0) { 597 mkdir_recursively(CACHE_LOG_DIR, 0777, false, sehandle) == 0) {
598 for (const auto& log : log_files) { 598 for (const auto& log : log_files) {
599 if (!android::base::WriteStringToFile(log.data, log.name, log.sb.st_mode, log.sb.st_uid, 599 if (!android::base::WriteStringToFile(log.data, log.name, log.sb.st_mode, log.sb.st_uid,
600 log.sb.st_gid)) { 600 log.sb.st_gid)) {