DEV_UNMAP devctl()

FSDEVUNMAP svrctl()
This commit is contained in:
Ben Gras 2005-10-03 14:17:33 +00:00
parent 8c4166ee85
commit 2986c11811
2 changed files with 25 additions and 3 deletions

View File

@ -68,7 +68,7 @@ PUBLIC int do_devctl()
result = map_driver(m_in.dev_nr, m_in.driver_nr, m_in.dev_style);
break;
case DEV_UNMAP:
result = ENOSYS;
result = map_driver(m_in.dev_nr, NONE, 0);
break;
default:
result = EINVAL;
@ -86,20 +86,30 @@ int style; /* style of the device */
{
/* Set a new device driver mapping in the dmap table. Given that correct
* arguments are given, this only works if the entry is mutable and the
* current driver is not busy.
* current driver is not busy. If the proc_nr is set to NONE, we're supposed
* to unmap it.
*
* Normal error codes are returned so that this function can be used from
* a system call that tries to dynamically install a new driver.
*/
struct dmap *dp;
/* Get pointer to device entry in the dmap table. */
if (major >= NR_DEVICES) return(ENODEV);
if (major < 0 || major >= NR_DEVICES) return(ENODEV);
dp = &dmap[major];
/* See if updating the entry is allowed. */
if (! (dp->dmap_flags & DMAP_MUTABLE)) return(EPERM);
if (dp->dmap_flags & DMAP_BUSY) return(EBUSY);
/* Check if we're supposed to unmap it. */
if(proc_nr == NONE) {
dp->dmap_opcl = no_dev;
dp->dmap_io = 0;
dp->dmap_driver = 0;
return(OK);
}
/* Check process number of new driver. */
if (! isokprocnr(proc_nr)) return(EINVAL);

View File

@ -439,6 +439,18 @@ PUBLIC int do_svrctl()
r=map_driver(major, who, device.style);
return(r);
}
case FSDEVUNMAP: {
struct fsdevunmap fdu;
int r, major;
/* Try to copy request structure to FS. */
if ((r = sys_datacopy(who, (vir_bytes) m_in.svrctl_argp,
FS_PROC_NR, (vir_bytes) &fdu,
(phys_bytes) sizeof(fdu))) != OK)
return(r);
major = (fdu.dev >> MAJOR) & BYTE;
r=map_driver(major, NONE, 0);
return(r);
}
default:
return(EINVAL);
}