aboutsummaryrefslogtreecommitdiffstats
path: root/updater/install.c
diff options
context:
space:
mode:
authorKenny Root <kroot@google.com>2012-03-30 20:48:34 -0700
committerKenny Root <kroot@google.com>2012-03-30 21:26:01 -0700
commit41dda82d847ae8c261b09c383806b412d680f935 (patch)
tree98edeec4fa5d9df2d0104624d66b1608cecdaf50 /updater/install.c
parentb2364342a05a689bc302bfcd7d5d15f528eb772c (diff)
parent0b1fee1b2aa7da86ffdabfe4c577ee8adb93d803 (diff)
downloadbootable_recovery-41dda82d847ae8c261b09c383806b412d680f935.zip
bootable_recovery-41dda82d847ae8c261b09c383806b412d680f935.tar.gz
bootable_recovery-41dda82d847ae8c261b09c383806b412d680f935.tar.bz2
resolved conflicts for merge of 0b1fee1b to master
Change-Id: I2e8298ff5988a96754f56f80a5186c9605ad9928
Diffstat (limited to 'updater/install.c')
-rw-r--r--updater/install.c46
1 files changed, 39 insertions, 7 deletions
diff --git a/updater/install.c b/updater/install.c
index 7b7bfc9..31f08b8 100644
--- a/updater/install.c
+++ b/updater/install.c
@@ -78,8 +78,24 @@ Value* MountFn(const char* name, State* state, int argc, Expr* argv[]) {
goto done;
}
+#ifdef HAVE_SELINUX
+ char *secontext = NULL;
+
+ if (sehandle) {
+ selabel_lookup(sehandle, &secontext, mount_point, 0755);
+ setfscreatecon(secontext);
+ }
+#endif
+
mkdir(mount_point, 0755);
+#ifdef HAVE_SELINUX
+ if (secontext) {
+ freecon(secontext);
+ setfscreatecon(NULL);
+ }
+#endif
+
if (strcmp(partition_type, "MTD") == 0) {
mtd_scan_partitions();
const MtdPartition* mtd;
@@ -176,25 +192,34 @@ done:
}
-// format(fs_type, partition_type, location, fs_size)
+// format(fs_type, partition_type, location, fs_size, mount_point)
//
-// fs_type="yaffs2" partition_type="MTD" location=partition fs_size=<bytes>
-// fs_type="ext4" partition_type="EMMC" location=device fs_size=<bytes>
+// fs_type="yaffs2" partition_type="MTD" location=partition fs_size=<bytes> mount_point=<location>
+// fs_type="ext4" partition_type="EMMC" location=device fs_size=<bytes> mount_point=<location>
// if fs_size == 0, then make_ext4fs uses the entire partition.
// if fs_size > 0, that is the size to use
// if fs_size < 0, then reserve that many bytes at the end of the partition
+// mount_point is used with SELinux as the location of the mount point, absent otherwise
Value* FormatFn(const char* name, State* state, int argc, Expr* argv[]) {
char* result = NULL;
- if (argc != 4) {
- return ErrorAbort(state, "%s() expects 4 args, got %d", name, argc);
+ if (argc != 4 && argc != 5) {
+ return ErrorAbort(state, "%s() expects 4 or 5 args, got %d", name, argc);
}
char* fs_type;
char* partition_type;
char* location;
char* fs_size;
+ char* mount_point = NULL;
+
+#ifdef HAVE_SELINUX
+ if (ReadArgs(state, argv, 5, &fs_type, &partition_type, &location, &fs_size, &mount_point) < 0) {
+ return NULL;
+ }
+#else
if (ReadArgs(state, argv, 4, &fs_type, &partition_type, &location, &fs_size) < 0) {
return NULL;
}
+#endif
if (strlen(fs_type) == 0) {
ErrorAbort(state, "fs_type argument to %s() can't be empty", name);
@@ -210,6 +235,13 @@ Value* FormatFn(const char* name, State* state, int argc, Expr* argv[]) {
goto done;
}
+#ifdef HAVE_SELINUX
+ if (!mount_point || strlen(mount_point) == 0) {
+ ErrorAbort(state, "mount_point argument to %s() can't be empty", name);
+ goto done;
+ }
+#endif
+
if (strcmp(partition_type, "MTD") == 0) {
mtd_scan_partitions();
const MtdPartition* mtd = mtd_find_partition_by_name(location);
@@ -239,7 +271,7 @@ Value* FormatFn(const char* name, State* state, int argc, Expr* argv[]) {
result = location;
#ifdef USE_EXT4
} else if (strcmp(fs_type, "ext4") == 0) {
- int status = make_ext4fs(location, atoll(fs_size));
+ int status = make_ext4fs(location, atoll(fs_size), mount_point, sehandle);
if (status != 0) {
fprintf(stderr, "%s: make_ext4fs failed (%d) on %s",
name, status, location);
@@ -346,7 +378,7 @@ Value* PackageExtractDirFn(const char* name, State* state,
bool success = mzExtractRecursive(za, zip_path, dest_path,
MZ_EXTRACT_FILES_ONLY, &timestamp,
- NULL, NULL);
+ NULL, NULL, sehandle);
free(zip_path);
free(dest_path);
return StringValue(strdup(success ? "t" : ""));