summaryrefslogtreecommitdiffstats
path: root/recovery.cpp
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2017-07-31 02:15:43 +0200
committerandroid-build-merger <android-build-merger@google.com>2017-07-31 02:15:43 +0200
commit5507c3d63ca44dfc5d57165a5e0370fb9995ddfe (patch)
tree7ed09e43bbafe166fc70f706f7c1ee70d297255f /recovery.cpp
parentMerge "Add more specific error codes for uncrypt failures" (diff)
parentMerge "otautil: Clean up dirCreateHierarchy()." (diff)
downloadandroid_bootable_recovery-5507c3d63ca44dfc5d57165a5e0370fb9995ddfe.tar
android_bootable_recovery-5507c3d63ca44dfc5d57165a5e0370fb9995ddfe.tar.gz
android_bootable_recovery-5507c3d63ca44dfc5d57165a5e0370fb9995ddfe.tar.bz2
android_bootable_recovery-5507c3d63ca44dfc5d57165a5e0370fb9995ddfe.tar.lz
android_bootable_recovery-5507c3d63ca44dfc5d57165a5e0370fb9995ddfe.tar.xz
android_bootable_recovery-5507c3d63ca44dfc5d57165a5e0370fb9995ddfe.tar.zst
android_bootable_recovery-5507c3d63ca44dfc5d57165a5e0370fb9995ddfe.zip
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 8f08c53f4..9abb9341c 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -179,19 +179,19 @@ struct selabel_handle* sehandle;
* 7b. the user reboots (pulling the battery, etc) into the main system
*/
-// open a given path, mounting partitions as necessary
-FILE* fopen_path(const char *path, const char *mode) {
- if (ensure_path_mounted(path) != 0) {
- LOG(ERROR) << "Can't mount " << path;
- return NULL;
- }
-
- // When writing, try to create the containing directory, if necessary.
- // Use generous permissions, the system (init.rc) will reset them.
- if (strchr("wa", mode[0])) dirCreateHierarchy(path, 0777, NULL, 1, sehandle);
+// Open a given path, mounting partitions as necessary.
+FILE* fopen_path(const char* path, const char* mode) {
+ if (ensure_path_mounted(path) != 0) {
+ LOG(ERROR) << "Can't mount " << path;
+ return nullptr;
+ }
- FILE *fp = fopen(path, mode);
- return fp;
+ // When writing, try to create the containing directory, if necessary. Use generous permissions,
+ // the system (init.rc) will reset them.
+ if (strchr("wa", mode[0])) {
+ mkdir_recursively(path, 0777, true, sehandle);
+ }
+ return fopen(path, mode);
}
// close a file, log an error if the error indicator is set
@@ -594,7 +594,7 @@ static bool erase_volume(const char* volume) {
if (is_cache) {
// Re-create the log dir and write back the log entries.
if (ensure_path_mounted(CACHE_LOG_DIR) == 0 &&
- dirCreateHierarchy(CACHE_LOG_DIR, 0777, nullptr, false, sehandle) == 0) {
+ mkdir_recursively(CACHE_LOG_DIR, 0777, false, sehandle) == 0) {
for (const auto& log : log_files) {
if (!android::base::WriteStringToFile(log.data, log.name, log.sb.st_mode, log.sb.st_uid,
log.sb.st_gid)) {