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
pull/9/head
Yu Yezhong 8 years ago committed by cfig
parent 094252e583
commit 24499bb9a5

@ -23,6 +23,7 @@ model {
components {
mkbootfs(NativeExecutableSpec) {
binaries.all {
// cCompiler.define 'CFIG_NO_FIX_STAT'
}
}
}

@ -33,6 +33,8 @@
#include <sys/stat.h>
#include <sys/types.h>
#ifndef CFIG_NO_FIX_STAT
#include <private/android_filesystem_config.h>
#include <utils/Compat.h>
@ -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

@ -12,7 +12,9 @@
#include <stdarg.h>
#include <fcntl.h>
#ifndef CFIG_NO_FIX_STAT
#include <private/android_filesystem_config.h>
#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"

Loading…
Cancel
Save