lkml.org 
[lkml]   [2000]   [Oct]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject2.4.0-test9 [PATCH] Fix floppy ioctls
On Sat, Sep 16, 2000 at 07:22:38PM +0200, Alain Knaff wrote:
> The following patch (against 2.4.0-test8) restores floppy ioctl functionality,
> which has been broken in 2.4.0-test6-pre7. It now tests for fake
> ioctl's, so their should be no interaction with read-only mounts:

Still not in test9: even root cannot fdformat. To recall:

--- 2.4.0-test8/linux/drivers/block/floppy.c Mon Sep 11 20:09:28 2000
+++ linux/drivers/block/floppy.c Sat Sep 16 18:57:14 2000
@@ -3435,6 +3435,7 @@
static int fd_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long param)
{
+#define FD_IOCTL_ALLOWED ((filp) && (filp)->private_data)
#define OUT(c,x) case c: outparam = (const char *) (x); break
#define IN(c,x,tag) case c: *(x) = inparam. tag ; return 0

@@ -3502,7 +3503,7 @@
return -EINVAL;

/* permission checks */
- if (((cmd & 0x40) && !(filp->f_mode & 2)) ||
+ if (((cmd & 0x40) && !FD_IOCTL_ALLOWED) ||
((cmd & 0x80) && !capable(CAP_SYS_ADMIN)))
return -EPERM;

@@ -3708,6 +3709,8 @@
return -EIO;
}

+ filp->private_data = (void*) 0;
+
drive = DRIVE(inode->i_rdev);
if (drive >= N_DRIVE ||
!(allowed_drive_mask & (1 << drive)) ||
@@ -3774,6 +3777,13 @@
buffer_track = -1;
invalidate_buffers(MKDEV(FLOPPY_MAJOR,old_dev));
}
+
+ /* Allow ioctls if we have write-permissions even if read-only open.
+ * Needed so that programs such as fdrawcmd still can work on write
+ * protected disks */
+ if ((filp->f_mode & 2) ||
+ (inode->i_sb && (permission(inode,2) == 0)))
+ filp->private_data = (void*) 8;

if (UFDCS->rawcmd == 1)
UFDCS->rawcmd = 2;
--
Frank
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 12:39    [W:0.053 / U:0.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site