aboutsummaryrefslogtreecommitdiffstats
path: root/fs/fat/inode.c
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2013-07-08 19:00:46 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-07-09 13:33:25 -0400
commit6e5b93ee55d401f1619092fb675b57c28c9ed7ec (patch)
treed6d9627ec023d7375d8dc996523509ee45d082bd /fs/fat/inode.c
parent4e80b1880c5a31d051d1e4a7377dec0a20701c23 (diff)
fatfs: add FAT_IOCTL_GET_VOLUME_ID
This patch, originally from Android kernel, adds vfat ioctl command FAT_IOCTL_GET_VOLUME_ID, with this command we can get the vfat volume ID using following code: ioctl(fd, FAT_IOCTL_GET_VOLUME_ID, &volume_ID) This patch is a modified version of the patch by Mike Lockwood, with changes from Dmitry Pervushin, who noticed the original patch makes some volume IDs abiguous with error returns: for example, if volume id is 0xFFFFFDAD, that matches -ENOIOCTLCMD, we get "FFFFFFFF" from the user space. So add a parameter to ioctl to get the correct volume ID. Android uses vfat volume ID to identify different sd card, when a new sd card is inserted to device, android can scan the media on it and pop up new contents. Signed-off-by: Bintian Wang <bintian.wang@linaro.org> Cc: dmitry pervushin <dpervushin@gmail.com> Cc: Mike Lockwood <lockwood@android.com> Cc: Colin Cross <ccross@android.com> Acked-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> Cc: John Stultz <john.stultz@linaro.org> Cc: Sean McNeil <sean@mcneil.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/fat/inode.c')
-rw-r--r--fs/fat/inode.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index 5d4513cb1b3c..11b51bb55b42 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -1415,6 +1415,18 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat,
1415 brelse(fsinfo_bh); 1415 brelse(fsinfo_bh);
1416 } 1416 }
1417 1417
1418 /* interpret volume ID as a little endian 32 bit integer */
1419 if (sbi->fat_bits == 32)
1420 sbi->vol_id = (((u32)b->fat32.vol_id[0]) |
1421 ((u32)b->fat32.vol_id[1] << 8) |
1422 ((u32)b->fat32.vol_id[2] << 16) |
1423 ((u32)b->fat32.vol_id[3] << 24));
1424 else /* fat 16 or 12 */
1425 sbi->vol_id = (((u32)b->fat16.vol_id[0]) |
1426 ((u32)b->fat16.vol_id[1] << 8) |
1427 ((u32)b->fat16.vol_id[2] << 16) |
1428 ((u32)b->fat16.vol_id[3] << 24));
1429
1418 sbi->dir_per_block = sb->s_blocksize / sizeof(struct msdos_dir_entry); 1430 sbi->dir_per_block = sb->s_blocksize / sizeof(struct msdos_dir_entry);
1419 sbi->dir_per_block_bits = ffs(sbi->dir_per_block) - 1; 1431 sbi->dir_per_block_bits = ffs(sbi->dir_per_block) - 1;
1420 1432