summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2017-12-11 13:07:40 +0100
committerandroid-build-team Robot <android-build-team-robot@google.com>2017-12-11 13:07:40 +0100
commit60548a22009f3860fc7e98696c42fa6731d0c84e (patch)
tree80fdd59466e67924dd5475dbefb404fb24a563e1
parentSnap for 4481641 from 1ab7bf47a60a39cc3d44fdac977e0a044cf06d8a to pi-release (diff)
parentMerge "applypatch: Remove the 'st' field from FileContents." am: 9203e77e7d am: 710712f235 (diff)
downloadandroid_bootable_recovery-60548a22009f3860fc7e98696c42fa6731d0c84e.tar
android_bootable_recovery-60548a22009f3860fc7e98696c42fa6731d0c84e.tar.gz
android_bootable_recovery-60548a22009f3860fc7e98696c42fa6731d0c84e.tar.bz2
android_bootable_recovery-60548a22009f3860fc7e98696c42fa6731d0c84e.tar.lz
android_bootable_recovery-60548a22009f3860fc7e98696c42fa6731d0c84e.tar.xz
android_bootable_recovery-60548a22009f3860fc7e98696c42fa6731d0c84e.tar.zst
android_bootable_recovery-60548a22009f3860fc7e98696c42fa6731d0c84e.zip
-rw-r--r--Android.mk2
-rw-r--r--applypatch/applypatch.cpp18
-rw-r--r--applypatch/include/applypatch/applypatch.h2
-rw-r--r--etc/init.rc1
-rw-r--r--roots.cpp19
-rw-r--r--updater/install.cpp9
6 files changed, 27 insertions, 24 deletions
diff --git a/Android.mk b/Android.mk
index 50627b9b9..54f405466 100644
--- a/Android.mk
+++ b/Android.mk
@@ -89,7 +89,7 @@ LOCAL_REQUIRED_MODULES := e2fsdroid_static mke2fs_static mke2fs.conf
ifeq ($(TARGET_USERIMAGES_USE_F2FS),true)
ifeq ($(HOST_OS),linux)
-LOCAL_REQUIRED_MODULES += mkfs.f2fs
+LOCAL_REQUIRED_MODULES += sload.f2fs mkfs.f2fs
endif
endif
diff --git a/applypatch/applypatch.cpp b/applypatch/applypatch.cpp
index 41a72eb15..04b964b17 100644
--- a/applypatch/applypatch.cpp
+++ b/applypatch/applypatch.cpp
@@ -58,12 +58,13 @@ int LoadFileContents(const char* filename, FileContents* 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));
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"));
if (!f) {
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);
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;
}
@@ -212,15 +209,6 @@ int SaveFileContents(const char* filename, const FileContents* file) {
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;
}
diff --git a/applypatch/include/applypatch/applypatch.h b/applypatch/include/applypatch/applypatch.h
index 6d7ffd78c..c8ad91505 100644
--- a/applypatch/include/applypatch/applypatch.h
+++ b/applypatch/include/applypatch/applypatch.h
@@ -18,7 +18,6 @@
#define _APPLYPATCH_H
#include <stdint.h>
-#include <sys/stat.h>
#include <functional>
#include <memory>
@@ -33,7 +32,6 @@ struct Value;
struct FileContents {
uint8_t sha1[SHA_DIGEST_LENGTH];
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,
diff --git a/etc/init.rc b/etc/init.rc
index d8121cc4e..0fc6c4c13 100644
--- a/etc/init.rc
+++ b/etc/init.rc
@@ -11,6 +11,7 @@ on init
export ANDROID_DATA /data
export EXTERNAL_STORAGE /sdcard
+ symlink /system/bin /bin
symlink /system/etc /etc
mount cgroup none /acct cpuacct
diff --git a/roots.cpp b/roots.cpp
index eb299ad6b..e2d5d6543 100644
--- a/roots.cpp
+++ b/roots.cpp
@@ -324,16 +324,23 @@ int format_volume(const char* volume, const char* directory) {
}
// Has to be f2fs because we checked earlier.
- std::vector<std::string> f2fs_args = { "/sbin/mkfs.f2fs", "-d1", "-f",
- "-O", "encrypt", "-O", "quota",
- v->blk_device };
+ std::string cmd("/sbin/mkfs.f2fs");
+ std::vector<std::string> make_f2fs_cmd = { cmd, "-d1", "-f", "-O",
+ "encrypt", "-O", "quota", v->blk_device };
if (length >= 512) {
- f2fs_args.push_back(std::to_string(length / 512));
+ make_f2fs_cmd.push_back(std::to_string(length / 512));
}
- int result = exec_cmd(f2fs_args);
+ int result = exec_cmd(make_f2fs_cmd);
+ if (result == 0 && directory != nullptr) {
+ cmd = "/sbin/sload.f2fs";
+ std::vector<std::string> sload_f2fs_cmd = {
+ cmd, "-f", directory, "-t", volume, v->blk_device,
+ };
+ result = exec_cmd(sload_f2fs_cmd);
+ }
if (result != 0) {
- PLOG(ERROR) << "format_volume: Failed to make f2fs on " << v->blk_device;
+ PLOG(ERROR) << "format_volume: Failed " << cmd << " on " << v->blk_device;
return -1;
}
return 0;
diff --git a/updater/install.cpp b/updater/install.cpp
index 870b85791..b83d30ff3 100644
--- a/updater/install.cpp
+++ b/updater/install.cpp
@@ -318,6 +318,15 @@ Value* FormatFn(const char* name, State* state, const std::vector<std::unique_pt
LOG(ERROR) << name << ": mkfs.f2fs failed (" << status << ") on " << location;
return StringValue("");
}
+
+ const char* sload_argv[] = { "/sbin/sload.f2fs", "-t", mount_point.c_str(), location.c_str(),
+ nullptr };
+ status = exec_cmd(sload_argv[0], const_cast<char**>(sload_argv));
+ if (status != 0) {
+ LOG(ERROR) << name << ": sload.f2fs failed (" << status << ") on " << location;
+ return StringValue("");
+ }
+
return StringValue(location);
} else {
LOG(ERROR) << name << ": unsupported fs_type \"" << fs_type << "\" partition_type \""