2005-04-21 16:53:53 +02:00
|
|
|
/* When a needed block is not in the cache, it must be fetched from the disk.
|
|
|
|
* Special character files also require I/O. The routines for these are here.
|
|
|
|
*
|
|
|
|
* The entry points in this file are:
|
|
|
|
* dev_open: FS opens a device
|
|
|
|
* dev_close: FS closes a device
|
|
|
|
* dev_io: FS does a read or write on a device
|
2005-07-27 15:08:52 +02:00
|
|
|
* dev_status: FS processes callback request alert
|
2005-04-21 16:53:53 +02:00
|
|
|
* gen_opcl: generic call to a task to perform an open/close
|
|
|
|
* gen_io: generic call to a task to perform an I/O operation
|
|
|
|
* no_dev: open/close processing for devices that don't exist
|
2005-10-05 17:38:15 +02:00
|
|
|
* no_dev_io: i/o processing for devices that don't exist
|
2005-04-21 16:53:53 +02:00
|
|
|
* tty_opcl: perform tty-specific processing for open/close
|
|
|
|
* ctty_opcl: perform controlling-tty-specific processing for open/close
|
|
|
|
* ctty_io: perform controlling-tty-specific processing for I/O
|
|
|
|
* do_ioctl: perform the IOCTL system call
|
2006-10-25 15:40:36 +02:00
|
|
|
* do_setsid: perform the SETSID system call (FS side)
|
2005-04-21 16:53:53 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "fs.h"
|
|
|
|
#include <fcntl.h>
|
2006-06-20 12:12:09 +02:00
|
|
|
#include <assert.h>
|
2005-04-21 16:53:53 +02:00
|
|
|
#include <minix/callnr.h>
|
|
|
|
#include <minix/com.h>
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
#include <minix/endpoint.h>
|
2006-06-20 12:12:09 +02:00
|
|
|
#include <minix/ioctl.h>
|
2006-11-27 15:21:43 +01:00
|
|
|
#include <minix/u64.h>
|
2005-04-21 16:53:53 +02:00
|
|
|
#include "file.h"
|
|
|
|
#include "fproc.h"
|
2006-10-25 15:40:36 +02:00
|
|
|
|
|
|
|
#include <minix/vfsif.h>
|
|
|
|
#include "vnode.h"
|
|
|
|
#include "vmnt.h"
|
2005-04-21 16:53:53 +02:00
|
|
|
#include "param.h"
|
|
|
|
|
2005-07-08 19:30:01 +02:00
|
|
|
#define ELEMENTS(a) (sizeof(a)/sizeof((a)[0]))
|
|
|
|
|
2006-06-29 16:24:07 +02:00
|
|
|
FORWARD _PROTOTYPE( int safe_io_conversion, (endpoint_t,
|
2006-06-20 12:12:09 +02:00
|
|
|
cp_grant_id_t *, int *, cp_grant_id_t *, int, endpoint_t *,
|
2007-04-24 15:27:33 +02:00
|
|
|
void **, int *, vir_bytes, u32_t *));
|
2006-06-29 16:24:07 +02:00
|
|
|
FORWARD _PROTOTYPE( void safe_io_cleanup, (cp_grant_id_t, cp_grant_id_t *,
|
|
|
|
int));
|
2006-06-20 12:12:09 +02:00
|
|
|
|
2005-07-08 19:30:01 +02:00
|
|
|
extern int dmap_size;
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
PRIVATE int dummyproc;
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* dev_open *
|
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC int dev_open(dev, proc, flags)
|
|
|
|
dev_t dev; /* device to open */
|
|
|
|
int proc; /* process to open for */
|
|
|
|
int flags; /* mode bits and flags */
|
|
|
|
{
|
|
|
|
int major, r;
|
|
|
|
struct dmap *dp;
|
|
|
|
|
|
|
|
/* Determine the major device number call the device class specific
|
|
|
|
* open/close routine. (This is the only routine that must check the
|
|
|
|
* device number for being in range. All others can trust this check.)
|
|
|
|
*/
|
|
|
|
major = (dev >> MAJOR) & BYTE;
|
2005-06-07 16:43:35 +02:00
|
|
|
if (major >= NR_DEVICES) major = 0;
|
2005-04-21 16:53:53 +02:00
|
|
|
dp = &dmap[major];
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
if (dp->dmap_driver == NONE)
|
2006-01-17 18:55:35 +01:00
|
|
|
return ENXIO;
|
2005-04-21 16:53:53 +02:00
|
|
|
r = (*dp->dmap_opcl)(DEV_OPEN, dev, proc, flags);
|
2005-06-01 16:31:00 +02:00
|
|
|
if (r == SUSPEND) panic(__FILE__,"suspend on open from", dp->dmap_driver);
|
2005-04-21 16:53:53 +02:00
|
|
|
return(r);
|
|
|
|
}
|
|
|
|
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* dev_close *
|
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC void dev_close(dev)
|
|
|
|
dev_t dev; /* device to close */
|
|
|
|
{
|
2005-10-21 21:31:38 +02:00
|
|
|
/* See if driver is roughly valid. */
|
|
|
|
if (dmap[(dev >> MAJOR)].dmap_driver == NONE) {
|
|
|
|
return;
|
|
|
|
}
|
2005-04-21 16:53:53 +02:00
|
|
|
(void) (*dmap[(dev >> MAJOR) & BYTE].dmap_opcl)(DEV_CLOSE, dev, 0, 0);
|
|
|
|
}
|
|
|
|
|
2005-07-27 15:08:52 +02:00
|
|
|
/*===========================================================================*
|
2006-06-20 12:12:09 +02:00
|
|
|
* suspended_ep *
|
|
|
|
*===========================================================================*/
|
|
|
|
endpoint_t suspended_ep(endpoint_t driver, cp_grant_id_t g)
|
|
|
|
{
|
|
|
|
/* A process is suspended on a driver for which FS issued
|
|
|
|
* a grant. Find out which process it was.
|
|
|
|
*/
|
2006-10-25 15:40:36 +02:00
|
|
|
struct fproc *rfp;
|
|
|
|
for (rfp = &fproc[0]; rfp < &fproc[NR_PROCS]; rfp++) {
|
|
|
|
if(rfp->fp_pid == PID_FREE)
|
|
|
|
continue;
|
|
|
|
if(rfp->fp_suspended == SUSPENDED &&
|
|
|
|
rfp->fp_task == -driver && rfp->fp_grant == g) {
|
|
|
|
return rfp->fp_endpoint;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NONE;
|
2006-06-20 12:12:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* dev_status *
|
2005-07-27 15:08:52 +02:00
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC void dev_status(message *m)
|
|
|
|
{
|
|
|
|
message st;
|
|
|
|
int d, get_more = 1;
|
2006-06-20 12:12:09 +02:00
|
|
|
endpoint_t endpt;
|
2005-07-27 15:08:52 +02:00
|
|
|
|
|
|
|
for(d = 0; d < NR_DEVICES; d++)
|
2005-10-20 21:39:32 +02:00
|
|
|
if (dmap[d].dmap_driver != NONE &&
|
|
|
|
dmap[d].dmap_driver == m->m_source)
|
2005-07-27 15:08:52 +02:00
|
|
|
break;
|
|
|
|
|
2005-09-11 18:45:46 +02:00
|
|
|
if (d >= NR_DEVICES)
|
2005-07-27 15:08:52 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
do {
|
|
|
|
int r;
|
|
|
|
st.m_type = DEV_STATUS;
|
2005-10-20 21:39:32 +02:00
|
|
|
if ((r=sendrec(m->m_source, &st)) != OK) {
|
|
|
|
printf("DEV_STATUS failed to %d: %d\n", m->m_source, r);
|
|
|
|
if (r == EDEADSRCDST) return;
|
2005-10-20 22:46:04 +02:00
|
|
|
if (r == EDSTDIED) return;
|
|
|
|
if (r == ESRCDIED) return;
|
2005-07-27 15:08:52 +02:00
|
|
|
panic(__FILE__,"couldn't sendrec for DEV_STATUS", r);
|
2005-10-20 21:39:32 +02:00
|
|
|
}
|
2005-07-27 15:08:52 +02:00
|
|
|
|
|
|
|
switch(st.m_type) {
|
|
|
|
case DEV_REVIVE:
|
2006-06-20 12:12:09 +02:00
|
|
|
endpt = st.REP_ENDPT;
|
|
|
|
if(endpt == FS_PROC_NR) {
|
|
|
|
endpt = suspended_ep(m->m_source,
|
|
|
|
st.REP_IO_GRANT);
|
|
|
|
if(endpt == NONE) {
|
|
|
|
printf("FS: proc with "
|
2006-08-04 15:31:06 +02:00
|
|
|
"grant %d from %d not found (revive)\n",
|
Mostly bugfixes of bugs triggered by the test set.
bugfixes:
SYSTEM:
. removed
rc->p_priv->s_flags = 0;
for the priv struct shared by all user processes in get_priv(). this
should only be done once. doing a SYS_PRIV_USER in sys_privctl()
caused the flags of all user processes to be reset, so they were no
longer PREEMPTIBLE. this happened when RS executed a policy script.
(this broke test1 in the test set)
VFS/MFS:
. chown can change the mode of a file, and chmod arguments are only
part of the full file mode so the full filemode is slightly magic.
changed these calls so that the final modes are returned to VFS, so
that the vnode can be kept up-to-date.
(this broke test11 in the test set)
MFS:
. lookup() checked for sizeof(string) instead of sizeof(user_path),
truncating long path names
(caught by test 23)
. truncate functions neglected to update ctime
(this broke test16)
VFS:
. corner case of an empty filename lookup caused fields of a request
not to be filled in in the lookup functions, not making it clear
that the lookup had failed, causing messages to garbage processes,
causing strange failures.
(caught by test 30)
. trust v_size in vnode when doing reads or writes on non-special
files, truncating i/o where necessary; this is necessary for pipes,
as MFS can't tell when a pipe has been truncated without it being
told explicitly each time.
when the last reader/writer on a pipe closes, tell FS about
the new size using truncate_vn().
(this broke test 25, among others)
. permission check for chdir() had disappeared; added a
forbidden() call
(caught by test 23)
new code, shouldn't change anything:
. introduced RTS_SET, RTS_UNSET, and RTS_ISSET macro's, and their
LOCK variants. These macros set and clear the p_rts_flags field,
causing a lot of duplicated logic like
old_flags = rp->p_rts_flags; /* save value of the flags */
rp->p_rts_flags &= ~NO_PRIV;
if (old_flags != 0 && rp->p_rts_flags == 0) lock_enqueue(rp);
to change into the simpler
RTS_LOCK_UNSET(rp, NO_PRIV);
so the macros take care of calling dequeue() and enqueue() (or lock_*()),
as the case may be). This makes the code a bit more readable and a
bit less fragile.
. removed return code from do_clocktick in CLOCK as it currently
never replies
. removed some debug code from VFS
. fixed grant debug message in device.c
preemptive checks, tests, changes:
. added return code checks of receive() to SYSTEM and CLOCK
. O_TRUNC should never arrive at MFS (added sanity check and removed
O_TRUNC code)
. user_path declared with PATH_MAX+1 to let it be null-terminated
. checks in MFS to see if strings passed by VFS are null-terminated
IS:
. static irq name table thrown out
2007-02-01 18:50:02 +01:00
|
|
|
st.REP_IO_GRANT,
|
|
|
|
st.m_source);
|
2006-06-20 12:12:09 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
revive(endpt, st.REP_STATUS);
|
2005-07-27 15:08:52 +02:00
|
|
|
break;
|
|
|
|
case DEV_IO_READY:
|
2006-06-29 16:24:07 +02:00
|
|
|
select_notified(d, st.DEV_MINOR,
|
|
|
|
st.DEV_SEL_OPS);
|
2005-07-27 15:08:52 +02:00
|
|
|
break;
|
|
|
|
default:
|
2006-06-29 16:24:07 +02:00
|
|
|
printf("FS: unrecognized reply %d to "
|
|
|
|
"DEV_STATUS\n", st.m_type);
|
2005-07-27 15:08:52 +02:00
|
|
|
/* Fall through. */
|
|
|
|
case DEV_NO_STATUS:
|
|
|
|
get_more = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while(get_more);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-06-20 12:12:09 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* safe_io_conversion *
|
|
|
|
*===========================================================================*/
|
2006-06-29 16:24:07 +02:00
|
|
|
PRIVATE int safe_io_conversion(driver, gid, op, gids, gids_size,
|
2007-04-24 15:27:33 +02:00
|
|
|
io_ept, buf, vec_grants, bytes, pos_lo)
|
2006-06-20 12:12:09 +02:00
|
|
|
endpoint_t driver;
|
|
|
|
cp_grant_id_t *gid;
|
|
|
|
int *op;
|
|
|
|
cp_grant_id_t *gids;
|
|
|
|
int gids_size;
|
|
|
|
endpoint_t *io_ept;
|
2006-06-29 16:24:07 +02:00
|
|
|
void **buf;
|
2006-06-20 12:12:09 +02:00
|
|
|
int *vec_grants;
|
|
|
|
vir_bytes bytes;
|
2007-04-24 15:27:33 +02:00
|
|
|
u32_t *pos_lo;
|
2006-06-20 12:12:09 +02:00
|
|
|
{
|
|
|
|
int access = 0, size;
|
2006-06-27 18:47:35 +02:00
|
|
|
int j;
|
2006-06-20 12:12:09 +02:00
|
|
|
iovec_t *v;
|
2006-06-29 16:24:07 +02:00
|
|
|
static iovec_t new_iovec[NR_IOREQS];
|
2006-06-20 12:12:09 +02:00
|
|
|
|
|
|
|
/* Number of grants allocated in vector I/O. */
|
|
|
|
*vec_grants = 0;
|
|
|
|
|
|
|
|
/* Driver can handle it - change request to a safe one. */
|
|
|
|
|
|
|
|
*gid = GRANT_INVALID;
|
|
|
|
|
|
|
|
switch(*op) {
|
2007-02-07 17:22:19 +01:00
|
|
|
case VFS_DEV_READ:
|
|
|
|
case VFS_DEV_WRITE:
|
2006-06-20 12:12:09 +02:00
|
|
|
/* Change to safe op. */
|
2007-02-07 17:22:19 +01:00
|
|
|
*op = *op == VFS_DEV_READ ? DEV_READ_S : DEV_WRITE_S;
|
2006-06-20 12:12:09 +02:00
|
|
|
|
|
|
|
if((*gid=cpf_grant_magic(driver, *io_ept,
|
2006-06-29 16:24:07 +02:00
|
|
|
(vir_bytes) *buf, bytes,
|
2006-06-20 12:12:09 +02:00
|
|
|
*op == DEV_READ_S ? CPF_WRITE : CPF_READ)) < 0) {
|
|
|
|
panic(__FILE__,
|
|
|
|
"cpf_grant_magic of buffer failed\n", NO_NUM);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
2007-02-07 17:22:19 +01:00
|
|
|
case VFS_DEV_GATHER:
|
|
|
|
case VFS_DEV_SCATTER:
|
2006-06-20 12:12:09 +02:00
|
|
|
/* Change to safe op. */
|
2007-02-07 17:22:19 +01:00
|
|
|
*op = *op == VFS_DEV_GATHER ?
|
|
|
|
DEV_GATHER_S : DEV_SCATTER_S;
|
2006-06-20 12:12:09 +02:00
|
|
|
|
2006-06-28 14:20:30 +02:00
|
|
|
/* Grant access to my new i/o vector. */
|
2006-06-29 16:24:07 +02:00
|
|
|
if((*gid = cpf_grant_direct(driver,
|
|
|
|
(vir_bytes) new_iovec, bytes * sizeof(iovec_t),
|
2006-06-20 12:12:09 +02:00
|
|
|
CPF_READ | CPF_WRITE)) < 0) {
|
|
|
|
panic(__FILE__,
|
|
|
|
"cpf_grant_direct of vector failed", NO_NUM);
|
|
|
|
}
|
2006-06-29 16:24:07 +02:00
|
|
|
v = (iovec_t *) *buf;
|
2006-06-20 12:12:09 +02:00
|
|
|
/* Grant access to i/o buffers. */
|
|
|
|
for(j = 0; j < bytes; j++) {
|
2006-06-29 16:24:07 +02:00
|
|
|
if(j >= NR_IOREQS)
|
|
|
|
panic(__FILE__, "vec too big", bytes);
|
2006-06-28 14:20:30 +02:00
|
|
|
new_iovec[j].iov_addr = gids[j] =
|
2006-06-20 12:12:09 +02:00
|
|
|
cpf_grant_direct(driver, (vir_bytes)
|
|
|
|
v[j].iov_addr, v[j].iov_size,
|
|
|
|
*op == DEV_GATHER_S ? CPF_WRITE : CPF_READ);
|
|
|
|
if(!GRANT_VALID(gids[j])) {
|
|
|
|
panic(__FILE__, "grant to iovec buf failed",
|
|
|
|
NO_NUM);
|
|
|
|
}
|
2006-06-28 14:20:30 +02:00
|
|
|
new_iovec[j].iov_size = v[j].iov_size;
|
2006-06-20 12:12:09 +02:00
|
|
|
(*vec_grants)++;
|
|
|
|
}
|
2006-06-29 16:24:07 +02:00
|
|
|
|
|
|
|
/* Set user's vector to the new one. */
|
|
|
|
*buf = new_iovec;
|
2006-06-20 12:12:09 +02:00
|
|
|
break;
|
2007-02-07 17:22:19 +01:00
|
|
|
case VFS_DEV_IOCTL:
|
2007-04-24 15:27:33 +02:00
|
|
|
*pos_lo = *io_ept; /* Old endpoint in POSITION field. */
|
2006-06-20 12:12:09 +02:00
|
|
|
*op = DEV_IOCTL_S;
|
|
|
|
if(_MINIX_IOCTL_IOR(m_in.REQUEST)) access |= CPF_WRITE;
|
|
|
|
if(_MINIX_IOCTL_IOW(m_in.REQUEST)) access |= CPF_READ;
|
2006-07-25 11:41:40 +02:00
|
|
|
if(_MINIX_IOCTL_BIG(m_in.REQUEST))
|
|
|
|
size = _MINIX_IOCTL_SIZE_BIG(m_in.REQUEST);
|
|
|
|
else
|
|
|
|
size = _MINIX_IOCTL_SIZE(m_in.REQUEST);
|
2006-06-26 18:08:42 +02:00
|
|
|
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2006-06-26 18:08:42 +02:00
|
|
|
/* Do this even if no I/O happens with the ioctl, in
|
|
|
|
* order to disambiguate requests with DEV_IOCTL_S.
|
|
|
|
*/
|
|
|
|
if((*gid=cpf_grant_magic(driver, *io_ept,
|
2006-06-29 16:24:07 +02:00
|
|
|
(vir_bytes) *buf, size, access)) < 0) {
|
2006-06-26 18:08:42 +02:00
|
|
|
panic(__FILE__,
|
|
|
|
"cpf_grant_magic failed (ioctl)\n",
|
|
|
|
NO_NUM);
|
2006-06-20 12:12:09 +02:00
|
|
|
}
|
2007-02-07 17:22:19 +01:00
|
|
|
break;
|
|
|
|
case VFS_DEV_SELECT:
|
|
|
|
*op = DEV_SELECT;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
panic(__FILE__,"safe_io_conversion: unknown operation",
|
|
|
|
*op);
|
2006-06-20 12:12:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* If we have converted to a safe operation, I/O
|
|
|
|
* endpoint becomes FS if it wasn't already.
|
|
|
|
*/
|
|
|
|
if(GRANT_VALID(*gid)) {
|
|
|
|
*io_ept = FS_PROC_NR;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Not converted to a safe operation (because there is no
|
|
|
|
* copying involved in this operation).
|
|
|
|
*/
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* safe_io_cleanup *
|
|
|
|
*===========================================================================*/
|
|
|
|
PRIVATE void safe_io_cleanup(gid, gids, gids_size)
|
|
|
|
cp_grant_id_t gid;
|
|
|
|
cp_grant_id_t *gids;
|
|
|
|
int gids_size;
|
|
|
|
{
|
|
|
|
/* Free resources (specifically, grants) allocated by safe_io_conversion(). */
|
|
|
|
int j;
|
|
|
|
|
|
|
|
cpf_revoke(gid);
|
|
|
|
|
|
|
|
for(j = 0; j < gids_size; j++)
|
|
|
|
cpf_revoke(gids[j]);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-05-11 16:57:23 +02:00
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* dev_io *
|
|
|
|
*===========================================================================*/
|
2007-04-24 15:27:33 +02:00
|
|
|
PUBLIC int dev_io(op, dev, proc_e, buf, pos, bytes, flags)
|
2005-04-21 16:53:53 +02:00
|
|
|
int op; /* DEV_READ, DEV_WRITE, DEV_IOCTL, etc. */
|
|
|
|
dev_t dev; /* major-minor device number */
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
int proc_e; /* in whose address space is buf? */
|
2005-04-21 16:53:53 +02:00
|
|
|
void *buf; /* virtual address of the buffer */
|
2007-04-24 15:27:33 +02:00
|
|
|
u64_t pos; /* byte position */
|
2005-04-21 16:53:53 +02:00
|
|
|
int bytes; /* how many bytes to transfer */
|
|
|
|
int flags; /* special flags, like O_NONBLOCK */
|
|
|
|
{
|
|
|
|
/* Read or write from a device. The parameter 'dev' tells which one. */
|
|
|
|
struct dmap *dp;
|
2007-04-24 15:27:33 +02:00
|
|
|
u32_t pos_lo, pos_high;
|
2005-04-21 16:53:53 +02:00
|
|
|
message dev_mess;
|
2006-06-20 12:12:09 +02:00
|
|
|
cp_grant_id_t gid = GRANT_INVALID;
|
|
|
|
static cp_grant_id_t gids[NR_IOREQS];
|
|
|
|
int vec_grants = 0, orig_op, safe;
|
2006-06-29 16:24:07 +02:00
|
|
|
void *buf_used;
|
2006-08-10 13:51:11 +02:00
|
|
|
endpoint_t ioproc;
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2007-04-24 15:27:33 +02:00
|
|
|
pos_lo= ex64lo(pos);
|
|
|
|
pos_high= ex64hi(pos);
|
2006-11-27 15:21:43 +01:00
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
/* Determine task dmap. */
|
|
|
|
dp = &dmap[(dev >> MAJOR) & BYTE];
|
2006-06-20 12:12:09 +02:00
|
|
|
orig_op = op;
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2005-10-05 17:38:15 +02:00
|
|
|
/* See if driver is roughly valid. */
|
2005-10-21 21:31:38 +02:00
|
|
|
if (dp->dmap_driver == NONE) {
|
|
|
|
printf("FS: dev_io: no driver for dev %x\n", dev);
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
return ENXIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(isokendpt(dp->dmap_driver, &dummyproc) != OK) {
|
|
|
|
printf("FS: dev_io: old driver for dev %x (%d)\n",
|
|
|
|
dev, dp->dmap_driver);
|
|
|
|
return ENXIO;
|
2005-10-21 21:31:38 +02:00
|
|
|
}
|
2005-10-05 17:38:15 +02:00
|
|
|
|
2006-06-20 12:12:09 +02:00
|
|
|
/* By default, these are right. */
|
|
|
|
dev_mess.IO_ENDPT = proc_e;
|
|
|
|
dev_mess.ADDRESS = buf;
|
|
|
|
|
|
|
|
/* Convert DEV_* to DEV_*_S variants. */
|
2006-06-29 16:24:07 +02:00
|
|
|
buf_used = buf;
|
|
|
|
safe = safe_io_conversion(dp->dmap_driver, &gid,
|
|
|
|
&op, gids, NR_IOREQS, &dev_mess.IO_ENDPT, &buf_used,
|
2007-04-24 15:27:33 +02:00
|
|
|
&vec_grants, bytes, &pos_lo);
|
2006-06-29 16:24:07 +02:00
|
|
|
|
|
|
|
if(buf != buf_used)
|
|
|
|
panic(__FILE__,"dev_io: safe_io_conversion changed buffer", NO_NUM);
|
2006-06-20 12:12:09 +02:00
|
|
|
|
|
|
|
/* If the safe conversion was done, set the ADDRESS to
|
|
|
|
* the grant id.
|
|
|
|
*/
|
|
|
|
if(safe) dev_mess.IO_GRANT = (char *) gid;
|
|
|
|
|
|
|
|
/* Set up the rest of the message passed to task. */
|
2005-04-21 16:53:53 +02:00
|
|
|
dev_mess.m_type = op;
|
|
|
|
dev_mess.DEVICE = (dev >> MINOR) & BYTE;
|
2007-04-24 15:27:33 +02:00
|
|
|
dev_mess.POSITION = pos_lo;
|
2005-04-21 16:53:53 +02:00
|
|
|
dev_mess.COUNT = bytes;
|
2007-04-24 15:27:33 +02:00
|
|
|
dev_mess.HIGHPOS = pos_high;
|
2006-06-20 12:12:09 +02:00
|
|
|
|
2006-08-10 13:51:11 +02:00
|
|
|
/* This will be used if the i/o is suspended. */
|
|
|
|
ioproc = dev_mess.IO_ENDPT;
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
/* Call the task. */
|
|
|
|
(*dp->dmap_io)(dp->dmap_driver, &dev_mess);
|
|
|
|
|
2006-03-15 22:55:32 +01:00
|
|
|
if(dp->dmap_driver == NONE) {
|
|
|
|
/* Driver has vanished. */
|
2006-06-20 12:12:09 +02:00
|
|
|
printf("Driver gone?\n");
|
|
|
|
if(safe) safe_io_cleanup(gid, gids, vec_grants);
|
2006-03-15 22:55:32 +01:00
|
|
|
return EIO;
|
|
|
|
}
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
/* Task has completed. See if call completed. */
|
|
|
|
if (dev_mess.REP_STATUS == SUSPEND) {
|
2006-06-20 12:12:09 +02:00
|
|
|
if(vec_grants > 0) {
|
|
|
|
panic(__FILE__,"SUSPEND on vectored i/o", NO_NUM);
|
|
|
|
}
|
2006-08-10 13:51:11 +02:00
|
|
|
/* fp is uninitialized at init time. */
|
|
|
|
if(!fp)
|
|
|
|
panic(__FILE__,"SUSPEND on NULL fp", NO_NUM);
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
if (flags & O_NONBLOCK) {
|
|
|
|
/* Not supposed to block. */
|
|
|
|
dev_mess.m_type = CANCEL;
|
2006-08-10 13:51:11 +02:00
|
|
|
dev_mess.IO_ENDPT = ioproc;
|
2006-06-20 12:12:09 +02:00
|
|
|
dev_mess.IO_GRANT = (char *) gid;
|
|
|
|
|
|
|
|
/* This R_BIT/W_BIT check taken from suspend()/unpause()
|
|
|
|
* logic. Mode is expected in the COUNT field.
|
|
|
|
*/
|
|
|
|
dev_mess.COUNT = 0;
|
|
|
|
if(call_nr == READ) dev_mess.COUNT = R_BIT;
|
|
|
|
else if(call_nr == WRITE) dev_mess.COUNT = W_BIT;
|
2005-04-21 16:53:53 +02:00
|
|
|
dev_mess.DEVICE = (dev >> MINOR) & BYTE;
|
|
|
|
(*dp->dmap_io)(dp->dmap_driver, &dev_mess);
|
|
|
|
if (dev_mess.REP_STATUS == EINTR) dev_mess.REP_STATUS = EAGAIN;
|
|
|
|
} else {
|
|
|
|
/* Suspend user. */
|
|
|
|
suspend(dp->dmap_driver);
|
2006-06-20 12:12:09 +02:00
|
|
|
assert(!GRANT_VALID(fp->fp_grant));
|
|
|
|
fp->fp_grant = gid; /* revoke this when unsuspended. */
|
2006-08-10 13:51:11 +02:00
|
|
|
fp->fp_ioproc = ioproc;
|
2005-04-21 16:53:53 +02:00
|
|
|
return(SUSPEND);
|
|
|
|
}
|
|
|
|
}
|
2006-06-20 12:12:09 +02:00
|
|
|
|
|
|
|
/* No suspend, or cancelled suspend, so I/O is over and can be cleaned up. */
|
|
|
|
if(safe) safe_io_cleanup(gid, gids, vec_grants);
|
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
return(dev_mess.REP_STATUS);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* gen_opcl *
|
|
|
|
*===========================================================================*/
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
PUBLIC int gen_opcl(op, dev, proc_e, flags)
|
2005-04-21 16:53:53 +02:00
|
|
|
int op; /* operation, DEV_OPEN or DEV_CLOSE */
|
|
|
|
dev_t dev; /* device to open or close */
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
int proc_e; /* process to open/close for */
|
2005-04-21 16:53:53 +02:00
|
|
|
int flags; /* mode bits and flags */
|
|
|
|
{
|
|
|
|
/* Called from the dmap struct in table.c on opens & closes of special files.*/
|
|
|
|
struct dmap *dp;
|
|
|
|
message dev_mess;
|
|
|
|
|
|
|
|
/* Determine task dmap. */
|
|
|
|
dp = &dmap[(dev >> MAJOR) & BYTE];
|
|
|
|
|
|
|
|
dev_mess.m_type = op;
|
|
|
|
dev_mess.DEVICE = (dev >> MINOR) & BYTE;
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
dev_mess.IO_ENDPT = proc_e;
|
2005-04-21 16:53:53 +02:00
|
|
|
dev_mess.COUNT = flags;
|
|
|
|
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
if (dp->dmap_driver == NONE) {
|
|
|
|
printf("FS: gen_opcl: no driver for dev %x\n", dev);
|
|
|
|
return ENXIO;
|
|
|
|
}
|
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
/* Call the task. */
|
|
|
|
(*dp->dmap_io)(dp->dmap_driver, &dev_mess);
|
|
|
|
|
|
|
|
return(dev_mess.REP_STATUS);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* tty_opcl *
|
|
|
|
*===========================================================================*/
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
PUBLIC int tty_opcl(op, dev, proc_e, flags)
|
2005-04-21 16:53:53 +02:00
|
|
|
int op; /* operation, DEV_OPEN or DEV_CLOSE */
|
|
|
|
dev_t dev; /* device to open or close */
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
int proc_e; /* process to open/close for */
|
2005-04-21 16:53:53 +02:00
|
|
|
int flags; /* mode bits and flags */
|
|
|
|
{
|
|
|
|
/* This procedure is called from the dmap struct on tty open/close. */
|
|
|
|
|
|
|
|
int r;
|
|
|
|
register struct fproc *rfp;
|
|
|
|
|
|
|
|
/* Add O_NOCTTY to the flags if this process is not a session leader, or
|
|
|
|
* if it already has a controlling tty, or if it is someone elses
|
|
|
|
* controlling tty.
|
|
|
|
*/
|
|
|
|
if (!fp->fp_sesldr || fp->fp_tty != 0) {
|
|
|
|
flags |= O_NOCTTY;
|
|
|
|
} else {
|
|
|
|
for (rfp = &fproc[0]; rfp < &fproc[NR_PROCS]; rfp++) {
|
2006-03-15 16:34:12 +01:00
|
|
|
if(rfp->fp_pid == PID_FREE) continue;
|
2005-04-21 16:53:53 +02:00
|
|
|
if (rfp->fp_tty == dev) flags |= O_NOCTTY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
r = gen_opcl(op, dev, proc_e, flags);
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
/* Did this call make the tty the controlling tty? */
|
|
|
|
if (r == 1) {
|
|
|
|
fp->fp_tty = dev;
|
|
|
|
r = OK;
|
|
|
|
}
|
|
|
|
return(r);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* ctty_opcl *
|
|
|
|
*===========================================================================*/
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
PUBLIC int ctty_opcl(op, dev, proc_e, flags)
|
2005-04-21 16:53:53 +02:00
|
|
|
int op; /* operation, DEV_OPEN or DEV_CLOSE */
|
|
|
|
dev_t dev; /* device to open or close */
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
int proc_e; /* process to open/close for */
|
2005-04-21 16:53:53 +02:00
|
|
|
int flags; /* mode bits and flags */
|
|
|
|
{
|
|
|
|
/* This procedure is called from the dmap struct in table.c on opening/closing
|
|
|
|
* /dev/tty, the magic device that translates to the controlling tty.
|
|
|
|
*/
|
|
|
|
|
|
|
|
return(fp->fp_tty == 0 ? ENXIO : OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
2006-05-11 16:57:23 +02:00
|
|
|
* pm_setsid *
|
2005-04-21 16:53:53 +02:00
|
|
|
*===========================================================================*/
|
2006-05-11 16:57:23 +02:00
|
|
|
PUBLIC void pm_setsid(proc_e)
|
|
|
|
int proc_e;
|
2005-04-21 16:53:53 +02:00
|
|
|
{
|
|
|
|
/* Perform the FS side of the SETSID call, i.e. get rid of the controlling
|
|
|
|
* terminal of a process, and make the process a session leader.
|
|
|
|
*/
|
|
|
|
register struct fproc *rfp;
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
int slot;
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
/* Make the process a session leader with no controlling tty. */
|
2006-05-11 16:57:23 +02:00
|
|
|
okendpt(proc_e, &slot);
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
rfp = &fproc[slot];
|
2005-04-21 16:53:53 +02:00
|
|
|
rfp->fp_sesldr = TRUE;
|
|
|
|
rfp->fp_tty = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* do_ioctl *
|
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC int do_ioctl()
|
|
|
|
{
|
|
|
|
/* Perform the ioctl(ls_fd, request, argx) system call (uses m2 fmt). */
|
|
|
|
|
|
|
|
struct filp *f;
|
2006-10-25 15:40:36 +02:00
|
|
|
register struct vnode *vp;
|
2005-04-21 16:53:53 +02:00
|
|
|
dev_t dev;
|
|
|
|
|
|
|
|
if ( (f = get_filp(m_in.ls_fd)) == NIL_FILP) return(err_code);
|
2006-10-25 15:40:36 +02:00
|
|
|
vp = f->filp_vno; /* get vnode pointer */
|
|
|
|
if ( (vp->v_mode & I_TYPE) != I_CHAR_SPECIAL
|
|
|
|
&& (vp->v_mode & I_TYPE) != I_BLOCK_SPECIAL) return(ENOTTY);
|
|
|
|
dev = (dev_t) vp->v_sdev;
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2007-02-07 17:22:19 +01:00
|
|
|
return (dev_io(VFS_DEV_IOCTL, dev, who_e, m_in.ADDRESS, cvu64(0),
|
2005-04-21 16:53:53 +02:00
|
|
|
m_in.REQUEST, f->filp_flags));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* gen_io *
|
|
|
|
*===========================================================================*/
|
2006-03-15 14:37:20 +01:00
|
|
|
PUBLIC int gen_io(task_nr, mess_ptr)
|
2005-04-21 16:53:53 +02:00
|
|
|
int task_nr; /* which task to call */
|
|
|
|
message *mess_ptr; /* pointer to message for task */
|
|
|
|
{
|
|
|
|
/* All file system I/O ultimately comes down to I/O on major/minor device
|
|
|
|
* pairs. These lead to calls on the following routines via the dmap table.
|
|
|
|
*/
|
|
|
|
|
2006-03-15 16:34:12 +01:00
|
|
|
int r, proc_e;
|
2005-04-21 16:53:53 +02:00
|
|
|
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
proc_e = mess_ptr->IO_ENDPT;
|
2005-04-21 16:53:53 +02:00
|
|
|
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
r = sendrec(task_nr, mess_ptr);
|
2005-04-21 16:53:53 +02:00
|
|
|
if (r != OK) {
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
if (r == EDEADSRCDST || r == EDSTDIED || r == ESRCDIED) {
|
|
|
|
printf("fs: dead driver %d\n", task_nr);
|
2006-03-15 14:37:20 +01:00
|
|
|
dmap_unmap_by_endpt(task_nr);
|
|
|
|
return r;
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
}
|
|
|
|
if (r == ELOCKED) {
|
|
|
|
printf("fs: ELOCKED talking to %d\n", task_nr);
|
2006-03-15 14:37:20 +01:00
|
|
|
return r;
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
}
|
|
|
|
panic(__FILE__,"call_task: can't send/receive", r);
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Did the process we did the sendrec() for get a result? */
|
2006-06-23 13:51:56 +02:00
|
|
|
if (mess_ptr->REP_ENDPT != proc_e) {
|
2005-04-21 16:53:53 +02:00
|
|
|
printf(
|
2006-06-23 13:51:56 +02:00
|
|
|
"fs: strange device reply from %d, type = %d, proc = %d (not %d) (2) ignored\n",
|
2005-04-21 16:53:53 +02:00
|
|
|
mess_ptr->m_source,
|
2006-06-23 13:51:56 +02:00
|
|
|
mess_ptr->m_type,
|
|
|
|
proc_e,
|
|
|
|
mess_ptr->REP_ENDPT);
|
|
|
|
return EIO;
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
2006-03-15 14:37:20 +01:00
|
|
|
|
|
|
|
return OK;
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* ctty_io *
|
|
|
|
*===========================================================================*/
|
2006-03-15 14:37:20 +01:00
|
|
|
PUBLIC int ctty_io(task_nr, mess_ptr)
|
2005-04-21 16:53:53 +02:00
|
|
|
int task_nr; /* not used - for compatibility with dmap_t */
|
|
|
|
message *mess_ptr; /* pointer to message for task */
|
|
|
|
{
|
|
|
|
/* This routine is only called for one device, namely /dev/tty. Its job
|
|
|
|
* is to change the message to use the controlling terminal, instead of the
|
|
|
|
* major/minor pair for /dev/tty itself.
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct dmap *dp;
|
|
|
|
|
|
|
|
if (fp->fp_tty == 0) {
|
|
|
|
/* No controlling tty present anymore, return an I/O error. */
|
|
|
|
mess_ptr->REP_STATUS = EIO;
|
|
|
|
} else {
|
|
|
|
/* Substitute the controlling terminal device. */
|
|
|
|
dp = &dmap[(fp->fp_tty >> MAJOR) & BYTE];
|
|
|
|
mess_ptr->DEVICE = (fp->fp_tty >> MINOR) & BYTE;
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
|
|
|
|
if (dp->dmap_driver == NONE) {
|
|
|
|
printf("FS: ctty_io: no driver for dev\n");
|
2006-03-15 14:37:20 +01:00
|
|
|
return EIO;
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(isokendpt(dp->dmap_driver, &dummyproc) != OK) {
|
|
|
|
printf("FS: ctty_io: old driver %d\n",
|
|
|
|
dp->dmap_driver);
|
2006-03-15 14:37:20 +01:00
|
|
|
return EIO;
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
}
|
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
(*dp->dmap_io)(dp->dmap_driver, mess_ptr);
|
|
|
|
}
|
2006-03-15 14:37:20 +01:00
|
|
|
return OK;
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
|
|
|
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* no_dev *
|
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC int no_dev(op, dev, proc, flags)
|
|
|
|
int op; /* operation, DEV_OPEN or DEV_CLOSE */
|
|
|
|
dev_t dev; /* device to open or close */
|
|
|
|
int proc; /* process to open/close for */
|
|
|
|
int flags; /* mode bits and flags */
|
|
|
|
{
|
|
|
|
/* Called when opening a nonexistent device. */
|
|
|
|
return(ENODEV);
|
|
|
|
}
|
|
|
|
|
2005-10-05 17:38:15 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* no_dev_io *
|
|
|
|
*===========================================================================*/
|
2006-03-15 14:37:20 +01:00
|
|
|
PUBLIC int no_dev_io(int proc, message *m)
|
2005-10-05 17:38:15 +02:00
|
|
|
{
|
|
|
|
/* Called when doing i/o on a nonexistent device. */
|
2006-10-25 15:40:36 +02:00
|
|
|
printf("VFS: I/O on unmapped device number\n");
|
2006-03-15 14:37:20 +01:00
|
|
|
return EIO;
|
2005-10-05 17:38:15 +02:00
|
|
|
}
|
|
|
|
|
2006-10-25 15:40:36 +02:00
|
|
|
|
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* clone_opcl *
|
|
|
|
*===========================================================================*/
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
PUBLIC int clone_opcl(op, dev, proc_e, flags)
|
2005-04-21 16:53:53 +02:00
|
|
|
int op; /* operation, DEV_OPEN or DEV_CLOSE */
|
|
|
|
dev_t dev; /* device to open or close */
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
int proc_e; /* process to open/close for */
|
2005-04-21 16:53:53 +02:00
|
|
|
int flags; /* mode bits and flags */
|
|
|
|
{
|
|
|
|
/* Some devices need special processing upon open. Such a device is "cloned",
|
|
|
|
* i.e. on a succesful open it is replaced by a new device with a new unique
|
|
|
|
* minor device number. This new device number identifies a new object (such
|
|
|
|
* as a new network connection) that has been allocated within a task.
|
|
|
|
*/
|
|
|
|
struct dmap *dp;
|
2006-03-15 14:37:20 +01:00
|
|
|
int r, minor;
|
2005-04-21 16:53:53 +02:00
|
|
|
message dev_mess;
|
|
|
|
|
|
|
|
/* Determine task dmap. */
|
|
|
|
dp = &dmap[(dev >> MAJOR) & BYTE];
|
|
|
|
minor = (dev >> MINOR) & BYTE;
|
|
|
|
|
|
|
|
dev_mess.m_type = op;
|
|
|
|
dev_mess.DEVICE = minor;
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
dev_mess.IO_ENDPT = proc_e;
|
2005-04-21 16:53:53 +02:00
|
|
|
dev_mess.COUNT = flags;
|
|
|
|
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
|
|
|
|
if (dp->dmap_driver == NONE) {
|
2007-08-07 14:52:47 +02:00
|
|
|
printf("vfs:clone_opcl: no driver for dev %x\n", dev);
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
return ENXIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(isokendpt(dp->dmap_driver, &dummyproc) != OK) {
|
2007-08-07 14:52:47 +02:00
|
|
|
printf("vfs:clone_opcl: bad driver endpoint for dev %x (%d)\n",
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
dev, dp->dmap_driver);
|
|
|
|
return ENXIO;
|
|
|
|
}
|
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
/* Call the task. */
|
2006-03-15 14:37:20 +01:00
|
|
|
r= (*dp->dmap_io)(dp->dmap_driver, &dev_mess);
|
|
|
|
if (r != OK)
|
|
|
|
return r;
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
if (op == DEV_OPEN && dev_mess.REP_STATUS >= 0) {
|
|
|
|
if (dev_mess.REP_STATUS != minor) {
|
2006-10-25 15:40:36 +02:00
|
|
|
struct vnode *vp;
|
|
|
|
struct vmnt *vmp;
|
|
|
|
struct node_details res;
|
2007-08-07 14:52:47 +02:00
|
|
|
|
2006-10-25 15:40:36 +02:00
|
|
|
/* A new minor device number has been returned.
|
2007-08-07 14:52:47 +02:00
|
|
|
* Request the root FS to create a temporary device file to
|
|
|
|
* hold it.
|
2006-10-25 15:40:36 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* Device number of the new device. */
|
2007-08-07 14:52:47 +02:00
|
|
|
dev = (dev & ~(BYTE << MINOR)) |
|
|
|
|
(dev_mess.REP_STATUS << MINOR);
|
2006-10-25 15:40:36 +02:00
|
|
|
|
|
|
|
/* Issue request */
|
2007-08-07 14:52:47 +02:00
|
|
|
r = req_newnode(ROOT_FS_E, fp->fp_effuid, fp->fp_effgid,
|
|
|
|
ALL_MODES | I_CHAR_SPECIAL, dev, &res);
|
|
|
|
if (r != OK) {
|
2006-10-25 15:40:36 +02:00
|
|
|
(void) clone_opcl(DEV_CLOSE, dev, proc_e, 0);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Drop old node and use the new values */
|
|
|
|
vp = fp->fp_filp[m_in.fd]->filp_vno;
|
|
|
|
|
|
|
|
put_vnode(vp);
|
2007-01-05 17:36:55 +01:00
|
|
|
if ((vp = get_free_vnode(__FILE__, __LINE__)) == NIL_VNODE) {
|
2007-08-07 14:52:47 +02:00
|
|
|
printf(
|
|
|
|
"vfs:clone_opcl: failed to get a free vnode..\n");
|
2006-10-25 15:40:36 +02:00
|
|
|
vp = fp->fp_filp[m_in.fd]->filp_vno;
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
2006-10-25 15:40:36 +02:00
|
|
|
|
|
|
|
vp->v_fs_e = res.fs_e;
|
|
|
|
if ((vmp = find_vmnt(vp->v_fs_e)) == NIL_VMNT)
|
2007-08-07 14:52:47 +02:00
|
|
|
printf("vfs:clone_opcl: no vmnt found\n");
|
2006-10-25 15:40:36 +02:00
|
|
|
|
|
|
|
vp->v_vmnt = vmp;
|
|
|
|
vp->v_dev = vmp->m_dev;
|
|
|
|
|
2007-08-07 14:52:47 +02:00
|
|
|
vp->v_fs_e = res.fs_e;
|
2006-10-25 15:40:36 +02:00
|
|
|
vp->v_inode_nr = res.inode_nr;
|
|
|
|
vp->v_mode = res.fmode;
|
|
|
|
vp->v_sdev = dev;
|
2007-01-05 17:36:55 +01:00
|
|
|
vp->v_fs_count = 1;
|
|
|
|
vp->v_ref_count = 1;
|
2006-10-25 15:40:36 +02:00
|
|
|
fp->fp_filp[m_in.fd]->filp_vno = vp;
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
|
|
|
dev_mess.REP_STATUS = OK;
|
|
|
|
}
|
|
|
|
return(dev_mess.REP_STATUS);
|
|
|
|
}
|
2005-07-27 15:08:52 +02:00
|
|
|
|
2007-08-07 14:52:47 +02:00
|
|
|
|
2005-10-20 21:39:32 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* dev_up *
|
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC void dev_up(int maj)
|
|
|
|
{
|
2006-10-25 15:40:36 +02:00
|
|
|
/* A new device driver has been mapped in. This function
|
|
|
|
* checks if any filesystems are mounted on it, and if so,
|
|
|
|
* dev_open()s them so the filesystem can be reused.
|
|
|
|
*/
|
|
|
|
struct filp *fp;
|
|
|
|
struct vmnt *vmp;
|
|
|
|
int r, new_driver_e;
|
|
|
|
message m;
|
|
|
|
|
|
|
|
/* Open a device once for every filp that's opened on it,
|
|
|
|
* and once for every filesystem mounted from it.
|
|
|
|
*/
|
|
|
|
new_driver_e = dmap[maj].dmap_driver;
|
|
|
|
|
|
|
|
for (vmp = &vmnt[0]; vmp < &vmnt[NR_MNTS]; ++vmp) {
|
|
|
|
int minor;
|
|
|
|
if (vmp->m_dev == NO_DEV) continue;
|
|
|
|
if ( ((vmp->m_dev >> MAJOR) & BYTE) != maj) continue;
|
|
|
|
minor = ((vmp->m_dev >> MINOR) & BYTE);
|
|
|
|
|
|
|
|
printf("VFS: re-opening dev: %d/%d\n", maj, minor);
|
|
|
|
|
|
|
|
if ((r = dev_open(vmp->m_dev, FS_PROC_NR,
|
|
|
|
vmp->m_flags ? R_BIT : (R_BIT|W_BIT))) != OK) {
|
|
|
|
printf("VFS: mounted dev %d/%d re-open failed: %d.\n",
|
|
|
|
maj, minor, r);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Send new driver endpoint */
|
2007-02-12 13:27:43 +01:00
|
|
|
printf("VFS: sending new driver for dev: %d, endpoint: %d, FS_e: %d\n",
|
2006-10-25 15:40:36 +02:00
|
|
|
vmp->m_dev, new_driver_e, vmp->m_fs_e);
|
|
|
|
|
|
|
|
if (OK != req_newdriver(vmp->m_fs_e, vmp->m_dev, new_driver_e))
|
|
|
|
printf("VFSdev_up: error sending new driver endpoint. FS_e: %d req_nr: %d\n",
|
|
|
|
vmp->m_fs_e, REQ_NEW_DRIVER);
|
|
|
|
else
|
|
|
|
vmp->m_driver_e = new_driver_e;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (fp = filp; fp < &filp[NR_FILPS]; fp++) {
|
|
|
|
struct vnode *vp;
|
|
|
|
int minor;
|
|
|
|
|
|
|
|
if(fp->filp_count < 1 || !(vp = fp->filp_vno)) continue;
|
|
|
|
if(((vp->v_sdev >> MAJOR) & BYTE) != maj) continue;
|
|
|
|
if(!(vp->v_mode & (I_BLOCK_SPECIAL|I_CHAR_SPECIAL))) continue;
|
|
|
|
|
|
|
|
minor = ((vp->v_sdev >> MINOR) & BYTE);
|
|
|
|
|
2007-08-15 14:53:52 +02:00
|
|
|
printf("vfs:dev_up: reopening special %d/%d..\n", maj, minor);
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2007-08-15 14:53:52 +02:00
|
|
|
printf("vfs:dev_up: before dev_open\n");
|
|
|
|
r = dev_open(vp->v_sdev, FS_PROC_NR, vp->v_mode & (R_BIT|W_BIT));
|
|
|
|
printf("vfs:dev_up: after dev_open: result = %d\n", r);
|
|
|
|
if (r != OK) {
|
2006-10-25 15:40:36 +02:00
|
|
|
int n;
|
|
|
|
/* This function will set the fp_filp[]s of processes
|
|
|
|
* holding that fp to NULL, but _not_ clear
|
|
|
|
* fp_filp_inuse, so that fd can't be recycled until
|
|
|
|
* it's close()d.
|
|
|
|
*/
|
|
|
|
n = inval_filp(fp);
|
|
|
|
if(n != fp->filp_count)
|
|
|
|
printf("VFS: warning: invalidate/count "
|
|
|
|
"discrepancy (%d, %d)\n", n, fp->filp_count);
|
|
|
|
fp->filp_count = 0;
|
|
|
|
printf("VFS: file on dev %d/%d re-open failed: %d; "
|
|
|
|
"invalidated %d fd's.\n", maj, minor, r, n);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
2005-10-20 21:39:32 +02:00
|
|
|
}
|
|
|
|
|