From: Ben Gras Date: Fri, 12 Apr 2013 16:41:23 +0000 (+0000) Subject: vfs: make m_out non-global X-Git-Tag: v3.3.0~1026 X-Git-Url: http://zhaoyanbai.com/repos/%22../static/gitweb.js?a=commitdiff_plain;h=cef94e096ec2b8f3c0ab90f3af595a9c55bbe316;p=minix.git 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 --- diff --git a/servers/vfs/device.c b/servers/vfs/device.c index 14ddd2fbc..2ef5c9bf0 100644 --- a/servers/vfs/device.c +++ b/servers/vfs/device.c @@ -652,7 +652,7 @@ void pm_setsid(endpoint_t proc_e) /*===========================================================================* * do_ioctl * *===========================================================================*/ -int do_ioctl() +int do_ioctl(message *UNUSED(m_out)) { /* Perform the ioctl(ls_fd, request, argx) system call */ @@ -1107,6 +1107,8 @@ int maj; struct vnode *vp; struct filp *rfilp; 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"); @@ -1154,7 +1156,7 @@ int maj; rfp->fp_task == driver_e && (rfp->fp_flags & FP_SUSP_REOPEN)) { rfp->fp_flags &= ~FP_SUSP_REOPEN; 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 */ rfp->fp_blocked_on = FP_BLOCKED_ON_NONE; FD_CLR(fd_nr, &rfp->fp_filp_inuse); - reply(rfp->fp_endpoint, EIO); + reply(&m_out, rfp->fp_endpoint, EIO); continue; } @@ -1183,7 +1185,7 @@ int maj; if (major(vp->v_sdev) != maj) continue; rfp->fp_blocked_on = FP_BLOCKED_ON_NONE; - reply(rfp->fp_endpoint, fd_nr); + reply(&m_out, rfp->fp_endpoint, fd_nr); } } diff --git a/servers/vfs/filedes.c b/servers/vfs/filedes.c index b3914757b..1ccdb8eb9 100644 --- a/servers/vfs/filedes.c +++ b/servers/vfs/filedes.c @@ -443,7 +443,7 @@ int fd; /*===========================================================================* * do_verify_fd * *===========================================================================*/ -int do_verify_fd(void) +int do_verify_fd(message *m_out) { struct filp *rfilp; endpoint_t proc_e; @@ -453,7 +453,7 @@ int do_verify_fd(void) fd = job_m_in.COUNT; rfilp = (struct filp *) verify_fd(proc_e, fd); - m_out.ADDRESS = (void *) rfilp; + m_out->ADDRESS = (void *) rfilp; if (rfilp != NULL) unlock_filp(rfilp); return (rfilp != NULL) ? OK : EINVAL; } @@ -476,7 +476,7 @@ filp_id_t sfilp; /*===========================================================================* * do_set_filp * *===========================================================================*/ -int do_set_filp(void) +int do_set_filp(message *UNUSED(m_out)) { filp_id_t f; f = (filp_id_t) job_m_in.ADDRESS; @@ -517,7 +517,7 @@ filp_id_t cfilp; /*===========================================================================* * do_copy_filp * *===========================================================================*/ -int do_copy_filp(void) +int do_copy_filp(message *UNUSED(m_out)) { endpoint_t proc_e; filp_id_t f; @@ -546,7 +546,7 @@ filp_id_t pfilp; /*===========================================================================* * do_put_filp * *===========================================================================*/ -int do_put_filp(void) +int do_put_filp(message *UNUSED(m_out)) { filp_id_t f; f = (filp_id_t) job_m_in.ADDRESS; @@ -591,7 +591,7 @@ int fd; /*===========================================================================* * do_cancel_fd * *===========================================================================*/ -int do_cancel_fd(void) +int do_cancel_fd(message *UNUSED(m_out)) { endpoint_t proc_e; int fd; diff --git a/servers/vfs/glo.h b/servers/vfs/glo.h index 8ad298abc..ad17d1ea4 100644 --- a/servers/vfs/glo.h +++ b/servers/vfs/glo.h @@ -24,7 +24,6 @@ EXTERN u32_t system_hz; /* system clock frequency. */ /* The parameters of the call are kept here. */ 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 isokslot(p) (p >= 0 && \ 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 */ /* Data initialized elsewhere. */ -extern int(*call_vec[]) (void); -extern int(*pfs_call_vec[]) (void); +extern int(*call_vec[]) (message *); +extern int(*pfs_call_vec[]) (message *m_out); extern char mode_map[]; /* mapping from O_ACCMODE mask to R_BIT/W_BIT flags */ EXTERN struct kinfo kinfo; /* kernel information */ diff --git a/servers/vfs/link.c b/servers/vfs/link.c index 0b68f4d2a..8ffc03ee0 100644 --- a/servers/vfs/link.c +++ b/servers/vfs/link.c @@ -29,7 +29,7 @@ /*===========================================================================* * do_link * *===========================================================================*/ -int do_link() +int do_link(message *UNUSED(m_out)) { /* Perform the link(name1, name2) system call. */ int r = OK; @@ -91,7 +91,7 @@ int do_link() /*===========================================================================* * do_unlink * *===========================================================================*/ -int do_unlink() +int do_unlink(message *UNUSED(m_out)) { /* Perform the unlink(name) or rmdir(name) system call. The code for these two * is almost the same. They differ only in some condition testing. Unlink() @@ -176,7 +176,7 @@ int do_unlink() /*===========================================================================* * do_rename * *===========================================================================*/ -int do_rename() +int do_rename(message *UNUSED(m_out)) { /* Perform the rename(name1, name2) system call. */ int r = OK, r1; @@ -283,7 +283,7 @@ int do_rename() /*===========================================================================* * do_truncate * *===========================================================================*/ -int do_truncate() +int do_truncate(message *UNUSED(m_out)) { /* truncate_vnode() does the actual work of do_truncate() and do_ftruncate(). * do_truncate() and do_ftruncate() have to get hold of the inode, either @@ -334,7 +334,7 @@ int do_truncate() /*===========================================================================* * do_ftruncate * *===========================================================================*/ -int do_ftruncate() +int do_ftruncate(message *UNUSED(m_out)) { /* As with do_truncate(), truncate_vnode() does the actual work. */ struct filp *rfilp; @@ -395,7 +395,7 @@ off_t newsize; /*===========================================================================* * do_slink * *===========================================================================*/ -int do_slink() +int do_slink(message *UNUSED(m_out)) { /* Perform the symlink(name1, name2) system call. */ int r; @@ -477,7 +477,7 @@ struct fproc *rfp; /*===========================================================================* * do_rdlink * *===========================================================================*/ -int do_rdlink() +int do_rdlink(message *UNUSED(m_out)) { /* Perform the readlink(name, buf, bufsize) system call. */ int r; diff --git a/servers/vfs/main.c b/servers/vfs/main.c index 1ba96cfba..d18cb752f 100644 --- a/servers/vfs/main.c +++ b/servers/vfs/main.c @@ -183,7 +183,7 @@ static void handle_work(void *(*func)(void *arg)) * one call back at a time. */ if (vmp->m_flags & VMNT_CALLBACK) { - reply(proc_e, EAGAIN); + replycode(proc_e, EAGAIN); return; } 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 * handle more, sorry */ - reply(proc_e, EAGAIN); + replycode(proc_e, EAGAIN); 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); if (r != SUSPEND) /* Do we have results to report? */ - reply(fp->fp_endpoint, r); + replycode(fp->fp_endpoint, r); unlock_filp(f); thread_cleanup(fp); @@ -424,6 +424,9 @@ static void *do_work(void *arg) { int error; struct job my_job; + message m_out; + + memset(&m_out, 0, sizeof(m_out)); my_job = *((struct job *) arg); fp = my_job.j_fp; @@ -443,7 +446,7 @@ static void *do_work(void *arg) error = ENOSYS; } else { job_call_nr -= PFS_BASE; - error = (*pfs_call_vec[job_call_nr])(); + error = (*pfs_call_vec[job_call_nr])(&m_out); } } else { /* 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 calls_stats[job_call_nr]++; #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. */ - if (error != SUSPEND) reply(fp->fp_endpoint, error); + if (error != SUSPEND) reply(&m_out, fp->fp_endpoint, error); thread_cleanup(fp); unlock_proc(fp); @@ -791,11 +794,31 @@ static void get_work() /*===========================================================================* * 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. */ 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; r = sendnb(whom, &m_out); if (r != OK) { @@ -812,6 +835,9 @@ static void service_pm_postponed(void) { int r; vir_bytes pc, newsp; + message m_out; + + memset(&m_out, 0, sizeof(m_out)); switch(job_call_nr) { case PM_EXEC: @@ -893,6 +919,9 @@ static void service_pm_postponed(void) static void service_pm() { int r, slot; + message m_out; + + memset(&m_out, 0, sizeof(m_out)); switch (job_call_nr) { case PM_SETUID: diff --git a/servers/vfs/misc.c b/servers/vfs/misc.c index dd1083792..78c5dd599 100644 --- a/servers/vfs/misc.c +++ b/servers/vfs/misc.c @@ -108,7 +108,7 @@ int do_getsysinfo() /*===========================================================================* * do_fcntl * *===========================================================================*/ -int do_fcntl() +int do_fcntl(message *UNUSED(m_out)) { /* Perform the fcntl(fd, request, ...) system call. */ @@ -250,10 +250,8 @@ int do_fcntl() return(r); } -/*===========================================================================* - * do_sync * - *===========================================================================*/ -int do_sync() +static int +sync_fses(void) { struct vmnt *vmp; int r = OK; @@ -271,10 +269,18 @@ int do_sync() return(r); } +/*===========================================================================* + * do_sync * + *===========================================================================*/ +int do_sync(message *UNUSED(m_out)) +{ + return sync_fses(); +} + /*===========================================================================* * do_fsync * *===========================================================================*/ -int do_fsync() +int do_fsync(message *UNUSED(m_out)) { /* Perform the fsync() system call. */ struct filp *rfilp; @@ -314,7 +320,7 @@ void pm_reboot() int i; struct fproc *rfp; - do_sync(); + sync_fses(); /* 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). @@ -333,7 +339,7 @@ void pm_reboot() unlock_proc(rfp); } - do_sync(); + sync_fses(); unmount_all(0 /* Don't force */); /* Try to exit all processes again including File Servers */ @@ -348,7 +354,7 @@ void pm_reboot() unlock_proc(rfp); } - do_sync(); + sync_fses(); unmount_all(1 /* Force */); } @@ -573,7 +579,7 @@ int ruid; /*===========================================================================* * do_svrctl * *===========================================================================*/ -int do_svrctl() +int do_svrctl(message *UNUSED(m_out)) { unsigned int svrctl; vir_bytes ptr; diff --git a/servers/vfs/mount.c b/servers/vfs/mount.c index a91a90ec7..51517ef46 100644 --- a/servers/vfs/mount.c +++ b/servers/vfs/mount.c @@ -86,7 +86,7 @@ static void update_bspec(dev_t dev, endpoint_t fs_e, int send_drv_e) /*===========================================================================* * do_fsready * *===========================================================================*/ -int do_fsready() +int do_fsready(message *UNUSED(m_out)) { /* deprecated */ return(SUSPEND); @@ -95,7 +95,7 @@ int do_fsready() /*===========================================================================* * do_mount * *===========================================================================*/ -int do_mount() +int do_mount(message *UNUSED(m_out)) { /* Perform the mount(name, mfile, mount_flags) system call. */ endpoint_t fs_e; @@ -414,7 +414,7 @@ void mount_pfs(void) /*===========================================================================* * do_umount * *===========================================================================*/ -int do_umount(void) +int do_umount(message *m_out) { /* Perform the umount(name) system call. * 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 */ 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); } diff --git a/servers/vfs/open.c b/servers/vfs/open.c index cd86331f2..36b722660 100644 --- a/servers/vfs/open.c +++ b/servers/vfs/open.c @@ -40,7 +40,7 @@ static int pipe_open(struct vnode *vp, mode_t bits, int oflags); /*===========================================================================* * do_open * *===========================================================================*/ -int do_open() +int do_open(message *UNUSED(m_out)) { /* Perform the open(name, flags,...) system call. * syscall might provide 'name' embedded in message when not creating file */ @@ -499,7 +499,7 @@ static int pipe_open(struct vnode *vp, mode_t bits, int oflags) /*===========================================================================* * do_mknod * *===========================================================================*/ -int do_mknod() +int do_mknod(message *UNUSED(m_out)) { /* Perform the mknod(name, mode, addr) system call. */ register mode_t bits, mode_bits; @@ -548,7 +548,7 @@ int do_mknod() /*===========================================================================* * do_mkdir * *===========================================================================*/ -int do_mkdir() +int do_mkdir(message *UNUSED(m_out)) { /* Perform the mkdir(name, mode) system call. */ mode_t bits; /* mode bits for the new inode */ @@ -590,7 +590,7 @@ int do_mkdir() /*===========================================================================* * do_lseek * *===========================================================================*/ -int do_lseek() +int do_lseek(message *m_out) { /* Perform the lseek(ls_fd, offset, whence) system call. */ register struct filp *rfilp; @@ -631,7 +631,7 @@ int do_lseek() r = EOVERFLOW; } else { /* 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) { rfilp->filp_pos = newpos; @@ -649,7 +649,7 @@ int do_lseek() /*===========================================================================* * do_llseek * *===========================================================================*/ -int do_llseek() +int do_llseek(message *m_out) { /* Perform the llseek(ls_fd, offset, whence) system call. */ register struct filp *rfilp; @@ -688,8 +688,8 @@ int do_llseek() r = EINVAL; else { /* insert the new position into the output message */ - m_out.reply_l1 = ex64lo(newpos); - m_out.reply_l2 = ex64hi(newpos); + m_out->reply_l1 = ex64lo(newpos); + m_out->reply_l2 = ex64hi(newpos); if (cmp64(newpos, rfilp->filp_pos) != 0) { rfilp->filp_pos = newpos; @@ -707,7 +707,7 @@ int do_llseek() /*===========================================================================* * do_close * *===========================================================================*/ -int do_close() +int do_close(message *UNUSED(m_out)) { /* Perform the close(fd) system call. */ diff --git a/servers/vfs/path.c b/servers/vfs/path.c index 6c0d2bbdf..3d94215db 100644 --- a/servers/vfs/path.c +++ b/servers/vfs/path.c @@ -870,7 +870,7 @@ size_t pathlen; /*===========================================================================* * do_check_perms * *===========================================================================*/ -int do_check_perms(void) +int do_check_perms(message *UNUSED(m_out)) { return check_perms(job_m_in.USER_ENDPT, (cp_grant_id_t) job_m_in.IO_GRANT, (size_t) job_m_in.COUNT); diff --git a/servers/vfs/pipe.c b/servers/vfs/pipe.c index 73d991018..a6cc0f9e0 100644 --- a/servers/vfs/pipe.c +++ b/servers/vfs/pipe.c @@ -18,6 +18,7 @@ #include "fs.h" #include #include +#include #include #include #include @@ -39,7 +40,7 @@ static int create_pipe(int fil_des[2], int flags); /*===========================================================================* * do_pipe * *===========================================================================*/ -int do_pipe() +int do_pipe(message *m_out) { /* Perform the pipe(fil_des[2]) system call. */ @@ -48,8 +49,8 @@ int do_pipe() r = create_pipe(fil_des, 0 /* no flags */); if (r == OK) { - m_out.reply_i1 = fil_des[0]; - m_out.reply_i2 = fil_des[1]; + m_out->reply_i1 = fil_des[0]; + m_out->reply_i2 = fil_des[1]; } return r; @@ -58,7 +59,7 @@ int do_pipe() /*===========================================================================* * do_pipe2 * *===========================================================================*/ -int do_pipe2() +int do_pipe2(message *m_out) { /* Perform the pipe2(fil_des[2], flags) system call. */ int r, flags; @@ -68,8 +69,8 @@ int do_pipe2() r = create_pipe(fil_des, flags); if (r == OK) { - m_out.reply_i1 = fil_des[0]; - m_out.reply_i2 = fil_des[1]; + m_out->reply_i1 = fil_des[0]; + m_out->reply_i2 = fil_des[1]; } return r; @@ -507,18 +508,18 @@ void revive(endpoint_t proc_e, int returned) unlock_filp(fil_ptr); put_vnode(fil_ptr->filp_vno); fil_ptr->filp_vno = NULL; - reply(proc_e, returned); + replycode(proc_e, returned); } else { - reply(proc_e, fd_nr); + replycode(proc_e, fd_nr); } } else { rfp->fp_blocked_on = FP_BLOCKED_ON_NONE; scratch(rfp).file.fd_nr = 0; if (blocked_on == FP_BLOCKED_ON_POPEN) { /* process blocked in open or create */ - reply(proc_e, fd_nr); + replycode(proc_e, fd_nr); } else if (blocked_on == FP_BLOCKED_ON_SELECT) { - reply(proc_e, returned); + replycode(proc_e, returned); } else { /* Revive a process suspended on TTY or other device. * Pretend it wants only what there is. @@ -534,7 +535,7 @@ void revive(endpoint_t proc_e, int returned) } 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--; } - reply(proc_e, status); /* signal interrupted call */ + replycode(proc_e, status); /* signal interrupted call */ } diff --git a/servers/vfs/protect.c b/servers/vfs/protect.c index 70a4536e2..ce71cee5e 100644 --- a/servers/vfs/protect.c +++ b/servers/vfs/protect.c @@ -23,7 +23,7 @@ /*===========================================================================* * do_chmod * *===========================================================================*/ -int do_chmod() +int do_chmod(message *UNUSED(m_out)) { /* Perform the chmod(name, mode) and fchmod(fd, mode) system calls. * syscall might provide 'name' embedded in the message. @@ -99,7 +99,7 @@ int do_chmod() /*===========================================================================* * do_chown * *===========================================================================*/ -int do_chown() +int do_chown(message *UNUSED(m_out)) { /* Perform the chown(path, owner, group) and fchmod(fd, owner, group) system * calls. */ @@ -181,7 +181,7 @@ int do_chown() /*===========================================================================* * do_umask * *===========================================================================*/ -int do_umask() +int do_umask(message *UNUSED(m_out)) { /* Perform the umask(co_mode) system call. */ mode_t complement, new_umask; @@ -197,7 +197,7 @@ int do_umask() /*===========================================================================* * do_access * *===========================================================================*/ -int do_access() +int do_access(message *UNUSED(m_out)) { /* Perform the access(name, mode) system call. * syscall might provide 'name' embedded in the message. diff --git a/servers/vfs/proto.h b/servers/vfs/proto.h index 6e4e40b0e..8ea43dc5d 100644 --- a/servers/vfs/proto.h +++ b/servers/vfs/proto.h @@ -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 clone_opcl(int op, dev_t dev, int proc, int flags); 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 dev_status(endpoint_t drv_e); void bdev_up(int major); @@ -96,26 +96,26 @@ void unlock_filps(struct filp *filp1, struct filp *filp2); int invalidate_filp(struct filp *); void invalidate_filp_by_endpt(endpoint_t proc_e); 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 do_set_filp(void); +int do_set_filp(message *m_out); 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 do_put_filp(void); +int do_put_filp(message *m_out); 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); /* fscall.c */ void nested_fs_call(message *m); /* link.c */ -int do_link(void); -int do_unlink(void); -int do_rename(void); -int do_truncate(void); -int do_ftruncate(void); +int do_link(message *m_out); +int do_unlink(message *m_out); +int do_rename(message *m_out); +int do_truncate(message *m_out); +int do_ftruncate(message *m_out); int truncate_vnode(struct vnode *vp, off_t newsize); int rdlink_direct(char *orig_path, char *link_path, struct fproc *rfp); @@ -126,29 +126,30 @@ void lock_revive(void); /* main.c */ int main(void); 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 unlock_proc(struct fproc *rfp); /* misc.c */ 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_setgid(int proc_e, int egid, int rgid); void pm_setuid(int proc_e, int euid, int ruid); void pm_setgroups(int proc_e, int ngroups, gid_t *addr); -int do_sync(void); -int do_fsync(void); +int do_sync(message *m_out); +int do_fsync(message *m_out); void pm_reboot(void); -int do_svrctl(void); +int do_svrctl(message *m_out); int do_getsysinfo(void); int pm_dumpcore(endpoint_t proc_e, int sig, vir_bytes exe_name); void * ds_event(void *arg); /* mount.c */ -int do_fsready(void); -int do_mount(void); -int do_umount(void); +int do_fsready(message *m_out); +int do_mount(message *m_out); +int do_umount(message *m_out); int is_nonedev(dev_t dev); void mount_pfs(void); 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); /* open.c */ -int do_close(void); +int do_close(message *m_out); int close_fd(struct fproc *rfp, int fd_nr); void close_reply(void); int common_open(char path[PATH_MAX], int oflags, mode_t omode); int do_creat(void); -int do_lseek(void); -int do_llseek(void); -int do_mknod(void); -int do_mkdir(void); -int do_open(void); -int do_slink(void); +int do_lseek(message *m_out); +int do_llseek(message *m_out); +int do_mknod(message *m_out); +int do_mkdir(message *m_out); +int do_open(message *m_out); +int do_slink(message *m_out); int do_vm_open(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); int get_name(struct vnode *dirp, struct vnode *entry, char *_name); int canonical_path(char *orig_path, struct fproc *rfp); -int do_check_perms(void); +int do_check_perms(message *m_out); /* pipe.c */ -int do_pipe(void); -int do_pipe2(void); +int do_pipe(message *m_out); +int do_pipe2(message *m_out); int map_vnode(struct vnode *vp, endpoint_t fs_e); void unpause(endpoint_t proc_e); 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); /* protect.c */ -int do_access(void); -int do_chmod(void); -int do_chown(void); -int do_umask(void); +int do_access(message *m_out); +int do_chmod(message *m_out); +int do_chown(message *m_out); +int do_umask(message *m_out); int forbidden(struct fproc *rfp, struct vnode *vp, mode_t access_desired); int read_only(struct vnode *vp); /* read.c */ -int do_read(void); -int do_getdents(void); +int do_read(message *m_out); +int do_getdents(message *m_out); void lock_bsf(void); void unlock_bsf(void); void check_bsf_lock(void); @@ -267,20 +268,20 @@ 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); /* stadir.c */ -int do_chdir(void); -int do_fchdir(void); -int do_chroot(void); -int do_fstat(void); -int do_stat(void); -int do_fstatfs(void); -int do_statvfs(void); -int do_fstatvfs(void); -int do_rdlink(void); -int do_lstat(void); +int do_chdir(message *m_out); +int do_fchdir(message *m_out); +int do_chroot(message *m_out); +int do_fstat(message *m_out); +int do_stat(message *m_out); +int do_fstatfs(message *m_out); +int do_statvfs(message *m_out); +int do_fstatvfs(message *m_out); +int do_rdlink(message *m_out); +int do_lstat(message *m_out); /* time.c */ -int do_utime(void); -int do_utimens(void); +int do_utime(message *); +int do_utimens(message *); /* tll.c */ void tll_downgrade(tll_t *tllp); @@ -299,7 +300,7 @@ unsigned conv2(int norm, int w); long conv4(int norm, long x); int copy_name(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 in_group(struct fproc *rfp, gid_t grp); @@ -336,7 +337,7 @@ void vnode_clean_refs(struct vnode *vp); void upgrade_vnode_lock(struct vnode *vp); /* write.c */ -int do_write(void); +int do_write(message *m_out); /* gcov.c */ int do_gcov_flush(void); @@ -345,7 +346,7 @@ int do_gcov_flush(void); #endif /* select.c */ -int do_select(void); +int do_select(message *m_out); void init_select(void); void select_callback(struct filp *, int ops); void select_forget(endpoint_t proc_e); diff --git a/servers/vfs/read.c b/servers/vfs/read.c index e85531a19..b278738f0 100644 --- a/servers/vfs/read.c +++ b/servers/vfs/read.c @@ -29,7 +29,7 @@ /*===========================================================================* * do_read * *===========================================================================*/ -int do_read() +int do_read(message *UNUSED(m_out)) { return(do_read_write_peek(READING, job_m_in.fd, job_m_in.buffer, (size_t) job_m_in.nbytes)); @@ -233,7 +233,7 @@ int read_write(int rw_flag, struct filp *f, char *buf, size_t size, /*===========================================================================* * do_getdents * *===========================================================================*/ -int do_getdents() +int do_getdents(message *UNUSED(m_out)) { /* Perform the getdents(fd, buf, size) system call. */ int r = OK; diff --git a/servers/vfs/select.c b/servers/vfs/select.c index bc46430b3..191b01ffc 100644 --- a/servers/vfs/select.c +++ b/servers/vfs/select.c @@ -84,7 +84,7 @@ static int select_majors[] = { /* List of majors that support selecting on */ /*===========================================================================* * do_select * *===========================================================================*/ -int do_select(void) +int do_select(message *UNUSED(m_out)) { /* Implement the select(nfds, readfds, writefds, errorfds, timeout) system * call. First we copy the arguments and verify their sanity. Then we check diff --git a/servers/vfs/stadir.c b/servers/vfs/stadir.c index 48237fc8c..09763f41b 100644 --- a/servers/vfs/stadir.c +++ b/servers/vfs/stadir.c @@ -32,7 +32,7 @@ static int change_into(struct vnode **iip, struct vnode *vp); /*===========================================================================* * do_fchdir * *===========================================================================*/ -int do_fchdir() +int do_fchdir(message *UNUSED(m_out)) { /* Change directory on already-opened fd. */ struct filp *rfilp; @@ -50,7 +50,7 @@ int do_fchdir() /*===========================================================================* * do_chdir * *===========================================================================*/ -int do_chdir() +int do_chdir(message *UNUSED(m_out)) { /* Perform the chdir(name) system call. * syscall might provide 'name' embedded in the message. @@ -91,7 +91,7 @@ int do_chdir() /*===========================================================================* * do_chroot * *===========================================================================*/ -int do_chroot() +int do_chroot(message *UNUSED(m_out)) { /* Perform the chroot(name) system call. * syscall might provide 'name' embedded in the message. @@ -156,7 +156,7 @@ static int change_into(struct vnode **result, struct vnode *vp) /*===========================================================================* * do_stat * *===========================================================================*/ -int do_stat() +int do_stat(message *UNUSED(m_out)) { /* Perform the stat(name, buf) system call. */ int r; @@ -189,7 +189,7 @@ int do_stat() /*===========================================================================* * do_fstat * *===========================================================================*/ -int do_fstat() +int do_fstat(message *UNUSED(m_out)) { /* Perform the fstat(fd, buf) system call. */ register struct filp *rfilp; @@ -213,7 +213,7 @@ int do_fstat() /*===========================================================================* * do_fstatfs * *===========================================================================*/ -int do_fstatfs() +int do_fstatfs(message *UNUSED(m_out)) { /* Perform the fstatfs(fd, buf) system call. */ struct filp *rfilp; @@ -236,7 +236,7 @@ int do_fstatfs() /*===========================================================================* * do_statvfs * *===========================================================================*/ -int do_statvfs() +int do_statvfs(message *UNUSED(m_out)) { /* Perform the stat(name, buf) system call. */ int r; @@ -269,7 +269,7 @@ int do_statvfs() /*===========================================================================* * do_fstatvfs * *===========================================================================*/ -int do_fstatvfs() +int do_fstatvfs(message *UNUSED(m_out)) { /* Perform the fstat(fd, buf) system call. */ register struct filp *rfilp; @@ -291,7 +291,7 @@ int do_fstatvfs() /*===========================================================================* * do_lstat * *===========================================================================*/ -int do_lstat() +int do_lstat(message *UNUSED(m_out)) { /* Perform the lstat(name, buf) system call. */ struct vnode *vp; diff --git a/servers/vfs/table.c b/servers/vfs/table.c index 00a0ae05f..5fe5b817e 100644 --- a/servers/vfs/table.c +++ b/servers/vfs/table.c @@ -14,7 +14,7 @@ #include "vnode.h" #include "vmnt.h" -int (*call_vec[])(void) = { +int (*call_vec[])(message *m_out) = { no_sys, /* 0 = unused */ no_sys, /* 1 = (exit) */ no_sys, /* 2 = (fork) */ @@ -136,7 +136,7 @@ int (*call_vec[])(void) = { /* This should not fail with "array size is negative": */ 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 */ do_check_perms, /* 1 */ diff --git a/servers/vfs/time.c b/servers/vfs/time.c index b366dde68..d3b42669b 100644 --- a/servers/vfs/time.c +++ b/servers/vfs/time.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include "file.h" @@ -25,7 +26,7 @@ /*===========================================================================* * do_utime * *===========================================================================*/ -int do_utime(void) +int do_utime(message *UNUSED(m_out)) { /* Perform the utime(name, timep) system call. */ int r; @@ -83,7 +84,7 @@ int do_utime(void) /*===========================================================================* * do_utimens * *===========================================================================*/ -int do_utimens(void) +int do_utimens(message *UNUSED(m_out)) { /* Perform the utimens(name, times, flag) system call, and its friends. * Implement a very large but not complete subset of the utimensat() @@ -108,6 +109,8 @@ int do_utimens(void) vir_bytes vname; size_t vname_length; + memset(&now, 0, sizeof(now)); + /* The case times==NULL is handled by the caller, replaced with UTIME_NOW */ actim.tv_sec = job_m_in.utime_actime; actim.tv_nsec = job_m_in.utimens_ansec; diff --git a/servers/vfs/utility.c b/servers/vfs/utility.c index 1af39f7e6..db2f831d6 100644 --- a/servers/vfs/utility.c +++ b/servers/vfs/utility.c @@ -97,7 +97,7 @@ int fetch_name(vir_bytes path, size_t len, char *dest) /*===========================================================================* * no_sys * *===========================================================================*/ -int no_sys() +int no_sys(message *UNUSED(m_out)) { /* Somebody has used an illegal system call number */ return(ENOSYS); diff --git a/servers/vfs/write.c b/servers/vfs/write.c index 6d9e939e4..9ba0cb849 100644 --- a/servers/vfs/write.c +++ b/servers/vfs/write.c @@ -13,7 +13,7 @@ /*===========================================================================* * do_write * *===========================================================================*/ -int do_write() +int do_write(message *UNUSED(m_out)) { /* Perform the write(fd, buffer, nbytes) system call. */ return(do_read_write_peek(WRITING, job_m_in.fd,