diff options
author | Stephen Smalley <sds@tycho.nsa.gov> | 2012-02-09 14:19:24 -0500 |
---|---|---|
committer | Stephen Smalley <sds@tycho.nsa.gov> | 2012-03-30 09:21:34 -0400 |
commit | 6ece70806883534d29a74b9785871505f71ecc1f (patch) | |
tree | 9d9a6cf666687897a0a8c2be17c48b118f7e6d43 | |
parent | b4eca4b24af9c80ebb2a7fa2ba539a48096b7576 (diff) | |
download | extras-6ece70806883534d29a74b9785871505f71ecc1f.tar.gz |
Extend make_ext4fs() interface to allow callers to pass selabel_handle.
Extend make_ext4fs() to allow callers to pass an selabel_handle for
labeling files in the ext4 image. Previously, this was only done
via the _internal() function. This extends the library interface
so that it can be used by the recovery and updater code for labeling
files from OTA and update packages.
Change-Id: I4f6755fe7c65b69587276d17ef5b971ebec0161f
-rw-r--r-- | ext4_utils/make_ext4fs.c | 16 | ||||
-rw-r--r-- | ext4_utils/make_ext4fs.h | 6 |
2 files changed, 16 insertions, 6 deletions
diff --git a/ext4_utils/make_ext4fs.c b/ext4_utils/make_ext4fs.c index 26068e69..af05eb31 100644 --- a/ext4_utils/make_ext4fs.c +++ b/ext4_utils/make_ext4fs.c @@ -266,15 +266,17 @@ void reset_ext4fs_info() { free_data_blocks(); } -int make_ext4fs(const char *filename, s64 len) +int make_ext4fs(const char *filename, s64 len, + const char *mountpoint, struct selabel_handle *sehnd) { reset_ext4fs_info(); info.len = len; - return make_ext4fs_internal(filename, NULL, NULL, 0, 0, 0, 0, 1, 0, 0); + return make_ext4fs_internal(filename, NULL, mountpoint, 0, 0, 0, 0, 1, 0, sehnd); } int make_ext4fs_internal(const char *filename, const char *directory, - char *mountpoint, int android, int gzip, int sparse, + const char *mountpoint, + int android, int gzip, int sparse, int crc, int wipe, int init_itabs, struct selabel_handle *sehnd) { @@ -374,7 +376,13 @@ int make_ext4fs_internal(const char *filename, const char *directory, if (sehnd) { char *sepath = NULL; char *secontext = NULL; - asprintf(&sepath, "/%s", mountpoint); + + if (mountpoint[0] == '/') + sepath = strdup(mountpoint); + else + asprintf(&sepath, "/%s", mountpoint); + if (!sepath) + critical_error_errno("malloc"); if (selabel_lookup(sehnd, &secontext, sepath, S_IFDIR) < 0) { error("cannot lookup security context for %s", sepath); } diff --git a/ext4_utils/make_ext4fs.h b/ext4_utils/make_ext4fs.h index 1f10bbff..53ff8401 100644 --- a/ext4_utils/make_ext4fs.h +++ b/ext4_utils/make_ext4fs.h @@ -28,9 +28,11 @@ struct selabel_handle; #endif void reset_ext4fs_info(); -int make_ext4fs(const char *filename, s64 len); +int make_ext4fs(const char *filename, s64 len, + const char *mountpoint, struct selabel_handle *sehnd); int make_ext4fs_internal(const char *filename, const char *directory, - char *mountpoint, int android, int gzip, int sparse, + const char *mountpoint, + int android, int gzip, int sparse, int crc, int wipe, int init_itabs, struct selabel_handle *sehnd); |