From 2986c1181194bb87cd24650e1e5ea67409600621 Mon Sep 17 00:00:00 2001 From: Ben Gras Date: Mon, 3 Oct 2005 14:17:33 +0000 Subject: [PATCH] DEV_UNMAP devctl() FSDEVUNMAP svrctl() --- servers/fs/dmap.c | 16 +++++++++++++--- servers/fs/misc.c | 12 ++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/servers/fs/dmap.c b/servers/fs/dmap.c index c177258ac..73a57fe87 100644 --- a/servers/fs/dmap.c +++ b/servers/fs/dmap.c @@ -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); diff --git a/servers/fs/misc.c b/servers/fs/misc.c index 1c1538631..b4abdb57f 100644 --- a/servers/fs/misc.c +++ b/servers/fs/misc.c @@ -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); } -- 2.44.0