diff options
author | Gao Xiang <hsiangkao@aol.com> | 2020-12-28 18:51:46 +0800 |
---|---|---|
committer | alk3pInjection <webmaster@raspii.tech> | 2021-08-31 15:54:40 +0800 |
commit | 912fab7dcb5819211570ed25b6f60a9001364831 (patch) | |
tree | 9f99dffd114176b667173b69c44862b7feeea710 /lib/inode.c | |
parent | deb8c62c351f3fb8af1a1d938c76a9ea9f002b49 (diff) |
AOSP: erofs-utils: fix sub-directory prefix for canned fs_config
"failed to find [%s] in canned fs_config" was observed by using
"--fs-config-file" option as reported by Yue Hu [1].
The root cause was that the mountpoint prefix to subdirectories is
also needed if "--mount-point" presents. However, such prefix cannot
be added by just using erofs_fspath().
One exception is that the root directory itself needs to be handled
specially for canned fs_config. For such case, the prefix of the root
directory has to be dropped instead.
[1] https://lkml.kernel.org/r/20201222020430.12512-1-zbestahu@gmail.com
Link: https://lore.kernel.org/r/20201228105146.2939914-1-hsiangkao@redhat.com
Fixes: 8a9e8046f170 ("AOSP: erofs-utils: add fs_config support")
Reported-and-tested-by: Yue Hu <huyue2@yulong.com>
Tested-by: Huang Jianan <huangjianan@oppo.com>
Reviewed-by: Li Guifu <bluce.lee@aliyun.com>
Signed-off-by: Gao Xiang <hsiangkao@aol.com>
(cherry picked from commit 26f7f29e800e857a3a823c1548c8b6e6a14b5416)
Change-Id: Ifb74fe0905073c53ef158761f5de9f410f30c269
Diffstat (limited to 'lib/inode.c')
-rw-r--r-- | lib/inode.c | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/lib/inode.c b/lib/inode.c index eb2e0f2..4e3685d 100644 --- a/lib/inode.c +++ b/lib/inode.c @@ -681,32 +681,42 @@ int erofs_droid_inode_fsconfig(struct erofs_inode *inode, /* filesystem_config does not preserve file type bits */ mode_t stat_file_type_mask = st->st_mode & S_IFMT; unsigned int uid = 0, gid = 0, mode = 0; - char *fspath; + const char *fspath; + char *decorated = NULL; inode->capabilities = 0; - if (cfg.fs_config_file) - canned_fs_config(erofs_fspath(path), - S_ISDIR(st->st_mode), - cfg.target_out_path, - &uid, &gid, &mode, &inode->capabilities); - else if (cfg.mount_point) { - if (asprintf(&fspath, "%s/%s", cfg.mount_point, + if (!cfg.fs_config_file && !cfg.mount_point) + return 0; + + if (!cfg.mount_point || + /* have to drop the mountpoint for rootdir of canned fsconfig */ + (cfg.fs_config_file && erofs_fspath(path)[0] == '\0')) { + fspath = erofs_fspath(path); + } else { + if (asprintf(&decorated, "%s/%s", cfg.mount_point, erofs_fspath(path)) <= 0) return -ENOMEM; + fspath = decorated; + } + if (cfg.fs_config_file) + canned_fs_config(fspath, S_ISDIR(st->st_mode), + cfg.target_out_path, + &uid, &gid, &mode, &inode->capabilities); + else fs_config(fspath, S_ISDIR(st->st_mode), cfg.target_out_path, &uid, &gid, &mode, &inode->capabilities); - free(fspath); - } - st->st_uid = uid; - st->st_gid = gid; - st->st_mode = mode | stat_file_type_mask; erofs_dbg("/%s -> mode = 0x%x, uid = 0x%x, gid = 0x%x, " "capabilities = 0x%" PRIx64 "\n", - erofs_fspath(path), - mode, uid, gid, inode->capabilities); + fspath, mode, uid, gid, inode->capabilities); + + if (decorated) + free(decorated); + st->st_uid = uid; + st->st_gid = gid; + st->st_mode = mode | stat_file_type_mask; return 0; } #else |