From mboxrd@z Thu Jan 1 00:00:00 1970 From: Artem Bityutskiy Subject: [PATCH] UBIFS: use anonymous device Date: Mon, 25 May 2009 17:39:32 +0300 Message-ID: <1243262372.21646.128.camel@localhost.localdomain> Reply-To: dedekind@infradead.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: linux-mtd , viro@ZenIV.linux.org.uk To: linux-fsdevel Return-path: Received: from smtp.nokia.com ([192.100.122.230]:61571 "EHLO mgw-mx03.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751734AbZEYOkz (ORCPT ); Mon, 25 May 2009 10:40:55 -0400 Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Hi, here is a patch which fixes a minor UBIFS issues spotted by Al Viro. I'm going to push it to ubifs-2.6.git. =46rom: Artem Bityutskiy Subject: [PATCH] UBIFS: use anonymous device UBIFS has erroneuosly set 'sb->s_dev' to the UBI volume character device major/minor. This may lead to clashes if there is another FS mounted to a block device with the same major/minor numbers. User-space programs which use 'stat->st_dev' may get confused because of this. This problem was spotted by Al Viro. He also pointed the way to fix the problem - use 'set_anon_super()' and 'kill_anon_super()' VFS helpers. Signed-off-by: Artem Bityutskiy --- fs/ubifs/super.c | 21 ++++----------------- 1 files changed, 4 insertions(+), 17 deletions(-) diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index 9a589d8..d8d9523 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c @@ -1945,7 +1945,6 @@ static int ubifs_fill_super(struct super_block *s= b, void *data, int silent) sb->s_magic =3D UBIFS_SUPER_MAGIC; sb->s_blocksize =3D UBIFS_BLOCK_SIZE; sb->s_blocksize_bits =3D UBIFS_BLOCK_SHIFT; - sb->s_dev =3D c->vi.cdev; sb->s_maxbytes =3D c->max_inode_sz =3D key_max_inode_size(c); if (c->max_inode_sz > MAX_LFS_FILESIZE) sb->s_maxbytes =3D c->max_inode_sz =3D MAX_LFS_FILESIZE; @@ -1990,16 +1989,9 @@ out_free: static int sb_test(struct super_block *sb, void *data) { dev_t *dev =3D data; + struct ubifs_info *c =3D sb->s_fs_info; =20 - return sb->s_dev =3D=3D *dev; -} - -static int sb_set(struct super_block *sb, void *data) -{ - dev_t *dev =3D data; - - sb->s_dev =3D *dev; - return 0; + return c->vi.cdev =3D=3D *dev; } =20 static int ubifs_get_sb(struct file_system_type *fs_type, int flags, @@ -2027,7 +2019,7 @@ static int ubifs_get_sb(struct file_system_type *= fs_type, int flags, =20 dbg_gen("opened ubi%d_%d", vi.ubi_num, vi.vol_id); =20 - sb =3D sget(fs_type, &sb_test, &sb_set, &vi.cdev); + sb =3D sget(fs_type, &sb_test, &set_anon_super, &vi.cdev); if (IS_ERR(sb)) { err =3D PTR_ERR(sb); goto out_close; @@ -2067,16 +2059,11 @@ out_close: return err; } =20 -static void ubifs_kill_sb(struct super_block *sb) -{ - generic_shutdown_super(sb); -} - static struct file_system_type ubifs_fs_type =3D { .name =3D "ubifs", .owner =3D THIS_MODULE, .get_sb =3D ubifs_get_sb, - .kill_sb =3D ubifs_kill_sb + .kill_sb =3D kill_anon_super, }; =20 /* --=20 1.6.0.6 --=20 Best regards, Artem Bityutskiy (=D0=91=D0=B8=D1=82=D1=8E=D1=86=D0=BA=D0=B8=D0=B9 =D0=90= =D1=80=D1=82=D1=91=D0=BC) -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel= " in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html