mirror of
https://github.com/adulau/aha.git
synced 2024-12-29 04:06:22 +00:00
[PATCH] switch floppy
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
47844fadb5
commit
a4af9b48cb
1 changed files with 26 additions and 25 deletions
|
@ -3450,14 +3450,14 @@ static int fd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int fd_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
|
static int fd_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd,
|
||||||
unsigned long param)
|
unsigned long param)
|
||||||
{
|
{
|
||||||
#define FD_IOCTL_ALLOWED ((filp) && (filp)->f_mode & (FMODE_WRITE|FMODE_WRITE_IOCTL))
|
#define FD_IOCTL_ALLOWED (mode & (FMODE_WRITE|FMODE_WRITE_IOCTL))
|
||||||
#define OUT(c,x) case c: outparam = (const char *) (x); break
|
#define OUT(c,x) case c: outparam = (const char *) (x); break
|
||||||
#define IN(c,x,tag) case c: *(x) = inparam. tag ; return 0
|
#define IN(c,x,tag) case c: *(x) = inparam. tag ; return 0
|
||||||
|
|
||||||
int drive = (long)inode->i_bdev->bd_disk->private_data;
|
int drive = (long)bdev->bd_disk->private_data;
|
||||||
int type = ITYPE(UDRS->fd_device);
|
int type = ITYPE(UDRS->fd_device);
|
||||||
int i;
|
int i;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -3516,11 +3516,11 @@ static int fd_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
|
||||||
current_type[drive] = NULL;
|
current_type[drive] = NULL;
|
||||||
floppy_sizes[drive] = MAX_DISK_SIZE << 1;
|
floppy_sizes[drive] = MAX_DISK_SIZE << 1;
|
||||||
UDRS->keep_data = 0;
|
UDRS->keep_data = 0;
|
||||||
return invalidate_drive(inode->i_bdev);
|
return invalidate_drive(bdev);
|
||||||
case FDSETPRM:
|
case FDSETPRM:
|
||||||
case FDDEFPRM:
|
case FDDEFPRM:
|
||||||
return set_geometry(cmd, &inparam.g,
|
return set_geometry(cmd, &inparam.g,
|
||||||
drive, type, inode->i_bdev);
|
drive, type, bdev);
|
||||||
case FDGETPRM:
|
case FDGETPRM:
|
||||||
ECALL(get_floppy_geometry(drive, type,
|
ECALL(get_floppy_geometry(drive, type,
|
||||||
(struct floppy_struct **)
|
(struct floppy_struct **)
|
||||||
|
@ -3551,7 +3551,7 @@ static int fd_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
|
||||||
case FDFMTEND:
|
case FDFMTEND:
|
||||||
case FDFLUSH:
|
case FDFLUSH:
|
||||||
LOCK_FDC(drive, 1);
|
LOCK_FDC(drive, 1);
|
||||||
return invalidate_drive(inode->i_bdev);
|
return invalidate_drive(bdev);
|
||||||
|
|
||||||
case FDSETEMSGTRESH:
|
case FDSETEMSGTRESH:
|
||||||
UDP->max_errors.reporting =
|
UDP->max_errors.reporting =
|
||||||
|
@ -3659,9 +3659,9 @@ static void __init config_types(void)
|
||||||
printk("\n");
|
printk("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int floppy_release(struct inode *inode, struct file *filp)
|
static int floppy_release(struct gendisk *disk, fmode_t mode)
|
||||||
{
|
{
|
||||||
int drive = (long)inode->i_bdev->bd_disk->private_data;
|
int drive = (long)disk->private_data;
|
||||||
|
|
||||||
mutex_lock(&open_lock);
|
mutex_lock(&open_lock);
|
||||||
if (UDRS->fd_ref < 0)
|
if (UDRS->fd_ref < 0)
|
||||||
|
@ -3682,17 +3682,17 @@ static int floppy_release(struct inode *inode, struct file *filp)
|
||||||
* /dev/PS0 etc), and disallows simultaneous access to the same
|
* /dev/PS0 etc), and disallows simultaneous access to the same
|
||||||
* drive with different device numbers.
|
* drive with different device numbers.
|
||||||
*/
|
*/
|
||||||
static int floppy_open(struct inode *inode, struct file *filp)
|
static int floppy_open(struct block_device *bdev, fmode_t mode)
|
||||||
{
|
{
|
||||||
int drive = (long)inode->i_bdev->bd_disk->private_data;
|
int drive = (long)bdev->bd_disk->private_data;
|
||||||
int old_dev;
|
int old_dev, new_dev;
|
||||||
int try;
|
int try;
|
||||||
int res = -EBUSY;
|
int res = -EBUSY;
|
||||||
char *tmp;
|
char *tmp;
|
||||||
|
|
||||||
mutex_lock(&open_lock);
|
mutex_lock(&open_lock);
|
||||||
old_dev = UDRS->fd_device;
|
old_dev = UDRS->fd_device;
|
||||||
if (opened_bdev[drive] && opened_bdev[drive] != inode->i_bdev)
|
if (opened_bdev[drive] && opened_bdev[drive] != bdev)
|
||||||
goto out2;
|
goto out2;
|
||||||
|
|
||||||
if (!UDRS->fd_ref && (UDP->flags & FD_BROKEN_DCL)) {
|
if (!UDRS->fd_ref && (UDP->flags & FD_BROKEN_DCL)) {
|
||||||
|
@ -3700,15 +3700,15 @@ static int floppy_open(struct inode *inode, struct file *filp)
|
||||||
USETF(FD_VERIFY);
|
USETF(FD_VERIFY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UDRS->fd_ref == -1 || (UDRS->fd_ref && (filp->f_mode & FMODE_EXCL)))
|
if (UDRS->fd_ref == -1 || (UDRS->fd_ref && (mode & FMODE_EXCL)))
|
||||||
goto out2;
|
goto out2;
|
||||||
|
|
||||||
if (filp->f_mode & FMODE_EXCL)
|
if (mode & FMODE_EXCL)
|
||||||
UDRS->fd_ref = -1;
|
UDRS->fd_ref = -1;
|
||||||
else
|
else
|
||||||
UDRS->fd_ref++;
|
UDRS->fd_ref++;
|
||||||
|
|
||||||
opened_bdev[drive] = inode->i_bdev;
|
opened_bdev[drive] = bdev;
|
||||||
|
|
||||||
res = -ENXIO;
|
res = -ENXIO;
|
||||||
|
|
||||||
|
@ -3743,9 +3743,10 @@ static int floppy_open(struct inode *inode, struct file *filp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UDRS->fd_device = iminor(inode);
|
new_dev = MINOR(bdev->bd_dev);
|
||||||
set_capacity(disks[drive], floppy_sizes[iminor(inode)]);
|
UDRS->fd_device = new_dev;
|
||||||
if (old_dev != -1 && old_dev != iminor(inode)) {
|
set_capacity(disks[drive], floppy_sizes[new_dev]);
|
||||||
|
if (old_dev != -1 && old_dev != new_dev) {
|
||||||
if (buffer_drive == drive)
|
if (buffer_drive == drive)
|
||||||
buffer_track = -1;
|
buffer_track = -1;
|
||||||
}
|
}
|
||||||
|
@ -3753,15 +3754,15 @@ static int floppy_open(struct inode *inode, struct file *filp)
|
||||||
if (UFDCS->rawcmd == 1)
|
if (UFDCS->rawcmd == 1)
|
||||||
UFDCS->rawcmd = 2;
|
UFDCS->rawcmd = 2;
|
||||||
|
|
||||||
if (!(filp->f_mode & FMODE_NDELAY)) {
|
if (!(mode & FMODE_NDELAY)) {
|
||||||
if (filp->f_mode & (FMODE_READ|FMODE_WRITE)) {
|
if (mode & (FMODE_READ|FMODE_WRITE)) {
|
||||||
UDRS->last_checked = 0;
|
UDRS->last_checked = 0;
|
||||||
check_disk_change(inode->i_bdev);
|
check_disk_change(bdev);
|
||||||
if (UTESTF(FD_DISK_CHANGED))
|
if (UTESTF(FD_DISK_CHANGED))
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
res = -EROFS;
|
res = -EROFS;
|
||||||
if ((filp->f_mode & FMODE_WRITE) && !(UTESTF(FD_DISK_WRITABLE)))
|
if ((mode & FMODE_WRITE) && !(UTESTF(FD_DISK_WRITABLE)))
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
mutex_unlock(&open_lock);
|
mutex_unlock(&open_lock);
|
||||||
|
@ -3902,9 +3903,9 @@ static int floppy_revalidate(struct gendisk *disk)
|
||||||
|
|
||||||
static struct block_device_operations floppy_fops = {
|
static struct block_device_operations floppy_fops = {
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
.__open = floppy_open,
|
.open = floppy_open,
|
||||||
.__release = floppy_release,
|
.release = floppy_release,
|
||||||
.__ioctl = fd_ioctl,
|
.locked_ioctl = fd_ioctl,
|
||||||
.getgeo = fd_getgeo,
|
.getgeo = fd_getgeo,
|
||||||
.media_changed = check_floppy_change,
|
.media_changed = check_floppy_change,
|
||||||
.revalidate_disk = floppy_revalidate,
|
.revalidate_disk = floppy_revalidate,
|
||||||
|
|
Loading…
Reference in a new issue