Skip to content

Commit

Permalink
udf: Use device size when drive reported bogus number of written blocks
Browse files Browse the repository at this point in the history
Some drives report 0 as the number of written blocks when there are some blocks
recorded. Use device size in such case so that we can automagically mount such
media.

Signed-off-by: Jan Kara <jack@suse.cz>
  • Loading branch information
Jan Kara committed Jun 18, 2009
1 parent 1d89b30 commit 24a5d59
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion fs/udf/lowlevel.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ unsigned long udf_get_last_block(struct super_block *sb)
struct block_device *bdev = sb->s_bdev;
unsigned long lblock = 0;

if (ioctl_by_bdev(bdev, CDROM_LAST_WRITTEN, (unsigned long) &lblock))
/*
* ioctl failed or returned obviously bogus value?
* Try using the device size...
*/
if (ioctl_by_bdev(bdev, CDROM_LAST_WRITTEN, (unsigned long) &lblock) ||
lblock == 0)
lblock = bdev->bd_inode->i_size >> sb->s_blocksize_bits;

if (lblock)
Expand Down

0 comments on commit 24a5d59

Please sign in to comment.