From 24499bb9a5d2064b9bbb95b889633f643591dbaf Mon Sep 17 00:00:00 2001 From: Yu Yezhong Date: Tue, 11 Apr 2017 16:25:36 +0800 Subject: [PATCH] add macro CFIG_NO_FIX_STAT to disable fix_stat() for mkbootfs just in case some geeks do not want the "fix stat" behavior of Android cpio, a.k.a mkbootfs. Test: original attributes: drw------- 2 yu yu 4.0K 2017-04-11 16:43 T1 drwxrwxrwx 2 yu yu 4.0K 2017-04-11 16:43 T2 generated boot image w/ fix_stat(): drwxr-xr-x 2 root root 0 1969-12-31 18:00 T1 drwxr-xr-x 2 root root 0 1969-12-31 18:00 T2 define CFIG_NO_FIX_STAT and disable fix_stat(): drw------- 2 root root 0 1969-12-31 18:00 T1 drwxrwxrwx 2 root root 0 1969-12-31 18:00 T2 --- build.gradle | 1 + src/mkbootfs/c/fs_config.c | 3 +++ src/mkbootfs/c/mkbootfs.c | 6 ++++++ 3 files changed, 10 insertions(+) diff --git a/build.gradle b/build.gradle index ff71413..9ccd272 100644 --- a/build.gradle +++ b/build.gradle @@ -23,6 +23,7 @@ model { components { mkbootfs(NativeExecutableSpec) { binaries.all { + // cCompiler.define 'CFIG_NO_FIX_STAT' } } } diff --git a/src/mkbootfs/c/fs_config.c b/src/mkbootfs/c/fs_config.c index 547e873..2163bf6 100644 --- a/src/mkbootfs/c/fs_config.c +++ b/src/mkbootfs/c/fs_config.c @@ -33,6 +33,8 @@ #include #include +#ifndef CFIG_NO_FIX_STAT + #include #include @@ -293,3 +295,4 @@ ssize_t fs_config_generate(char *buffer, size_t length, const struct fs_path_con strcpy(p->prefix, pc->prefix); return len; } +#endif diff --git a/src/mkbootfs/c/mkbootfs.c b/src/mkbootfs/c/mkbootfs.c index 0e35323..7e56de8 100644 --- a/src/mkbootfs/c/mkbootfs.c +++ b/src/mkbootfs/c/mkbootfs.c @@ -12,7 +12,9 @@ #include #include +#ifndef CFIG_NO_FIX_STAT #include +#endif /* NOTES ** @@ -54,6 +56,7 @@ static char *target_out_path = NULL; static int verbose = 0; static int total_size = 0; +#ifndef CFIG_NO_FIX_STAT static void fix_stat(const char *path, struct stat *s) { uint64_t capabilities; @@ -85,6 +88,7 @@ static void fix_stat(const char *path, struct stat *s) s->st_mode = (typeof(s->st_mode)) st_mode; } } +#endif static void _eject(struct stat *s, char *out, int olen, char *data, unsigned datasize) { @@ -98,7 +102,9 @@ static void _eject(struct stat *s, char *out, int olen, char *data, unsigned dat putchar(0); } +#ifndef CFIG_NO_FIX_STAT fix_stat(out, s); +#endif // fprintf(stderr, "_eject %s: mode=0%o\n", out, s->st_mode); printf("%06x%08x%08x%08x%08x%08x%08x"