diff options
author | Mohamad Ayyash <mkayyash@google.com> | 2016-04-07 22:12:10 -0700 |
---|---|---|
committer | Shinichiro Hamaji <hamaji@google.com> | 2016-06-07 13:53:54 +0900 |
commit | f4bd4674223a91e06caf6e57c5d3e01d203b2923 (patch) | |
tree | 1a30e7bfc7a1575b14e6b96e6fc394b9214cbbf3 | |
parent | 513774ac5d54e23110593b5935aebd3760b9e6b3 (diff) | |
download | squashfs-tools-marshmallow-dr-arc-dev.tar.gz |
UPSTREAM: Allow passing fs_config file for generating mksquashfsmarshmallow-dr-arc-m54marshmallow-dr-arc-m53marshmallow-dr-arc-dev
BUG: 27467028
Signed-off-by: Mohamad Ayyash <mkayyash@google.com>
BUG: 28704419
BUG: 29129593
(cherry picked from 481261fea8f579976a95d0422a9ba817642fa53e)
Change-Id: Ia57175b4804918ade0922ae2ae9fa7fcaa0489b1
-rw-r--r-- | squashfs-tools/android.c | 12 | ||||
-rw-r--r-- | squashfs-tools/android.h | 4 | ||||
-rw-r--r-- | squashfs-tools/mksquashfs.c | 40 |
3 files changed, 48 insertions, 8 deletions
diff --git a/squashfs-tools/android.c b/squashfs-tools/android.c index ecfb5d1..758dec2 100644 --- a/squashfs-tools/android.c +++ b/squashfs-tools/android.c @@ -30,6 +30,7 @@ #include "android.h" #include "private/android_filesystem_config.h" +#include "private/canned_fs_config.h" #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) @@ -43,9 +44,14 @@ void alloc_mounted_path(const char *mount_point, const char *subpath, char **mou strcat(*mounted_path, subpath); } -void android_fs_config(const char *path, struct stat *stat, const char *target_out_path, uint64_t *capabilities) { - fs_config(path, S_ISDIR(stat->st_mode), target_out_path, - &stat->st_uid, &stat->st_gid, &stat->st_mode, capabilities); +void android_fs_config(fs_config_func_t fs_config_func, const char *path, struct stat *stat, + const char *target_out_path, uint64_t *capabilities) { + // filesystem_config does not preserve file type bits + mode_t stat_file_type_mask = stat->st_mode & S_IFMT; + if (fs_config_func) + fs_config_func(path, S_ISDIR(stat->st_mode), target_out_path, + &stat->st_uid, &stat->st_gid, &stat->st_mode, capabilities); + stat->st_mode |= stat_file_type_mask; } diff --git a/squashfs-tools/android.h b/squashfs-tools/android.h index 656b628..998f710 100644 --- a/squashfs-tools/android.h +++ b/squashfs-tools/android.h @@ -18,9 +18,11 @@ #define _ANDROID_H_ #include <stdint.h> +typedef void (*fs_config_func_t)(const char *path, int dir, const char *target_out_path, + unsigned *uid, unsigned *gid, unsigned *mode, uint64_t *capabilities); void alloc_mounted_path(const char *mount_point, const char *subpath, char **mounted_path); -void android_fs_config(const char *path, struct stat *stat, const char *target_out_path, uint64_t *capabilities); +void android_fs_config(fs_config_func_t fs_config_func, const char *path, struct stat *stat, const char *target_out_path, uint64_t *capabilities); struct selabel_handle *get_sehnd(const char *context_file); char *set_selabel(const char *path, unsigned int mode, struct selabel_handle *sehnd); struct vfs_cap_data set_caps(uint64_t capabilities); diff --git a/squashfs-tools/mksquashfs.c b/squashfs-tools/mksquashfs.c index 0d62d8d..2d23f40 100644 --- a/squashfs-tools/mksquashfs.c +++ b/squashfs-tools/mksquashfs.c @@ -80,10 +80,13 @@ /* ANDROID CHANGES START*/ #ifdef ANDROID #include "android.h" +#include "private/android_filesystem_config.h" +#include "private/canned_fs_config.h" int android_config = FALSE; char *context_file = NULL; char *mount_point = NULL; char *target_out_path = NULL; +fs_config_func_t fs_config_func = NULL; #endif /* ANDROID CHANGES END */ @@ -3066,10 +3069,10 @@ inline void add_dir_entry(struct dir_ent *dir_ent, struct dir_info *sub_dir, rel_path = mounted_path; while (rel_path && *rel_path == '/') rel_path++; - android_fs_config(rel_path, &inode_info->buf, target_out_path, &dir_ent->capabilities); + android_fs_config(fs_config_func, rel_path, &inode_info->buf, target_out_path, &dir_ent->capabilities); free(mounted_path); } else { - android_fs_config(pathname(dir_ent), &inode_info->buf, target_out_path, &dir_ent->capabilities); + android_fs_config(fs_config_func, pathname(dir_ent), &inode_info->buf, target_out_path, &dir_ent->capabilities); } } #endif @@ -3175,9 +3178,9 @@ void dir_scan(squashfs_inode *inode, char *pathname, #ifdef ANDROID if (android_config) { if (mount_point) - android_fs_config(mount_point, &buf, target_out_path, &caps); + android_fs_config(fs_config_func, mount_point, &buf, target_out_path, &caps); else - android_fs_config(pathname, &buf, target_out_path, &caps); + android_fs_config(fs_config_func, pathname, &buf, target_out_path, &caps); } #endif /* ANDROID CHANGES END */ @@ -5190,6 +5193,11 @@ int main(int argc, char *argv[]) int progress = TRUE; int force_progress = FALSE; struct file_buffer **fragment = NULL; +/* ANDROID CHANGES START*/ +#ifdef ANDROID + const char *fs_config_file = NULL; +#endif +/* ANDROID CHANGES END */ if(argc > 1 && strcmp(argv[1], "-version") == 0) { VERSION(); @@ -5645,6 +5653,14 @@ print_compressor_options: } context_file = argv[i]; } + else if(strcmp(argv[i], "-fs-config-file") == 0) { + if(++i == argc) { + ERROR("%s: -fs-config-file: missing file name\n", + argv[0]); + exit(1); + } + fs_config_file = argv[i]; + } #endif /* ANDROID CHANGES END */ else if(strcmp(argv[i], "-nopad") == 0) @@ -5722,6 +5738,8 @@ printOptions: ERROR("-context-file <file>\tApply selinux security " "xattrs from context-file instead\n\t\t\t" "of reading xattrs from file system\n"); + ERROR("-fs-config-file <file>\tAndroid specific " + "filesystem config file\n"); #endif /* ANDROID CHANGES END */ ERROR("-noI\t\t\tdo not compress inode table\n"); @@ -5826,6 +5844,20 @@ printOptions: } } +/* ANDROID CHANGES START*/ +#ifdef ANDROID + if (fs_config_file) { + if (load_canned_fs_config(fs_config_file) < 0) { + fprintf(stderr, "failed to load %s\n", fs_config_file); + exit(1); + } + fs_config_func = canned_fs_config; + } else if (mount_point) { + fs_config_func = fs_config; + } +#endif +/* ANDROID CHANGES END */ + /* * Some compressors may need the options to be checked for validity * once all the options have been processed |