AOSP: erofs-utils: fix sub-directory prefix for canned fs_config
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 AOSP: erofs-utils: fix sub-directory prefix for canned fs_config
From: Gao Xiang <[email protected]>
"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/[email protected]
---
Hi Yue, Jianan,
I've verified cuttlefish booting with success, It'd be better to verify this patchset on your sides. Please kingly leave "Tested-by:" if possible.
Hi Guifu,
Could you also review this patch ? This needs to be included in the upcoming v1.2.1 as well...
Thanks,
Gao Xiang
lib/inode.c | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-)
lib/inode.c +25 -14
@@ -696,32 +696,43 @@ 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 && !cfg.mount_point) +return 0 ; + +if (!cfg.mount_point || +/* have to drop the mountpoint for rootdir of canned fsconfig */ + (cfg.fs_config_file &&IS_ROOT (inode))) { + 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 (erofs_fspath (path), +canned_fs_config (fspath,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, -erofs_fspath (path)) <=0 ) -return -ENOMEM ; - +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
Signature · 1 line
2.24.0
Quoted 19 lines · On Sat, 26 Dec 2020 14:27:36 +0800 Gao Xiang <[email protected]> wrote:
From: Gao Xiang <[email protected]>
"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/[email protected]Fixes 8a9e8046f170 ("AOSP: erofs-utils: add fs_config support")Reported-by Yue Hu <[email protected]>Signed-off-by Gao Xiang <[email protected]>
Quoted 6 lines
---
Hi Yue, Jianan,I've verified cuttlefish booting with success, It'd be better to verify this patchset on your sides. Please kingly leave "Tested-by:" if possible.
Hi Xiang,
I'm testing now. I will inform once finished.
Thx.
Quoted 75 lines
Hi Guifu,
Could you also review this patch ? This needs to be included in the upcoming v1.2.1 as well...Thanks,
Gao Xianglib/inode.c | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-)lib/inode.c +0
-0@@ -696,32 +696,43 @@ int erofs_droid_inode_fsconfig(struct
erofs_inode*inode, /*filesystem_configdoes not preserve file type bits */mode_tstat_file_type_mask=st->st_mode&S_IFMT;lib/inode.c +7
-1unsigned int uid =0 , gid =0 , mode =0 ; -char *fspath; +const char *fspath; +char *decorated =NULL ; inode->capabilities =0 ; +if (!cfg.fs_config_file && !cfg.mount_point) +return 0 ; + + if (!cfg.mount_point || +/* have to drop the mountpoint for rootdir of canned fsconfig */
lib/inode.c +10
-1+ (cfg.fs_config_file && IS_ROOT(inode))) { + 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(erofs_fspath(path), + canned_fs_config(fspath, S_ISDIR(st->st_mode), cfg.target_out_path, &uid, &gid, &mode,
&inode->capabilities);lib/inode.c +8
-12- else if (cfg.mount_point) { -if (asprintf (&fspath,"%s/%s" , cfg.mount_point, -erofs_fspath (path)) <=0 ) -return -ENOMEM ; - + 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
Quoted 44 lines · Gao Xiang
From: Gao Xiang <[email protected]>
"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/[email protected]
Fixes 8a9e8046f170 ("AOSP: erofs-utils: add fs_config support")Reported-by Yue Hu <[email protected]>Signed-off-by Gao Xiang <[email protected]>---
Hi Yue, Jianan,I've verified cuttlefish booting with success, It'd be better to verify this patchset on your sides. Please kingly leave "Tested-by:" if possible.
Hi Guifu,
Could you also review this patch ? This needs to be included in the upcoming v1.2.1 as well...Thanks,
Gao Xianglib/inode.c | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-)lib/inode.c +0
-1@@ -696,32 +696,43 @@ 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;
lib/inode.c int erofs_droid_inode_fsconfig(struct erofs_inode *inode, · line 708
Quoted 10 lines
lib/inode.c +8
-0+const char *fspath; +char *decorated =NULL ; inode->capabilities =0 ; +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 &&IS_ROOT (inode))) {
Hi Xiang,
I have tested this patch with --fs-config-file, and the problem still exists.
IS_ROOT can't be used here to determine the root directory , because inode->i_parent is null at this time. It will be set after this function.
Thanks,
Jianan
Quoted 43 lines
lib/inode.c +17
-13+ 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 (erofs_fspath (path), +canned_fs_config (fspath,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, -erofs_fspath (path)) <=0 ) -return -ENOMEM ; - +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
Quoted 2 lines · Huang Jianan
在 2020/12/26 14:27, Gao Xiang 写道:
...
Quoted 6 lines
lib/inode.c int erofs_droid_inode_fsconfig(struct erofs_inode *inode, · line 708
Quoted 3 lines
lib/inode.c +3
-0+if (!cfg.mount_point || +/* have to drop the mountpoint for rootdir of canned fsconfig */ + (cfg.fs_config_file &&IS_ROOT (inode))) {Hi Xiang,
Quoted 6 lines
I have tested this patch with --fs-config-file, and the problem still exists.
IS_ROOTcan't be used here to determine the root directory , becauseinode->i_parentis null at this time. It will be set after this function.
Hi Jianan,
Thanks for your report! Sorry for the troublesome.
I need to turn back as the next version.... Very sorry about this!
Thanks,
Gao Xiang
Quoted 47 lines
Thanks,
Jianan
Quoted 42 lines
lib/inode.c +17
-13+ 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 (erofs_fspath (path), +canned_fs_config (fspath,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, -erofs_fspath (path)) <=0 ) -return -ENOMEM ; - +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
PATCH v2 1/1 AOSP: erofs-utils: fix sub-directory prefix for canned fs_config
In reply to Gao Xiang via Linux-erofsFrom: Gao Xiang <[email protected]>
"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/[email protected]
---
changes since v2:
- fix IS_ROOT misuse reported by Jianan, very sorry about this since I know little about canned fs_config.
(please kindly test again...)
lib/inode.c | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-)
lib/inode.c +25 -14
@@ -696,32 +696,43 @@ 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 && !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 (erofs_fspath (path), +canned_fs_config (fspath,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, -erofs_fspath (path)) <=0 ) -return -ENOMEM ; - +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
Signature · 1 line
2.27.0
Hi Xiang,
This patch works well with or without --fs-config-file in build.
Thanks,
Jianan
Quoted 91 lines · Gao Xiang
From: Gao Xiang <[email protected]>
"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/[email protected]
Fixes 8a9e8046f170 ("AOSP: erofs-utils: add fs_config support")Reported-by Yue Hu <[email protected]>Signed-off-by Gao Xiang <[email protected]>---
changes since v2:
- fixIS_ROOTmisuse reported by Jianan, very sorry about this since I know little about cannedfs_config.(please kindly test again...)
lib/inode.c | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-)lib/inode.c +25
-14@@ -696,32 +696,43 @@ 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 && !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 (erofs_fspath (path), +canned_fs_config (fspath,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, -erofs_fspath (path)) <=0 ) -return -ENOMEM ; - +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
Quoted 49 lines · On Mon, 28 Dec 2020 18:51:46 +0800 Gao Xiang <[email protected]> wrote:
From: Gao Xiang <[email protected]>
"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/[email protected]Link:
https://lore.kernel.org/r/[email protected]Fixes 8a9e8046f170 ("AOSP: erofs-utils: add fs_config support")<[email protected]> ---
changes since v2:
- fixIS_ROOTmisuse reported by Jianan, very sorry about this since I know little about cannedfs_config.(please kindly test again...)
lib/inode.c | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-)lib/inode.c +0
-0@@ -696,32 +696,43 @@ int erofs_droid_inode_fsconfig(struct
erofs_inode*inode, /*filesystem_configdoes not preserve file type bits */mode_tstat_file_type_mask=st->st_mode&S_IFMT;lib/inode.c +7
-1unsigned int uid =0 , gid =0 , mode =0 ; -char *fspath; +const char *fspath; +char *decorated =NULL ; inode->capabilities =0 ; +if (!cfg.fs_config_file && !cfg.mount_point) +return 0 ; + + if (!cfg.mount_point || +/* have to drop the mountpoint for rootdir of canned fsconfig */
lib/inode.c int erofs_droid_inode_fsconfig(struct erofs_inode *inode, · line 717
Quoted 10 lines
lib/inode.c +9
-0+ (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)
Whether we can use the first "cfg.fs_config_file" when loading canned fs-config to reduce/simplify these duplicated calling?
Quoted 35 lines
lib/inode.c +1
-1- canned_fs_config(erofs_fspath(path), + canned_fs_config(fspath, S_ISDIR(st->st_mode), cfg.target_out_path, &uid, &gid, &mode,
&inode->capabilities);lib/inode.c +8
-12- else if (cfg.mount_point) { -if (asprintf (&fspath,"%s/%s" , cfg.mount_point, -erofs_fspath (path)) <=0 ) -return -ENOMEM ; - + 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
Hi Yue,
Quoted 2 lines · Yue Hu
On Mon, 28 Dec 2020 18:51:46 +0800
Gao Xiang <[email protected]> wrote:
...
Quoted 20 lines
Quoted 20 lines
(quoted diff) +0
-0@@ -696,32 +696,43 @@ int erofs_droid_inode_fsconfig(struct
erofs_inode*inode, /*filesystem_configdoes not preserve file type bits */mode_tstat_file_type_mask=st->st_mode&S_IFMT;lib/inode.c +7
-1unsigned int uid =0 , gid =0 , mode =0 ; -char *fspath; +const char *fspath; +char *decorated =NULL ; inode->capabilities =0 ; +if (!cfg.fs_config_file && !cfg.mount_point) +return 0 ; + + if (!cfg.mount_point || +/* have to drop the mountpoint for rootdir of canned fsconfig */
lib/inode.c +5
-0+ (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 )
Quoted 8 lines
lib/inode.c int erofs_droid_inode_fsconfig(struct erofs_inode *inode, · line 717
Quoted 5 lines
lib/inode.c +4
-0+return -ENOMEM ; + fspath = decorated; + } +if (cfg.fs_config_file)Whether we can use the first "cfg.fs_config_file" when loading canned fs-config to reduce/simplify these duplicated calling?
Not sure what you mean... If you mean why not using some "fs_config_func" as squashfs did, that is I'd like to 1) avoid such unneeded indirect function pointers, and 2) no need to introduce such function prototype (I don't want to maintain such function pointer type) since fs_config and canned_fs_config implement differently (and it seems they also behave differently so no need to mix them at all).
Thanks,
Gao Xiang
Quoted 39 lines · On Mon, 28 Dec 2020 19:32:47 +0800 Gao Xiang <[email protected]> wrote:
Hi Yue,
Quoted 2 lines · Yue Hu
On Mon, 28 Dec 2020 18:51:46 +0800
Gao Xiang <[email protected]> wrote:...
Quoted 22 lines
Quoted 22 lines
(quoted diff) +0
-0@@ -696,32 +696,43 @@ int erofs_droid_inode_fsconfig(struct
erofs_inode*inode, /*filesystem_configdoes not preserve file type bits */mode_tstat_file_type_mask=st->st_mode&S_IFMT;lib/inode.c +7
-1unsigned int uid =0 , gid =0 , mode =0 ; -char *fspath; +const char *fspath; +char *decorated =NULL ; inode->capabilities =0 ; +if (!cfg.fs_config_file && !cfg.mount_point) +return 0 ; + + if (!cfg.mount_point || +/* have to drop the mountpoint for rootdir of canned fsconfig */
(quoted diff) +1
-0+ (cfg.fs_config_file && erofs_fspath(path)[0] =='\0')) {
lib/inode.c +3
-0+ fspath =erofs_fspath (path); + }else { + if (asprintf(&decorated, "%s/%s",cfg.mount_point,
lib/inode.c +1
-0+ erofs_fspath(path)) <= 0)Quoted 8 lines
lib/inode.c int erofs_droid_inode_fsconfig(struct erofs_inode *inode, · line 717
Quoted 5 lines
lib/inode.c +4
-0+return -ENOMEM ; + fspath = decorated; + } +if (cfg.fs_config_file)Whether we can use the first "cfg.fs_config_file" when loading canned fs-config to reduce/simplify these duplicated calling?
Quoted 1 line
Not sure what you mean... If you mean why not using some
Sorry for my typo. I mean duplicated 'check' to cfg.fs_config_file.
Quoted 5 lines
"
fs_config_func" as squashfs did, that is I'd like to 1) avoid such unneeded indirect function pointers, and 2) no need to introduce such function prototype (I don't want to maintain such function pointer type) sincefs_configandcanned_fs_configimplement differently (and it seems they also behave differently so no need to mix them at all).
Ok.
Quoted 4 lines
Thanks,
Gao Xiang
Hi Xiang,
Works fine to me for canned/non-canned fs_config.
Thx.
Quoted 94 lines · On Mon, 28 Dec 2020 18:51:46 +0800 Gao Xiang <[email protected]> wrote:
From: Gao Xiang <[email protected]>
"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/[email protected]Link:
https://lore.kernel.org/r/[email protected]Fixes 8a9e8046f170 ("AOSP: erofs-utils: add fs_config support")<[email protected]> ---
changes since v2:
- fixIS_ROOTmisuse reported by Jianan, very sorry about this since I know little about cannedfs_config.(please kindly test again...)
lib/inode.c | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-)lib/inode.c +0
-0@@ -696,32 +696,43 @@ int erofs_droid_inode_fsconfig(struct
erofs_inode*inode, /*filesystem_configdoes not preserve file type bits */mode_tstat_file_type_mask=st->st_mode&S_IFMT;lib/inode.c +7
-1unsigned int uid =0 , gid =0 , mode =0 ; -char *fspath; +const char *fspath; +char *decorated =NULL ; inode->capabilities =0 ; +if (!cfg.fs_config_file && !cfg.mount_point) +return 0 ; + + if (!cfg.mount_point || +/* have to drop the mountpoint for rootdir of canned fsconfig */
lib/inode.c +10
-1+ (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(erofs_fspath(path), + canned_fs_config(fspath, S_ISDIR(st->st_mode), cfg.target_out_path, &uid, &gid, &mode,
&inode->capabilities);lib/inode.c +8
-12- else if (cfg.mount_point) { -if (asprintf (&fspath,"%s/%s" , cfg.mount_point, -erofs_fspath (path)) <=0 ) -return -ENOMEM ; - + 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
Quoted 6 lines · Yue Hu
Hi Xiang,
Works fine to me for canned/non-canned
fs_config.Tested-by Yue Hu <[email protected]>
Okay, got it. thanks you all for this :)
(also another link for indirect call: https://lwn.net/Articles/774743/
, so as long as some switch table, I'd like to avoid such usage...)
Thanks,
Gao Xiang
Quoted 1 line
Thx.
Thank for your works, Yue Hu, Jianan, Gao Xiang
Quoted 46 lines · Gao Xiang
From: Gao Xiang <[email protected]>
"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/[email protected]
Fixes 8a9e8046f170 ("AOSP: erofs-utils: add fs_config support")Reported-by Yue Hu <[email protected]>Signed-off-by Gao Xiang <[email protected]>---
changes since v2:
- fixIS_ROOTmisuse reported by Jianan, very sorry about this since I know little about cannedfs_config.(please kindly test again...)
lib/inode.c | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-)lib/inode.c +6
-1@@ -696,32 +696,43 @@ 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 && !cfg.mount_point) +return 0 ; + + if (!cfg.mount_point ||
lib/inode.c int erofs_droid_inode_fsconfig(struct erofs_inode *inode, · line 716
Quoted 10 lines
lib/inode.c +10
-0+/* 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; + } +
erofs_fspath has been written for three times, and called always. What do you think refact it ? Do it with
fspath = erofs_fspath(path);
if need decorated:
fspath = decorated
Hi Guifu,
Quoted 3 lines · Li GuiFu
Thank for your works, Yue Hu, Jianan, Gao Xiang
On 2020/12/28 18:51, Gao Xiang wrote:
...
Quoted 24 lines
Quoted 24 lines
lib/inode.c +13
-1@@ -696,32 +696,43 @@ 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 && !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 ;
Quoted 8 lines
lib/inode.c int erofs_droid_inode_fsconfig(struct erofs_inode *inode, · line 716
Quoted 3 lines
lib/inode.c +3
-0+ fspath = decorated; + } +
erofs_fspathhas been written for three times, and called always. What do you think refact it ? Do it with
fspath =erofs_fspath(path);
if need decorated:
fspath = decorated
Yeah, it sounds reasonable. Let's refine this as a improvement of an individual patch (if needed) since I have to rebuild AOSP again (that is a bit complex for me now to open my PC...)
Thanks,
Gao Xiang
Quoted 1 line
Quoted 24 lines · Gao Xiang
From: Gao Xiang <[email protected]>
"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/[email protected]
Fixes 8a9e8046f170 ("AOSP: erofs-utils: add fs_config support")Reported-by Yue Hu <[email protected]>Signed-off-by Gao Xiang <[email protected]>---
changes since v2:
- fixIS_ROOTmisuse reported by Jianan, very sorry about this since I know little about cannedfs_config.
Quoted 5 lines
(please kindly test again...)
lib/inode.c | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-)
It looks good
Thanks,