Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ghaerr committed Oct 6, 2023
1 parent 48aa86f commit 69c43be
Showing 1 changed file with 6 additions and 29 deletions.
35 changes: 6 additions & 29 deletions elks/arch/i86/drivers/block/directfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1005,11 +1005,12 @@ static void shake_one(void)
#if CHECK_DISK_CHANGE
/*
* This routine checks whether a removable media has been changed,
* and invalidates all inode and buffer-cache-entries in that case.
* invalidates all inode and buffer-cache-entries, unmounts
* any mounted filesystem and closes the driver.
* It is called from device open, mount and file read/write code.
* Because the FDC is interrupt driven and can't sleep, this routine
* must be called by a non-interrupt routine, as invalidate_buffers
* may sleep, and otherwise all accessed kernel variables would need
* may sleep. Even without that, all accessed kernel variables would need
* protection via interrupt disabling.
*
* Since this driver is the only driver implementing media change,
Expand All @@ -1032,10 +1033,8 @@ int check_disk_change(kdev_t dev)

if (!dev && changed_floppies) {
dev = (changed_floppies & 1)? MKDEV(MAJOR_NR, 0): MKDEV(MAJOR_NR, 1);
} else {
if (MAJOR(dev) != MAJOR_NR)
return 0;
}
} else if (MAJOR(dev) != MAJOR_NR)
return 0;
debug("C%d", dev&3);
mask = 1 << DEVICE_NR(dev);
if (!(changed_floppies & mask)) {
Expand All @@ -1051,7 +1050,7 @@ int check_disk_change(kdev_t dev)
if (s && s->s_mounted) {
do_umount(dev);
printk("VFS: Unmounting %s, media changed\n", s->s_mntonname);
/* fake up inode to enable device release */
/* fake up inode to enable device close */
inodep = new_inode(NULL, S_IFBLK);
inodep->i_rdev = dev;
floppy_release(inodep, NULL);
Expand All @@ -1063,7 +1062,6 @@ int check_disk_change(kdev_t dev)

changed_floppies &= ~mask;
debug_changed = 0;
//recalibrate = 1;
printk("VFS: Disk media change completed on dev %D\n", dev);

return 1;
Expand Down Expand Up @@ -1262,15 +1260,6 @@ static int fd_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
}
return err;
#ifdef UNUSED
case FDFMTEND:
if (!suser())
return -EPERM;
clr_irq();
fake_change |= 1 << (drive & 3);
set_irq();
drive &= 3;
cmd = FDCLRPRM;
break;
case FDFMTTRK:
if (!suser())
return -EPERM;
Expand Down Expand Up @@ -1300,22 +1289,10 @@ static int fd_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
floppy_off(drive & 3);
wake_up(&format_done);
return err ? 0 : -EIO;
case FDFLUSH:
if (!permission(inode, 2))
return -EPERM;
clr_irq();
fake_change |= 1 << (drive & 3);
set_irq();
check_disk_change(inode->i_rdev);
return 0;
}
if (!suser())
return -EPERM;
switch (cmd) {
case FDCLRPRM:
current_type[drive] = NULL;
keep_data[drive] = 0;
break;
case FDSETPRM:
case FDDEFPRM:
memcpy_fromfs(user_params + drive,
Expand Down

0 comments on commit 69c43be

Please sign in to comment.