]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
udf: Use device size when drive reported bogus number of written blocks
authorJan Kara <jack@suse.cz>
Thu, 18 Jun 2009 10:33:16 +0000 (12:33 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 24 Sep 2009 15:27:12 +0000 (08:27 -0700)
commit 24a5d59f3477bcff4c069ff4d0ca9a3e037d0235 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
fs/udf/lowlevel.c

index 703843f30ffd383f556639af7146c0d99a212c25..1b88fd5df05d6d7f6694a3d9284162d4ed386a0b 100644 (file)
@@ -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)