dmap_io now returns a status. map_driver no longer calls dev_up.

This commit is contained in:
Philip Homburg 2006-03-15 13:37:20 +00:00
parent 36e8c1a185
commit 50d805144c
5 changed files with 59 additions and 25 deletions

View file

@ -21,7 +21,7 @@ enum dev_style { STYLE_DEV, STYLE_NDEV, STYLE_TTY, STYLE_CLONE };
extern struct dmap {
int _PROTOTYPE ((*dmap_opcl), (int, Dev_t, int, int) );
void _PROTOTYPE ((*dmap_io), (int, message *) );
int _PROTOTYPE ((*dmap_io), (int, message *) );
int dmap_driver;
int dmap_flags;
} dmap[];

View file

@ -350,7 +350,7 @@ PUBLIC int do_ioctl()
/*===========================================================================*
* gen_io *
*===========================================================================*/
PUBLIC void gen_io(task_nr, mess_ptr)
PUBLIC int gen_io(task_nr, mess_ptr)
int task_nr; /* which task to call */
message *mess_ptr; /* pointer to message for task */
{
@ -378,7 +378,7 @@ message *mess_ptr; /* pointer to message for task */
* request. The caller will do the revive for the process.
*/
if (mess_ptr->m_type == CANCEL && local_m.REP_ENDPT == proc_e) {
return;
return OK;
}
/* Otherwise it should be a REVIVE. */
@ -402,11 +402,12 @@ message *mess_ptr; /* pointer to message for task */
if (r != OK) {
if (r == EDEADSRCDST || r == EDSTDIED || r == ESRCDIED) {
printf("fs: dead driver %d\n", task_nr);
return;
dmap_unmap_by_endpt(task_nr);
return r;
}
if (r == ELOCKED) {
printf("fs: ELOCKED talking to %d\n", task_nr);
return;
return r;
}
panic(__FILE__,"call_task: can't send/receive", r);
}
@ -425,12 +426,14 @@ message *mess_ptr; /* pointer to message for task */
}
r = receive(task_nr, mess_ptr);
}
return OK;
}
/*===========================================================================*
* ctty_io *
*===========================================================================*/
PUBLIC void ctty_io(task_nr, mess_ptr)
PUBLIC int ctty_io(task_nr, mess_ptr)
int task_nr; /* not used - for compatibility with dmap_t */
message *mess_ptr; /* pointer to message for task */
{
@ -451,17 +454,18 @@ message *mess_ptr; /* pointer to message for task */
if (dp->dmap_driver == NONE) {
printf("FS: ctty_io: no driver for dev\n");
return;
return EIO;
}
if(isokendpt(dp->dmap_driver, &dummyproc) != OK) {
printf("FS: ctty_io: old driver %d\n",
dp->dmap_driver);
return;
return EIO;
}
(*dp->dmap_io)(dp->dmap_driver, mess_ptr);
}
return OK;
}
/*===========================================================================*
@ -480,11 +484,11 @@ int flags; /* mode bits and flags */
/*===========================================================================*
* no_dev_io *
*===========================================================================*/
PUBLIC void no_dev_io(int proc, message *m)
PUBLIC int no_dev_io(int proc, message *m)
{
/* Called when doing i/o on a nonexistent device. */
printf("FS: I/O on unmapped device number\n");
return;
return EIO;
}
/*===========================================================================*
@ -502,7 +506,7 @@ int flags; /* mode bits and flags */
* as a new network connection) that has been allocated within a task.
*/
struct dmap *dp;
int minor;
int r, minor;
message dev_mess;
/* Determine task dmap. */
@ -527,7 +531,9 @@ int flags; /* mode bits and flags */
}
/* Call the task. */
(*dp->dmap_io)(dp->dmap_driver, &dev_mess);
r= (*dp->dmap_io)(dp->dmap_driver, &dev_mess);
if (r != OK)
return r;
if (op == DEV_OPEN && dev_mess.REP_STATUS >= 0) {
if (dev_mess.REP_STATUS != minor) {
@ -590,6 +596,7 @@ PUBLIC void dev_up(int maj)
for(fp = filp; fp < &filp[NR_FILPS]; fp++) {
struct inode *in;
int minor;
if(fp->filp_count < 1 || !(in=fp->filp_ino)) continue;
if(((in->i_zone[0] >> MAJOR) & BYTE) != maj) continue;
if(!(in->i_mode & (I_BLOCK_SPECIAL|I_CHAR_SPECIAL))) continue;

View file

@ -60,12 +60,28 @@ PRIVATE struct dmap init_dmap[] = {
*===========================================================================*/
PUBLIC int do_devctl()
{
int result;
int result, proc_nr_e, proc_nr_n;
switch(m_in.ctl_req) {
case DEV_MAP:
/* Check process number of new driver. */
proc_nr_e= m_in.driver_nr;
if (isokendpt(proc_nr_e, &proc_nr_n) != OK)
return(EINVAL);
/* Try to update device mapping. */
result = map_driver(m_in.dev_nr, m_in.driver_nr, m_in.dev_style);
result = map_driver(m_in.dev_nr, proc_nr_e, m_in.dev_style);
if (result == OK)
{
/* If a driver has completed its exec(), it can be announced to be
* up.
*/
if(fproc[proc_nr_n].fp_execced) {
dev_up(m_in.dev_nr);
} else {
dmap[m_in.dev_nr].dmap_flags |= DMAP_BABY;
}
}
break;
case DEV_UNMAP:
result = map_driver(m_in.dev_nr, NONE, 0);
@ -129,13 +145,6 @@ int style; /* style of the device */
dp->dmap_io = gen_io;
dp->dmap_driver = proc_nr_e;
/* If a driver has completed its exec(), it can be announced to be up. */
if(fproc[proc_nr_n].fp_execced) {
dev_up(major);
} else {
dp->dmap_flags |= DMAP_BABY;
}
return(OK);
}

View file

@ -336,6 +336,9 @@ PUBLIC int do_fork()
/* This child has not exec()ced yet. */
cp->fp_execced = 0;
#if 0
printf("do_fork: child %d, slot %d\n", m_in.child_endpt, cp-fproc);
#endif
/* Record the fact that both root and working dir have another user. */
dup_inode(cp->fp_rootdir);
@ -515,7 +518,7 @@ PUBLIC int do_svrctl()
case FSSIGNON: {
/* A server in user space calls in to manage a device. */
struct fssignon device;
int r, major;
int r, major, proc_nr_n;
if (fp->fp_effuid != SU_UID && fp->fp_effuid != SERVERS_UID)
return(EPERM);
@ -526,9 +529,24 @@ PUBLIC int do_svrctl()
(phys_bytes) sizeof(device))) != OK)
return(r);
if (isokendpt(who_e, &proc_nr_n) != OK)
return(EINVAL);
/* Try to update device mapping. */
major = (device.dev >> MAJOR) & BYTE;
r=map_driver(major, who_e, device.style);
if (r == OK)
{
/* If a driver has completed its exec(), it can be announced
* to be up.
*/
if(fproc[proc_nr_n].fp_execced) {
dev_up(major);
} else {
dmap[major].dmap_flags |= DMAP_BABY;
}
}
return(r);
}
case FSDEVUNMAP: {

View file

@ -32,13 +32,13 @@ _PROTOTYPE( void dev_close, (Dev_t dev) );
_PROTOTYPE( int dev_io, (int op, Dev_t dev, int proc, void *buf,
off_t pos, int bytes, int flags) );
_PROTOTYPE( int gen_opcl, (int op, Dev_t dev, int proc, int flags) );
_PROTOTYPE( void gen_io, (int task_nr, message *mess_ptr) );
_PROTOTYPE( int gen_io, (int task_nr, message *mess_ptr) );
_PROTOTYPE( int no_dev, (int op, Dev_t dev, int proc, int flags) );
_PROTOTYPE( void no_dev_io, (int, message *) );
_PROTOTYPE( int no_dev_io, (int, message *) );
_PROTOTYPE( int tty_opcl, (int op, Dev_t dev, int proc, int flags) );
_PROTOTYPE( int ctty_opcl, (int op, Dev_t dev, int proc, int flags) );
_PROTOTYPE( int clone_opcl, (int op, Dev_t dev, int proc, int flags) );
_PROTOTYPE( void ctty_io, (int task_nr, message *mess_ptr) );
_PROTOTYPE( int ctty_io, (int task_nr, message *mess_ptr) );
_PROTOTYPE( int do_ioctl, (void) );
_PROTOTYPE( int do_setsid, (void) );
_PROTOTYPE( void dev_status, (message *) );