Gao Xiang <[email protected]> writes:
> Hi Giuseppe,
>
> On 2026/7/14 23:48, Giuseppe Scrivano wrote:
>> Allow userspace to pass an already-opened file descriptor as the mount
>> source instead of a path string. This is useful for tools that already
>> hold an fd to the image, such as composefs reusing an existing erofs
>> backing file.
>> Signed-off-by: Giuseppe Scrivano <[email protected]>
>
> Use the current erofs-utils testsuite, the following tests seems skipped
> incorrectly.
>
> [Error 22] Invalid argument
> SKIP: erofs/008
> [Error 22] Invalid argument
> SKIP: erofs/009
> [Error 22] Invalid argument
> SKIP: erofs/010
> [Error 22] Invalid argument
> SKIP: erofs/011
>
> [Error 22] Invalid argument
> SKIP: erofs/017
> [Error 22] Invalid argument
> SKIP: erofs/018
>
> And the kernel message shows:
> [ 116.477816] erofs: source is unsupported
> ...
>
> git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs-utils.git -b
> experimental-tests
> $ sudo make check
>
> Thanks,
> Gao Xiang
it seems to be caused by the different error returned by erofs_fc_get_tree.
Would you be fine if I amend this on top of v3?
Thanks,
Giuseppe
diff --git a/fs/erofs/super.c b/fs/erofs/super.c
index d7baf9f34dc0..829ae530d7ca 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -791,17 +791,22 @@ static int erofs_fc_fill_super(struct super_block *sb,
struct fs_context *fc)
static int erofs_fc_get_tree(struct fs_context *fc)
{
struct erofs_sb_info *sbi = fc->s_fs_info;
- struct file *file = sbi->dif0.file;
+ int ret;
- if (!IS_ENABLED(CONFIG_EROFS_FS_BACKED_BY_FILE) || !file) {
- int ret;
+ if (IS_ENABLED(CONFIG_EROFS_FS_BACKED_BY_FILE) && sbi->dif0.file) {
+ if (!S_ISREG(file_inode(sbi->dif0.file)->i_mode) ||
+ !sbi->dif0.file->f_mapping->a_ops->read_folio) {
+ errorfc(fc, "source is unsupported");
+ return -EINVAL;
+ }
+ return get_tree_nodev(fc, erofs_fc_fill_super);
+ }
- ret = get_tree_bdev_flags(fc, erofs_fc_fill_super,
- IS_ENABLED(CONFIG_EROFS_FS_BACKED_BY_FILE) ?
- GET_TREE_BDEV_QUIET_LOOKUP : 0);
- if (!IS_ENABLED(CONFIG_EROFS_FS_BACKED_BY_FILE) ||
- ret != -ENOTBLK)
- return ret;
+ ret = get_tree_bdev_flags(fc, erofs_fc_fill_super,
+ IS_ENABLED(CONFIG_EROFS_FS_BACKED_BY_FILE) ?
+ GET_TREE_BDEV_QUIET_LOOKUP : 0);
+ if (IS_ENABLED(CONFIG_EROFS_FS_BACKED_BY_FILE) && ret == -ENOTBLK) {
+ struct file *file;
if (!fc->source)
return invalf(fc, "No source specified");
@@ -809,13 +814,12 @@ static int erofs_fc_get_tree(struct fs_context *fc)
if (IS_ERR(file))
return PTR_ERR(file);
sbi->dif0.file = file;
+
+ if (S_ISREG(file_inode(sbi->dif0.file)->i_mode) &&
+ sbi->dif0.file->f_mapping->a_ops->read_folio)
+ return get_tree_nodev(fc, erofs_fc_fill_super);
}
- if (!S_ISREG(file_inode(file)->i_mode) ||
- !file->f_mapping->a_ops->read_folio) {
- errorfc(fc, "source is unsupported");
- return -EINVAL;
- }
- return get_tree_nodev(fc, erofs_fc_fill_super);
+ return ret;
}
static int erofs_fc_reconfigure(struct fs_context *fc)