vfs: make m_out non-global

m_out is shared between threads as the reply message, and it can happen
results get overwritten by another thread before the reply is sent. This
change

	. makes m_out local to the message handling function,
	  declared on the stack of the caller
	. forces callers of reply() to give it a message, or
	  declare the reply message has no significant fields except
	  for the return code by calling replycode()

Change-Id: Id06300083a63c72c00f34f86a5c7d96e4bbdf9f6
This commit is contained in:
Ben Gras 2013-04-12 16:41:23 +00:00
parent 08ff44c446
commit db3dff6796
12 changed files with 136 additions and 98 deletions

View File

@ -1107,6 +1107,8 @@ int maj;
struct vnode *vp; struct vnode *vp;
struct filp *rfilp; struct filp *rfilp;
struct fproc *rfp; struct fproc *rfp;
message m_out;
memset(&m_out, 0, sizeof(m_out));
if (maj < 0 || maj >= NR_DEVICES) panic("VFS: out-of-bound major"); if (maj < 0 || maj >= NR_DEVICES) panic("VFS: out-of-bound major");
@ -1154,7 +1156,7 @@ int maj;
rfp->fp_task == driver_e && (rfp->fp_flags & FP_SUSP_REOPEN)) { rfp->fp_task == driver_e && (rfp->fp_flags & FP_SUSP_REOPEN)) {
rfp->fp_flags &= ~FP_SUSP_REOPEN; rfp->fp_flags &= ~FP_SUSP_REOPEN;
rfp->fp_blocked_on = FP_BLOCKED_ON_NONE; rfp->fp_blocked_on = FP_BLOCKED_ON_NONE;
reply(rfp->fp_endpoint, ERESTART); reply(&m_out, rfp->fp_endpoint, ERESTART);
} }
} }
@ -1173,7 +1175,7 @@ int maj;
/* Open failed, and automatic reopen was not requested */ /* Open failed, and automatic reopen was not requested */
rfp->fp_blocked_on = FP_BLOCKED_ON_NONE; rfp->fp_blocked_on = FP_BLOCKED_ON_NONE;
FD_CLR(fd_nr, &rfp->fp_filp_inuse); FD_CLR(fd_nr, &rfp->fp_filp_inuse);
reply(rfp->fp_endpoint, EIO); reply(&m_out, rfp->fp_endpoint, EIO);
continue; continue;
} }
@ -1183,7 +1185,7 @@ int maj;
if (major(vp->v_sdev) != maj) continue; if (major(vp->v_sdev) != maj) continue;
rfp->fp_blocked_on = FP_BLOCKED_ON_NONE; rfp->fp_blocked_on = FP_BLOCKED_ON_NONE;
reply(rfp->fp_endpoint, fd_nr); reply(&m_out, rfp->fp_endpoint, fd_nr);
} }
} }

View File

