From b9254539811ce912bfd16dd1d185eba7a10cceff Mon Sep 17 00:00:00 2001 From: Markus Mayer Date: Wed, 7 Sep 2016 12:58:47 +0300 Subject: [PATCH] ext4_utils: add -o argument to preserve ownership See also https://android-review.googlesource.com/#/c/100312/ Upstream-Status: Inappropriate --- ext4_utils/make_ext4fs.c | 6 ++++++ ext4_utils/make_ext4fs_main.c | 10 ++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ext4_utils/make_ext4fs.c b/ext4_utils/make_ext4fs.c index 732afbed7..2cbf04399 100644 --- a/ext4_utils/make_ext4fs.c +++ b/ext4_utils/make_ext4fs.c @@ -67,6 +67,8 @@ #endif +int preserve_owner = 0; + /* TODO: Not implemented: Allocating blocks in the same block group as the file inode Hash or binary tree directories @@ -185,6 +187,10 @@ static u32 build_directory_structure(const char *full_path, const char *dir_path } else { dentries[i].mtime = fixed_time; } + if (preserve_owner) { + dentries[i].uid = stat.st_uid; + dentries[i].gid = stat.st_gid; + } uint64_t capabilities; if (fs_config_func != NULL) { #ifdef ANDROID diff --git a/ext4_utils/make_ext4fs_main.c b/ext4_utils/make_ext4fs_main.c index f8e7b9da9..e82d43277 100644 --- a/ext4_utils/make_ext4fs_main.c +++ b/ext4_utils/make_ext4fs_main.c @@ -47,13 +47,15 @@ struct selabel_handle; extern struct fs_info info; +extern int preserve_owner; + static void usage(char *path) { fprintf(stderr, "%s [ -l ] [ -j ] [ -b ]\n", basename(path)); fprintf(stderr, " [ -g ] [ -i ] [ -I ]\n"); fprintf(stderr, " [ -L