diff --git a/servers/vfs/device.c b/servers/vfs/device.c index 14ddd2fbc..d83481cac 100644 --- a/servers/vfs/device.c +++ b/servers/vfs/device.c @@ -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..a4ea065f6 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() { 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() { 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() { 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() { 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/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..7564da607 100644 --- a/servers/vfs/misc.c +++ b/servers/vfs/misc.c @@ -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,6 +269,14 @@ int do_sync() return(r); } +/*===========================================================================* + * do_sync * + *===========================================================================*/ +int do_sync() +{ + return sync_fses(); +} + /*===========================================================================* * do_fsync * *===========================================================================*/ @@ -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 */); } diff --git a/servers/vfs/mount.c b/servers/vfs/mount.c index a91a90ec7..e9c4716c5 100644 --- a/servers/vfs/mount.c +++ b/servers/vfs/mount.c @@ -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..59b972f88 100644 --- a/servers/vfs/open.c +++ b/servers/vfs/open.c @@ -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; diff --git a/servers/vfs/path.c b/servers/vfs/path.c index 6c0d2bbdf..fd8dc20b6 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() { 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/proto.h b/servers/vfs/proto.h index 36c3ef0e8..ade3073a3 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,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); /* 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_utime(message *m_out); /* tll.c */ void tll_downgrade(tll_t *tllp); @@ -298,7 +299,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); @@ -335,7 +336,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); @@ -344,7 +345,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/select.c b/servers/vfs/select.c index bc46430b3..e8a256f03 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() { /* 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/table.c b/servers/vfs/table.c index b65542635..125d0b05f 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 */