summaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2000-07-18 23:31:08 +0000
committerRalf Baechle <ralf@linux-mips.org>2000-07-18 23:31:08 +0000
commite8f9b6396e79654ea5932f64131cafbe8caadfb1 (patch)
tree90cf8b3a2475a774369eda22247cab7874fd7bbf /drivers/block
parentd4c419dfaa853f5db107973976d4215ae648e976 (diff)
Merge with Linux 2.4.0-test5-pre2.
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/floppy.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index b8426a6dd..60e6ac44f 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -3422,6 +3422,9 @@ static int get_floppy_geometry(int drive, int type, struct floppy_struct **g)
static int fd_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long param)
{
+#define IOCTL_MODE_BIT 8
+#define OPEN_WRITE_BIT 16
+#define IOCTL_ALLOWED (filp && (filp->f_mode & IOCTL_MODE_BIT))
#define OUT(c,x) case c: outparam = (const char *) (x); break
#define IN(c,x,tag) case c: *(x) = inparam. tag ; return 0
@@ -3489,7 +3492,8 @@ static int fd_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
return -EINVAL;
/* permission checks */
- if ((cmd & 0x80) && !suser())
+ if (((cmd & 0x40) && !IOCTL_ALLOWED) ||
+ ((cmd & 0x80) && !suser()))
return -EPERM;
/* copyin */
@@ -3609,6 +3613,7 @@ static int fd_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
return fd_copyout((void *)param, outparam, size);
else
return 0;
+#undef IOCTL_ALLOWED
#undef OUT
#undef IN
}
@@ -3761,6 +3766,12 @@ static int floppy_open(struct inode * inode, struct file * filp)
invalidate_buffers(MKDEV(FLOPPY_MAJOR,old_dev));
}
+ /* Allow ioctls if we have write-permissions even if read-only open */
+ if ((filp->f_mode & 2) || (permission(inode,2) == 0))
+ filp->f_mode |= IOCTL_MODE_BIT;
+ if (filp->f_mode & 2)
+ filp->f_mode |= OPEN_WRITE_BIT;
+
if (UFDCS->rawcmd == 1)
UFDCS->rawcmd = 2;