@ -443,7 +443,7 @@ int fd;
/*===========================================================================* /*===========================================================================*
* do_verify_fd * * do_verify_fd *
*===========================================================================*/ *===========================================================================*/
int do_verify_fd(void) int do_verify_fd(message *m_out)
{ {
struct filp *rfilp; struct filp *rfilp;
endpoint_t proc_e; endpoint_t proc_e;
@ -453,7 +453,7 @@ int do_verify_fd(void)
fd = job_m_in.COUNT; fd = job_m_in.COUNT;
rfilp = (struct filp *) verify_fd(proc_e, fd); rfilp = (struct filp *) verify_fd(proc_e, fd);
m_out.ADDRESS = (void *) rfilp; m_out->ADDRESS = (void *) rfilp;
if (rfilp != NULL) unlock_filp(rfilp); if (rfilp != NULL) unlock_filp(rfilp);
return (rfilp != NULL) ? OK : EINVAL; return (rfilp != NULL) ? OK : EINVAL;
} }
@ -476,7 +476,7 @@ filp_id_t sfilp;
/*===========================================================================* /*===========================================================================*
* do_set_filp * * do_set_filp *
*===========================================================================*/ *===========================================================================*/
int do_set_filp(void) int do_set_filp()
{ {
filp_id_t f; filp_id_t f;
f = (filp_id_t) job_m_in.ADDRESS; f = (filp_id_t) job_m_in.ADDRESS;
@ -517,7 +517,7 @@ filp_id_t cfilp;
/*===========================================================================* /*===========================================================================*
* do_copy_filp * * do_copy_filp *
*===========================================================================*/ *===========================================================================*/
int do_copy_filp(void) int do_copy_filp()
{ {
endpoint_t proc_e; endpoint_t proc_e;
filp_id_t f; filp_id_t f;
@ -546,7 +546,7 @@ filp_id_t pfilp;
/*===========================================================================* /*===========================================================================*
* do_put_filp * * do_put_filp *
*===========================================================================*/ *===========================================================================*/
int do_put_filp(void) int do_put_filp()
{ {
filp_id_t f; filp_id_t f;
f = (filp_id_t) job_m_in.ADDRESS; f = (filp_id_t) job_m_in.ADDRESS;
@ -591,7 +591,7 @@ int fd;
/*===========================================================================* /*===========================================================================*
* do_cancel_fd * * do_cancel_fd *
*===========================================================================*/ *===========================================================================*/
int do_cancel_fd(void) int do_cancel_fd()
{ {
endpoint_t proc_e; endpoint_t proc_e;
int fd; int fd;

View File

@ -24,7 +24,6 @@ EXTERN u32_t system_hz; /* system clock frequency. */
/* The parameters of the call are kept here. */ /* The parameters of the call are kept here. */
EXTERN message m_in; /* the input message itself */ EXTERN message m_in; /* the input message itself */
EXTERN message m_out; /* the output message used for reply */
# define who_p ((int) (fp - fproc)) # define who_p ((int) (fp - fproc))
# define isokslot(p) (p >= 0 && \ # define isokslot(p) (p >= 0 && \
p < (int)(sizeof(fproc) / sizeof(struct fproc))) p < (int)(sizeof(fproc) / sizeof(struct fproc)))
@ -50,8 +49,8 @@ EXTERN char mount_label[LABEL_MAX]; /* label of file system to mount */
EXTERN int err_code; /* temporary storage for error number */ EXTERN int err_code; /* temporary storage for error number */
/* Data initialized elsewhere. */ /* Data initialized elsewhere. */
extern int(*call_vec[]) (void); extern int(*call_vec[]) (message *);
extern int(*pfs_call_vec[]) (void); extern int(*pfs_call_vec[]) (message *m_out);
extern char mode_map[]; /* mapping from O_ACCMODE mask to R_BIT/W_BIT flags */ extern char mode_map[]; /* mapping from O_ACCMODE mask to R_BIT/W_BIT flags */
EXTERN struct kinfo kinfo; /* kernel information */ EXTERN struct kinfo kinfo; /* kernel information */

View File

@ -183,7 +183,7 @@ static void handle_work(void *(*func)(void *arg))
* one call back at a time. * one call back at a time.
*/ */
if (vmp->m_flags & VMNT_CALLBACK) { if (vmp->m_flags & VMNT_CALLBACK) {
reply(proc_e, EAGAIN); replycode(proc_e, EAGAIN);
return; return;
} }
vmp->m_flags |= VMNT_CALLBACK; vmp->m_flags |= VMNT_CALLBACK;
@ -203,7 +203,7 @@ static void handle_work(void *(*func)(void *arg))
/* Already trying to resolve a deadlock, can't /* Already trying to resolve a deadlock, can't
* handle more, sorry */ * handle more, sorry */
reply(proc_e, EAGAIN); replycode(proc_e, EAGAIN);
return; return;
} }
} }
@ -388,7 +388,7 @@ static void *do_pending_pipe(void *arg)
r = rw_pipe(op, who_e, f, scratch(fp).io.io_buffer, scratch(fp).io.io_nbytes); r = rw_pipe(op, who_e, f, scratch(fp).io.io_buffer, scratch(fp).io.io_nbytes);
if (r != SUSPEND) /* Do we have results to report? */ if (r != SUSPEND) /* Do we have results to report? */
reply(fp->fp_endpoint, r); replycode(fp->fp_endpoint, r);
unlock_filp(f); unlock_filp(f);
thread_cleanup(fp); thread_cleanup(fp);
@ -424,6 +424,9 @@ static void *do_work(void *arg)
{ {
int error; int error;
struct job my_job; struct job my_job;
message m_out;
memset(&m_out, 0, sizeof(m_out));
my_job = *((struct job *) arg); my_job = *((struct job *) arg);
fp = my_job.j_fp; fp = my_job.j_fp;
@ -443,7 +446,7 @@ static void *do_work(void *arg)
error = ENOSYS; error = ENOSYS;
} else { } else {
job_call_nr -= PFS_BASE; job_call_nr -= PFS_BASE;
error = (*pfs_call_vec[job_call_nr])(); error = (*pfs_call_vec[job_call_nr])(&m_out);
} }
} else { } else {
/* We're dealing with a POSIX system call from a normal /* We're dealing with a POSIX system call from a normal
@ -459,12 +462,12 @@ static void *do_work(void *arg)
#if ENABLE_SYSCALL_STATS #if ENABLE_SYSCALL_STATS
calls_stats[job_call_nr]++; calls_stats[job_call_nr]++;
#endif #endif
error = (*call_vec[job_call_nr])(); error = (*call_vec[job_call_nr])(&m_out);
} }
} }
/* Copy the results back to the user and send reply. */ /* Copy the results back to the user and send reply. */
if (error != SUSPEND) reply(fp->fp_endpoint, error); if (error != SUSPEND) reply(&m_out, fp->fp_endpoint, error);
thread_cleanup(fp); thread_cleanup(fp);
unlock_proc(fp); unlock_proc(fp);
@ -791,11 +794,31 @@ static void get_work()
/*===========================================================================* /*===========================================================================*
* reply * * reply *
*===========================================================================*/ *===========================================================================*/
void reply(endpoint_t whom, int result) void reply(message *m_out, endpoint_t whom, int result)
{ {
/* Send a reply to a user process. If the send fails, just ignore it. */ /* Send a reply to a user process. If the send fails, just ignore it. */
int r; int r;
m_out->reply_type = result;
r = sendnb(whom, m_out);
if (r != OK) {
printf("VFS: %d couldn't send reply %d to %d: %d\n", mthread_self(),
result, whom, r);
util_stacktrace();
}
}
/*===========================================================================*
* replycode *
*===========================================================================*/
void replycode(endpoint_t whom, int result)
{
/* Send a reply to a user process. If the send fails, just ignore it. */
int r;
message m_out;
memset(&m_out, 0, sizeof(m_out));
m_out.reply_type = result; m_out.reply_type = result;
r = sendnb(whom, &m_out); r = sendnb(whom, &m_out);
if (r != OK) { if (r != OK) {
@ -812,6 +835,9 @@ static void service_pm_postponed(void)
{ {
int r; int r;
vir_bytes pc, newsp; vir_bytes pc, newsp;
message m_out;
memset(&m_out, 0, sizeof(m_out));
switch(job_call_nr) { switch(job_call_nr) {
case PM_EXEC: case PM_EXEC:
@ -893,6 +919,9 @@ static void service_pm_postponed(void)
static void service_pm() static void service_pm()
{ {
int r, slot; int r, slot;
message m_out;
memset(&m_out, 0, sizeof(m_out));
switch (job_call_nr) { switch (job_call_nr) {
case PM_SETUID: case PM_SETUID:

View File

@ -250,10 +250,8 @@ int do_fcntl()
return(r); return(r);
} }
/*===========================================================================* static int
* do_sync * sync_fses(void)
*===========================================================================*/
int do_sync()
{ {
struct vmnt *vmp; struct vmnt *vmp;
int r = OK; int r = OK;
@ -271,6 +269,14 @@ int do_sync()
return(r); return(r);
} }
/*===========================================================================*
* do_sync *
*===========================================================================*/
int do_sync()
{
return sync_fses();
}
/*===========================================================================* /*===========================================================================*
* do_fsync * * do_fsync *
*===========================================================================*/ *===========================================================================*/
@ -314,7 +320,7 @@ void pm_reboot()
int i; int i;
struct fproc *rfp; struct fproc *rfp;
do_sync(); sync_fses();
/* Do exit processing for all leftover processes and servers, but don't /* Do exit processing for all leftover processes and servers, but don't
* actually exit them (if they were really gone, PM will tell us about it). * actually exit them (if they were really gone, PM will tell us about it).
@ -333,7 +339,7 @@ void pm_reboot()
unlock_proc(rfp); unlock_proc(rfp);
} }
do_sync(); sync_fses();
unmount_all(0 /* Don't force */); unmount_all(0 /* Don't force */);
/* Try to exit all processes again including File Servers */ /* Try to exit all processes again including File Servers */
@ -348,7 +354,7 @@ void pm_reboot()
unlock_proc(rfp); unlock_proc(rfp);
} }
do_sync(); sync_fses();
unmount_all(1 /* Force */); unmount_all(1 /* Force */);
} }

View File

@ -414,7 +414,7 @@ void mount_pfs(void)
/*===========================================================================* /*===========================================================================*
* do_umount * * do_umount *
*===========================================================================*/ *===========================================================================*/
int do_umount(void) int do_umount(message *m_out)
{ {
/* Perform the umount(name) system call. /* Perform the umount(name) system call.
* syscall might provide 'name' embedded in the message. * syscall might provide 'name' embedded in the message.
@ -448,7 +448,7 @@ int do_umount(void)
*/ */
if (strlen(label) >= M3_LONG_STRING) /* should never evaluate to true */ if (strlen(label) >= M3_LONG_STRING) /* should never evaluate to true */
label[M3_LONG_STRING-1] = 0; label[M3_LONG_STRING-1] = 0;
strlcpy(m_out.umount_label, label, M3_LONG_STRING); strlcpy(m_out->umount_label, label, M3_LONG_STRING);
return(OK); return(OK);
} }

View File

@ -590,7 +590,7 @@ int do_mkdir()
/*===========================================================================* /*===========================================================================*
* do_lseek * * do_lseek *
*===========================================================================*/ *===========================================================================*/
int do_lseek() int do_lseek(message *m_out)
{ {
/* Perform the lseek(ls_fd, offset, whence) system call. */ /* Perform the lseek(ls_fd, offset, whence) system call. */
register struct filp *rfilp; register struct filp *rfilp;
@ -631,7 +631,7 @@ int do_lseek()
r = EOVERFLOW; r = EOVERFLOW;
} else { } else {
/* insert the new position into the output message */ /* insert the new position into the output message */
m_out.reply_l1 = ex64lo(newpos); m_out->reply_l1 = ex64lo(newpos);
if (cmp64(newpos, rfilp->filp_pos) != 0) { if (cmp64(newpos, rfilp->filp_pos) != 0) {
rfilp->filp_pos = newpos; rfilp->filp_pos = newpos;
@ -649,7 +649,7 @@ int do_lseek()
/*===========================================================================* /*===========================================================================*
* do_llseek * * do_llseek *
*===========================================================================*/ *===========================================================================*/
int do_llseek() int do_llseek(message *m_out)
{ {
/* Perform the llseek(ls_fd, offset, whence) system call. */ /* Perform the llseek(ls_fd, offset, whence) system call. */
register struct filp *rfilp; register struct filp *rfilp;
@ -688,8 +688,8 @@ int do_llseek()
r = EINVAL; r = EINVAL;
else { else {
/* insert the new position into the output message */ /* insert the new position into the output message */
m_out.reply_l1 = ex64lo(newpos); m_out->reply_l1 = ex64lo(newpos);
m_out.reply_l2 = ex64hi(newpos); m_out->reply_l2 = ex64hi(newpos);
if (cmp64(newpos, rfilp->filp_pos) != 0) { if (cmp64(newpos, rfilp->filp_pos) != 0) {
rfilp->filp_pos = newpos; rfilp->filp_pos = newpos;

View File

@ -870,7 +870,7 @@ size_t pathlen;
/*===========================================================================* /*===========================================================================*
* do_check_perms * * do_check_perms *
*===========================================================================*/ *===========================================================================*/
int do_check_perms(void) int do_check_perms()
{ {
return check_perms(job_m_in.USER_ENDPT, (cp_grant_id_t) job_m_in.IO_GRANT, return check_perms(job_m_in.USER_ENDPT, (cp_grant_id_t) job_m_in.IO_GRANT,
(size_t) job_m_in.COUNT); (size_t) job_m_in.COUNT);

View File

@ -18,6 +18,7 @@
#include "fs.h" #include "fs.h"
#include <fcntl.h> #include <fcntl.h>
#include <signal.h> #include <signal.h>
#include <string.h>
#include <assert.h> #include <assert.h>
#include <minix/callnr.h> #include <minix/callnr.h>
#include <minix/endpoint.h> #include <minix/endpoint.h>
@ -39,7 +40,7 @@ static int create_pipe(int fil_des[2], int flags);
/*===========================================================================* /*===========================================================================*
* do_pipe * * do_pipe *
*===========================================================================*/ *===========================================================================*/
int do_pipe() int do_pipe(message *m_out)
{ {
/* Perform the pipe(fil_des[2]) system call. */ /* Perform the pipe(fil_des[2]) system call. */
@ -48,8 +49,8 @@ int do_pipe()
r = create_pipe(fil_des, 0 /* no flags */); r = create_pipe(fil_des, 0 /* no flags */);
if (r == OK) { if (r == OK) {
m_out.reply_i1 = fil_des[0]; m_out->reply_i1 = fil_des[0];
m_out.reply_i2 = fil_des[1]; m_out->reply_i2 = fil_des[1];
} }
return r; return r;
@ -58,7 +59,7 @@ int do_pipe()
/*===========================================================================* /*===========================================================================*
* do_pipe2 * * do_pipe2 *
*===========================================================================*/ *===========================================================================*/
int do_pipe2() int do_pipe2(message *m_out)
{ {
/* Perform the pipe2(fil_des[2], flags) system call. */ /* Perform the pipe2(fil_des[2], flags) system call. */
int r, flags; int r, flags;
@ -68,8 +69,8 @@ int do_pipe2()
r = create_pipe(fil_des, flags); r = create_pipe(fil_des, flags);
if (r == OK) { if (r == OK) {
m_out.reply_i1 = fil_des[0]; m_out->reply_i1 = fil_des[0];
m_out.reply_i2 = fil_des[1]; m_out->reply_i2 = fil_des[1];
} }
return r; return r;
@ -507,18 +508,18 @@ void revive(endpoint_t proc_e, int returned)
unlock_filp(fil_ptr); unlock_filp(fil_ptr);
put_vnode(fil_ptr->filp_vno); put_vnode(fil_ptr->filp_vno);
fil_ptr->filp_vno = NULL; fil_ptr->filp_vno = NULL;
reply(proc_e, returned); replycode(proc_e, returned);
} else { } else {
reply(proc_e, fd_nr); replycode(proc_e, fd_nr);
} }
} else { } else {
rfp->fp_blocked_on = FP_BLOCKED_ON_NONE; rfp->fp_blocked_on = FP_BLOCKED_ON_NONE;
scratch(rfp).file.fd_nr = 0; scratch(rfp).file.fd_nr = 0;
if (blocked_on == FP_BLOCKED_ON_POPEN) { if (blocked_on == FP_BLOCKED_ON_POPEN) {
/* process blocked in open or create */ /* process blocked in open or create */
reply(proc_e, fd_nr); replycode(proc_e, fd_nr);
} else if (blocked_on == FP_BLOCKED_ON_SELECT) { } else if (blocked_on == FP_BLOCKED_ON_SELECT) {
reply(proc_e, returned); replycode(proc_e, returned);
} else { } else {
/* Revive a process suspended on TTY or other device. /* Revive a process suspended on TTY or other device.
* Pretend it wants only what there is. * Pretend it wants only what there is.
@ -534,7 +535,7 @@ void revive(endpoint_t proc_e, int returned)
} }
rfp->fp_grant = GRANT_INVALID; rfp->fp_grant = GRANT_INVALID;
} }
reply(proc_e, returned);/* unblock the process */ replycode(proc_e, returned);/* unblock the process */
} }
} }
} }
@ -641,6 +642,6 @@ void unpause(endpoint_t proc_e)
susp_count--; susp_count--;
} }
reply(proc_e, status); /* signal interrupted call */ replycode(proc_e, status); /* signal interrupted call */
} }

View File

@ -46,7 +46,7 @@ int tty_opcl(int op, dev_t dev, endpoint_t proc, int flags);
int ctty_opcl(int op, dev_t dev, endpoint_t proc, int flags); int ctty_opcl(int op, dev_t dev, endpoint_t proc, int flags);
int clone_opcl(int op, dev_t dev, int proc, int flags); int clone_opcl(int op, dev_t dev, int proc, int flags);
int ctty_io(int task_nr, message *mess_ptr); int ctty_io(int task_nr, message *mess_ptr);
int do_ioctl(void); int do_ioctl(message *m_out);
void pm_setsid(endpoint_t proc_e); void pm_setsid(endpoint_t proc_e);
void dev_status(endpoint_t drv_e); void dev_status(endpoint_t drv_e);
void bdev_up(int major); void bdev_up(int major);
@ -96,26 +96,26 @@ void unlock_filps(struct filp *filp1, struct filp *filp2);
int invalidate_filp(struct filp *); int invalidate_filp(struct filp *);
void invalidate_filp_by_endpt(endpoint_t proc_e); void invalidate_filp_by_endpt(endpoint_t proc_e);
void invalidate_filp_by_char_major(int major); void invalidate_filp_by_char_major(int major);
int do_verify_fd(void); int do_verify_fd(message *m_out);
int set_filp(filp_id_t sfilp); int set_filp(filp_id_t sfilp);
int do_set_filp(void); int do_set_filp(message *m_out);
int copy_filp(endpoint_t to_ep, filp_id_t cfilp); int copy_filp(endpoint_t to_ep, filp_id_t cfilp);
int do_copy_filp(void); int do_copy_filp(message *m_out);
int put_filp(filp_id_t pfilp); int put_filp(filp_id_t pfilp);
int do_put_filp(void); int do_put_filp(message *m_out);
int cancel_fd(endpoint_t ep, int fd); int cancel_fd(endpoint_t ep, int fd);
int do_cancel_fd(void); int do_cancel_fd(message *m_out);
void close_filp(struct filp *fp); void close_filp(struct filp *fp);
/* fscall.c */ /* fscall.c */
void nested_fs_call(message *m); void nested_fs_call(message *m);
/* link.c */ /* link.c */
int do_link(void); int do_link(message *m_out);
int do_unlink(void); int do_unlink(message *m_out);
int do_rename(void); int do_rename(message *m_out);
int do_truncate(void); int do_truncate(message *m_out);
int do_ftruncate(void); int do_ftruncate(message *m_out);
int truncate_vnode(struct vnode *vp, off_t newsize); int truncate_vnode(struct vnode *vp, off_t newsize);
int rdlink_direct(char *orig_path, char *link_path, struct fproc *rfp); int rdlink_direct(char *orig_path, char *link_path, struct fproc *rfp);
@ -126,29 +126,30 @@ void lock_revive(void);
/* main.c */ /* main.c */
int main(void); int main(void);
void lock_proc(struct fproc *rfp, int force_lock); void lock_proc(struct fproc *rfp, int force_lock);
void reply(endpoint_t whom, int result); void reply(message *m_out, endpoint_t whom, int result);
void replycode(endpoint_t whom, int result);
void thread_cleanup(struct fproc *rfp); void thread_cleanup(struct fproc *rfp);
void unlock_proc(struct fproc *rfp); void unlock_proc(struct fproc *rfp);
/* misc.c */ /* misc.c */
void pm_exit(int proc); void pm_exit(int proc);
int do_fcntl(void); int do_fcntl(message *m_out);
void pm_fork(int pproc, int cproc, int cpid); void pm_fork(int pproc, int cproc, int cpid);
void pm_setgid(int proc_e, int egid, int rgid); void pm_setgid(int proc_e, int egid, int rgid);
void pm_setuid(int proc_e, int euid, int ruid); void pm_setuid(int proc_e, int euid, int ruid);
void pm_setgroups(int proc_e, int ngroups, gid_t *addr); void pm_setgroups(int proc_e, int ngroups, gid_t *addr);
int do_sync(void); int do_sync(message *m_out);
int do_fsync(void); int do_fsync(message *m_out);
void pm_reboot(void); void pm_reboot(void);
int do_svrctl(void); int do_svrctl(message *m_out);
int do_getsysinfo(void); int do_getsysinfo(void);
int pm_dumpcore(endpoint_t proc_e, int sig, vir_bytes exe_name); int pm_dumpcore(endpoint_t proc_e, int sig, vir_bytes exe_name);
void * ds_event(void *arg); void * ds_event(void *arg);
/* mount.c */ /* mount.c */
int do_fsready(void); int do_fsready(message *m_out);
int do_mount(void); int do_mount(message *m_out);
int do_umount(void); int do_umount(message *m_out);
int is_nonedev(dev_t dev); int is_nonedev(dev_t dev);
void mount_pfs(void); void mount_pfs(void);
int mount_fs(dev_t dev, char mount_dev[PATH_MAX], char mount_path[PATH_MAX], int mount_fs(dev_t dev, char mount_dev[PATH_MAX], char mount_path[PATH_MAX],
@ -157,17 +158,17 @@ int unmount(dev_t dev, char label[LABEL_MAX]);
void unmount_all(int force); void unmount_all(int force);
/* open.c */ /* open.c */
int do_close(void); int do_close(message *m_out);
int close_fd(struct fproc *rfp, int fd_nr); int close_fd(struct fproc *rfp, int fd_nr);
void close_reply(void); void close_reply(void);
int common_open(char path[PATH_MAX], int oflags, mode_t omode); int common_open(char path[PATH_MAX], int oflags, mode_t omode);
int do_creat(void); int do_creat(void);
int do_lseek(void); int do_lseek(message *m_out);
int do_llseek(void); int do_llseek(message *m_out);
int do_mknod(void); int do_mknod(message *m_out);
int do_mkdir(void); int do_mkdir(message *m_out);
int do_open(void); int do_open(message *m_out);
int do_slink(void); int do_slink(message *m_out);
int do_vm_open(void); int do_vm_open(void);
int do_vm_close(void); int do_vm_close(void);
@ -180,11 +181,11 @@ void lookup_init(struct lookup *resolve, char *path, int flags, struct
vmnt **vmp, struct vnode **vp); vmnt **vmp, struct vnode **vp);
int get_name(struct vnode *dirp, struct vnode *entry, char *_name); int get_name(struct vnode *dirp, struct vnode *entry, char *_name);
int canonical_path(char *orig_path, struct fproc *rfp); int canonical_path(char *orig_path, struct fproc *rfp);
int do_check_perms(void); int do_check_perms(message *m_out);
/* pipe.c */ /* pipe.c */
int do_pipe(void); int do_pipe(message *m_out);
int do_pipe2(void); int do_pipe2(message *m_out);
int map_vnode(struct vnode *vp, endpoint_t fs_e); int map_vnode(struct vnode *vp, endpoint_t fs_e);
void unpause(endpoint_t proc_e); void unpause(endpoint_t proc_e);
int pipe_check(struct filp *filp, int rw_flag, int oflags, int bytes, int pipe_check(struct filp *filp, int rw_flag, int oflags, int bytes,
@ -197,17 +198,17 @@ void unsuspend_by_endpt(endpoint_t proc_e);
void wait_for(endpoint_t proc_e); void wait_for(endpoint_t proc_e);
/* protect.c */ /* protect.c */
int do_access(void); int do_access(message *m_out);
int do_chmod(void); int do_chmod(message *m_out);
int do_chown(void); int do_chown(message *m_out);
int do_umask(void); int do_umask(message *m_out);
int forbidden(struct fproc *rfp, struct vnode *vp, mode_t int forbidden(struct fproc *rfp, struct vnode *vp, mode_t
access_desired); access_desired);
int read_only(struct vnode *vp); int read_only(struct vnode *vp);
/* read.c */ /* read.c */
int do_read(void); int do_read(message *m_out);
int do_getdents(void); int do_getdents(message *m_out);
void lock_bsf(void); void lock_bsf(void);
void unlock_bsf(void); void unlock_bsf(void);
void check_bsf_lock(void); void check_bsf_lock(void);
@ -267,19 +268,19 @@ int req_utime(endpoint_t fs_e, ino_t inode_nr, struct timespec * actv,
int req_newdriver(endpoint_t fs_e, dev_t dev, char *label); int req_newdriver(endpoint_t fs_e, dev_t dev, char *label);
/* stadir.c */ /* stadir.c */
int do_chdir(void); int do_chdir(message *m_out);
int do_fchdir(void); int do_fchdir(message *m_out);
int do_chroot(void); int do_chroot(message *m_out);
int do_fstat(void); int do_fstat(message *m_out);
int do_stat(void); int do_stat(message *m_out);
int do_fstatfs(void); int do_fstatfs(message *m_out);
int do_statvfs(void); int do_statvfs(message *m_out);
int do_fstatvfs(void); int do_fstatvfs(message *m_out);
int do_rdlink(void); int do_rdlink(message *m_out);
int do_lstat(void); int do_lstat(message *m_out);
/* time.c */ /* time.c */
int do_utime(void); int do_utime(message *m_out);
/* tll.c */ /* tll.c */
void tll_downgrade(tll_t *tllp); void tll_downgrade(tll_t *tllp);
@ -298,7 +299,7 @@ unsigned conv2(int norm, int w);
long conv4(int norm, long x); long conv4(int norm, long x);
int copy_name(size_t len, char *dest); int copy_name(size_t len, char *dest);
int fetch_name(vir_bytes path, size_t len, char *dest); int fetch_name(vir_bytes path, size_t len, char *dest);
int no_sys(void); int no_sys(message *);
int isokendpt_f(char *f, int l, endpoint_t e, int *p, int ft); int isokendpt_f(char *f, int l, endpoint_t e, int *p, int ft);
int in_group(struct fproc *rfp, gid_t grp); int in_group(struct fproc *rfp, gid_t grp);
@ -335,7 +336,7 @@ void vnode_clean_refs(struct vnode *vp);
void upgrade_vnode_lock(struct vnode *vp); void upgrade_vnode_lock(struct vnode *vp);
/* write.c */ /* write.c */
int do_write(void); int do_write(message *m_out);
/* gcov.c */ /* gcov.c */
int do_gcov_flush(void); int do_gcov_flush(void);
@ -344,7 +345,7 @@ int do_gcov_flush(void);
#endif #endif
/* select.c */ /* select.c */
int do_select(void); int do_select(message *m_out);
void init_select(void); void init_select(void);
void select_callback(struct filp *, int ops); void select_callback(struct filp *, int ops);
void select_forget(endpoint_t proc_e); void select_forget(endpoint_t proc_e);

View File

@ -84,7 +84,7 @@ static int select_majors[] = { /* List of majors that support selecting on */
/*===========================================================================* /*===========================================================================*
* do_select * * do_select *
*===========================================================================*/ *===========================================================================*/
int do_select(void) int do_select()
{ {
/* Implement the select(nfds, readfds, writefds, errorfds, timeout) system /* Implement the select(nfds, readfds, writefds, errorfds, timeout) system
* call. First we copy the arguments and verify their sanity. Then we check * call. First we copy the arguments and verify their sanity. Then we check

View File

@ -14,7 +14,7 @@
#include "vnode.h" #include "vnode.h"
#include "vmnt.h" #include "vmnt.h"
int (*call_vec[])(void) = { int (*call_vec[])(message *m_out) = {
no_sys, /* 0 = unused */ no_sys, /* 0 = unused */
no_sys, /* 1 = (exit) */ no_sys, /* 1 = (exit) */
no_sys, /* 2 = (fork) */ no_sys, /* 2 = (fork) */
@ -136,7 +136,7 @@ int (*call_vec[])(void) = {
/* This should not fail with "array size is negative": */ /* This should not fail with "array size is negative": */
extern int dummy[sizeof(call_vec) == NCALLS * sizeof(call_vec[0]) ? 1 : -1]; extern int dummy[sizeof(call_vec) == NCALLS * sizeof(call_vec[0]) ? 1 : -1];
int (*pfs_call_vec[])(void) = { int (*pfs_call_vec[])(message *m_out) = {
no_sys, /* 0 */ no_sys, /* 0 */
do_check_perms, /* 1 */ do_check_perms, /* 1 */