Skip to content

Commit 88baf3e

Browse files
Jon MastersLinus Torvalds
Jon Masters
authored and
Linus Torvalds
committed
[PATCH] fix floppy.c to store correct ro/rw status in underlying gendisk
Evgeny Stambulchik found that doing the following always worked: # mount /dev/fd0 /mnt/floppy/ mount: block device /dev/fd0 is write-protected, mounting read-only # mount -o remount,rw /mnt/floppy # echo $? 0 This is the case because the block device /dev/fd0 is writeable but the floppy disk is marked protected. A fix is to simply have floppy_open mark the underlying gendisk policy according to reality (since the VFS doesn't provide a way for do_remount_sb to inquire as to the current device status). Signed-off-by: Jon Masters <[email protected]> Cc: Al Viro <[email protected]> Cc: Christoph Hellwig <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 4448aaf commit 88baf3e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/block/floppy.c

+6
Original file line numberDiff line numberDiff line change
@@ -3714,6 +3714,12 @@ static int floppy_open(struct inode *inode, struct file *filp)
37143714
USETF(FD_VERIFY);
37153715
}
37163716

3717+
/* set underlying gendisk policy to reflect real ro/rw status */
3718+
if (UTESTF(FD_DISK_WRITABLE))
3719+
inode->i_bdev->bd_disk->policy = 0;
3720+
else
3721+
inode->i_bdev->bd_disk->policy = 1;
3722+
37173723
if (UDRS->fd_ref == -1 || (UDRS->fd_ref && (filp->f_flags & O_EXCL)))
37183724
goto out2;
37193725

0 commit comments

Comments
 (0)