Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fs/adfs: return f_fsid for statfs(2)

Currently many file systems in Linux kernel do not return f_fsid in statfs
info, the value is set as 0 in vfs layer. Anyway, in some conditions,
f_fsid from statfs(2) is useful, especially being used as (f_fsid, ino)
pair to uniquely identify a file.

Basic idea of the patches is generating a unique fs ID by
huge_encode_dev(sb->s_bdev->bd_dev) during file system mounting life time
(no endian consistent issue). sb is a point of struct super_block of
current mounted file system being accessed by statfs(2).

This patch:

Make adfs return f_fsid info for statfs(2), and do a little variable
renaming in adfs_statfs().

Signed-off-by: Coly Li <coly.li@suse.de>
Cc: Roman Zippel <zippel@linux-m68k.org>
Cc: "Sergey S. Kostyliov" <rathamahata@php4.ru>
Cc: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Cc: Mikulas Patocka <mikulas@artax.karlin.mff.cuni.cz>
Cc: Dave Kleikamp <shaggy@austin.ibm.com>
Cc: Bob Copeland <me@bobcopeland.com>
Cc: Anders Larsen <al@alarsen.net>
Cc: Phillip Lougher <phillip@lougher.demon.co.uk>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Evgeniy Dushistov <dushistov@mail.ru>
Cc: Jan Kara <jack@suse.cz>
Cc: Andreas Dilger <adilger@sun.com>
Cc: Jamie Lokier <jamie@shareable.org>
Cc: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Coly Li and committed by
Linus Torvalds
accb4012 10c7db27

+10 -6
+10 -6
fs/adfs/super.c
··· 219 219 220 220 static int adfs_statfs(struct dentry *dentry, struct kstatfs *buf) 221 221 { 222 - struct adfs_sb_info *asb = ADFS_SB(dentry->d_sb); 222 + struct super_block *sb = dentry->d_sb; 223 + struct adfs_sb_info *sbi = ADFS_SB(sb); 224 + u64 id = huge_encode_dev(sb->s_bdev->bd_dev); 223 225 224 226 buf->f_type = ADFS_SUPER_MAGIC; 225 - buf->f_namelen = asb->s_namelen; 226 - buf->f_bsize = dentry->d_sb->s_blocksize; 227 - buf->f_blocks = asb->s_size; 228 - buf->f_files = asb->s_ids_per_zone * asb->s_map_size; 227 + buf->f_namelen = sbi->s_namelen; 228 + buf->f_bsize = sb->s_blocksize; 229 + buf->f_blocks = sbi->s_size; 230 + buf->f_files = sbi->s_ids_per_zone * sbi->s_map_size; 229 231 buf->f_bavail = 230 - buf->f_bfree = adfs_map_free(dentry->d_sb); 232 + buf->f_bfree = adfs_map_free(sb); 231 233 buf->f_ffree = (long)(buf->f_bfree * buf->f_files) / (long)buf->f_blocks; 234 + buf->f_fsid.val[0] = (u32)id; 235 + buf->f_fsid.val[1] = (u32)(id >> 32); 232 236 233 237 return 0; 234 238 }