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 cb51426c6a
commit cef94e096e
19 changed files with 176 additions and 135 deletions

View File

@ -652,7 +652,7 @@ void pm_setsid(endpoint_t proc_e)
/*===========================================================================* /*===========================================================================*
* do_ioctl * * do_ioctl *
*===========================================================================*/ *===========================================================================*/
int do_ioctl() int do_ioctl(message *UNUSED(m_out))
{ {
/* Perform the ioctl(ls_fd, request, argx) system call */ /* Perform the ioctl(ls_fd, request, argx) system call */
@ -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(message *UNUSED(m_out))
{ {
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(message *UNUSED(m_out))
{ {
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(message *UNUSED(m_out))
{ {
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(message *UNUSED(m_out))
{ {
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

@ -29,7 +29,7 @@
/*===========================================================================* /*===========================================================================*
* do_link * * do_link *
*===========================================================================*/ *===========================================================================*/
int do_link() int do_link(message *UNUSED(m_out))
{ {
/* Perform the link(name1, name2) system call. */ /* Perform the link(name1, name2) system call. */
int r = OK; int r = OK;
@ -91,7 +91,7 @@ int do_link()
/*===========================================================================* /*===========================================================================*
* do_unlink * * 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 /* 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() * is almost the same. They differ only in some condition testing. Unlink()
@ -176,7 +176,7 @@ int do_unlink()
/*===========================================================================* /*===========================================================================*
* do_rename * * do_rename *
*===========================================================================*/ *===========================================================================*/
int do_rename() int do_rename(message *UNUSED(m_out))
{ {
/* Perform the rename(name1, name2) system call. */ /* Perform the rename(name1, name2) system call. */
int r = OK, r1; int r = OK, r1;
@ -283,7 +283,7 @@ int do_rename()
/*===========================================================================* /*===========================================================================*
* do_truncate * * do_truncate *
*===========================================================================*/ *===========================================================================*/
int do_truncate() int do_truncate(message *UNUSED(m_out))
{ {
/* truncate_vnode() does the actual work of do_truncate() and do_ftruncate(). /* 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 * do_truncate() and do_ftruncate() have to get hold of the inode, either
@ -334,7 +334,7 @@ int do_truncate()
/*===========================================================================* /*===========================================================================*
* do_ftruncate * * do_ftruncate *
*===========================================================================*/ *===========================================================================*/
int do_ftruncate() int do_ftruncate(message *UNUSED(m_out))
{ {
/* As with do_truncate(), truncate_vnode() does the actual work. */ /* As with do_truncate(), truncate_vnode() does the actual work. */
struct filp *rfilp; struct filp *rfilp;
@ -395,7 +395,7 @@ off_t newsize;
/*===========================================================================* /*===========================================================================*
* do_slink * * do_slink *
*===========================================================================*/ *===========================================================================*/
int do_slink() int do_slink(message *UNUSED(m_out))
{ {
/* Perform the symlink(name1, name2) system call. */ /* Perform the symlink(name1, name2) system call. */
int r; int r;
@ -477,7 +477,7 @@ struct fproc *rfp;
/*===========================================================================* /*===========================================================================*
* do_rdlink * * do_rdlink *
*===========================================================================*/ *===========================================================================*/
int do_rdlink() int do_rdlink(message *UNUSED(m_out))
{ {
/* Perform the readlink(name, buf, bufsize) system call. */ /* Perform the readlink(name, buf, bufsize) system call. */
int r; int r;

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

@ -108,7 +108,7 @@ int do_getsysinfo()
/*===========================================================================* /*===========================================================================*
* do_fcntl * * do_fcntl *
*===========================================================================*/ *===========================================================================*/
int do_fcntl() int do_fcntl(message *UNUSED(m_out))
{ {
/* Perform the fcntl(fd, request, ...) system call. */ /* Perform the fcntl(fd, request, ...) system call. */
@ -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,10 +269,18 @@ int do_sync()
return(r); return(r);
} }
/*===========================================================================*
* do_sync *
*===========================================================================*/
int do_sync(message *UNUSED(m_out))
{
return sync_fses();
}
/*===========================================================================* /*===========================================================================*
* do_fsync * * do_fsync *
*===========================================================================*/ *===========================================================================*/
int do_fsync() int do_fsync(message *UNUSED(m_out))
{ {
/* Perform the fsync() system call. */ /* Perform the fsync() system call. */
struct filp *rfilp; struct filp *rfilp;
@ -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 */);
} }
@ -573,7 +579,7 @@ int ruid;
/*===========================================================================* /*===========================================================================*
* do_svrctl * * do_svrctl *
*===========================================================================*/ *===========================================================================*/
int do_svrctl() int do_svrctl(message *UNUSED(m_out))
{ {
unsigned int svrctl; unsigned int svrctl;
vir_bytes ptr; vir_bytes ptr;

View File

@ -86,7 +86,7 @@ static void update_bspec(dev_t dev, endpoint_t fs_e, int send_drv_e)
/*===========================================================================* /*===========================================================================*
* do_fsready * * do_fsready *
*===========================================================================*/ *===========================================================================*/
int do_fsready() int do_fsready(message *UNUSED(m_out))
{ {
/* deprecated */ /* deprecated */
return(SUSPEND); return(SUSPEND);
@ -95,7 +95,7 @@ int do_fsready()
/*===========================================================================* /*===========================================================================*
* do_mount * * do_mount *
*===========================================================================*/ *===========================================================================*/
int do_mount() int do_mount(message *UNUSED(m_out))
{ {
/* Perform the mount(name, mfile, mount_flags) system call. */ /* Perform the mount(name, mfile, mount_flags) system call. */
endpoint_t fs_e; endpoint_t fs_e;
@ -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

@ -40,7 +40,7 @@ static int pipe_open(struct vnode *vp, mode_t bits, int oflags);
/*===========================================================================* /*===========================================================================*
* do_open * * do_open *
*===========================================================================*/ *===========================================================================*/
int do_open() int do_open(message *UNUSED(m_out))
{ {
/* Perform the open(name, flags,...) system call. /* Perform the open(name, flags,...) system call.
* syscall might provide 'name' embedded in message when not creating file */ * 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 * * do_mknod *
*===========================================================================*/ *===========================================================================*/
int do_mknod() int do_mknod(message *UNUSED(m_out))
{ {
/* Perform the mknod(name, mode, addr) system call. */ /* Perform the mknod(name, mode, addr) system call. */
register mode_t bits, mode_bits; register mode_t bits, mode_bits;
@ -548,7 +548,7 @@ int do_mknod()
/*===========================================================================* /*===========================================================================*
* do_mkdir * * do_mkdir *
*===========================================================================*/ *===========================================================================*/
int do_mkdir() int do_mkdir(message *UNUSED(m_out))
{ {
/* Perform the mkdir(name, mode) system call. */ /* Perform the mkdir(name, mode) system call. */
mode_t bits; /* mode bits for the new inode */ mode_t bits; /* mode bits for the new inode */
@ -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;
@ -707,7 +707,7 @@ int do_llseek()
/*===========================================================================* /*===========================================================================*
* do_close * * do_close *
*===========================================================================*/ *===========================================================================*/
int do_close() int do_close(message *UNUSED(m_out))
{ {
/* Perform the close(fd) system call. */ /* Perform the close(fd) system call. */

View File

@ -870,7 +870,7 @@ size_t pathlen;
/*===========================================================================* /*===========================================================================*
* do_check_perms * * 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, 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

@ -23,7 +23,7 @@
/*===========================================================================* /*===========================================================================*
* do_chmod * * do_chmod *
*===========================================================================*/ *===========================================================================*/
int do_chmod() int do_chmod(message *UNUSED(m_out))
{ {
/* Perform the chmod(name, mode) and fchmod(fd, mode) system calls. /* Perform the chmod(name, mode) and fchmod(fd, mode) system calls.
* syscall might provide 'name' embedded in the message. * syscall might provide 'name' embedded in the message.
@ -99,7 +99,7 @@ int do_chmod()
/*===========================================================================* /*===========================================================================*
* do_chown * * do_chown *
*===========================================================================*/ *===========================================================================*/
int do_chown() int do_chown(message *UNUSED(m_out))
{ {
/* Perform the chown(path, owner, group) and fchmod(fd, owner, group) system /* Perform the chown(path, owner, group) and fchmod(fd, owner, group) system
* calls. */ * calls. */
@ -181,7 +181,7 @@ int do_chown()
/*===========================================================================* /*===========================================================================*
* do_umask * * do_umask *
*===========================================================================*/ *===========================================================================*/
int do_umask() int do_umask(message *UNUSED(m_out))
{ {
/* Perform the umask(co_mode) system call. */ /* Perform the umask(co_mode) system call. */
mode_t complement, new_umask; mode_t complement, new_umask;
@ -197,7 +197,7 @@ int do_umask()
/*===========================================================================* /*===========================================================================*
* do_access * * do_access *
*===========================================================================*/ *===========================================================================*/
int do_access() int do_access(message *UNUSED(m_out))
{ {
/* Perform the access(name, mode) system call. /* Perform the access(name, mode) system call.
* syscall might provide 'name' embedded in the message. * syscall might provide 'name' embedded in the message.

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,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); 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 *);
int do_utimens(void); int do_utimens(message *);
/* tll.c */ /* tll.c */
void tll_downgrade(tll_t *tllp); void tll_downgrade(tll_t *tllp);
@ -299,7 +300,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);
@ -336,7 +337,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);
@ -345,7 +346,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

@ -29,7 +29,7 @@
/*===========================================================================* /*===========================================================================*
* do_read * * do_read *
*===========================================================================*/ *===========================================================================*/
int do_read() int do_read(message *UNUSED(m_out))
{ {
return(do_read_write_peek(READING, job_m_in.fd, return(do_read_write_peek(READING, job_m_in.fd,
job_m_in.buffer, (size_t) job_m_in.nbytes)); 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 * * do_getdents *
*===========================================================================*/ *===========================================================================*/
int do_getdents() int do_getdents(message *UNUSED(m_out))
{ {
/* Perform the getdents(fd, buf, size) system call. */ /* Perform the getdents(fd, buf, size) system call. */
int r = OK; int r = OK;

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(message *UNUSED(m_out))
{ {
/* 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

@ -32,7 +32,7 @@ static int change_into(struct vnode **iip, struct vnode *vp);
/*===========================================================================* /*===========================================================================*
* do_fchdir * * do_fchdir *
*===========================================================================*/ *===========================================================================*/
int do_fchdir() int do_fchdir(message *UNUSED(m_out))
{ {
/* Change directory on already-opened fd. */ /* Change directory on already-opened fd. */
struct filp *rfilp; struct filp *rfilp;
@ -50,7 +50,7 @@ int do_fchdir()
/*===========================================================================* /*===========================================================================*
* do_chdir * * do_chdir *
*===========================================================================*/ *===========================================================================*/
int do_chdir() int do_chdir(message *UNUSED(m_out))
{ {
/* Perform the chdir(name) system call. /* Perform the chdir(name) system call.
* syscall might provide 'name' embedded in the message. * syscall might provide 'name' embedded in the message.
@ -91,7 +91,7 @@ int do_chdir()
/*===========================================================================* /*===========================================================================*
* do_chroot * * do_chroot *
*===========================================================================*/ *===========================================================================*/
int do_chroot() int do_chroot(message *UNUSED(m_out))
{ {
/* Perform the chroot(name) system call. /* Perform the chroot(name) system call.
* syscall might provide 'name' embedded in the message. * syscall might provide 'name' embedded in the message.
@ -156,7 +156,7 @@ static int change_into(struct vnode **result, struct vnode *vp)
/*===========================================================================* /*===========================================================================*
* do_stat * * do_stat *
*===========================================================================*/ *===========================================================================*/
int do_stat() int do_stat(message *UNUSED(m_out))
{ {
/* Perform the stat(name, buf) system call. */ /* Perform the stat(name, buf) system call. */
int r; int r;
@ -189,7 +189,7 @@ int do_stat()
/*===========================================================================* /*===========================================================================*
* do_fstat * * do_fstat *
*===========================================================================*/ *===========================================================================*/
int do_fstat() int do_fstat(message *UNUSED(m_out))
{ {
/* Perform the fstat(fd, buf) system call. */ /* Perform the fstat(fd, buf) system call. */
register struct filp *rfilp; register struct filp *rfilp;
@ -213,7 +213,7 @@ int do_fstat()
/*===========================================================================* /*===========================================================================*
* do_fstatfs * * do_fstatfs *
*===========================================================================*/ *===========================================================================*/
int do_fstatfs() int do_fstatfs(message *UNUSED(m_out))
{ {
/* Perform the fstatfs(fd, buf) system call. */ /* Perform the fstatfs(fd, buf) system call. */
struct filp *rfilp; struct filp *rfilp;
@ -236,7 +236,7 @@ int do_fstatfs()
/*===========================================================================* /*===========================================================================*
* do_statvfs * * do_statvfs *
*===========================================================================*/ *===========================================================================*/
int do_statvfs() int do_statvfs(message *UNUSED(m_out))
{ {
/* Perform the stat(name, buf) system call. */ /* Perform the stat(name, buf) system call. */
int r; int r;
@ -269,7 +269,7 @@ int do_statvfs()
/*===========================================================================* /*===========================================================================*
* do_fstatvfs * * do_fstatvfs *
*===========================================================================*/ *===========================================================================*/
int do_fstatvfs() int do_fstatvfs(message *UNUSED(m_out))
{ {
/* Perform the fstat(fd, buf) system call. */ /* Perform the fstat(fd, buf) system call. */
register struct filp *rfilp; register struct filp *rfilp;
@ -291,7 +291,7 @@ int do_fstatvfs()
/*===========================================================================* /*===========================================================================*
* do_lstat * * do_lstat *
*===========================================================================*/ *===========================================================================*/
int do_lstat() int do_lstat(message *UNUSED(m_out))
{ {
/* Perform the lstat(name, buf) system call. */ /* Perform the lstat(name, buf) system call. */
struct vnode *vp; struct vnode *vp;

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 */

View File

@ -9,6 +9,7 @@
#include <minix/callnr.h> #include <minix/callnr.h>
#include <minix/com.h> #include <minix/com.h>
#include <time.h> #include <time.h>
#include <string.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include "file.h" #include "file.h"
@ -25,7 +26,7 @@
/*===========================================================================* /*===========================================================================*
* do_utime * * do_utime *
*===========================================================================*/ *===========================================================================*/
int do_utime(void) int do_utime(message *UNUSED(m_out))
{ {
/* Perform the utime(name, timep) system call. */ /* Perform the utime(name, timep) system call. */
int r; int r;
@ -83,7 +84,7 @@ int do_utime(void)
/*===========================================================================* /*===========================================================================*
* do_utimens * * do_utimens *
*===========================================================================*/ *===========================================================================*/
int do_utimens(void) int do_utimens(message *UNUSED(m_out))
{ {
/* Perform the utimens(name, times, flag) system call, and its friends. /* Perform the utimens(name, times, flag) system call, and its friends.
* Implement a very large but not complete subset of the utimensat() * Implement a very large but not complete subset of the utimensat()
@ -108,6 +109,8 @@ int do_utimens(void)
vir_bytes vname; vir_bytes vname;
size_t vname_length; size_t vname_length;
memset(&now, 0, sizeof(now));
/* The case times==NULL is handled by the caller, replaced with UTIME_NOW */ /* The case times==NULL is handled by the caller, replaced with UTIME_NOW */
actim.tv_sec = job_m_in.utime_actime; actim.tv_sec = job_m_in.utime_actime;
actim.tv_nsec = job_m_in.utimens_ansec; actim.tv_nsec = job_m_in.utimens_ansec;

View File

@ -97,7 +97,7 @@ int fetch_name(vir_bytes path, size_t len, char *dest)
/*===========================================================================* /*===========================================================================*
* no_sys * * no_sys *
*===========================================================================*/ *===========================================================================*/
int no_sys() int no_sys(message *UNUSED(m_out))
{ {
/* Somebody has used an illegal system call number */ /* Somebody has used an illegal system call number */
return(ENOSYS); return(ENOSYS);

View File

@ -13,7 +13,7 @@
/*===========================================================================* /*===========================================================================*
* do_write * * do_write *
*===========================================================================*/ *===========================================================================*/
int do_write() int do_write(message *UNUSED(m_out))
{ {
/* Perform the write(fd, buffer, nbytes) system call. */ /* Perform the write(fd, buffer, nbytes) system call. */
return(do_read_write_peek(WRITING, job_m_in.fd, return(do_read_write_peek(WRITING, job_m_in.fd,