[PATCH 2/2] erofs: use get_tree_bdev_by_dev() to avoid misleading messages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Users can pass in an arbitrary source path for the proper type of
a mount then without "Can't lookup blockdev" error message.

Reported-by: Allison Karlitskaya <allison.karlitskaya@xxxxxxxxxx>
Closes: https://lore.kernel.org/r/CAOYeF9VQ8jKVmpy5Zy9DNhO6xmWSKMB-DO8yvBB0XvBE7=3Ugg@xxxxxxxxxxxxxx
Signed-off-by: Gao Xiang <hsiangkao@xxxxxxxxxxxxxxxxx>
---
 fs/erofs/super.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/fs/erofs/super.c b/fs/erofs/super.c
index 666873f745da..04a5873c1594 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -700,16 +700,19 @@ 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;
+	dev_t dev;
 	int ret;
 
 	if (IS_ENABLED(CONFIG_EROFS_FS_ONDEMAND) && sbi->fsid)
 		return get_tree_nodev(fc, erofs_fc_fill_super);
 
-	ret = get_tree_bdev(fc, erofs_fc_fill_super);
+	if (!fc->source)
+		return invalf(fc, "No source specified");
+	ret = lookup_bdev(fc->source, &dev);
+	if (!ret)
+		return get_tree_bdev_by_dev(fc, erofs_fc_fill_super, dev);
 #ifdef CONFIG_EROFS_FS_BACKED_BY_FILE
 	if (ret == -ENOTBLK) {
-		if (!fc->source)
-			return invalf(fc, "No source specified");
 		sbi->fdev = filp_open(fc->source, O_RDONLY | O_LARGEFILE, 0);
 		if (IS_ERR(sbi->fdev))
 			return PTR_ERR(sbi->fdev);
-- 
2.43.5





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux