aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/floppy.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/block/floppy.c')
-rw-r--r--drivers/block/floppy.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index ae3ef8945f3f..5d60c05a736a 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -3453,7 +3453,7 @@ static int fd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
3453static int fd_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, 3453static int fd_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
3454 unsigned long param) 3454 unsigned long param)
3455{ 3455{
3456#define FD_IOCTL_ALLOWED ((filp) && (filp)->private_data) 3456#define FD_IOCTL_ALLOWED ((filp) && (filp)->f_mode & (FMODE_WRITE|FMODE_WRITE_IOCTL))
3457#define OUT(c,x) case c: outparam = (const char *) (x); break 3457#define OUT(c,x) case c: outparam = (const char *) (x); break
3458#define IN(c,x,tag) case c: *(x) = inparam. tag ; return 0 3458#define IN(c,x,tag) case c: *(x) = inparam. tag ; return 0
3459 3459
@@ -3690,7 +3690,6 @@ static int floppy_open(struct inode *inode, struct file *filp)
3690 int res = -EBUSY; 3690 int res = -EBUSY;
3691 char *tmp; 3691 char *tmp;
3692 3692
3693 filp->private_data = (void *)0;
3694 mutex_lock(&open_lock); 3693 mutex_lock(&open_lock);
3695 old_dev = UDRS->fd_device; 3694 old_dev = UDRS->fd_device;
3696 if (opened_bdev[drive] && opened_bdev[drive] != inode->i_bdev) 3695 if (opened_bdev[drive] && opened_bdev[drive] != inode->i_bdev)
@@ -3701,10 +3700,10 @@ static int floppy_open(struct inode *inode, struct file *filp)
3701 USETF(FD_VERIFY); 3700 USETF(FD_VERIFY);
3702 } 3701 }
3703 3702
3704 if (UDRS->fd_ref == -1 || (UDRS->fd_ref && (filp->f_flags & O_EXCL))) 3703 if (UDRS->fd_ref == -1 || (UDRS->fd_ref && (filp->f_mode & FMODE_EXCL)))
3705 goto out2; 3704 goto out2;
3706 3705
3707 if (filp->f_flags & O_EXCL) 3706 if (filp->f_mode & FMODE_EXCL)
3708 UDRS->fd_ref = -1; 3707 UDRS->fd_ref = -1;
3709 else 3708 else
3710 UDRS->fd_ref++; 3709 UDRS->fd_ref++;
@@ -3751,16 +3750,10 @@ static int floppy_open(struct inode *inode, struct file *filp)
3751 buffer_track = -1; 3750 buffer_track = -1;
3752 } 3751 }
3753 3752
3754 /* Allow ioctls if we have write-permissions even if read-only open.
3755 * Needed so that programs such as fdrawcmd still can work on write
3756 * protected disks */
3757 if ((filp->f_mode & FMODE_WRITE) || !file_permission(filp, MAY_WRITE))
3758 filp->private_data = (void *)8;
3759
3760 if (UFDCS->rawcmd == 1) 3753 if (UFDCS->rawcmd == 1)
3761 UFDCS->rawcmd = 2; 3754 UFDCS->rawcmd = 2;
3762 3755
3763 if (!(filp->f_flags & O_NDELAY)) { 3756 if (!(filp->f_mode & FMODE_NDELAY)) {
3764 if (filp->f_mode & (FMODE_READ|FMODE_WRITE)) { 3757 if (filp->f_mode & (FMODE_READ|FMODE_WRITE)) {
3765 UDRS->last_checked = 0; 3758 UDRS->last_checked = 0;
3766 check_disk_change(inode->i_bdev); 3759 check_disk_change(inode->i_bdev);