diff options
author | Jan Kara <jack@suse.cz> | 2009-06-18 12:33:16 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-09-24 08:47:31 -0700 |
commit | ce6e6c3fd056731a213c9c6cce0c46e36fd2c644 (patch) | |
tree | 0ce5057cc84613a3b6f31f45ed7548611994065b | |
parent | 1c27e4044eabce1fd6aa27d7178c7a07811d6f16 (diff) | |
download | lwn-ce6e6c3fd056731a213c9c6cce0c46e36fd2c644.tar.gz lwn-ce6e6c3fd056731a213c9c6cce0c46e36fd2c644.zip |
udf: Use device size when drive reported bogus number of written blocks
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>
-rw-r--r-- | fs/udf/lowlevel.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/fs/udf/lowlevel.c b/fs/udf/lowlevel.c index 703843f30ffd..1b88fd5df05d 100644 --- a/fs/udf/lowlevel.c +++ b/fs/udf/lowlevel.c @@ -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) |