blob: 5c90397194d07d1278027da21c60708e27431631 [file] [log] [blame]
Brad Bishop316dfdd2018-06-25 12:45:53 -04001From aa669312a380611d280d126cb509fa282080707e Mon Sep 17 00:00:00 2001
2From: Markus Mayer <mmayer@mmayer.net>
3Date: Wed, 7 Sep 2016 12:58:47 +0300
4Subject: [PATCH] android-tools: add recipe from AOSP tag android-5.1.1_r37
5
Patrick Williamsddad1a12017-02-23 20:36:32 -06006Description: add -o argument to preserve ownership
Patrick Williamsddad1a12017-02-23 20:36:32 -06007
8See also https://android-review.googlesource.com/#/c/100312/
9
10Upstream-Status: Inappropriate
Brad Bishop316dfdd2018-06-25 12:45:53 -040011
Patrick Williamsddad1a12017-02-23 20:36:32 -060012---
Brad Bishop316dfdd2018-06-25 12:45:53 -040013 ext4_utils/make_ext4fs.c | 6 ++++++
14 ext4_utils/make_ext4fs_main.c | 10 ++++++++--
Patrick Williamsddad1a12017-02-23 20:36:32 -060015 2 files changed, 14 insertions(+), 2 deletions(-)
16
Brad Bishop316dfdd2018-06-25 12:45:53 -040017diff --git a/ext4_utils/make_ext4fs.c b/ext4_utils/make_ext4fs.c
18index 2f89ae8a..cc41d623 100644
19--- a/ext4_utils/make_ext4fs.c
20+++ b/ext4_utils/make_ext4fs.c
21@@ -68,6 +68,8 @@
Patrick Williamsddad1a12017-02-23 20:36:32 -060022
Brad Bishop316dfdd2018-06-25 12:45:53 -040023 #endif
24
25+int preserve_owner = 0;
26+
27 /* TODO: Not implemented:
28 Allocating blocks in the same block group as the file inode
29 Hash or binary tree directories
30@@ -186,6 +188,10 @@ static u32 build_directory_structure(const char *full_path, const char *dir_path
31 } else {
32 dentries[i].mtime = fixed_time;
33 }
34+ if (preserve_owner) {
35+ dentries[i].uid = stat.st_uid;
36+ dentries[i].gid = stat.st_gid;
37+ }
38 uint64_t capabilities;
39 if (fs_config_func != NULL) {
40 #ifdef ANDROID
41diff --git a/ext4_utils/make_ext4fs_main.c b/ext4_utils/make_ext4fs_main.c
42index a6c5f616..7af0dddf 100644
43--- a/ext4_utils/make_ext4fs_main.c
44+++ b/ext4_utils/make_ext4fs_main.c
45@@ -48,13 +48,15 @@ struct selabel_handle;
46 extern struct fs_info info;
47
Patrick Williamsddad1a12017-02-23 20:36:32 -060048
49+extern int preserve_owner;
50+
51 static void usage(char *path)
52 {
53 fprintf(stderr, "%s [ -l <len> ] [ -j <journal size> ] [ -b <block_size> ]\n", basename(path));
54 fprintf(stderr, " [ -g <blocks per group> ] [ -i <inodes> ] [ -I <inode size> ]\n");
55 fprintf(stderr, " [ -L <label> ] [ -f ] [ -a <android mountpoint> ]\n");
56 fprintf(stderr, " [ -S file_contexts ] [ -C fs_config ] [ -T timestamp ]\n");
57- fprintf(stderr, " [ -z | -s ] [ -w ] [ -c ] [ -J ] [ -v ] [ -B <block_list_file> ]\n");
58+ fprintf(stderr, " [ -z | -s ] [ -w ] [ -c ] [ -J ] [ -o ] [ -v ] [ -B <block_list_file> ]\n");
59 fprintf(stderr, " <filename> [<directory>]\n");
60 }
61
Brad Bishop316dfdd2018-06-25 12:45:53 -040062@@ -80,7 +82,7 @@ int main(int argc, char **argv)
Patrick Williamsddad1a12017-02-23 20:36:32 -060063 struct selinux_opt seopts[] = { { SELABEL_OPT_PATH, "" } };
64 #endif
65
66- while ((opt = getopt(argc, argv, "l:j:b:g:i:I:L:a:S:T:C:B:fwzJsctv")) != -1) {
67+ while ((opt = getopt(argc, argv, "l:j:b:g:i:I:L:a:S:T:C:B:fwzJsctov")) != -1) {
68 switch (opt) {
69 case 'l':
70 info.len = parse_num(optarg);
Brad Bishop316dfdd2018-06-25 12:45:53 -040071@@ -143,6 +145,10 @@ int main(int argc, char **argv)
Patrick Williamsddad1a12017-02-23 20:36:32 -060072 }
73 #endif
74 break;
75+ case 'o':
76+ preserve_owner = 1;
77+ printf("Warning: Enabling 'preserve ownership', this is an unofficial feature!\n");
78+ break;
79 case 'v':
80 verbose = 1;
81 break;