From 24ec0d73b579fa9d134ae21dec2ad75019bf2ec0 Mon Sep 17 00:00:00 2001 From: David van Moolenbroek Date: Mon, 4 Nov 2013 22:48:08 +0100 Subject: [PATCH] Clean up interface to PM and VFS - introduce new call numbers, names, and field aliases; - initialize request messages to zero for all ABI calls; - format callnr.h in the same way as com.h; - redo call tables in both servers; - remove param.h namespace pollution in the servers; - make brk(2) go to VM directly, rather than through PM; - remove obsolete BRK, UTIME, and WAIT calls; - clean up path copying routine in VFS; - move remaining system calls from libminlib to libc; - correct some errno-related mistakes in libc routines. Change-Id: I2d8ec5d061cd7e0b30c51ffd77aa72ebf84e2565 --- commands/readclock/readclock.c | 2 + commands/service/parse.c | 1 - commands/service/service.c | 1 + etc/system.conf | 1 - include/minix/callnr.h | 511 ++++++++++++++++----- include/minix/com.h | 168 ++----- include/minix/syslib.h | 3 + include/minix/vm.h | 1 - kernel/extract-mtype.sh | 4 +- lib/libc/gen/minix/utime.c | 28 -- lib/libc/gen/minix/wait.c | 8 +- lib/libc/gen/minix/waitpid.c | 10 +- lib/libc/sys-minix/Makefile.inc | 6 +- lib/libc/sys-minix/_exit.c | 6 +- lib/libc/sys-minix/_mcontext.c | 11 +- lib/libc/sys-minix/access.c | 6 +- lib/libc/sys-minix/adjtime.c | 12 +- lib/libc/sys-minix/brk.c | 9 +- lib/libc/sys-minix/chdir.c | 9 +- lib/libc/sys-minix/chmod.c | 6 +- lib/libc/sys-minix/chown.c | 11 +- lib/libc/sys-minix/chroot.c | 4 +- lib/libc/sys-minix/clock_getres.c | 10 +- lib/libc/sys-minix/clock_gettime.c | 10 +- lib/libc/sys-minix/clock_settime.c | 12 +- lib/libc/sys-minix/close.c | 6 +- lib/libc/sys-minix/cprofile.c | 4 +- lib/libc/sys-minix/execve.c | 12 +- lib/libc/sys-minix/fchmod.c | 8 +- lib/libc/sys-minix/fchown.c | 9 +- lib/libc/sys-minix/fcntl.c | 14 +- lib/libc/sys-minix/fork.c | 6 +- lib/libc/sys-minix/fstatvfs.c | 10 +- lib/libc/sys-minix/fsync.c | 6 +- lib/libc/sys-minix/ftruncate.c | 9 +- lib/libc/sys-minix/futimens.c | 18 +- lib/libc/sys-minix/futimes.c | 22 +- lib/libc/sys-minix/gcov_flush.c | 19 + lib/libc/sys-minix/getdents.c | 10 +- lib/libc/sys-minix/getegid.c | 8 +- lib/libc/sys-minix/geteuid.c | 8 +- lib/libc/sys-minix/getgid.c | 6 +- lib/libc/sys-minix/getgroups.c | 9 +- lib/libc/sys-minix/getitimer.c | 10 +- lib/libc/sys-minix/getpgrp.c | 6 +- lib/libc/sys-minix/getpid.c | 6 +- lib/libc/sys-minix/getppid.c | 8 +- lib/libc/sys-minix/getrusage.c | 13 +- lib/libc/sys-minix/gettimeofday.c | 9 +- lib/libc/sys-minix/getuid.c | 6 +- lib/libc/sys-minix/getvfsstat.c | 6 +- lib/libc/sys-minix/ioctl.c | 3 +- lib/libc/sys-minix/issetugid.c | 7 +- lib/libc/sys-minix/kill.c | 10 +- lib/libc/sys-minix/link.c | 11 +- lib/libc/sys-minix/loadname.c | 7 +- lib/libc/sys-minix/lseek.c | 17 +- lib/libc/sys-minix/lseek64.c | 14 +- lib/libc/sys-minix/lutimes.c | 31 +- lib/libc/sys-minix/minix_rs.c | 2 +- lib/libc/sys-minix/mkdir.c | 8 +- lib/libc/sys-minix/mknod.c | 12 +- lib/libc/sys-minix/mmap.c | 7 + lib/libc/sys-minix/mount.c | 6 +- lib/libc/sys-minix/nanosleep.c | 12 +- lib/libc/sys-minix/open.c | 22 +- lib/libc/sys-minix/pipe.c | 23 +- lib/libc/sys-minix/priority.c | 16 +- lib/libc/sys-minix/ptrace.c | 16 +- lib/libc/sys-minix/read.c | 10 +- lib/libc/sys-minix/readlink.c | 11 +- lib/libc/sys-minix/reboot.c | 10 +- lib/libc/sys-minix/rename.c | 11 +- lib/libc/sys-minix/rmdir.c | 4 +- lib/libc/sys-minix/select.c | 14 +- lib/libc/sys-minix/sem.c | 4 + lib/libc/sys-minix/setgid.c | 12 +- lib/libc/sys-minix/setgroups.c | 11 +- lib/libc/sys-minix/setitimer.c | 15 +- lib/libc/sys-minix/setsid.c | 6 +- lib/libc/sys-minix/setuid.c | 11 +- lib/libc/sys-minix/shmat.c | 3 + lib/libc/sys-minix/shmctl.c | 2 + lib/libc/sys-minix/shmget.c | 3 +- lib/libc/sys-minix/sigaction.c | 13 +- lib/libc/sys-minix/sigpending.c | 6 +- lib/libc/sys-minix/sigprocmask.c | 14 +- lib/libc/sys-minix/sigreturn.c | 9 +- lib/libc/sys-minix/sigsuspend.c | 6 +- lib/libc/sys-minix/sprofile.c | 4 +- lib/libc/sys-minix/stat.c | 25 +- lib/libc/sys-minix/statvfs.c | 3 +- lib/libc/sys-minix/stime.c | 6 +- lib/{libminlib => libc/sys-minix}/svrctl.c | 6 +- lib/libc/sys-minix/symlink.c | 11 +- lib/libc/sys-minix/sync.c | 7 +- lib/libc/sys-minix/sysuname.c | 16 +- lib/libc/sys-minix/truncate.c | 11 +- lib/libc/sys-minix/umask.c | 6 +- lib/libc/sys-minix/unlink.c | 4 +- lib/libc/sys-minix/utimensat.c | 41 +- lib/libc/sys-minix/utimes.c | 31 +- lib/libc/sys-minix/vfork.c | 6 +- lib/libc/sys-minix/write.c | 10 +- lib/libexec/exec_general.c | 9 +- lib/libminlib/Makefile | 3 - lib/libminlib/gcov.c | 16 - lib/libsys/Makefile | 1 - lib/libsys/copyfd.c | 2 +- lib/libsys/getepinfo.c | 2 +- lib/libsys/getprocnr.c | 2 +- lib/libsys/mapdriver.c | 2 +- lib/libsys/sef.c | 5 +- lib/libsys/srv_fork.c | 6 +- lib/libsys/srv_kill.c | 6 +- lib/libsys/vm_brk.c | 20 - servers/pm/Makefile | 2 +- servers/pm/alarm.c | 32 +- servers/pm/break.c | 20 - servers/pm/exec.c | 32 +- servers/pm/forkexit.c | 49 +- servers/pm/getset.c | 70 +-- servers/pm/glo.h | 2 +- servers/pm/main.c | 53 +-- servers/pm/mcontext.c | 5 +- servers/pm/misc.c | 58 +-- servers/pm/mproc.h | 6 +- servers/pm/param.h | 53 --- servers/pm/profile.c | 1 - servers/pm/proto.h | 9 +- servers/pm/signal.c | 76 +-- servers/pm/table.c | 183 ++------ servers/pm/time.c | 27 +- servers/pm/trace.c | 62 +-- servers/pm/utility.c | 12 - servers/rs/exec.c | 11 +- servers/vfs/README | 8 +- servers/vfs/coredump.c | 1 - servers/vfs/device.c | 3 +- servers/vfs/dmap.c | 3 +- servers/vfs/exec.c | 6 +- servers/vfs/filedes.c | 2 +- servers/vfs/glo.h | 2 +- servers/vfs/link.c | 58 ++- servers/vfs/lock.c | 1 - servers/vfs/main.c | 65 ++- servers/vfs/misc.c | 23 +- servers/vfs/mount.c | 11 - servers/vfs/open.c | 108 ++--- servers/vfs/param.h | 57 --- servers/vfs/path.c | 5 +- servers/vfs/pipe.c | 44 +- servers/vfs/protect.c | 72 ++- servers/vfs/proto.h | 15 +- servers/vfs/read.c | 11 +- servers/vfs/select.c | 12 +- servers/vfs/stadir.c | 51 +- servers/vfs/table.c | 184 +++----- servers/vfs/time.c | 82 +--- servers/vfs/utility.c | 54 +-- servers/vfs/write.c | 7 +- servers/vm/break.c | 4 +- servers/vm/vfs.c | 1 + test/test5.c | 2 +- 164 files changed, 1625 insertions(+), 1788 deletions(-) delete mode 100644 lib/libc/gen/minix/utime.c create mode 100644 lib/libc/sys-minix/gcov_flush.c rename lib/{libminlib => libc/sys-minix}/svrctl.c (84%) delete mode 100644 lib/libsys/vm_brk.c delete mode 100644 servers/pm/break.c delete mode 100644 servers/pm/param.h delete mode 100644 servers/vfs/param.h diff --git a/commands/readclock/readclock.c b/commands/readclock/readclock.c index a71c64679..07741e3c8 100644 --- a/commands/readclock/readclock.c +++ b/commands/readclock/readclock.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -146,6 +147,7 @@ readclock(int type, struct tm *t, int flags) exit(1); } + memset(&m, 0, sizeof(m)); m.RTCDEV_TM = (char *) t; m.RTCDEV_FLAGS = flags; diff --git a/commands/service/parse.c b/commands/service/parse.c index e00911afc..08ccd3fe1 100644 --- a/commands/service/parse.c +++ b/commands/service/parse.c @@ -727,7 +727,6 @@ struct { { "EXIT", VM_EXIT }, { "FORK", VM_FORK }, - { "BRK", VM_BRK }, { "EXEC_NEWMEM", VM_EXEC_NEWMEM }, { "PUSH_SIG", 0 }, { "WILLEXIT", VM_WILLEXIT }, diff --git a/commands/service/service.c b/commands/service/service.c index afd5b72df..cdfc86cda 100644 --- a/commands/service/service.c +++ b/commands/service/service.c @@ -416,6 +416,7 @@ int main(int argc, char **argv) * should end up here. The default is used for not yet supported requests. */ result = OK; + memset(&m, 0, sizeof(m)); switch(request) { case RS_UPDATE: m.RS_LU_STATE = req_lu_state; diff --git a/etc/system.conf b/etc/system.conf index 841c32c51..8b248ff53 100644 --- a/etc/system.conf +++ b/etc/system.conf @@ -57,7 +57,6 @@ service pm vm # Extra VM calls allowed: EXIT # 00 FORK # 01 - BRK # 02 EXEC_NEWMEM # 03 WILLEXIT # 05 NOTIFY_SIG # 39 diff --git a/include/minix/callnr.h b/include/minix/callnr.h index 32c5c3a34..7da48ab56 100644 --- a/include/minix/callnr.h +++ b/include/minix/callnr.h @@ -1,116 +1,395 @@ -#define NCALLS 129 /* number of system calls allowed */ - -/* In case it isn't obvious enough: this list is sorted numerically. */ -#define EXIT 1 -#define FORK 2 -#define READ 3 -#define WRITE 4 -#define OPEN 5 -#define CLOSE 6 -#define WAIT 7 -#define LINK 9 -#define UNLINK 10 -#define WAITPID 11 -#define CHDIR 12 -#define TIME 13 -#define MKNOD 14 -#define CHMOD 15 -#define CHOWN 16 -#define BRK 17 -#define MINIX_GETPID 20 -#define MOUNT 21 -#define UMOUNT 22 -#define SETUID 23 -#define GETUID 24 -#define STIME 25 -#define PTRACE 26 -#define UTIME 30 -#define GETEPINFO 31 -#define SETGROUPS 32 -#define ACCESS 33 -#define GETGROUPS 34 -#define SYNC 36 -#define KILL 37 -#define RENAME 38 -#define MKDIR 39 -#define RMDIR 40 -#define PIPE 42 -#define SYMLINK 45 -#define SETGID 46 -#define GETGID 47 -#define SIGNAL 48 -#define RDLNK 49 -#define STAT 51 -#define FSTAT 52 -#define LSTAT 53 -#define IOCTL 54 -#define COPYFD 56 -#define FS_READY 57 -#define PIPE2 58 -#define EXEC 59 -#define UMASK 60 -#define CHROOT 61 -#define SETSID 62 -#define GETPGRP 63 -#define ITIMER 64 -#define GETMCONTEXT 67 -#define SETMCONTEXT 68 -#define GETDENTS 69 -#define FTRUNCATE 70 - -/* Posix signal handling. */ -#define SIGACTION 71 -#define SIGSUSPEND 72 -#define SIGPENDING 73 -#define SIGPROCMASK 74 -#define SIGRETURN 75 - -#define REBOOT 76 -#define PM_SVRCTL 77 /* to PM */ -#define SYSUNAME 78 -#define LLSEEK 81 /* to VFS */ -#define GETVFSSTAT 82 /* to VFS */ -#define STATVFS1 83 /* to VFS */ -#define FSTATVFS1 84 /* to VFS */ -#define SELECT 85 /* to VFS */ -#define FCHDIR 86 /* to VFS */ -#define FSYNC 87 /* to VFS */ -#define GETPRIORITY 88 /* to PM */ -#define SETPRIORITY 89 /* to PM */ -#define GETTIMEOFDAY 90 /* to PM */ -#define SETEUID 91 /* to PM */ -#define SETEGID 92 /* to PM */ -#define FCHMOD 95 /* to VFS */ -#define FCHOWN 96 /* to VFS */ -#define LSEEK 97 -#define SPROF 98 /* to PM */ -#define CPROF 99 /* to PM */ - -#define PM_NEWEXEC 100 /* from VFS or RS to PM: new exec */ -#define SRV_FORK 101 /* to PM: special fork call for RS */ -#define EXEC_RESTART 102 /* to PM: final part of exec for RS */ -#define GETPROCNR 104 /* to PM */ -#define ISSETUGID 106 /* to PM: ask if process is tainted */ -#define UTIMENS 108 /* to FS: [f]utimens(); also [fl]utimes */ -#define FCNTL 109 /* to VFS */ -#define TRUNCATE 110 /* to VFS */ -#define SRV_KILL 111 /* to PM: special kill call for RS */ - -#define GCOV_FLUSH 112 /* flush gcov data from server to gcov files */ - -#define PM_GETSID 113 /* PM getsid() */ -#define CLOCK_GETRES 114 /* clock_getres() */ -#define CLOCK_GETTIME 115 /* clock_gettime() */ -#define CLOCK_SETTIME 116 /* clock_settime() */ - -#define VFS_VMCALL 117 - -#define MAPDRIVER 122 /* to VFS, map a device */ -#define PM_GETRUSAGE 123 /* to PM */ - -#define VFS_CHECKPERMS 124 /* to VFS */ - -#define PM_GETSYSINFO 125 /* to PM */ -#define VFS_GETSYSINFO 126 /* to VFS */ -#define VFS_GETRUSAGE 127 /* to VFS */ -#define VFS_SVRCTL 128 /* to VFS */ +/* This header file defines the calls to PM and VFS. */ +#ifndef _MINIX_CALLNR_H +#define _MINIX_CALLNR_H + +/*===========================================================================* + * Calls to PM * + *===========================================================================*/ + +#define PM_BASE 0x000 + +#define IS_PM_CALL(type) (((type) & ~0xff) == PM_BASE) + +/* Message type 0 is traditionally reserved. */ +#define PM_EXIT (PM_BASE + 1) +#define PM_FORK (PM_BASE + 2) +#define PM_WAITPID (PM_BASE + 3) +#define PM_GETPID (PM_BASE + 4) +#define PM_SETUID (PM_BASE + 5) +#define PM_GETUID (PM_BASE + 6) +#define PM_STIME (PM_BASE + 7) +#define PM_PTRACE (PM_BASE + 8) +#define PM_SETGROUPS (PM_BASE + 9) +#define PM_GETGROUPS (PM_BASE + 10) +#define PM_KILL (PM_BASE + 11) +#define PM_SETGID (PM_BASE + 12) +#define PM_GETGID (PM_BASE + 13) +#define PM_EXEC (PM_BASE + 14) +#define PM_SETSID (PM_BASE + 15) +#define PM_GETPGRP (PM_BASE + 16) +#define PM_ITIMER (PM_BASE + 17) +#define PM_GETMCONTEXT (PM_BASE + 18) +#define PM_SETMCONTEXT (PM_BASE + 19) +#define PM_SIGACTION (PM_BASE + 20) +#define PM_SIGSUSPEND (PM_BASE + 21) +#define PM_SIGPENDING (PM_BASE + 22) +#define PM_SIGPROCMASK (PM_BASE + 23) +#define PM_SIGRETURN (PM_BASE + 24) +#define PM_SYSUNAME (PM_BASE + 25) +#define PM_GETPRIORITY (PM_BASE + 26) +#define PM_SETPRIORITY (PM_BASE + 27) +#define PM_GETTIMEOFDAY (PM_BASE + 28) +#define PM_SETEUID (PM_BASE + 29) +#define PM_SETEGID (PM_BASE + 30) +#define PM_ISSETUGID (PM_BASE + 31) +#define PM_GETSID (PM_BASE + 32) +#define PM_CLOCK_GETRES (PM_BASE + 33) +#define PM_CLOCK_GETTIME (PM_BASE + 34) +#define PM_CLOCK_SETTIME (PM_BASE + 35) +#define PM_GETRUSAGE (PM_BASE + 36) +#define PM_REBOOT (PM_BASE + 37) +#define PM_SVRCTL (PM_BASE + 38) +#define PM_SPROF (PM_BASE + 39) +#define PM_CPROF (PM_BASE + 40) +#define PM_SRV_FORK (PM_BASE + 41) +#define PM_SRV_KILL (PM_BASE + 42) +#define PM_EXEC_NEW (PM_BASE + 43) +#define PM_EXEC_RESTART (PM_BASE + 44) +#define PM_GETEPINFO (PM_BASE + 45) +#define PM_GETPROCNR (PM_BASE + 46) +#define PM_GETSYSINFO (PM_BASE + 47) + +#define NR_PM_CALLS 48 /* highest number from base plus one */ + +/* Field names for the getprocnr(2) call. */ +#define PM_GETPROCNR_PID m1_i1 /* pid_t */ +#define PM_GETPROCNR_ENDPT m1_i1 /* endpoint_t */ + +/* Field names for the getepinfo(2) call. */ +#define PM_GETEPINFO_ENDPT m1_i1 /* endpoint_t */ +#define PM_GETEPINFO_UID m1_i1 /* uid_t */ +#define PM_GETEPINFO_GID m1_i2 /* gid_t */ + +/* Field names for the exit(2) call. */ +#define PM_EXIT_STATUS m1_i1 /* int */ + +/* Field names for the waitpid(2) call. */ +#define PM_WAITPID_PID m1_i1 /* pid_t */ +#define PM_WAITPID_OPTIONS m1_i2 /* int */ +#define PM_WAITPID_STATUS m2_i1 /* int */ + +/* Field names for the gettimeofday(2), clock_*(2), adjtime(2), stime(2) calls. + */ +#define PM_TIME_CLK_ID m2_i1 /* clockid_t */ +#define PM_TIME_NOW m2_i2 /* int */ +#define PM_TIME_SEC m2_l1 /* time_t */ +#define PM_TIME_USEC m2_l2 /* long */ +#define PM_TIME_NSEC m2_l2 /* long */ + +/* Field names for the ptrace(2) call. */ +#define PM_PTRACE_PID m2_i1 /* pid_t */ +#define PM_PTRACE_REQ m2_i2 /* int */ +#define PM_PTRACE_ADDR m2_l1 /* long */ +#define PM_PTRACE_DATA m2_l2 /* long */ + +/* Field names for the sysuname(2) call. */ +#define PM_SYSUNAME_REQ m1_i1 /* int */ +#define PM_SYSUNAME_FIELD m1_i2 /* int */ +#define PM_SYSUNAME_LEN m1_i3 /* char * */ +#define PM_SYSUNAME_VALUE m1_p1 /* size_t */ + +/* Field names for the getitimer(2)/setitimer(2) calls. */ +#define PM_ITIMER_WHICH m1_i1 /* int */ +#define PM_ITIMER_VALUE m1_p1 /* const struct itimerval * */ +#define PM_ITIMER_OVALUE m1_p2 /* struct itimerval * */ + +/* Field names for the execve(2) call. */ +#define PM_EXEC_NAME m1_p1 /* const char * */ +#define PM_EXEC_NAMELEN m1_i1 /* size_t */ +#define PM_EXEC_FRAME m1_p2 /* char * */ +#define PM_EXEC_FRAMELEN m1_i2 /* size_t */ +#define PM_EXEC_PS_STR m1_p3 /* char * */ + +/* Field names for the kill(2), srv_kill(2), and sigaction(2) calls. */ +#define PM_SIG_PID m1_i1 /* pid_t */ +#define PM_SIG_NR m1_i2 /* int */ +#define PM_SIG_ACT m1_p1 /* const struct sigaction * */ +#define PM_SIG_OACT m1_p2 /* struct sigaction * */ +#define PM_SIG_RET m1_p3 /* int (*)(void) */ + +/* Field names for the remaining sigpending(2), sigprocmask(2), sigreturn(2), + * sigsuspend(2) calls. + */ +#define PM_SIG_HOW m2_i1 /* int */ +#define PM_SIG_SET m2_l1 /* sigset_t */ +#define PM_SIG_CTX m2_p1 /* struct sigcontext * */ + +/* Field names for the srv_fork(2) call. */ +#define PM_SRV_FORK_UID m1_i1 /* uid_t */ +#define PM_SRV_FORK_GID m1_i2 /* gid_t */ + +/* Field names for the getuid(2) call. */ +#define PM_GETUID_EUID m1_i1 /* uid_t */ + +/* Field names for the getgid(2) call. */ +#define PM_GETGID_EGID m1_i1 /* gid_t */ + +/* Field names for the setuid(2)/seteuid(2) calls. */ +#define PM_SETUID_UID m1_i1 /* uid_t */ + +/* Field names for the setgid(2)/setegid(2) calls. */ +#define PM_SETGID_GID m1_i1 /* gid_t */ + +/* Field names for the getppid(2) call. */ +#define PM_GETPID_PARENT m2_i1 /* pid_t */ + +/* Field names for the setsid(2) call. */ +#define PM_GETSID_PID m1_i1 /* pid_t */ + +/* Field names for the setgroups(2)/setgroups(2) calls. */ +#define PM_GROUPS_NUM m1_i1 /* int */ +#define PM_GROUPS_PTR m1_p1 /* gid_t * */ + +/* Field names for the getpriority(2)/setpriority(2) calls. */ +#define PM_PRIORITY_WHICH m1_i1 /* int */ +#define PM_PRIORITY_WHO m1_i2 /* int */ +#define PM_PRIORITY_PRIO m1_i3 /* int */ + +/* Field names for the getmcontext(2)/setmcontext(2) calls. */ +#define PM_MCONTEXT_CTX m1_p1 /* mcontext_t * */ + +/* Field names for the reboot(2) call. */ +#define PM_REBOOT_HOW m1_i1 /* int */ + +/* Field names for the PM_EXEC_NEW call. */ +#define PM_EXEC_NEW_ENDPT m1_i1 /* endpoint_t */ +#define PM_EXEC_NEW_PTR m1_p1 /* struct exec_info * */ +#define PM_EXEC_NEW_SUID m1_i2 /* int */ + +/* Field names for the PM_EXEC_RESTART call. */ +#define PM_EXEC_RESTART_ENDPT m1_i1 /* endpoint_t */ +#define PM_EXEC_RESTART_RESULT m1_i2 /* int */ +#define PM_EXEC_RESTART_PC m1_p1 /* vir_bytes */ +#define PM_EXEC_RESTART_PS_STR m1_p2 /* vir_bytes */ + +/*===========================================================================* + * Calls to VFS * + *===========================================================================*/ + +#define VFS_BASE 0x100 + +#define IS_VFS_CALL(type) (((type) & ~0xff) == VFS_BASE) + +#define VFS_READ (VFS_BASE + 0) +#define VFS_WRITE (VFS_BASE + 1) +#define VFS_LSEEK (VFS_BASE + 2) +#define VFS_OPEN (VFS_BASE + 3) +#define VFS_CREAT (VFS_BASE + 4) +#define VFS_CLOSE (VFS_BASE + 5) +#define VFS_LINK (VFS_BASE + 6) +#define VFS_UNLINK (VFS_BASE + 7) +#define VFS_CHDIR (VFS_BASE + 8) +#define VFS_MKDIR (VFS_BASE + 9) +#define VFS_MKNOD (VFS_BASE + 10) +#define VFS_CHMOD (VFS_BASE + 11) +#define VFS_CHOWN (VFS_BASE + 12) +#define VFS_MOUNT (VFS_BASE + 13) +#define VFS_UMOUNT (VFS_BASE + 14) +#define VFS_ACCESS (VFS_BASE + 15) +#define VFS_SYNC (VFS_BASE + 16) +#define VFS_RENAME (VFS_BASE + 17) +#define VFS_RMDIR (VFS_BASE + 18) +#define VFS_SYMLINK (VFS_BASE + 19) +#define VFS_READLINK (VFS_BASE + 20) +#define VFS_STAT (VFS_BASE + 21) +#define VFS_FSTAT (VFS_BASE + 22) +#define VFS_LSTAT (VFS_BASE + 23) +#define VFS_IOCTL (VFS_BASE + 24) +#define VFS_FCNTL (VFS_BASE + 25) +#define VFS_PIPE2 (VFS_BASE + 26) +#define VFS_UMASK (VFS_BASE + 27) +#define VFS_CHROOT (VFS_BASE + 28) +#define VFS_GETDENTS (VFS_BASE + 29) +#define VFS_SELECT (VFS_BASE + 30) +#define VFS_FCHDIR (VFS_BASE + 31) +#define VFS_FSYNC (VFS_BASE + 32) +#define VFS_TRUNCATE (VFS_BASE + 33) +#define VFS_FTRUNCATE (VFS_BASE + 34) +#define VFS_FCHMOD (VFS_BASE + 35) +#define VFS_FCHOWN (VFS_BASE + 36) +#define VFS_UTIMENS (VFS_BASE + 37) +#define VFS_VMCALL (VFS_BASE + 38) +#define VFS_GETVFSSTAT (VFS_BASE + 39) +#define VFS_STATVFS1 (VFS_BASE + 40) +#define VFS_FSTATVFS1 (VFS_BASE + 41) +#define VFS_GETRUSAGE (VFS_BASE + 42) +#define VFS_SVRCTL (VFS_BASE + 43) +#define VFS_GCOV_FLUSH (VFS_BASE + 44) +#define VFS_MAPDRIVER (VFS_BASE + 45) +#define VFS_COPYFD (VFS_BASE + 46) +#define VFS_CHECKPERMS (VFS_BASE + 47) +#define VFS_GETSYSINFO (VFS_BASE + 48) + +#define NR_VFS_CALLS 49 /* highest number from base plus one */ + +/* Field names for the select(2) call. */ +#define VFS_SELECT_NFDS m8_i1 /* int */ +#define VFS_SELECT_READFDS m8_p1 /* fd_set * */ +#define VFS_SELECT_WRITEFDS m8_p2 /* fd_set * */ +#define VFS_SELECT_ERRORFDS m8_p3 /* fd_set * */ +#define VFS_SELECT_TIMEOUT m8_p4 /* struct timeval * */ + +/* Field names for the getvfsstat(2) call. */ +#define VFS_GETVFSSTAT_BUF m1_p1 /* struct statvfs * */ +#define VFS_GETVFSSTAT_LEN m1_i1 /* size_t */ +#define VFS_GETVFSSTAT_FLAGS m1_i2 /* int */ + +/* Field names for the statvfs1(2) and fstatvfs1(2) calls. */ +#define VFS_STATVFS1_LEN m1_i1 /* size_t */ +#define VFS_STATVFS1_NAME m1_p1 /* const char * */ +#define VFS_STATVFS1_FD m1_i1 /* int */ +#define VFS_STATVFS1_BUF m1_p2 /* struct statvfs * */ +#define VFS_STATVFS1_FLAGS m1_i2 /* int */ + +/* Field names for the mount(2) call. */ +#define VFS_MOUNT_FLAGS m11_i1 /* int */ +#define VFS_MOUNT_DEVLEN m11_s1 /* size_t */ +#define VFS_MOUNT_PATHLEN m11_s2 /* size_t */ +#define VFS_MOUNT_TYPELEN m11_s3 /* size_t */ +#define VFS_MOUNT_LABELLEN m11_s4 /* size_t */ +#define VFS_MOUNT_DEV m11_p1 /* char * */ +#define VFS_MOUNT_PATH m11_p2 /* char * */ +#define VFS_MOUNT_TYPE m11_p3 /* char * */ +#define VFS_MOUNT_LABEL m11_p4 /* char * */ + +/* Field names for the umount(2) call. */ +#define VFS_UMOUNT_NAME m1_p1 /* char * */ +#define VFS_UMOUNT_NAMELEN m1_i1 /* size_t */ +#define VFS_UMOUNT_LABEL m1_p2 /* char * */ +#define VFS_UMOUNT_LABELLEN m1_i2 /* size_t */ + +/* Field names for the ioctl(2) call. */ +#define VFS_IOCTL_FD m2_i1 /* int */ +#define VFS_IOCTL_REQ m2_i3 /* unsigned long */ +#define VFS_IOCTL_ARG m2_p1 /* void * */ + +/* Field names for the checkperms(2) call. */ +#define VFS_CHECKPERMS_ENDPT m2_i1 /* endpoint_t */ +#define VFS_CHECKPERMS_GRANT m2_i2 /* cp_grant_id_t */ +#define VFS_CHECKPERMS_COUNT m2_i3 /* size_t */ + +/* Field names for the copyfd(2) call. */ +#define VFS_COPYFD_ENDPT m1_i1 /* endpoint_t */ +#define VFS_COPYFD_FD m1_i2 /* int */ +#define VFS_COPYFD_WHAT m1_i3 /* int */ + +/* Field names for the mapdriver(2) call. */ +#define VFS_MAPDRIVER_MAJOR m1_i1 /* devmajor_t */ +#define VFS_MAPDRIVER_LABELLEN m1_i2 /* size_t */ +#define VFS_MAPDRIVER_LABEL m1_p1 /* char * */ + +/* Field names for the utimens(2) call. */ +#define VFS_UTIMENS_FD m2_i1 /* int */ +#define VFS_UTIMENS_NAME m2_p1 /* const char * */ +#define VFS_UTIMENS_LEN m2_i1 /* size_t */ +#define VFS_UTIMENS_ATIME m2_l1 /* time_t */ +#define VFS_UTIMENS_ANSEC m2_i2 /* long */ +#define VFS_UTIMENS_MTIME m2_l2 /* time_t */ +#define VFS_UTIMENS_MNSEC m2_i3 /* long */ +#define VFS_UTIMENS_FLAGS m2_s1 /* int */ + +/* Field names for the fsync(2) call. */ +#define VFS_FSYNC_FD m1_i1 /* int */ + +/* Field names for the lseek(2) call. */ +#define VFS_LSEEK_FD m2_i1 /* int */ +#define VFS_LSEEK_OFF_LO m2_l1 /* off_t (low 32 bits) */ +#define VFS_LSEEK_OFF_HI m2_l2 /* off_t (high 32 bits) */ +#define VFS_LSEEK_WHENCE m2_i2 /* int */ + +/* Field names for the truncate(2) and ftruncate(2) calls. */ +#define VFS_TRUNCATE_FD m2_i1 /* int */ +#define VFS_TRUNCATE_NAME m2_p1 /* const char * */ +#define VFS_TRUNCATE_LEN m2_i1 /* size_t */ +#define VFS_TRUNCATE_OFF_LO m2_l1 /* off_t (low 32 bits) */ +#define VFS_TRUNCATE_OFF_HI m2_l2 /* off_t (high 32 bits) */ + +/* Field names for the pipe2(2) call. */ +#define VFS_PIPE2_FD0 m1_i1 /* int */ +#define VFS_PIPE2_FD1 m1_i2 /* int */ +#define VFS_PIPE2_FLAGS m1_i3 /* int */ + +/* Field names for the umask(2) call. */ +#define VFS_UMASK_MASK m1_i1 /* mode_t */ + +/* Field names for the link(2), symlink(2), and rename(2) call. */ +#define VFS_LINK_NAME1 m1_p1 /* const char * */ +#define VFS_LINK_LEN1 m1_i1 /* size_t */ +#define VFS_LINK_NAME2 m1_p2 /* const char * */ +#define VFS_LINK_LEN2 m1_i2 /* size_t */ + +/* Field names for the readlink(2) call. */ +#define VFS_READLINK_NAME m1_p1 /* const char * */ +#define VFS_READLINK_NAMELEN m1_i1 /* size_t */ +#define VFS_READLINK_BUF m1_p2 /* char * */ +#define VFS_READLINK_BUFSIZE m1_i2 /* size_t */ + +/* Field names for the stat(2) and lstat(2) calls. */ +#define VFS_STAT_NAME m1_p1 /* const char * */ +#define VFS_STAT_LEN m1_i1 /* size_t */ +#define VFS_STAT_BUF m1_p2 /* struct stat * */ + +/* Field names for the fstat(2) call. */ +#define VFS_FSTAT_FD m1_i1 /* int */ +#define VFS_FSTAT_BUF m1_p1 /* struct stat * */ + +/* Field names for the fcntl(2) call. */ +#define VFS_FCNTL_FD m1_i1 /* int */ +#define VFS_FCNTL_CMD m1_i2 /* int */ +#define VFS_FCNTL_ARG_INT m1_i3 /* int */ +#define VFS_FCNTL_ARG_PTR m1_p1 /* struct flock * */ + +/* Field names for the mknod(2) call. */ +#define VFS_MKNOD_NAME m1_p1 /* const char * */ +#define VFS_MKNOD_LEN m1_i1 /* size_t */ +#define VFS_MKNOD_MODE m1_i2 /* mode_t */ +#define VFS_MKNOD_DEV m1_i3 /* dev_t */ + +/* Field names for the open(2), chdir(2), chmod(2), chroot(2), rmdir(2), and + * unlink(2) calls. + */ +#define VFS_PATH_NAME m3_p1 /* const char * */ +#define VFS_PATH_LEN m3_i1 /* size_t */ +#define VFS_PATH_FLAGS m3_i2 /* int */ +#define VFS_PATH_MODE m3_i2 /* mode_t */ +#define VFS_PATH_BUF m3_ca1 /* char[M3_STRING] */ + +/* Field names for the creat(2) call. */ +#define VFS_CREAT_NAME m1_p1 /* const char * */ +#define VFS_CREAT_LEN m1_i1 /* size_t */ +#define VFS_CREAT_FLAGS m1_i2 /* int */ +#define VFS_CREAT_MODE m1_i3 /* mode_t */ + +/* Field names for the chown(2) and fchown(2) calls. */ +#define VFS_CHOWN_NAME m1_p1 /* const char * */ +#define VFS_CHOWN_LEN m1_i1 /* size_t */ +#define VFS_CHOWN_FD m1_i1 /* int */ +#define VFS_CHOWN_OWNER m1_i2 /* uid_t */ +#define VFS_CHOWN_GROUP m1_i3 /* gid_t */ + +/* Field names for the fchdir(2) call. */ +#define VFS_FCHDIR_FD m1_i1 /* int */ + +/* Field names for the fchmod(2) call. */ +#define VFS_FCHMOD_FD m1_i1 /* int */ +#define VFS_FCHMOD_MODE m1_i2 /* mode_t */ + +/* Field names for the close(2) call. */ +#define VFS_CLOSE_FD m1_i1 /* int */ + +/* Field names for the read(2), write(2), and getdents(2) calls. */ +#define VFS_READWRITE_FD m1_i1 /* int */ +#define VFS_READWRITE_BUF m1_p1 /* char * */ +#define VFS_READWRITE_LEN m1_i2 /* size_t */ + +#endif /* !_MINIX_CALLNR_H */ diff --git a/include/minix/com.h b/include/minix/com.h index 12a404908..79c1fac7f 100644 --- a/include/minix/com.h +++ b/include/minix/com.h @@ -5,29 +5,29 @@ * debugging purposes, each protocol is assigned its own unique number range. * The following such message type ranges have been allocated: * - * 1 - 0xFF POSIX requests (see callnr.h) + * 0x00 - 0xFF Process Manager (PM) requests (see callnr.h) + * 0x100 - 0x1FF Virtual File System (VFS) requests (see callnr.h) * 0x200 - 0x2FF Data link layer requests and responses * 0x300 - 0x3FF Bus controller requests and responses * 0x400 - 0x4FF Character device requests and responses * 0x500 - 0x5FF Block device requests and responses - * 0x600 - 0x6FF Kernel calls to SYSTEM task + * 0x600 - 0x6FF Kernel calls * 0x700 - 0x7FF Reincarnation Server (RS) requests * 0x800 - 0x8FF Data Store (DS) requests * 0x900 - 0x9FF Requests from PM to VFS, and responses * 0xA00 - 0xAFF Requests from VFS to file systems (see vfsif.h) - * 0xB00 - 0xBFF Requests from VM to VFS + * 0xB00 - 0xBFF Transaction IDs from VFS to file systems (see vfsif.h) * 0xC00 - 0xCFF Virtual Memory (VM) requests * 0xD00 - 0xDFF IPC server requests * 0xE00 - 0xEFF Common system messages (e.g. system signals) - * 0xF00 - 0xFFF Scheduling messages + * 0xF00 - 0xFFF Scheduling messages * 0x1000 - 0x10FF Notify messages * 0x1100 - 0x11FF USB - * 0x1200 - 0x12FF Devman + * 0x1200 - 0x12FF Devman * 0x1300 - 0x13FF TTY requests - * 0x1400 - 0x14FF VFS-FS transaction IDs + * 0x1400 - 0x14FF Real Time Clock requests and responses * 0x1500 - 0x15FF Input server messages * 0x1600 - 0x16FF VirtualBox (VBOX) requests (see vboxif.h) - * 0x1700 - 0x17FF Real Time Clock requests and responses * * Zero and negative values are widely used for OK and error responses. */ @@ -493,9 +493,7 @@ #define PR_FORK_MSGADDR m1_p1 /* reply message address of forked child */ #define PR_CTX_PTR m1_p1 /* pointer to mcontext_t structure */ -/* Field names for EXEC sent from userland to PM. */ -#define PMEXEC_FLAGS m1_i3 /* PMEF_* */ - +/* Constants for exec. FIXME: these do not belong here. */ #define PMEF_AUXVECTORS 20 #define PMEF_EXECNAMELEN1 PATH_MAX @@ -756,7 +754,6 @@ */ # define VFS_PM_FRAME m7_p2 /* arguments and environment */ # define VFS_PM_FRAME_LEN m7_i3 /* size of frame */ -# define VFS_PM_EXECFLAGS m7_i4 /* PMEXEC_FLAGS */ # define VFS_PM_PS_STR m7_i5 /* ps_strings pointer */ /* Additional parameters for PM_EXEC_REPLY and PM_CORE_REPLY */ @@ -774,29 +771,6 @@ /* Additional parameters for PM_DUMPCORE */ # define VFS_PM_TERM_SIG m7_i2 /* process's termination signal */ -/* Parameters for the EXEC_NEWMEM call */ -#define EXC_NM_PROC m1_i1 /* process that needs new map */ -#define EXC_NM_PTR m1_p1 /* parameters in struct exec_info */ -/* Results: - * the status will be in m_type. - * the top of the stack will be in m1_i1. - * the following flags will be in m1_i2: - */ -#define EXC_NM_RF_LOAD_TEXT 1 /* Load text segment (otherwise the - * text segment is already present) - */ -#define EXC_NM_RF_ALLOW_SETUID 2 /* Setuid execution is allowed (tells - * FS to update its uid and gid - * fields. - */ -#define EXC_NM_RF_FULLVM 4 - -/* Parameters for the EXEC_RESTART call */ -#define EXC_RS_PROC m1_i1 /* process that needs to be restarted */ -#define EXC_RS_RESULT m1_i2 /* result of the exec */ -#define EXC_RS_PC m1_p1 /* program counter */ -#define EXC_RS_PS_STR m1_p2 /* ps_strings pointer */ - /*===========================================================================* * Messages used from VFS to file servers * *===========================================================================*/ @@ -822,103 +796,6 @@ # define GCOV_BUFF_P m1_p1 # define GCOV_BUFF_SZ m1_i1 -/* Field names for the getsysinfo(2) call. */ -#define SI_WHAT m1_i1 -#define SI_WHERE m1_p1 -#define SI_SIZE m1_i2 - -/* PM field names */ -/* BRK */ -#define PMBRK_ADDR m1_p1 - -/* TRACE */ -#define PMTRACE_ADDR m2_l1 - -#define PM_ENDPT m1_i1 -#define PM_PENDPT m1_i2 - -#define PM_NUID m2_i1 -#define PM_NGID m2_i2 - -#define PM_GETSID_PID m1_i1 - -/* Field names for SELECT (FS). */ -#define SEL_NFDS m8_i1 -#define SEL_READFDS m8_p1 -#define SEL_WRITEFDS m8_p2 -#define SEL_ERRORFDS m8_p3 -#define SEL_TIMEOUT m8_p4 - -/* Field names for the getvfsstat(2) call. */ -#define VFS_GETVFSSTAT_BUF m1_p1 -#define VFS_GETVFSSTAT_SIZE m1_i1 -#define VFS_GETVFSSTAT_FLAGS m1_i2 - -/* Field names for the fstatvfs1(2) call. */ -#define VFS_FSTATVFS1_FD m1_i1 -#define VFS_FSTATVFS1_BUF m1_p1 -#define VFS_FSTATVFS1_FLAGS m1_i2 - -/* Field names for the statvfs1(2) call. */ -#define VFS_STATVFS1_LEN m1_i1 -#define VFS_STATVFS1_NAME m1_p1 -#define VFS_STATVFS1_BUF m1_p2 -#define VFS_STATVFS1_FLAGS m1_i2 - -/* Field names for the mount(2) call. */ -#define VFS_MOUNT_FLAGS m11_i1 -#define VFS_MOUNT_DEVLEN m11_s1 -#define VFS_MOUNT_PATHLEN m11_s2 -#define VFS_MOUNT_TYPELEN m11_s3 -#define VFS_MOUNT_LABELLEN m11_s4 -#define VFS_MOUNT_DEV m11_p1 -#define VFS_MOUNT_PATH m11_p2 -#define VFS_MOUNT_TYPE m11_p3 -#define VFS_MOUNT_LABEL m11_p4 - -/* Field names for the umount(2) call. */ -#define VFS_UMOUNT_NAME m1_p1 -#define VFS_UMOUNT_NAMELEN m1_i1 -#define VFS_UMOUNT_LABEL m1_p2 -#define VFS_UMOUNT_LABELLEN m1_i2 - -/* Field names for the ioctl(2) call. */ -#define VFS_IOCTL_FD m2_i1 -#define VFS_IOCTL_REQ m2_i3 -#define VFS_IOCTL_ARG m2_p1 - -/* Field names for the checkperms(2) call. */ -#define VFS_CHECKPERMS_ENDPT m2_i1 -#define VFS_CHECKPERMS_GRANT m2_i2 -#define VFS_CHECKPERMS_COUNT m2_i3 - -/* Field names for the copyfd(2) call. */ -#define VFS_COPYFD_ENDPT m1_i1 -#define VFS_COPYFD_FD m1_i2 -#define VFS_COPYFD_WHAT m1_i3 -# define COPYFD_FROM 0 /* copy file descriptor from remote process */ -# define COPYFD_TO 1 /* copy file descriptor to remote process */ -# define COPYFD_CLOSE 2 /* close file descriptor in remote process */ - -/* Field names for the getprocnr(2) call. */ -#define PM_GETPROCNR_PID m1_i1 -#define PM_GETPROCNR_ENDPT m1_i1 - -/* Field names for the getepinfo(2) call. */ -#define PM_GETEPINFO_ENDPT m1_i1 -#define PM_GETEPINFO_UID m1_i1 -#define PM_GETEPINFO_GID m1_i2 - -/* Field names for the mapdriver(2) call. */ -#define VFS_MAPDRIVER_MAJOR m1_i1 -#define VFS_MAPDRIVER_LABELLEN m1_i2 -#define VFS_MAPDRIVER_LABEL m1_p1 - -/* Field names for GETRUSAGE related calls */ -#define RU_ENDPT m1_i1 /* indicates a process for sys_getrusage */ -#define RU_WHO m1_i1 /* who argument in getrusage call */ -#define RU_RUSAGE_ADDR m1_p1 /* pointer to struct rusage */ - /*===========================================================================* * Messages for VM server * *===========================================================================*/ @@ -932,9 +809,7 @@ # define VMF_SLOTNO m1_i2 # define VMF_CHILD_ENDPOINT m1_i3 /* result */ #define VM_BRK (VM_RQ_BASE+2) -# define VMB_ENDPOINT m1_i1 # define VMB_ADDR m1_p1 -# define VMB_RETADDR m1_p2 /* result */ #define VM_EXEC_NEWMEM (VM_RQ_BASE+3) # define VMEN_ENDPOINT m1_i1 # define VMEN_ARGSPTR m1_p1 @@ -1117,7 +992,8 @@ /* Basic vm calls allowed to every process. */ #define VM_BASIC_CALLS \ - VM_MMAP, VM_MUNMAP, VM_MAP_PHYS, VM_UNMAP_PHYS, VM_INFO, VM_GETRUSAGE + VM_BRK, VM_MMAP, VM_MUNMAP, VM_MAP_PHYS, VM_UNMAP_PHYS, VM_INFO, \ + VM_GETRUSAGE /*===========================================================================* * Messages for IPC server * @@ -1297,7 +1173,7 @@ * VFS-FS TRANSACTION IDs * *===========================================================================*/ -#define VFS_TRANSACTION_BASE 0x1400 +#define VFS_TRANSACTION_BASE 0xB00 #define VFS_TRANSID (VFS_TRANSACTION_BASE + 1) #define IS_VFS_FS_TRANSID(type) (((type) & ~0xff) == VFS_TRANSACTION_BASE) @@ -1410,8 +1286,8 @@ *===========================================================================*/ /* Base type for real time clock requests and responses. */ -#define RTCDEV_RQ_BASE 0x1700 -#define RTCDEV_RS_BASE 0x1780 +#define RTCDEV_RQ_BASE 0x1400 +#define RTCDEV_RS_BASE 0x1480 #define IS_RTCDEV_RQ(type) (((type) & ~0x7f) == RTCDEV_RQ_BASE) #define IS_RTCDEV_RS(type) (((type) & ~0x7f) == RTCDEV_RS_BASE) @@ -1439,6 +1315,24 @@ #define RTCDEV_Y2KBUG 0x01 /* Interpret 1980 as 2000 for RTC w/Y2K bug */ #define RTCDEV_CMOSREG 0x02 /* Also set the CMOS clock register bits. */ +/*===========================================================================* + * Field names shared across several call codes * + *===========================================================================*/ + +/* Field names for the getsysinfo(2) call. */ +#define SI_WHAT m1_i1 /* int */ +#define SI_WHERE m1_p1 /* void */ +#define SI_SIZE m1_i2 /* size_t */ + +/* Field names for the svrctl(2) call. */ +#define SVRCTL_REQ m2_i1 /* int */ +#define SVRCTL_ARG m2_p1 /* void * */ + +/* Field names for the getrusage(2) call. */ +#define RU_ENDPT m1_i1 /* endpoint_t */ +#define RU_WHO m1_i1 /* int */ +#define RU_RUSAGE_ADDR m1_p1 /* struct rusage * */ + /*===========================================================================* * Internal codes used by several services * *===========================================================================*/ diff --git a/include/minix/syslib.h b/include/minix/syslib.h index 37c2911a9..f2c004051 100644 --- a/include/minix/syslib.h +++ b/include/minix/syslib.h @@ -270,6 +270,9 @@ uid_t getnuid(endpoint_t proc_ep); gid_t getngid(endpoint_t proc_ep); int checkperms(endpoint_t endpt, char *path, size_t size); int copyfd(endpoint_t endpt, int fd, int what); +#define COPYFD_FROM 0 /* copy file descriptor from remote process */ +#define COPYFD_TO 1 /* copy file descriptor to remote process */ +#define COPYFD_CLOSE 2 /* close file descriptor in remote process */ #endif /* _SYSLIB_H */ diff --git a/include/minix/vm.h b/include/minix/vm.h index f41cbf002..63bca2b81 100644 --- a/include/minix/vm.h +++ b/include/minix/vm.h @@ -8,7 +8,6 @@ int vm_exit(endpoint_t ep); int vm_fork(endpoint_t ep, int slotno, endpoint_t *child_ep); -int vm_brk(endpoint_t ep, char *newaddr); int vm_willexit(endpoint_t ep); int vm_adddma(endpoint_t proc_e, phys_bytes start, phys_bytes size); int vm_deldma(endpoint_t proc_e, phys_bytes start, phys_bytes size); diff --git a/kernel/extract-mtype.sh b/kernel/extract-mtype.sh index 3322ad83c..259821624 100644 --- a/kernel/extract-mtype.sh +++ b/kernel/extract-mtype.sh @@ -7,8 +7,8 @@ set -e cat ../include/minix/callnr.h | \ tr -s ' \t' ' ' | \ sed 's/^# /#/' | \ - egrep '^#define [A-Z_][A-Z0-9_]* [0-9]+' | grep -v NCALLS - + egrep '^#define [A-Z_][A-Z0-9_]* \((PM|VFS)_BASE \+ *[0-9]+\)' + cat ../include/minix/com.h | \ tr -s ' \t' ' ' | \ sed 's/^# /#/' | \ diff --git a/lib/libc/gen/minix/utime.c b/lib/libc/gen/minix/utime.c deleted file mode 100644 index ab91a0000..000000000 --- a/lib/libc/gen/minix/utime.c +++ /dev/null @@ -1,28 +0,0 @@ -/* utime(2) for POSIX Authors: Terrence W. Holm & Edwin L. Froese */ - -#include -#include "namespace.h" -#include - -#include -#include - -int utime(const char *name, const struct utimbuf *timp) -{ - message m; - - if (timp == NULL) { - m.m2_i1 = 0; /* name size 0 means NULL `timp' */ - m.m2_i2 = strlen(name) + 1; /* actual size here */ - } else { - m.m2_l1 = timp->actime; - m.m2_l2 = timp->modtime; - m.m2_i1 = strlen(name) + 1; - } - m.m2_p1 = (char *) __UNCONST(name); - return(_syscall(VFS_PROC_NR, UTIME, &m)); -} - -#if defined(__minix) && defined(__weak_alias) -__weak_alias(utime, __utime50) -#endif diff --git a/lib/libc/gen/minix/wait.c b/lib/libc/gen/minix/wait.c index faf12a328..3217c7d79 100644 --- a/lib/libc/gen/minix/wait.c +++ b/lib/libc/gen/minix/wait.c @@ -2,6 +2,7 @@ #include #include "namespace.h" +#include #include #ifdef __weak_alias @@ -12,7 +13,10 @@ pid_t wait(int * status) { message m; - if (_syscall(PM_PROC_NR, WAIT, &m) < 0) return(-1); - if (status != 0) *status = m.m2_i1; + memset(&m, 0, sizeof(m)); + m.PM_WAITPID_PID = -1; + m.PM_WAITPID_OPTIONS = 0; + if (_syscall(PM_PROC_NR, PM_WAITPID, &m) < 0) return(-1); + if (status != 0) *status = m.PM_WAITPID_STATUS; return(m.m_type); } diff --git a/lib/libc/gen/minix/waitpid.c b/lib/libc/gen/minix/waitpid.c index cd214f8de..20500477f 100644 --- a/lib/libc/gen/minix/waitpid.c +++ b/lib/libc/gen/minix/waitpid.c @@ -2,6 +2,7 @@ #include #include "namespace.h" +#include #include #ifdef __weak_alias @@ -12,9 +13,10 @@ pid_t waitpid(pid_t pid, int *status, int options) { message m; - m.m1_i1 = pid; - m.m1_i2 = options; - if (_syscall(PM_PROC_NR, WAITPID, &m) < 0) return(-1); - if (status != 0) *status = m.m2_i1; + memset(&m, 0, sizeof(m)); + m.PM_WAITPID_PID = pid; + m.PM_WAITPID_OPTIONS = options; + if (_syscall(PM_PROC_NR, PM_WAITPID, &m) < 0) return(-1); + if (status != 0) *status = m.PM_WAITPID_STATUS; return m.m_type; } diff --git a/lib/libc/sys-minix/Makefile.inc b/lib/libc/sys-minix/Makefile.inc index 22c409420..26c48bbff 100644 --- a/lib/libc/sys-minix/Makefile.inc +++ b/lib/libc/sys-minix/Makefile.inc @@ -4,7 +4,8 @@ SRCS+= accept.c access.c adjtime.c bind.c brk.c sbrk.c m_closefrom.c getsid.c \ chdir.c chmod.c fchmod.c chown.c fchown.c chroot.c close.c \ clock_getres.c clock_gettime.c clock_settime.c \ connect.c dup.c dup2.c execve.c fcntl.c flock.c fpathconf.c fork.c \ - fstatfs.c fstatvfs.c fsync.c ftruncate.c getdents.c getegid.c getgid.c \ + fstatfs.c fstatvfs.c fsync.c ftruncate.c gcov_flush.c getdents.c \ + getegid.c getgid.c \ getgroups.c getitimer.c setitimer.c __getlogin.c getpeername.c \ getpgrp.c getpid.c getppid.c priority.c getrlimit.c getsockname.c \ getsockopt.c setsockopt.c gettimeofday.c geteuid.c getuid.c \ @@ -16,7 +17,8 @@ SRCS+= accept.c access.c adjtime.c bind.c brk.c sbrk.c m_closefrom.c getsid.c \ rmdir.c select.c sem.c sendmsg.c sendto.c setgroups.c setsid.c \ setgid.c settimeofday.c setuid.c shmat.c shmctl.c shmget.c stime.c \ vectorio.c shutdown.c sigaction.c sigpending.c sigreturn.c sigsuspend.c\ - sigprocmask.c socket.c socketpair.c stat.c statvfs.c symlink.c \ + sigprocmask.c socket.c socketpair.c stat.c statvfs.c svrctl.c \ + symlink.c \ sync.c syscall.c sysuname.c truncate.c umask.c unlink.c write.c \ utimensat.c utimes.c futimes.c lutimes.c futimens.c \ _exit.c _ucontext.c environ.c __getcwd.c vfork.c sizeup.c init.c \ diff --git a/lib/libc/sys-minix/_exit.c b/lib/libc/sys-minix/_exit.c index 3cd818d98..14b83b669 100644 --- a/lib/libc/sys-minix/_exit.c +++ b/lib/libc/sys-minix/_exit.c @@ -2,6 +2,7 @@ #include "namespace.h" #include +#include #include #ifdef __weak_alias @@ -14,8 +15,9 @@ int status; void (*suicide)(void); message m; - m.m1_i1 = status; - _syscall(PM_PROC_NR, EXIT, &m); + memset(&m, 0, sizeof(m)); + m.PM_EXIT_STATUS = status; + _syscall(PM_PROC_NR, PM_EXIT, &m); /* If exiting nicely through PM fails for some reason, try to * commit suicide. E.g., message to PM might fail due to deadlock. diff --git a/lib/libc/sys-minix/_mcontext.c b/lib/libc/sys-minix/_mcontext.c index 14502250c..b881e220a 100644 --- a/lib/libc/sys-minix/_mcontext.c +++ b/lib/libc/sys-minix/_mcontext.c @@ -5,6 +5,7 @@ #include #include +#include #include #include @@ -12,9 +13,10 @@ int setmcontext(const mcontext_t *mcp) { message m; - m.m1_p1 = (char *) __UNCONST(mcp); + memset(&m, 0, sizeof(m)); + m.PM_MCONTEXT_CTX = (char *) __UNCONST(mcp); - return(_syscall(PM_PROC_NR, SETMCONTEXT, &m)); + return(_syscall(PM_PROC_NR, PM_SETMCONTEXT, &m)); } @@ -22,8 +24,9 @@ int getmcontext(mcontext_t *mcp) { message m; - m.m1_p1 = (char *) mcp; + memset(&m, 0, sizeof(m)); + m.PM_MCONTEXT_CTX = (char *) mcp; - return(_syscall(PM_PROC_NR, GETMCONTEXT, &m)); + return(_syscall(PM_PROC_NR, PM_GETMCONTEXT, &m)); } diff --git a/lib/libc/sys-minix/access.c b/lib/libc/sys-minix/access.c index 1d3fd901a..0a2330a75 100644 --- a/lib/libc/sys-minix/access.c +++ b/lib/libc/sys-minix/access.c @@ -2,6 +2,7 @@ #include "namespace.h" #include +#include #include #ifdef __weak_alias @@ -14,7 +15,8 @@ int mode; { message m; - m.m3_i2 = mode; + memset(&m, 0, sizeof(m)); + m.VFS_PATH_MODE = mode; _loadname(name, &m); - return(_syscall(VFS_PROC_NR, ACCESS, &m)); + return(_syscall(VFS_PROC_NR, VFS_ACCESS, &m)); } diff --git a/lib/libc/sys-minix/adjtime.c b/lib/libc/sys-minix/adjtime.c index b38d8846d..fac50499f 100644 --- a/lib/libc/sys-minix/adjtime.c +++ b/lib/libc/sys-minix/adjtime.c @@ -2,6 +2,7 @@ #include #include "namespace.h" +#include #include #include @@ -13,12 +14,13 @@ int adjtime(const struct timeval *delta, struct timeval *olddelta) { message m; - m.m2_i2 = 0; /* use adjtime() method to slowly adjust the clock. */ - m.m2_i1 = (clockid_t) CLOCK_REALTIME; - m.m2_l1 = (time_t) delta->tv_sec; - m.m2_l2 = (long) delta->tv_usec * 1000; /* convert usec to nsec */ + memset(&m, 0, sizeof(m)); + m.PM_TIME_CLK_ID = (clockid_t) CLOCK_REALTIME; + m.PM_TIME_NOW = 0; /* use adjtime() method to slowly adjust the clock. */ + m.PM_TIME_SEC = (time_t) delta->tv_sec; + m.PM_TIME_NSEC = (long) delta->tv_usec * 1000; /* convert usec to nsec */ - if (_syscall(PM_PROC_NR, CLOCK_SETTIME, &m) < 0) + if (_syscall(PM_PROC_NR, PM_CLOCK_SETTIME, &m) < 0) return -1; if (olddelta != NULL) { diff --git a/lib/libc/sys-minix/brk.c b/lib/libc/sys-minix/brk.c index b4f76cdee..8b63978d9 100644 --- a/lib/libc/sys-minix/brk.c +++ b/lib/libc/sys-minix/brk.c @@ -2,6 +2,7 @@ #include "namespace.h" #include +#include #include #ifdef __weak_alias @@ -13,7 +14,6 @@ extern char *_brksize; /* Both OSF/1 and SYSVR4 man pages specify that brk(2) returns int. * However, BSD4.3 specifies that brk() returns char*. POSIX omits * brk() on the grounds that it imposes a memory model on an architecture. - * For this reason, brk() and sbrk() are not in the lib/posix directory. * On the other hand, they are so crucial to correct operation of so many * parts of the system, that we have chosen to hide the name brk using _brk, * as with system calls. In this way, if a user inadvertently defines a @@ -25,9 +25,10 @@ void *addr; message m; if (addr != _brksize) { - m.PMBRK_ADDR = addr; - if (_syscall(PM_PROC_NR, BRK, &m) < 0) return(-1); - _brksize = m.m2_p1; + memset(&m, 0, sizeof(m)); + m.VMB_ADDR = addr; + if (_syscall(VM_PROC_NR, VM_BRK, &m) < 0) return(-1); + _brksize = addr; } return(0); } diff --git a/lib/libc/sys-minix/chdir.c b/lib/libc/sys-minix/chdir.c index e514326ab..d01bed1b2 100644 --- a/lib/libc/sys-minix/chdir.c +++ b/lib/libc/sys-minix/chdir.c @@ -2,6 +2,7 @@ #include "namespace.h" #include +#include #include #ifdef __weak_alias @@ -14,8 +15,9 @@ const char *name; { message m; + memset(&m, 0, sizeof(m)); _loadname(name, &m); - return(_syscall(VFS_PROC_NR, CHDIR, &m)); + return(_syscall(VFS_PROC_NR, VFS_CHDIR, &m)); } int fchdir(fd) @@ -23,6 +25,7 @@ int fd; { message m; - m.m1_i1 = fd; - return(_syscall(VFS_PROC_NR, FCHDIR, &m)); + memset(&m, 0, sizeof(m)); + m.VFS_FCHDIR_FD = fd; + return(_syscall(VFS_PROC_NR, VFS_FCHDIR, &m)); } diff --git a/lib/libc/sys-minix/chmod.c b/lib/libc/sys-minix/chmod.c index e19979dd9..daa9b431e 100644 --- a/lib/libc/sys-minix/chmod.c +++ b/lib/libc/sys-minix/chmod.c @@ -2,6 +2,7 @@ #include "namespace.h" #include +#include #include #ifdef __weak_alias @@ -12,7 +13,8 @@ int chmod(const char *name, mode_t mode) { message m; - m.m3_i2 = mode; + memset(&m, 0, sizeof(m)); + m.VFS_PATH_MODE = mode; _loadname(name, &m); - return(_syscall(VFS_PROC_NR, CHMOD, &m)); + return(_syscall(VFS_PROC_NR, VFS_CHMOD, &m)); } diff --git a/lib/libc/sys-minix/chown.c b/lib/libc/sys-minix/chown.c index cbaf2b27a..f6d5517e5 100644 --- a/lib/libc/sys-minix/chown.c +++ b/lib/libc/sys-minix/chown.c @@ -13,9 +13,10 @@ int chown(const char *name, uid_t owner, gid_t grp) { message m; - m.m1_i1 = strlen(name) + 1; - m.m1_i2 = owner; - m.m1_i3 = grp; - m.m1_p1 = (char *) __UNCONST(name); - return(_syscall(VFS_PROC_NR, CHOWN, &m)); + memset(&m, 0, sizeof(m)); + m.VFS_CHOWN_LEN = strlen(name) + 1; + m.VFS_CHOWN_OWNER = owner; + m.VFS_CHOWN_GROUP = grp; + m.VFS_CHOWN_NAME = (char *) __UNCONST(name); + return(_syscall(VFS_PROC_NR, VFS_CHOWN, &m)); } diff --git a/lib/libc/sys-minix/chroot.c b/lib/libc/sys-minix/chroot.c index decd519b2..364a9e5e8 100644 --- a/lib/libc/sys-minix/chroot.c +++ b/lib/libc/sys-minix/chroot.c @@ -2,6 +2,7 @@ #include "namespace.h" #include +#include #include #ifdef __weak_alias @@ -13,6 +14,7 @@ const char *name; { message m; + memset(&m, 0, sizeof(m)); _loadname(name, &m); - return(_syscall(VFS_PROC_NR, CHROOT, &m)); + return(_syscall(VFS_PROC_NR, VFS_CHROOT, &m)); } diff --git a/lib/libc/sys-minix/clock_getres.c b/lib/libc/sys-minix/clock_getres.c index 3763305c6..41b45ac28 100644 --- a/lib/libc/sys-minix/clock_getres.c +++ b/lib/libc/sys-minix/clock_getres.c @@ -2,6 +2,7 @@ #include #include "namespace.h" +#include #include #ifdef __weak_alias @@ -12,13 +13,14 @@ int clock_getres(clockid_t clock_id, struct timespec *res) { message m; - m.m2_i1 = (clockid_t) clock_id; + memset(&m, 0, sizeof(m)); + m.PM_TIME_CLK_ID = (clockid_t) clock_id; - if (_syscall(PM_PROC_NR, CLOCK_GETRES, &m) < 0) + if (_syscall(PM_PROC_NR, PM_CLOCK_GETRES, &m) < 0) return -1; - res->tv_sec = (time_t) m.m2_l1; - res->tv_nsec = (long) m.m2_l2; + res->tv_sec = (time_t) m.PM_TIME_SEC; + res->tv_nsec = (long) m.PM_TIME_NSEC; return 0; } diff --git a/lib/libc/sys-minix/clock_gettime.c b/lib/libc/sys-minix/clock_gettime.c index 8ea6d34d0..9a3f98ca6 100644 --- a/lib/libc/sys-minix/clock_gettime.c +++ b/lib/libc/sys-minix/clock_gettime.c @@ -2,6 +2,7 @@ #include #include "namespace.h" +#include #include #ifdef __weak_alias @@ -12,13 +13,14 @@ int clock_gettime(clockid_t clock_id, struct timespec *res) { message m; - m.m2_i1 = (clockid_t) clock_id; + memset(&m, 0, sizeof(m)); + m.PM_TIME_CLK_ID = (clockid_t) clock_id; - if (_syscall(PM_PROC_NR, CLOCK_GETTIME, &m) < 0) + if (_syscall(PM_PROC_NR, PM_CLOCK_GETTIME, &m) < 0) return -1; - res->tv_sec = (time_t) m.m2_l1; - res->tv_nsec = (long) m.m2_l2; + res->tv_sec = (time_t) m.PM_TIME_SEC; + res->tv_nsec = (long) m.PM_TIME_USEC; return 0; } diff --git a/lib/libc/sys-minix/clock_settime.c b/lib/libc/sys-minix/clock_settime.c index d608ef66f..4e0e3a510 100644 --- a/lib/libc/sys-minix/clock_settime.c +++ b/lib/libc/sys-minix/clock_settime.c @@ -2,6 +2,7 @@ #include #include "namespace.h" +#include #include #ifdef __weak_alias @@ -12,12 +13,13 @@ int clock_settime(clockid_t clock_id, const struct timespec *ts) { message m; - m.m2_i2 = 1; /* set time immediately. don't use adjtime() method. */ - m.m2_i1 = (clockid_t) clock_id; - m.m2_l1 = (time_t) ts->tv_sec; - m.m2_l2 = (long) ts->tv_nsec; + memset(&m, 0, sizeof(m)); + m.PM_TIME_CLK_ID = (clockid_t) clock_id; + m.PM_TIME_NOW = 1; /* set time immediately. don't use adjtime() method. */ + m.PM_TIME_SEC = (time_t) ts->tv_sec; + m.PM_TIME_NSEC = (long) ts->tv_nsec; - if (_syscall(PM_PROC_NR, CLOCK_SETTIME, &m) < 0) + if (_syscall(PM_PROC_NR, PM_CLOCK_SETTIME, &m) < 0) return -1; return 0; diff --git a/lib/libc/sys-minix/close.c b/lib/libc/sys-minix/close.c index 587e5f1b4..efada4fe2 100644 --- a/lib/libc/sys-minix/close.c +++ b/lib/libc/sys-minix/close.c @@ -2,6 +2,7 @@ #include "namespace.h" #include +#include #include #ifdef __weak_alias @@ -13,6 +14,7 @@ int fd; { message m; - m.m1_i1 = fd; - return(_syscall(VFS_PROC_NR, CLOSE, &m)); + memset(&m, 0, sizeof(m)); + m.VFS_CLOSE_FD = fd; + return(_syscall(VFS_PROC_NR, VFS_CLOSE, &m)); } diff --git a/lib/libc/sys-minix/cprofile.c b/lib/libc/sys-minix/cprofile.c index a9bfd1189..7d569af1f 100644 --- a/lib/libc/sys-minix/cprofile.c +++ b/lib/libc/sys-minix/cprofile.c @@ -7,17 +7,19 @@ __weak_alias(cprofile, _cprofile) #endif #include +#include #include int cprofile(int action, int size, void *ctl_ptr, void *mem_ptr) { message m; + memset(&m, 0, sizeof(m)); m.PROF_ACTION = action; m.PROF_MEM_SIZE = size; m.PROF_CTL_PTR = (void *) ctl_ptr; m.PROF_MEM_PTR = (void *) mem_ptr; - return _syscall(PM_PROC_NR, CPROF, &m); + return _syscall(PM_PROC_NR, PM_CPROF, &m); } diff --git a/lib/libc/sys-minix/execve.c b/lib/libc/sys-minix/execve.c index 95ca5a9db..c2c682538 100644 --- a/lib/libc/sys-minix/execve.c +++ b/lib/libc/sys-minix/execve.c @@ -48,13 +48,13 @@ int execve(const char *path, char * const *argv, char * const *envp) memset(&m, 0, sizeof(m)); /* We can finally make the system call. */ - m.m1_i1 = strlen(path) + 1; - m.m1_i2 = frame_size; - m.m1_p1 = (char *) __UNCONST(path); - m.m1_p2 = frame; - m.m1_p4 = (char *)(vsp + ((char *)psp - frame)); + m.PM_EXEC_NAME = (char *) __UNCONST(path); + m.PM_EXEC_NAMELEN = strlen(path) + 1; + m.PM_EXEC_FRAME = frame; + m.PM_EXEC_FRAMELEN = frame_size; + m.PM_EXEC_PS_STR = (char *)(vsp + ((char *)psp - frame)); - (void) _syscall(PM_PROC_NR, EXEC, &m); + (void) _syscall(PM_PROC_NR, PM_EXEC, &m); /* Failure, return the memory used for the frame and exit. */ (void) sbrk(-frame_size); diff --git a/lib/libc/sys-minix/fchmod.c b/lib/libc/sys-minix/fchmod.c index 8a62a8bbf..e5ec121a7 100644 --- a/lib/libc/sys-minix/fchmod.c +++ b/lib/libc/sys-minix/fchmod.c @@ -2,6 +2,7 @@ #include "namespace.h" #include +#include #include #ifdef __weak_alias @@ -12,7 +13,8 @@ int fchmod(int fd, mode_t mode) { message m; - m.m1_i1 = fd; - m.m1_i2 = mode; - return(_syscall(VFS_PROC_NR, FCHMOD, &m)); + memset(&m, 0, sizeof(m)); + m.VFS_FCHMOD_FD = fd; + m.VFS_FCHMOD_MODE = mode; + return(_syscall(VFS_PROC_NR, VFS_FCHMOD, &m)); } diff --git a/lib/libc/sys-minix/fchown.c b/lib/libc/sys-minix/fchown.c index 6949df983..d3538562f 100644 --- a/lib/libc/sys-minix/fchown.c +++ b/lib/libc/sys-minix/fchown.c @@ -13,8 +13,9 @@ int fchown(int fd, uid_t owner, gid_t grp) { message m; - m.m1_i1 = fd; - m.m1_i2 = owner; - m.m1_i3 = grp; - return(_syscall(VFS_PROC_NR, FCHOWN, &m)); + memset(&m, 0, sizeof(m)); + m.VFS_CHOWN_FD = fd; + m.VFS_CHOWN_OWNER = owner; + m.VFS_CHOWN_GROUP = grp; + return(_syscall(VFS_PROC_NR, VFS_FCHOWN, &m)); } diff --git a/lib/libc/sys-minix/fcntl.c b/lib/libc/sys-minix/fcntl.c index 59c37a652..b664aa63d 100644 --- a/lib/libc/sys-minix/fcntl.c +++ b/lib/libc/sys-minix/fcntl.c @@ -2,6 +2,7 @@ #include "namespace.h" #include +#include #include #include @@ -19,27 +20,26 @@ int fcntl(int fd, int cmd, ...) /* Set up for the sensible case where there is no variable parameter. This * covers F_GETFD, F_GETFL and invalid commands. */ - m.m1_i3 = 0; - m.m1_p1 = NULL; + memset(&m, 0, sizeof(m)); /* Adjust for the stupid cases. */ switch(cmd) { case F_DUPFD: case F_SETFD: case F_SETFL: - m.m1_i3 = va_arg(argp, int); + m.VFS_FCNTL_ARG_INT = va_arg(argp, int); break; case F_GETLK: case F_SETLK: case F_SETLKW: case F_FREESP: - m.m1_p1 = (char *) va_arg(argp, struct flock *); + m.VFS_FCNTL_ARG_PTR = (char *) va_arg(argp, struct flock *); break; } /* Clean up and make the system call. */ va_end(argp); - m.m1_i1 = fd; - m.m1_i2 = cmd; - return(_syscall(VFS_PROC_NR, FCNTL, &m)); + m.VFS_FCNTL_FD = fd; + m.VFS_FCNTL_CMD = cmd; + return(_syscall(VFS_PROC_NR, VFS_FCNTL, &m)); } diff --git a/lib/libc/sys-minix/fork.c b/lib/libc/sys-minix/fork.c index 55b6bdc58..fab67c726 100644 --- a/lib/libc/sys-minix/fork.c +++ b/lib/libc/sys-minix/fork.c @@ -2,15 +2,17 @@ #include "namespace.h" #include +#include #include #ifdef __weak_alias __weak_alias(fork, _fork) #endif -pid_t fork() +pid_t fork(void) { message m; - return(_syscall(PM_PROC_NR, FORK, &m)); + memset(&m, 0, sizeof(m)); + return(_syscall(PM_PROC_NR, PM_FORK, &m)); } diff --git a/lib/libc/sys-minix/fstatvfs.c b/lib/libc/sys-minix/fstatvfs.c index c4bbb9e15..c15f32a8c 100644 --- a/lib/libc/sys-minix/fstatvfs.c +++ b/lib/libc/sys-minix/fstatvfs.c @@ -2,6 +2,7 @@ #include "namespace.h" #include +#include #include #ifdef __weak_alias @@ -13,10 +14,11 @@ int fstatvfs1(int fd, struct statvfs *buffer, int flags) { message m; - m.VFS_FSTATVFS1_FD = fd; - m.VFS_FSTATVFS1_BUF = (char *) buffer; - m.VFS_FSTATVFS1_FLAGS = flags; - return(_syscall(VFS_PROC_NR, FSTATVFS1, &m)); + memset(&m, 0, sizeof(m)); + m.VFS_STATVFS1_FD = fd; + m.VFS_STATVFS1_BUF = (char *) buffer; + m.VFS_STATVFS1_FLAGS = flags; + return(_syscall(VFS_PROC_NR, VFS_FSTATVFS1, &m)); } int fstatvfs(int fd, struct statvfs *buffer) diff --git a/lib/libc/sys-minix/fsync.c b/lib/libc/sys-minix/fsync.c index 15ef3feba..d35853f39 100644 --- a/lib/libc/sys-minix/fsync.c +++ b/lib/libc/sys-minix/fsync.c @@ -2,6 +2,7 @@ #include "namespace.h" #include +#include #include #ifdef __weak_alias @@ -12,7 +13,8 @@ int fsync(int fd) { message m; - m.m1_i1 = fd; + memset(&m, 0, sizeof(m)); + m.VFS_FSYNC_FD = fd; - return(_syscall(VFS_PROC_NR, FSYNC, &m)); + return(_syscall(VFS_PROC_NR, VFS_FSYNC, &m)); } diff --git a/lib/libc/sys-minix/ftruncate.c b/lib/libc/sys-minix/ftruncate.c index 937a3dcdb..9cb65e0c5 100644 --- a/lib/libc/sys-minix/ftruncate.c +++ b/lib/libc/sys-minix/ftruncate.c @@ -14,9 +14,10 @@ int ftruncate(int _fd, off_t _length) { message m; - m.m2_l1 = ex64lo(_length); - m.m2_l2 = ex64hi(_length); - m.m2_i1 = _fd; + memset(&m, 0, sizeof(m)); + m.VFS_TRUNCATE_OFF_LO = ex64lo(_length); + m.VFS_TRUNCATE_OFF_HI = ex64hi(_length); + m.VFS_TRUNCATE_FD = _fd; - return(_syscall(VFS_PROC_NR, FTRUNCATE, &m)); + return(_syscall(VFS_PROC_NR, VFS_FTRUNCATE, &m)); } diff --git a/lib/libc/sys-minix/futimens.c b/lib/libc/sys-minix/futimens.c index 4483260a8..08fdfe407 100644 --- a/lib/libc/sys-minix/futimens.c +++ b/lib/libc/sys-minix/futimens.c @@ -2,6 +2,7 @@ #include "namespace.h" #include +#include #include int futimens(int fd, const struct timespec tv[2]) @@ -11,13 +12,14 @@ int futimens(int fd, const struct timespec tv[2]) if (tv == NULL) tv = now; - m.m2_i1 = fd; - m.m2_l1 = tv[0].tv_sec; - m.m2_l2 = tv[1].tv_sec; - m.m2_i2 = tv[0].tv_nsec; - m.m2_i3 = tv[1].tv_nsec; - m.m2_p1 = NULL; - m.m2_s1 = 0; + memset(&m, 0, sizeof(m)); + m.VFS_UTIMENS_FD = fd; + m.VFS_UTIMENS_ATIME = tv[0].tv_sec; + m.VFS_UTIMENS_MTIME = tv[1].tv_sec; + m.VFS_UTIMENS_ANSEC = tv[0].tv_nsec; + m.VFS_UTIMENS_MNSEC = tv[1].tv_nsec; + m.VFS_UTIMENS_NAME = NULL; + m.VFS_UTIMENS_FLAGS = 0; - return(_syscall(VFS_PROC_NR, UTIMENS, &m)); + return(_syscall(VFS_PROC_NR, VFS_UTIMENS, &m)); } diff --git a/lib/libc/sys-minix/futimes.c b/lib/libc/sys-minix/futimes.c index 7d7d26e0c..c5c4e4070 100644 --- a/lib/libc/sys-minix/futimes.c +++ b/lib/libc/sys-minix/futimes.c @@ -2,6 +2,7 @@ #include "namespace.h" #include +#include #include #include @@ -13,19 +14,20 @@ int futimes(int fd, const struct timeval tv[2]) { message m; - m.m2_i1 = fd; + memset(&m, 0, sizeof(m)); + m.VFS_UTIMENS_FD = fd; if (tv == NULL) { - m.m2_l1 = m.m2_l2 = 0; - m.m2_i2 = m.m2_i3 = UTIME_NOW; + m.VFS_UTIMENS_ATIME = m.VFS_UTIMENS_MTIME = 0; + m.VFS_UTIMENS_ANSEC = m.VFS_UTIMENS_MNSEC = UTIME_NOW; } else { - m.m2_l1 = tv[0].tv_sec; - m.m2_l2 = tv[1].tv_sec; - m.m2_i2 = tv[0].tv_usec * 1000; - m.m2_i3 = tv[1].tv_usec * 1000; + m.VFS_UTIMENS_ATIME = tv[0].tv_sec; + m.VFS_UTIMENS_MTIME = tv[1].tv_sec; + m.VFS_UTIMENS_ANSEC = tv[0].tv_usec * 1000; + m.VFS_UTIMENS_MNSEC = tv[1].tv_usec * 1000; } - m.m2_p1 = NULL; - m.m2_s1 = 0; + m.VFS_UTIMENS_NAME = NULL; + m.VFS_UTIMENS_FLAGS = 0; - return(_syscall(VFS_PROC_NR, UTIMENS, &m)); + return(_syscall(VFS_PROC_NR, VFS_UTIMENS, &m)); } diff --git a/lib/libc/sys-minix/gcov_flush.c b/lib/libc/sys-minix/gcov_flush.c new file mode 100644 index 000000000..2f9058a9b --- /dev/null +++ b/lib/libc/sys-minix/gcov_flush.c @@ -0,0 +1,19 @@ +#include +#include +#include + +int gcov_flush_svr(char *buff, int buff_sz, int server_nr) +{ + message m; + + memset(&m, 0, sizeof(m)); + m.GCOV_BUFF_P = buff; + m.GCOV_BUFF_SZ = buff_sz; + m.GCOV_PID = server_nr; + + /* Make the call to server. It will call the gcov library, + * buffer the stdio requests, and copy the buffer to this user + * space + */ + return _syscall(VFS_PROC_NR, VFS_GCOV_FLUSH, &m); +} diff --git a/lib/libc/sys-minix/getdents.c b/lib/libc/sys-minix/getdents.c index ef17e5440..890a09bbd 100644 --- a/lib/libc/sys-minix/getdents.c +++ b/lib/libc/sys-minix/getdents.c @@ -2,16 +2,18 @@ #include "namespace.h" #include +#include #include ssize_t getdents(int fd, char *buffer, size_t nbytes) { message m; - m.m1_i1 = fd; - m.m1_i2 = nbytes; - m.m1_p1 = (char *) buffer; - return _syscall(VFS_PROC_NR, GETDENTS, &m); + memset(&m, 0, sizeof(m)); + m.VFS_READWRITE_FD = fd; + m.VFS_READWRITE_LEN = nbytes; + m.VFS_READWRITE_BUF = (char *) buffer; + return _syscall(VFS_PROC_NR, VFS_GETDENTS, &m); } #if defined(__minix) && defined(__weak_alias) diff --git a/lib/libc/sys-minix/getegid.c b/lib/libc/sys-minix/getegid.c index e77649e1a..91af8cc35 100644 --- a/lib/libc/sys-minix/getegid.c +++ b/lib/libc/sys-minix/getegid.c @@ -2,21 +2,23 @@ #include "namespace.h" #include +#include #include #ifdef __weak_alias __weak_alias(getegid, _getegid) #endif -gid_t getegid() +gid_t getegid(void) { message m; + memset(&m, 0, sizeof(m)); /* POSIX says that this function is always successful and that no * return value is reserved to indicate an error. Minix syscalls * are not always successful and Minix returns the unreserved value * (gid_t) -1 when there is an error. */ - if (_syscall(PM_PROC_NR, GETGID, &m) < 0) return ( (gid_t) -1); - return( (gid_t) m.m2_i1); + if (_syscall(PM_PROC_NR, PM_GETGID, &m) < 0) return ( (gid_t) -1); + return( (gid_t) m.PM_GETGID_EGID); } diff --git a/lib/libc/sys-minix/geteuid.c b/lib/libc/sys-minix/geteuid.c index ecde17313..1b28ccb8b 100644 --- a/lib/libc/sys-minix/geteuid.c +++ b/lib/libc/sys-minix/geteuid.c @@ -2,21 +2,23 @@ #include "namespace.h" #include +#include #include #ifdef __weak_alias __weak_alias(geteuid, _geteuid) #endif -uid_t geteuid() +uid_t geteuid(void) { message m; + memset(&m, 0, sizeof(m)); /* POSIX says that this function is always successful and that no * return value is reserved to indicate an error. Minix syscalls * are not always successful and Minix returns the unreserved value * (uid_t) -1 when there is an error. */ - if (_syscall(PM_PROC_NR, GETUID, &m) < 0) return ( (uid_t) -1); - return( (uid_t) m.m2_i1); + if (_syscall(PM_PROC_NR, PM_GETUID, &m) < 0) return ( (uid_t) -1); + return( (uid_t) m.PM_GETUID_EUID); } diff --git a/lib/libc/sys-minix/getgid.c b/lib/libc/sys-minix/getgid.c index 86228e7ba..532836911 100644 --- a/lib/libc/sys-minix/getgid.c +++ b/lib/libc/sys-minix/getgid.c @@ -2,15 +2,17 @@ #include "namespace.h" #include +#include #include #ifdef __weak_alias __weak_alias(getgid, _getgid) #endif -gid_t getgid() +gid_t getgid(void) { message m; - return( (gid_t) _syscall(PM_PROC_NR, GETGID, &m)); + memset(&m, 0, sizeof(m)); + return( (gid_t) _syscall(PM_PROC_NR, PM_GETGID, &m)); } diff --git a/lib/libc/sys-minix/getgroups.c b/lib/libc/sys-minix/getgroups.c index 87f83502a..60854613e 100644 --- a/lib/libc/sys-minix/getgroups.c +++ b/lib/libc/sys-minix/getgroups.c @@ -6,6 +6,7 @@ getgroups.c #include "namespace.h" #include +#include #include #ifdef __weak_alias @@ -16,9 +17,11 @@ __weak_alias(getgroups, _getgroups) int getgroups(int ngroups, gid_t *arr) { message m; - m.m1_i1 = ngroups; - m.m1_p1 = (char *) arr; - return(_syscall(PM_PROC_NR, GETGROUPS, &m)); + memset(&m, 0, sizeof(m)); + m.PM_GROUPS_NUM = ngroups; + m.PM_GROUPS_PTR = (char *) arr; + + return(_syscall(PM_PROC_NR, PM_GETGROUPS, &m)); } diff --git a/lib/libc/sys-minix/getitimer.c b/lib/libc/sys-minix/getitimer.c index e6f382f0e..5e06e1953 100644 --- a/lib/libc/sys-minix/getitimer.c +++ b/lib/libc/sys-minix/getitimer.c @@ -2,6 +2,7 @@ #include "namespace.h" #include +#include #include /* @@ -12,11 +13,12 @@ int getitimer(int which, struct itimerval *value) { message m; - m.m1_i1 = which; - m.m1_p1 = NULL; /* only retrieve the timer */ - m.m1_p2 = (char *) value; + memset(&m, 0, sizeof(m)); + m.PM_ITIMER_WHICH = which; + m.PM_ITIMER_VALUE = NULL; /* only retrieve the timer */ + m.PM_ITIMER_OVALUE = (char *) value; - return _syscall(PM_PROC_NR, ITIMER, &m); + return _syscall(PM_PROC_NR, PM_ITIMER, &m); } #if defined(__minix) && defined(__weak_alias) diff --git a/lib/libc/sys-minix/getpgrp.c b/lib/libc/sys-minix/getpgrp.c index 8df2865f6..e3a71b043 100644 --- a/lib/libc/sys-minix/getpgrp.c +++ b/lib/libc/sys-minix/getpgrp.c @@ -2,15 +2,17 @@ #include "namespace.h" #include +#include #include #ifdef __weak_alias __weak_alias(getpgrp, _getpgrp) #endif -pid_t getpgrp() +pid_t getpgrp(void) { message m; - return(_syscall(PM_PROC_NR, GETPGRP, &m)); + memset(&m, 0, sizeof(m)); + return(_syscall(PM_PROC_NR, PM_GETPGRP, &m)); } diff --git a/lib/libc/sys-minix/getpid.c b/lib/libc/sys-minix/getpid.c index a041af71e..b71667c96 100644 --- a/lib/libc/sys-minix/getpid.c +++ b/lib/libc/sys-minix/getpid.c @@ -2,15 +2,17 @@ #include "namespace.h" #include +#include #include #ifdef __weak_alias __weak_alias(getpid, _getpid) #endif -pid_t getpid() +pid_t getpid(void) { message m; - return(_syscall(PM_PROC_NR, MINIX_GETPID, &m)); + memset(&m, 0, sizeof(m)); + return(_syscall(PM_PROC_NR, PM_GETPID, &m)); } diff --git a/lib/libc/sys-minix/getppid.c b/lib/libc/sys-minix/getppid.c index 61bd275f4..cc22582ad 100644 --- a/lib/libc/sys-minix/getppid.c +++ b/lib/libc/sys-minix/getppid.c @@ -2,21 +2,23 @@ #include "namespace.h" #include +#include #include #ifdef __weak_alias __weak_alias(getppid, _getppid) #endif -pid_t getppid() +pid_t getppid(void) { message m; + memset(&m, 0, sizeof(m)); /* POSIX says that this function is always successful and that no * return value is reserved to indicate an error. Minix syscalls * are not always successful and Minix returns the reserved value * (pid_t) -1 when there is an error. */ - if (_syscall(PM_PROC_NR, MINIX_GETPID, &m) < 0) return ( (pid_t) -1); - return( (pid_t) m.m2_i1); + if (_syscall(PM_PROC_NR, PM_GETPID, &m) < 0) return ( (pid_t) -1); + return( (pid_t) m.PM_GETPID_PARENT); } diff --git a/lib/libc/sys-minix/getrusage.c b/lib/libc/sys-minix/getrusage.c index 6c983d778..faeb83230 100644 --- a/lib/libc/sys-minix/getrusage.c +++ b/lib/libc/sys-minix/getrusage.c @@ -2,6 +2,7 @@ #include "namespace.h" #include +#include #include #include @@ -9,8 +10,10 @@ int getrusage(int who, struct rusage *r_usage) { int rc; message m; + + memset(&m, 0, sizeof(m)); m.RU_WHO = who; - m.RU_RUSAGE_ADDR = r_usage; + m.RU_RUSAGE_ADDR = (char *) r_usage; if (r_usage == NULL) { errno = EFAULT; @@ -24,9 +27,13 @@ int getrusage(int who, struct rusage *r_usage) memset(r_usage, 0, sizeof(struct rusage)); if ((rc = _syscall(PM_PROC_NR, PM_GETRUSAGE, &m)) < 0) return rc; - m.RU_RUSAGE_ADDR = r_usage; + + memset(&m, 0, sizeof(m)); + m.RU_RUSAGE_ADDR = (char *) r_usage; if ((rc = _syscall(VFS_PROC_NR, VFS_GETRUSAGE, &m)) < 0) return rc; - m.RU_RUSAGE_ADDR = r_usage; + + memset(&m, 0, sizeof(m)); + m.RU_RUSAGE_ADDR = (char *) r_usage; return _syscall(VM_PROC_NR, VM_GETRUSAGE, &m); } diff --git a/lib/libc/sys-minix/gettimeofday.c b/lib/libc/sys-minix/gettimeofday.c index 352c59612..824fe7a58 100644 --- a/lib/libc/sys-minix/gettimeofday.c +++ b/lib/libc/sys-minix/gettimeofday.c @@ -6,6 +6,7 @@ gettimeofday.c #include "namespace.h" #include +#include #include #ifdef __weak_alias @@ -16,11 +17,13 @@ int gettimeofday(struct timeval *__restrict tp, void *__restrict tzp) { message m; - if (_syscall(PM_PROC_NR, GETTIMEOFDAY, &m) < 0) + memset(&m, 0, sizeof(m)); + + if (_syscall(PM_PROC_NR, PM_GETTIMEOFDAY, &m) < 0) return -1; - tp->tv_sec = m.m2_l1; - tp->tv_usec = m.m2_l2; + tp->tv_sec = m.PM_TIME_SEC; + tp->tv_usec = m.PM_TIME_USEC; return 0; } diff --git a/lib/libc/sys-minix/getuid.c b/lib/libc/sys-minix/getuid.c index b8662b7e3..12f51db18 100644 --- a/lib/libc/sys-minix/getuid.c +++ b/lib/libc/sys-minix/getuid.c @@ -2,15 +2,17 @@ #include "namespace.h" #include +#include #include #ifdef __weak_alias __weak_alias(getuid, _getuid) #endif -uid_t getuid() +uid_t getuid(void) { message m; - return( (uid_t) _syscall(PM_PROC_NR, GETUID, &m)); + memset(&m, 0, sizeof(m)); + return( (uid_t) _syscall(PM_PROC_NR, PM_GETUID, &m)); } diff --git a/lib/libc/sys-minix/getvfsstat.c b/lib/libc/sys-minix/getvfsstat.c index 69a086496..90e4ad309 100644 --- a/lib/libc/sys-minix/getvfsstat.c +++ b/lib/libc/sys-minix/getvfsstat.c @@ -2,6 +2,7 @@ #include #include "namespace.h" +#include #include #ifdef __weak_alias @@ -12,8 +13,9 @@ int getvfsstat(struct statvfs *buf, size_t bufsize, int flags) { message m; + memset(&m, 0, sizeof(m)); m.VFS_GETVFSSTAT_BUF = (char *) buf; - m.VFS_GETVFSSTAT_SIZE = bufsize; + m.VFS_GETVFSSTAT_LEN = bufsize; m.VFS_GETVFSSTAT_FLAGS = flags; - return(_syscall(VFS_PROC_NR, GETVFSSTAT, &m)); + return(_syscall(VFS_PROC_NR, VFS_GETVFSSTAT, &m)); } diff --git a/lib/libc/sys-minix/ioctl.c b/lib/libc/sys-minix/ioctl.c index 5086c1458..4aec91632 100644 --- a/lib/libc/sys-minix/ioctl.c +++ b/lib/libc/sys-minix/ioctl.c @@ -73,11 +73,12 @@ void *data; break; } + memset(&m, 0, sizeof(m)); m.VFS_IOCTL_FD = fd; m.VFS_IOCTL_REQ = request; m.VFS_IOCTL_ARG = (char *) addr; - r = _syscall(VFS_PROC_NR, IOCTL, &m); + r = _syscall(VFS_PROC_NR, VFS_IOCTL, &m); /* Translate back to original form */ switch (request_save) { diff --git a/lib/libc/sys-minix/issetugid.c b/lib/libc/sys-minix/issetugid.c index 499331f15..d0eb172db 100644 --- a/lib/libc/sys-minix/issetugid.c +++ b/lib/libc/sys-minix/issetugid.c @@ -2,14 +2,13 @@ #include "namespace.h" #include +#include #include int issetugid(void) { - int r; message m; - r = _syscall(PM_PROC_NR, ISSETUGID, &m); - if (r == -1) return 0; /* Default to old behavior */ - return(r); + memset(&m, 0, sizeof(m)); + return _syscall(PM_PROC_NR, PM_ISSETUGID, &m); } diff --git a/lib/libc/sys-minix/kill.c b/lib/libc/sys-minix/kill.c index fb4c86c53..367d2ef22 100644 --- a/lib/libc/sys-minix/kill.c +++ b/lib/libc/sys-minix/kill.c @@ -2,6 +2,7 @@ #include "namespace.h" #include +#include #include #ifdef __weak_alias @@ -9,12 +10,13 @@ __weak_alias(kill, _kill) #endif int kill(proc, sig) -int proc; /* which process is to be sent the signal */ +pid_t proc; /* which process is to be sent the signal */ int sig; /* signal number */ { message m; - m.m1_i1 = proc; - m.m1_i2 = sig; - return(_syscall(PM_PROC_NR, KILL, &m)); + memset(&m, 0, sizeof(m)); + m.PM_SIG_PID = proc; + m.PM_SIG_NR = sig; + return(_syscall(PM_PROC_NR, PM_KILL, &m)); } diff --git a/lib/libc/sys-minix/link.c b/lib/libc/sys-minix/link.c index f87c9062b..20bbe8713 100644 --- a/lib/libc/sys-minix/link.c +++ b/lib/libc/sys-minix/link.c @@ -13,9 +13,10 @@ int link(const char *name, const char *name2) { message m; - m.m1_i1 = strlen(name) + 1; - m.m1_i2 = strlen(name2) + 1; - m.m1_p1 = (char *) __UNCONST(name); - m.m1_p2 = (char *) __UNCONST(name2); - return(_syscall(VFS_PROC_NR, LINK, &m)); + memset(&m, 0, sizeof(m)); + m.VFS_LINK_LEN1 = strlen(name) + 1; + m.VFS_LINK_LEN2 = strlen(name2) + 1; + m.VFS_LINK_NAME1 = (char *) __UNCONST(name); + m.VFS_LINK_NAME2 = (char *) __UNCONST(name2); + return(_syscall(VFS_PROC_NR, VFS_LINK, &m)); } diff --git a/lib/libc/sys-minix/loadname.c b/lib/libc/sys-minix/loadname.c index 0b1986776..0cd4974df 100644 --- a/lib/libc/sys-minix/loadname.c +++ b/lib/libc/sys-minix/loadname.c @@ -10,11 +10,10 @@ void _loadname(const char *name, message *msgptr) * string fits in the message, it is copied there. If not, a pointer to * it is passed. */ - register size_t k; k = strlen(name) + 1; - msgptr->m3_i1 = k; - msgptr->m3_p1 = (char *) __UNCONST(name); - if (k <= M3_STRING) strcpy(msgptr->m3_ca1, name); + msgptr->VFS_PATH_LEN = k; + msgptr->VFS_PATH_NAME = (char *) __UNCONST(name); + if (k <= M3_STRING) strcpy(msgptr->VFS_PATH_BUF, name); } diff --git a/lib/libc/sys-minix/lseek.c b/lib/libc/sys-minix/lseek.c index 570f7b8a4..a0bfc041a 100644 --- a/lib/libc/sys-minix/lseek.c +++ b/lib/libc/sys-minix/lseek.c @@ -2,6 +2,7 @@ #include "namespace.h" #include +#include #include #include @@ -14,13 +15,11 @@ lseek(int fd, off_t offset, int whence) { message m; - m.m2_i1 = fd; - m.m2_l1 = ex64lo(offset); - m.m2_l2 = ex64hi(offset); - m.m2_i2 = whence; - - if (_syscall(VFS_PROC_NR, LSEEK, &m) < 0) - return( (off_t) -1); - - return( (off_t) make64(m.m2_l1, m.m2_l2)); + memset(&m, 0, sizeof(m)); + m.VFS_LSEEK_FD = fd; + m.VFS_LSEEK_OFF_LO = ex64lo(offset); + m.VFS_LSEEK_OFF_HI = ex64hi(offset); + m.VFS_LSEEK_WHENCE = whence; + if (_syscall(VFS_PROC_NR, VFS_LSEEK, &m) < 0) return( (off_t) -1); + return( (off_t) make64(m.VFS_LSEEK_OFF_LO, m.VFS_LSEEK_OFF_HI)); } diff --git a/lib/libc/sys-minix/lseek64.c b/lib/libc/sys-minix/lseek64.c index 1310cba5f..b75b1322d 100644 --- a/lib/libc/sys-minix/lseek64.c +++ b/lib/libc/sys-minix/lseek64.c @@ -2,6 +2,7 @@ #include "namespace.h" #include +#include #include #include @@ -13,12 +14,13 @@ u64_t *newpos; { message m; - m.m2_i1 = fd; - m.m2_l1 = ex64lo(offset); - m.m2_l2 = ex64hi(offset); - m.m2_i2 = whence; - if (_syscall(VFS_PROC_NR, LLSEEK, &m) < 0) return -1; + memset(&m, 0, sizeof(m)); + m.VFS_LSEEK_FD = fd; + m.VFS_LSEEK_OFF_LO = ex64lo(offset); + m.VFS_LSEEK_OFF_HI = ex64hi(offset); + m.VFS_LSEEK_WHENCE = whence; + if (_syscall(VFS_PROC_NR, VFS_LSEEK, &m) < 0) return -1; if (newpos) - *newpos= make64(m.m2_l1, m.m2_l2); + *newpos= make64(m.VFS_LSEEK_OFF_LO, m.VFS_LSEEK_OFF_HI); return 0; } diff --git a/lib/libc/sys-minix/lutimes.c b/lib/libc/sys-minix/lutimes.c index 5b6fa5016..688ab3146 100644 --- a/lib/libc/sys-minix/lutimes.c +++ b/lib/libc/sys-minix/lutimes.c @@ -16,21 +16,28 @@ int lutimes(const char *name, const struct timeval tv[2]) { message m; - if (name == NULL) return EINVAL; - if (name[0] == '\0') return ENOENT; /* X/Open requirement */ - m.m2_i1 = strlen(name) + 1; - m.m2_p1 = (char *) __UNCONST(name); + if (name == NULL) { + errno = EINVAL; + return -1; + } + if (name[0] == '\0') { /* X/Open requirement */ + errno = ENOENT; + return -1; + } + memset(&m, 0, sizeof(m)); + m.VFS_UTIMENS_FD = strlen(name) + 1; + m.VFS_UTIMENS_NAME = (char *) __UNCONST(name); if (tv == NULL) { - m.m2_l1 = m.m2_l2 = 0; - m.m2_i2 = m.m2_i3 = UTIME_NOW; + m.VFS_UTIMENS_ATIME = m.VFS_UTIMENS_MTIME = 0; + m.VFS_UTIMENS_ANSEC = m.VFS_UTIMENS_MNSEC = UTIME_NOW; } else { - m.m2_l1 = tv[0].tv_sec; - m.m2_l2 = tv[1].tv_sec; - m.m2_i2 = tv[0].tv_usec * 1000; - m.m2_i3 = tv[1].tv_usec * 1000; + m.VFS_UTIMENS_ATIME = tv[0].tv_sec; + m.VFS_UTIMENS_MTIME = tv[1].tv_sec; + m.VFS_UTIMENS_ANSEC = tv[0].tv_usec * 1000; + m.VFS_UTIMENS_MNSEC = tv[1].tv_usec * 1000; } - m.m2_s1 = AT_SYMLINK_NOFOLLOW; + m.VFS_UTIMENS_FLAGS = AT_SYMLINK_NOFOLLOW; - return(_syscall(VFS_PROC_NR, UTIMENS, &m)); + return(_syscall(VFS_PROC_NR, VFS_UTIMENS, &m)); } diff --git a/lib/libc/sys-minix/minix_rs.c b/lib/libc/sys-minix/minix_rs.c index e7b19fded..d858556c2 100644 --- a/lib/libc/sys-minix/minix_rs.c +++ b/lib/libc/sys-minix/minix_rs.c @@ -2,7 +2,6 @@ #include -#include #include #include #include @@ -27,6 +26,7 @@ int minix_rs_lookup(const char *name, endpoint_t *value) len_key = strlen(name)+1; + memset(&m, 0, sizeof(m)); m.RS_NAME = (char *) __UNCONST(name); m.RS_NAME_LEN = len_key; diff --git a/lib/libc/sys-minix/mkdir.c b/lib/libc/sys-minix/mkdir.c index a014868da..59e632dd7 100644 --- a/lib/libc/sys-minix/mkdir.c +++ b/lib/libc/sys-minix/mkdir.c @@ -13,8 +13,8 @@ int mkdir(const char *name, mode_t mode) { message m; - m.m1_i1 = strlen(name) + 1; - m.m1_i2 = mode; - m.m1_p1 = (char *) __UNCONST(name); - return(_syscall(VFS_PROC_NR, MKDIR, &m)); + memset(&m, 0, sizeof(m)); + m.VFS_PATH_MODE = mode; + _loadname(name, &m); + return(_syscall(VFS_PROC_NR, VFS_MKDIR, &m)); } diff --git a/lib/libc/sys-minix/mknod.c b/lib/libc/sys-minix/mknod.c index 606e0205c..a425b61c1 100644 --- a/lib/libc/sys-minix/mknod.c +++ b/lib/libc/sys-minix/mknod.c @@ -11,12 +11,12 @@ int mknod(const char *name, mode_t mode, dev_t dev) { message m; - m.m1_i1 = strlen(name) + 1; - m.m1_i2 = mode; - m.m1_i3 = dev; - m.m1_p1 = (char *) __UNCONST(name); - m.m1_p2 = (char *) ((int) 0); /* obsolete size field */ - return(_syscall(VFS_PROC_NR, MKNOD, &m)); + memset(&m, 0, sizeof(m)); + m.VFS_MKNOD_LEN = strlen(name) + 1; + m.VFS_MKNOD_MODE = mode; + m.VFS_MKNOD_DEV = dev; + m.VFS_MKNOD_NAME = (char *) __UNCONST(name); + return(_syscall(VFS_PROC_NR, VFS_MKNOD, &m)); } #if defined(__minix) && defined(__weak_alias) diff --git a/lib/libc/sys-minix/mmap.c b/lib/libc/sys-minix/mmap.c index f213f8fbf..bdf97ff84 100644 --- a/lib/libc/sys-minix/mmap.c +++ b/lib/libc/sys-minix/mmap.c @@ -28,6 +28,7 @@ void *minix_mmap_for(endpoint_t forwhom, message m; int r; + memset(&m, 0, sizeof(m)); m.VMM_ADDR = (vir_bytes) addr; m.VMM_LEN = len; m.VMM_PROT = prot; @@ -87,6 +88,7 @@ int minix_munmap(void *addr, size_t len) { message m; + memset(&m, 0, sizeof(m)); m.VMUM_ADDR = addr; m.VMUM_LEN = len; @@ -103,6 +105,7 @@ void *vm_remap(endpoint_t d, message m; int r; + memset(&m, 0, sizeof(m)); m.VMRE_D = d; m.VMRE_S = s; m.VMRE_DA = (char *) da; @@ -124,6 +127,7 @@ void *vm_remap_ro(endpoint_t d, message m; int r; + memset(&m, 0, sizeof(m)); m.VMRE_D = d; m.VMRE_S = s; m.VMRE_DA = (char *) da; @@ -140,6 +144,7 @@ int vm_unmap(endpoint_t endpt, void *addr) { message m; + memset(&m, 0, sizeof(m)); m.VMUN_ENDPT = endpt; m.VMUN_ADDR = (long) addr; @@ -151,6 +156,7 @@ unsigned long vm_getphys(endpoint_t endpt, void *addr) message m; int r; + memset(&m, 0, sizeof(m)); m.VMPHYS_ENDPT = endpt; m.VMPHYS_ADDR = (long) addr; @@ -165,6 +171,7 @@ u8_t vm_getrefcount(endpoint_t endpt, void *addr) message m; int r; + memset(&m, 0, sizeof(m)); m.VMREFCNT_ENDPT = endpt; m.VMREFCNT_ADDR = (long) addr; diff --git a/lib/libc/sys-minix/mount.c b/lib/libc/sys-minix/mount.c index fabb6a78d..e9609f92b 100644 --- a/lib/libc/sys-minix/mount.c +++ b/lib/libc/sys-minix/mount.c @@ -148,6 +148,7 @@ int mountflags, srvflags; } /* Now perform mount(). */ + memset(&m, 0, sizeof(m)); m.VFS_MOUNT_FLAGS = mountflags; m.VFS_MOUNT_DEVLEN = special ? strlen(special) + 1 : 0; m.VFS_MOUNT_PATHLEN = strlen(name) + 1; @@ -157,7 +158,7 @@ int mountflags, srvflags; m.VFS_MOUNT_PATH = name; m.VFS_MOUNT_TYPE = type; m.VFS_MOUNT_LABEL = label; - r = _syscall(VFS_PROC_NR, MOUNT, &m); + r = _syscall(VFS_PROC_NR, VFS_MOUNT, &m); if (r != OK && !use_existing) { /* If mount() failed, tell RS to shutdown FS process. @@ -177,11 +178,12 @@ int srvflags; message m; int r; + memset(&m, 0, sizeof(m)); m.VFS_UMOUNT_NAME = __UNCONST(name); m.VFS_UMOUNT_NAMELEN = strlen(name) + 1; m.VFS_UMOUNT_LABEL = label; m.VFS_UMOUNT_LABELLEN = sizeof(label); - r = _syscall(VFS_PROC_NR, UMOUNT, &m); + r = _syscall(VFS_PROC_NR, VFS_UMOUNT, &m); /* don't shut down the driver when exist flag is set */ if (!(srvflags & MS_EXISTING)) { diff --git a/lib/libc/sys-minix/nanosleep.c b/lib/libc/sys-minix/nanosleep.c index 5478d9a3b..c69c4cf68 100644 --- a/lib/libc/sys-minix/nanosleep.c +++ b/lib/libc/sys-minix/nanosleep.c @@ -26,13 +26,17 @@ int nanosleep(const struct timespec *rqtp, struct timespec *rmtp) struct timespec rqt; /* check parameters */ - if (!rqtp) - return EFAULT; + if (!rqtp) { + errno = EFAULT; + return -1; + } if (rqtp->tv_sec < 0 || rqtp->tv_nsec < 0 || - rqtp->tv_nsec >= NSEC_PER_SEC) - return EINVAL; + rqtp->tv_nsec >= NSEC_PER_SEC) { + errno = EINVAL; + return -1; + } /* store *rqtp to make sure it is not overwritten */ rqt = *rqtp; diff --git a/lib/libc/sys-minix/open.c b/lib/libc/sys-minix/open.c index 47dd62477..ba401664e 100644 --- a/lib/libc/sys-minix/open.c +++ b/lib/libc/sys-minix/open.c @@ -14,20 +14,24 @@ int open(const char *name, int flags, ...) { va_list argp; message m; + int call; + memset(&m, 0, sizeof(m)); va_start(argp, flags); + /* Depending on whether O_CREAT is set, a different message layout is used, + * and therefore a different call number as well. + */ if (flags & O_CREAT) { - m.m1_i1 = strlen(name) + 1; - m.m1_i2 = flags; - /* Since it's a vararg parameter that is smaller than - * an int, the mode was passed as an int. - */ - m.m1_i3 = va_arg(argp, int); - m.m1_p1 = (char *) __UNCONST(name); + m.VFS_CREAT_LEN = strlen(name) + 1; + m.VFS_CREAT_FLAGS = flags; + m.VFS_CREAT_MODE = va_arg(argp, int); + m.VFS_CREAT_NAME = (char *) __UNCONST(name); + call = VFS_CREAT; } else { _loadname(name, &m); - m.m3_i2 = flags; + m.VFS_PATH_FLAGS = flags; + call = VFS_OPEN; } va_end(argp); - return (_syscall(VFS_PROC_NR, OPEN, &m)); + return (_syscall(VFS_PROC_NR, call, &m)); } diff --git a/lib/libc/sys-minix/pipe.c b/lib/libc/sys-minix/pipe.c index fa71e4e65..a8cc05d82 100644 --- a/lib/libc/sys-minix/pipe.c +++ b/lib/libc/sys-minix/pipe.c @@ -2,6 +2,7 @@ #include "namespace.h" #include +#include #include #ifdef __weak_alias @@ -10,25 +11,21 @@ __weak_alias(pipe2, _pipe2) #endif int -pipe(int fild[2]) +pipe2(int fild[2], int flags) { message m; - if (_syscall(VFS_PROC_NR, PIPE, &m) < 0) return(-1); - fild[0] = m.m1_i1; - fild[1] = m.m1_i2; + memset(&m, 0, sizeof(m)); + m.VFS_PIPE2_FLAGS = flags; + + if (_syscall(VFS_PROC_NR, VFS_PIPE2, &m) < 0) return(-1); + fild[0] = m.VFS_PIPE2_FD0; + fild[1] = m.VFS_PIPE2_FD1; return(0); } int -pipe2(int fild[2], int flags) +pipe(int fild[2]) { - message m; - - m.m1_i3 = flags; - - if (_syscall(VFS_PROC_NR, PIPE2, &m) < 0) return(-1); - fild[0] = m.m1_i1; - fild[1] = m.m1_i2; - return(0); + return pipe2(fild, 0); } diff --git a/lib/libc/sys-minix/priority.c b/lib/libc/sys-minix/priority.c index 451d4497a..c6e6a5d94 100644 --- a/lib/libc/sys-minix/priority.c +++ b/lib/libc/sys-minix/priority.c @@ -18,8 +18,9 @@ int getpriority(int which, int who) int v; message m; - m.m1_i1 = which; - m.m1_i2 = who; + memset(&m, 0, sizeof(m)); + m.PM_PRIORITY_WHICH = which; + m.PM_PRIORITY_WHO = who; /* GETPRIORITY returns negative for error. * Otherwise, it returns the priority plus the minimum @@ -28,7 +29,7 @@ int getpriority(int which, int who) * to see if something really went wrong.) */ - if((v = _syscall(PM_PROC_NR, GETPRIORITY, &m)) < 0) { + if((v = _syscall(PM_PROC_NR, PM_GETPRIORITY, &m)) < 0) { return v; } @@ -39,10 +40,11 @@ int setpriority(int which, int who, int prio) { message m; - m.m1_i1 = which; - m.m1_i2 = who; - m.m1_i3 = prio; + memset(&m, 0, sizeof(m)); + m.PM_PRIORITY_WHICH = which; + m.PM_PRIORITY_WHO = who; + m.PM_PRIORITY_PRIO = prio; - return _syscall(PM_PROC_NR, SETPRIORITY, &m); + return _syscall(PM_PROC_NR, PM_SETPRIORITY, &m); } diff --git a/lib/libc/sys-minix/ptrace.c b/lib/libc/sys-minix/ptrace.c index 859f736f2..79c28aa58 100644 --- a/lib/libc/sys-minix/ptrace.c +++ b/lib/libc/sys-minix/ptrace.c @@ -2,6 +2,7 @@ #include "namespace.h" #include +#include #include #ifdef __weak_alias @@ -12,16 +13,17 @@ long ptrace(int req, pid_t pid, long addr, long data) { message m; - m.m2_i1 = pid; - m.m2_i2 = req; - m.PMTRACE_ADDR = addr; - m.m2_l2 = data; - if (_syscall(PM_PROC_NR, PTRACE, &m) < 0) return(-1); + memset(&m, 0, sizeof(m)); + m.PM_PTRACE_PID = pid; + m.PM_PTRACE_REQ = req; + m.PM_PTRACE_ADDR = addr; + m.PM_PTRACE_DATA = data; + if (_syscall(PM_PROC_NR, PM_PTRACE, &m) < 0) return(-1); /* There was no error, but -1 is a legal return value. Clear errno if * necessary to distinguish this case. _syscall has set errno to nonzero * for the error case. */ - if (m.m2_l2 == -1) errno = 0; - return(m.m2_l2); + if (m.PM_PTRACE_DATA == -1) errno = 0; + return(m.PM_PTRACE_DATA); } diff --git a/lib/libc/sys-minix/read.c b/lib/libc/sys-minix/read.c index b14391203..7e0349103 100644 --- a/lib/libc/sys-minix/read.c +++ b/lib/libc/sys-minix/read.c @@ -2,6 +2,7 @@ #include #include "namespace.h" +#include #include #ifdef __weak_alias @@ -12,8 +13,9 @@ ssize_t read(int fd, void *buffer, size_t nbytes) { message m; - m.m1_i1 = fd; - m.m1_i2 = nbytes; - m.m1_p1 = (char *) buffer; - return(_syscall(VFS_PROC_NR, READ, &m)); + memset(&m, 0, sizeof(m)); + m.VFS_READWRITE_FD = fd; + m.VFS_READWRITE_LEN = nbytes; + m.VFS_READWRITE_BUF = (char *) buffer; + return(_syscall(VFS_PROC_NR, VFS_READ, &m)); } diff --git a/lib/libc/sys-minix/readlink.c b/lib/libc/sys-minix/readlink.c index b141941f7..41f423f33 100644 --- a/lib/libc/sys-minix/readlink.c +++ b/lib/libc/sys-minix/readlink.c @@ -13,10 +13,11 @@ ssize_t readlink(const char *name, char *buffer, size_t bufsiz) { message m; - m.m1_i1 = strlen(name) + 1; - m.m1_i2 = bufsiz; - m.m1_p1 = (char *) __UNCONST(name); - m.m1_p2 = (char *) buffer; + memset(&m, 0, sizeof(m)); + m.VFS_READLINK_NAMELEN = strlen(name) + 1; + m.VFS_READLINK_BUFSIZE = bufsiz; + m.VFS_READLINK_NAME = (char *) __UNCONST(name); + m.VFS_READLINK_BUF = (char *) buffer; - return(_syscall(VFS_PROC_NR, RDLNK, &m)); + return(_syscall(VFS_PROC_NR, VFS_READLINK, &m)); } diff --git a/lib/libc/sys-minix/reboot.c b/lib/libc/sys-minix/reboot.c index 806d9dbdd..9e292cd6f 100644 --- a/lib/libc/sys-minix/reboot.c +++ b/lib/libc/sys-minix/reboot.c @@ -1,4 +1,4 @@ -/* reboot.c - Systemcall interface to mm/signal.c::do_reboot() +/* reboot.c author: Edvard Tuinder v892231@si.hhs.NL */ @@ -8,14 +8,14 @@ #include #include "namespace.h" -#include +#include #include -#include int reboot(int how) { message m; - m.m1_i1 = how; - return _syscall(PM_PROC_NR, REBOOT, &m); + memset(&m, 0, sizeof(m)); + m.PM_REBOOT_HOW = how; + return _syscall(PM_PROC_NR, PM_REBOOT, &m); } diff --git a/lib/libc/sys-minix/rename.c b/lib/libc/sys-minix/rename.c index 50aedbd2f..d8ec5419a 100644 --- a/lib/libc/sys-minix/rename.c +++ b/lib/libc/sys-minix/rename.c @@ -9,9 +9,10 @@ int rename(const char *name, const char *name2) { message m; - m.m1_i1 = strlen(name) + 1; - m.m1_i2 = strlen(name2) + 1; - m.m1_p1 = (char *) __UNCONST(name); - m.m1_p2 = (char *) __UNCONST(name2); - return(_syscall(VFS_PROC_NR, RENAME, &m)); + memset(&m, 0, sizeof(m)); + m.VFS_LINK_LEN1 = strlen(name) + 1; + m.VFS_LINK_LEN2 = strlen(name2) + 1; + m.VFS_LINK_NAME1 = (char *) __UNCONST(name); + m.VFS_LINK_NAME2 = (char *) __UNCONST(name2); + return(_syscall(VFS_PROC_NR, VFS_RENAME, &m)); } diff --git a/lib/libc/sys-minix/rmdir.c b/lib/libc/sys-minix/rmdir.c index 272c1e4bf..e4efcae08 100644 --- a/lib/libc/sys-minix/rmdir.c +++ b/lib/libc/sys-minix/rmdir.c @@ -6,6 +6,7 @@ __weak_alias(rmdir, _rmdir) #endif +#include #include int rmdir(name) @@ -13,6 +14,7 @@ const char *name; { message m; + memset(&m, 0, sizeof(m)); _loadname(name, &m); - return(_syscall(VFS_PROC_NR, RMDIR, &m)); + return(_syscall(VFS_PROC_NR, VFS_RMDIR, &m)); } diff --git a/lib/libc/sys-minix/select.c b/lib/libc/sys-minix/select.c index a703d7cf1..09f4ab1be 100644 --- a/lib/libc/sys-minix/select.c +++ b/lib/libc/sys-minix/select.c @@ -2,6 +2,7 @@ #include #include "namespace.h" +#include #include #include @@ -11,13 +12,14 @@ int select(int nfds, { message m; - m.SEL_NFDS = nfds; - m.SEL_READFDS = (char *) readfds; - m.SEL_WRITEFDS = (char *) writefds; - m.SEL_ERRORFDS = (char *) errorfds; - m.SEL_TIMEOUT = (char *) timeout; + memset(&m, 0, sizeof(m)); + m.VFS_SELECT_NFDS = nfds; + m.VFS_SELECT_READFDS = (char *) readfds; + m.VFS_SELECT_WRITEFDS = (char *) writefds; + m.VFS_SELECT_ERRORFDS = (char *) errorfds; + m.VFS_SELECT_TIMEOUT = (char *) timeout; - return (_syscall(VFS_PROC_NR, SELECT, &m)); + return (_syscall(VFS_PROC_NR, VFS_SELECT, &m)); } diff --git a/lib/libc/sys-minix/sem.c b/lib/libc/sys-minix/sem.c index 3726811ce..6f961d51b 100644 --- a/lib/libc/sys-minix/sem.c +++ b/lib/libc/sys-minix/sem.c @@ -14,6 +14,7 @@ #include #include #include +#include static int get_ipc_endpt(endpoint_t *pt) { @@ -32,6 +33,7 @@ int semget(key_t key, int nsems, int semflag) return -1; } + memset(&m, 0, sizeof(m)); m.SEMGET_KEY = key; m.SEMGET_NR = nsems; m.SEMGET_FLAG = semflag; @@ -56,6 +58,7 @@ int semctl(int semid, int semnum, int cmd, ...) return -1; } + memset(&m, 0, sizeof(m)); m.SEMCTL_ID = semid; m.SEMCTL_NUM = semnum; m.SEMCTL_CMD = cmd; @@ -85,6 +88,7 @@ int semop(int semid, struct sembuf *sops, size_t nsops) return -1; } + memset(&m, 0, sizeof(m)); m.SEMOP_ID = semid; m.SEMOP_OPS = (long) sops; m.SEMOP_SIZE = nsops; diff --git a/lib/libc/sys-minix/setgid.c b/lib/libc/sys-minix/setgid.c index 90fc6e40e..576f32d97 100644 --- a/lib/libc/sys-minix/setgid.c +++ b/lib/libc/sys-minix/setgid.c @@ -2,6 +2,8 @@ #include #include "namespace.h" +#include + #ifdef __weak_alias __weak_alias(setgid, _setgid) __weak_alias(setegid, _setegid) @@ -13,14 +15,16 @@ int setgid(gid_t grp) { message m; - m.m1_i1 = (int) grp; - return(_syscall(PM_PROC_NR, SETGID, &m)); + memset(&m, 0, sizeof(m)); + m.PM_SETGID_GID = (int) grp; + return(_syscall(PM_PROC_NR, PM_SETGID, &m)); } int setegid(gid_t grp) { message m; - m.m1_i1 = (int) grp; - return(_syscall(PM_PROC_NR, SETEGID, &m)); + memset(&m, 0, sizeof(m)); + m.PM_SETGID_GID = (int) grp; + return(_syscall(PM_PROC_NR, PM_SETEGID, &m)); } diff --git a/lib/libc/sys-minix/setgroups.c b/lib/libc/sys-minix/setgroups.c index 6080596ec..8bf35c62e 100644 --- a/lib/libc/sys-minix/setgroups.c +++ b/lib/libc/sys-minix/setgroups.c @@ -2,6 +2,8 @@ #include #include "namespace.h" +#include + #ifdef __weak_alias __weak_alias(setgroups, _setgroups) #endif @@ -12,10 +14,9 @@ int setgroups(int ngroups, const gid_t *gidset) { message m; - m.m1_p1 = (char *) __UNCONST(gidset); - m.m1_i1 = ngroups; + memset(&m, 0, sizeof(m)); + m.PM_GROUPS_PTR = (char *) __UNCONST(gidset); + m.PM_GROUPS_NUM = ngroups; - return(_syscall(PM_PROC_NR, SETGROUPS, &m)); + return(_syscall(PM_PROC_NR, PM_SETGROUPS, &m)); } - - diff --git a/lib/libc/sys-minix/setitimer.c b/lib/libc/sys-minix/setitimer.c index 1552b9ddc..882b68657 100644 --- a/lib/libc/sys-minix/setitimer.c +++ b/lib/libc/sys-minix/setitimer.c @@ -2,6 +2,7 @@ #include "namespace.h" #include +#include #include /* @@ -16,13 +17,17 @@ int setitimer(int which, const struct itimerval *__restrict value, /* A null pointer for 'value' would make setitimer behave like getitimer, * which is not according to the specification, so disallow null pointers. */ - if (value == NULL) return(EINVAL); + if (value == NULL) { + errno = EINVAL; + return -1; + } - m.m1_i1 = which; - m.m1_p1 = (char *) __UNCONST(value); - m.m1_p2 = (char *) ovalue; + memset(&m, 0, sizeof(m)); + m.PM_ITIMER_WHICH = which; + m.PM_ITIMER_VALUE = (char *) __UNCONST(value); + m.PM_ITIMER_OVALUE = (char *) ovalue; - return _syscall(PM_PROC_NR, ITIMER, &m); + return _syscall(PM_PROC_NR, PM_ITIMER, &m); } #if defined(__minix) && defined(__weak_alias) diff --git a/lib/libc/sys-minix/setsid.c b/lib/libc/sys-minix/setsid.c index 72b6010e0..7337a0737 100644 --- a/lib/libc/sys-minix/setsid.c +++ b/lib/libc/sys-minix/setsid.c @@ -2,15 +2,17 @@ #include #include "namespace.h" +#include #include #ifdef __weak_alias __weak_alias(setsid, _setsid) #endif -pid_t setsid() +pid_t setsid(void) { message m; - return(_syscall(PM_PROC_NR, SETSID, &m)); + memset(&m, 0, sizeof(m)); + return(_syscall(PM_PROC_NR, PM_SETSID, &m)); } diff --git a/lib/libc/sys-minix/setuid.c b/lib/libc/sys-minix/setuid.c index 0d066bea8..2a1376514 100644 --- a/lib/libc/sys-minix/setuid.c +++ b/lib/libc/sys-minix/setuid.c @@ -2,6 +2,7 @@ #include #include "namespace.h" +#include #include #ifdef __weak_alias @@ -13,14 +14,16 @@ int setuid(uid_t usr) { message m; - m.m1_i1 = usr; - return(_syscall(PM_PROC_NR, SETUID, &m)); + memset(&m, 0, sizeof(m)); + m.PM_SETUID_UID = usr; + return(_syscall(PM_PROC_NR, PM_SETUID, &m)); } int seteuid(uid_t usr) { message m; - m.m1_i1 = usr; - return(_syscall(PM_PROC_NR, SETEUID, &m)); + memset(&m, 0, sizeof(m)); + m.PM_SETUID_UID = usr; + return(_syscall(PM_PROC_NR, PM_SETEUID, &m)); } diff --git a/lib/libc/sys-minix/shmat.c b/lib/libc/sys-minix/shmat.c index 3ea34e3e9..77a5548ab 100644 --- a/lib/libc/sys-minix/shmat.c +++ b/lib/libc/sys-minix/shmat.c @@ -12,6 +12,7 @@ #include #include #include +#include #ifdef __weak_alias __weak_alias(shmat, _shmat) @@ -36,6 +37,7 @@ void *shmat(int shmid, const void *shmaddr, int shmflg) return NULL; } + memset(&m, 0, sizeof(m)); m.SHMAT_ID = shmid; m.SHMAT_ADDR = (long) shmaddr; m.SHMAT_FLAG = shmflg; @@ -57,6 +59,7 @@ int shmdt(const void *shmaddr) return -1; } + memset(&m, 0, sizeof(m)); m.SHMDT_ADDR = (long) shmaddr; return _syscall(ipc_pt, IPC_SHMDT, &m); diff --git a/lib/libc/sys-minix/shmctl.c b/lib/libc/sys-minix/shmctl.c index 1c7d47dea..474ecc39c 100644 --- a/lib/libc/sys-minix/shmctl.c +++ b/lib/libc/sys-minix/shmctl.c @@ -11,6 +11,7 @@ #include #include #include +#include static int get_ipc_endpt(endpoint_t *pt) { @@ -29,6 +30,7 @@ int shmctl(int shmid, int cmd, struct shmid_ds *buf) return -1; } + memset(&m, 0, sizeof(m)); m.SHMCTL_ID = shmid; m.SHMCTL_CMD = cmd; m.SHMCTL_BUF = (long) buf; diff --git a/lib/libc/sys-minix/shmget.c b/lib/libc/sys-minix/shmget.c index 968b31c6e..d7924ff3a 100644 --- a/lib/libc/sys-minix/shmget.c +++ b/lib/libc/sys-minix/shmget.c @@ -10,7 +10,7 @@ #include #include #include - +#include #ifdef __weak_alias __weak_alias(shmget, _shmget) @@ -33,6 +33,7 @@ int shmget(key_t key, size_t size, int shmflg) return -1; } + memset(&m, 0, sizeof(m)); m.SHMGET_KEY = key; m.SHMGET_SIZE = size; m.SHMGET_FLAG = shmflg; diff --git a/lib/libc/sys-minix/sigaction.c b/lib/libc/sys-minix/sigaction.c index 2bb96c818..7f006caf1 100644 --- a/lib/libc/sys-minix/sigaction.c +++ b/lib/libc/sys-minix/sigaction.c @@ -2,6 +2,7 @@ #include #include "namespace.h" +#include #include int __sigreturn(void); @@ -10,13 +11,13 @@ int sigaction(int sig, const struct sigaction *act, struct sigaction *oact) { message m; - m.m1_i2 = sig; + memset(&m, 0, sizeof(m)); + m.PM_SIG_NR = sig; + m.PM_SIG_ACT = (char *) __UNCONST(act); + m.PM_SIG_OACT = (char *) oact; + m.PM_SIG_RET = (char *) __sigreturn; - m.m1_p1 = (char *) __UNCONST(act); - m.m1_p2 = (char *) oact; - m.m1_p3 = (char *) __sigreturn; - - return(_syscall(PM_PROC_NR, SIGACTION, &m)); + return(_syscall(PM_PROC_NR, PM_SIGACTION, &m)); } #if defined(__minix) && defined(__weak_alias) diff --git a/lib/libc/sys-minix/sigpending.c b/lib/libc/sys-minix/sigpending.c index e52f5edc5..e561ce826 100644 --- a/lib/libc/sys-minix/sigpending.c +++ b/lib/libc/sys-minix/sigpending.c @@ -2,6 +2,7 @@ #include #include "namespace.h" +#include #include int sigpending(set) @@ -9,8 +10,9 @@ sigset_t *set; { message m; - if (_syscall(PM_PROC_NR, SIGPENDING, &m) < 0) return(-1); - *set = (sigset_t) m.m2_l1; + memset(&m, 0, sizeof(m)); + if (_syscall(PM_PROC_NR, PM_SIGPENDING, &m) < 0) return(-1); + *set = (sigset_t) m.PM_SIG_SET; return(m.m_type); } diff --git a/lib/libc/sys-minix/sigprocmask.c b/lib/libc/sys-minix/sigprocmask.c index 4770e8074..fe6a2c7e2 100644 --- a/lib/libc/sys-minix/sigprocmask.c +++ b/lib/libc/sys-minix/sigprocmask.c @@ -2,6 +2,7 @@ #include #include "namespace.h" +#include #include int sigprocmask(how, set, oset) @@ -11,15 +12,16 @@ sigset_t *oset; { message m; + memset(&m, 0, sizeof(m)); if (set == (sigset_t *) NULL) { - m.m2_i1 = SIG_INQUIRE; - m.m2_l1 = 0; + m.PM_SIG_HOW = SIG_INQUIRE; + m.PM_SIG_SET = 0; } else { - m.m2_i1 = how; - m.m2_l1 = (long) *set; + m.PM_SIG_HOW = how; + m.PM_SIG_SET = (long) *set; } - if (_syscall(PM_PROC_NR, SIGPROCMASK, &m) < 0) return(-1); - if (oset != (sigset_t *) NULL) *oset = (sigset_t) (m.m2_l1); + if (_syscall(PM_PROC_NR, PM_SIGPROCMASK, &m) < 0) return(-1); + if (oset != (sigset_t *) NULL) *oset = (sigset_t) (m.PM_SIG_SET); return(m.m_type); } diff --git a/lib/libc/sys-minix/sigreturn.c b/lib/libc/sys-minix/sigreturn.c index d80cca991..15c56f8d4 100644 --- a/lib/libc/sys-minix/sigreturn.c +++ b/lib/libc/sys-minix/sigreturn.c @@ -2,6 +2,7 @@ #include #include "namespace.h" +#include #include #include @@ -25,8 +26,8 @@ register struct sigcontext *scp; sigfillset(&set); /* splhi */ sigprocmask(SIG_SETMASK, &set, (sigset_t *) NULL); - m.m2_l1 = scp->sc_mask; - m.m2_i2 = scp->sc_flags; - m.m2_p1 = (char *) scp; - return(_syscall(PM_PROC_NR, SIGRETURN, &m)); /* normally this doesn't return */ + memset(&m, 0, sizeof(m)); + m.PM_SIG_SET = scp->sc_mask; + m.PM_SIG_CTX = (char *) scp; + return(_syscall(PM_PROC_NR, PM_SIGRETURN, &m)); /* normally doesn't return */ } diff --git a/lib/libc/sys-minix/sigsuspend.c b/lib/libc/sys-minix/sigsuspend.c index 64a402334..c7c8d7b58 100644 --- a/lib/libc/sys-minix/sigsuspend.c +++ b/lib/libc/sys-minix/sigsuspend.c @@ -2,6 +2,7 @@ #include #include "namespace.h" +#include #include int sigsuspend(set) @@ -9,8 +10,9 @@ const sigset_t *set; { message m; - m.m2_l1 = (long) *set; - return(_syscall(PM_PROC_NR, SIGSUSPEND, &m)); + memset(&m, 0, sizeof(m)); + m.PM_SIG_SET = (long) *set; + return(_syscall(PM_PROC_NR, PM_SIGSUSPEND, &m)); } #if defined(__minix) && defined(__weak_alias) diff --git a/lib/libc/sys-minix/sprofile.c b/lib/libc/sys-minix/sprofile.c index bd9397c28..cfbb9c671 100644 --- a/lib/libc/sys-minix/sprofile.c +++ b/lib/libc/sys-minix/sprofile.c @@ -7,6 +7,7 @@ __weak_alias(sprofile, _sprofile) #endif #include +#include #include int sprofile(int action, @@ -18,6 +19,7 @@ int sprofile(int action, { message m; + memset(&m, 0, sizeof(m)); m.PROF_ACTION = action; m.PROF_MEM_SIZE = size; m.PROF_FREQ = freq; @@ -25,6 +27,6 @@ int sprofile(int action, m.PROF_CTL_PTR = (void *) ctl_ptr; m.PROF_MEM_PTR = (void *) mem_ptr; - return _syscall(PM_PROC_NR, SPROF, &m); + return _syscall(PM_PROC_NR, PM_SPROF, &m); } diff --git a/lib/libc/sys-minix/stat.c b/lib/libc/sys-minix/stat.c index e5c40707a..4daefdfd9 100644 --- a/lib/libc/sys-minix/stat.c +++ b/lib/libc/sys-minix/stat.c @@ -23,11 +23,12 @@ int stat(const char *name, struct stat *buffer) { message m; - m.m1_i1 = strlen(name) + 1; - m.m1_p1 = (char *) __UNCONST(name); - m.m1_p2 = (char *) buffer; + memset(&m, 0, sizeof(m)); + m.VFS_STAT_LEN = strlen(name) + 1; + m.VFS_STAT_NAME = (char *) __UNCONST(name); + m.VFS_STAT_BUF = (char *) buffer; - return _syscall(VFS_PROC_NR, STAT, &m); + return _syscall(VFS_PROC_NR, VFS_STAT, &m); } int _fstat(int fd, struct stat *buffer) { return fstat(fd, buffer); } @@ -36,10 +37,11 @@ int fstat(int fd, struct stat *buffer) { message m; - m.m1_i1 = fd; - m.m1_p1 = (char *) buffer; + memset(&m, 0, sizeof(m)); + m.VFS_FSTAT_FD = fd; + m.VFS_FSTAT_BUF = (char *) buffer; - return _syscall(VFS_PROC_NR, FSTAT, &m); + return _syscall(VFS_PROC_NR, VFS_FSTAT, &m); } int _lstat(const char *name, struct stat *buffer) { return lstat(name, buffer); } @@ -48,9 +50,10 @@ int lstat(const char *name, struct stat *buffer) { message m; - m.m1_i1 = strlen(name) + 1; - m.m1_p1 = (char *) __UNCONST(name); - m.m1_p2 = (char *) buffer; + memset(&m, 0, sizeof(m)); + m.VFS_STAT_LEN = strlen(name) + 1; + m.VFS_STAT_NAME = (char *) __UNCONST(name); + m.VFS_STAT_BUF = (char *) buffer; - return _syscall(VFS_PROC_NR, LSTAT, &m); + return _syscall(VFS_PROC_NR, VFS_LSTAT, &m); } diff --git a/lib/libc/sys-minix/statvfs.c b/lib/libc/sys-minix/statvfs.c index 54c046c54..97a50b851 100644 --- a/lib/libc/sys-minix/statvfs.c +++ b/lib/libc/sys-minix/statvfs.c @@ -14,11 +14,12 @@ int statvfs1(const char *name, struct statvfs *buffer, int flags) { message m; + memset(&m, 0, sizeof(m)); m.VFS_STATVFS1_LEN = strlen(name) + 1; m.VFS_STATVFS1_NAME = (char *) __UNCONST(name); m.VFS_STATVFS1_BUF = (char *) buffer; m.VFS_STATVFS1_FLAGS = flags; - return(_syscall(VFS_PROC_NR, STATVFS1, &m)); + return(_syscall(VFS_PROC_NR, VFS_STATVFS1, &m)); } int statvfs(const char *name, struct statvfs *buffer) diff --git a/lib/libc/sys-minix/stime.c b/lib/libc/sys-minix/stime.c index c2d2323be..1f9d1c653 100644 --- a/lib/libc/sys-minix/stime.c +++ b/lib/libc/sys-minix/stime.c @@ -2,6 +2,7 @@ #include #include "namespace.h" +#include #include #ifdef __weak_alias @@ -12,6 +13,7 @@ int stime(time_t *top) { message m; - m.m2_l1 = (long)*top; - return(_syscall(PM_PROC_NR, STIME, &m)); + memset(&m, 0, sizeof(m)); + m.PM_TIME_SEC = (long)*top; + return(_syscall(PM_PROC_NR, PM_STIME, &m)); } diff --git a/lib/libminlib/svrctl.c b/lib/libc/sys-minix/svrctl.c similarity index 84% rename from lib/libminlib/svrctl.c rename to lib/libc/sys-minix/svrctl.c index e0f43948f..c691ce2dd 100644 --- a/lib/libminlib/svrctl.c +++ b/lib/libc/sys-minix/svrctl.c @@ -3,14 +3,16 @@ */ #include #include +#include #include int svrctl(int request, void *argp) { message m; - m.m2_i1 = request; - m.m2_p1 = argp; + memset(&m, 0, sizeof(m)); + m.SVRCTL_REQ = request; + m.SVRCTL_ARG = argp; switch ((request >> 8) & 0xFF) { case 'M': diff --git a/lib/libc/sys-minix/symlink.c b/lib/libc/sys-minix/symlink.c index 6db8ff81b..845e9bd03 100644 --- a/lib/libc/sys-minix/symlink.c +++ b/lib/libc/sys-minix/symlink.c @@ -13,9 +13,10 @@ int symlink(const char *name, const char *name2) { message m; - m.m1_i1 = strlen(name) + 1; - m.m1_i2 = strlen(name2) + 1; - m.m1_p1 = (char *) __UNCONST(name); - m.m1_p2 = (char *) __UNCONST(name2); - return(_syscall(VFS_PROC_NR, SYMLINK, &m)); + memset(&m, 0, sizeof(m)); + m.VFS_LINK_LEN1 = strlen(name) + 1; + m.VFS_LINK_LEN2 = strlen(name2) + 1; + m.VFS_LINK_NAME1 = (char *) __UNCONST(name); + m.VFS_LINK_NAME2 = (char *) __UNCONST(name2); + return(_syscall(VFS_PROC_NR, VFS_SYMLINK, &m)); } diff --git a/lib/libc/sys-minix/sync.c b/lib/libc/sys-minix/sync.c index 3bf0c3b63..3f425bd95 100644 --- a/lib/libc/sys-minix/sync.c +++ b/lib/libc/sys-minix/sync.c @@ -2,15 +2,18 @@ #include #include "namespace.h" +#include + #ifdef __weak_alias __weak_alias(sync, _sync) #endif #include -void sync() +void sync(void) { message m; - (void)(_syscall(VFS_PROC_NR, SYNC, &m)); + memset(&m, 0, sizeof(m)); + (void)(_syscall(VFS_PROC_NR, VFS_SYNC, &m)); } diff --git a/lib/libc/sys-minix/sysuname.c b/lib/libc/sys-minix/sysuname.c index 142d3bea4..6aa78c1b8 100644 --- a/lib/libc/sys-minix/sysuname.c +++ b/lib/libc/sys-minix/sysuname.c @@ -5,22 +5,20 @@ #include #include "namespace.h" #include +#include #include int sysuname(int req, int field, char *value, size_t len) { message m; - m.m1_i1 = req; - m.m1_i2 = field; - m.m1_i3 = len; - m.m1_p1 = value; + memset(&m, 0, sizeof(m)); + m.PM_SYSUNAME_REQ = req; + m.PM_SYSUNAME_FIELD = field; + m.PM_SYSUNAME_LEN = len; + m.PM_SYSUNAME_VALUE = value; - /* Clear unused fields */ - m.m1_p2 = NULL; - m.m1_p3 = NULL; - - return _syscall(PM_PROC_NR, SYSUNAME, &m); + return _syscall(PM_PROC_NR, PM_SYSUNAME, &m); } /* diff --git a/lib/libc/sys-minix/truncate.c b/lib/libc/sys-minix/truncate.c index 5072a982e..ae18b74a4 100644 --- a/lib/libc/sys-minix/truncate.c +++ b/lib/libc/sys-minix/truncate.c @@ -14,10 +14,11 @@ int truncate(const char *_path, off_t _length) { message m; - m.m2_p1 = (char *) __UNCONST(_path); - m.m2_i1 = strlen(_path)+1; - m.m2_l1 = ex64lo(_length); - m.m2_l2 = ex64hi(_length); + memset(&m, 0, sizeof(m)); + m.VFS_TRUNCATE_NAME = (char *) __UNCONST(_path); + m.VFS_TRUNCATE_LEN = strlen(_path)+1; + m.VFS_TRUNCATE_OFF_LO = ex64lo(_length); + m.VFS_TRUNCATE_OFF_HI = ex64hi(_length); - return(_syscall(VFS_PROC_NR, TRUNCATE, &m)); + return(_syscall(VFS_PROC_NR, VFS_TRUNCATE, &m)); } diff --git a/lib/libc/sys-minix/umask.c b/lib/libc/sys-minix/umask.c index e9cd43f4c..dce334e27 100644 --- a/lib/libc/sys-minix/umask.c +++ b/lib/libc/sys-minix/umask.c @@ -2,6 +2,7 @@ #include #include "namespace.h" +#include #include #ifdef __weak_alias @@ -12,6 +13,7 @@ mode_t umask(mode_t complmode) { message m; - m.m1_i1 = complmode; - return( (mode_t) _syscall(VFS_PROC_NR, UMASK, &m)); + memset(&m, 0, sizeof(m)); + m.VFS_UMASK_MASK = complmode; + return( (mode_t) _syscall(VFS_PROC_NR, VFS_UMASK, &m)); } diff --git a/lib/libc/sys-minix/unlink.c b/lib/libc/sys-minix/unlink.c index a8cbed13a..000a29ece 100644 --- a/lib/libc/sys-minix/unlink.c +++ b/lib/libc/sys-minix/unlink.c @@ -2,6 +2,7 @@ #include #include "namespace.h" +#include #include #ifdef __weak_alias @@ -13,6 +14,7 @@ const char *name; { message m; + memset(&m, 0, sizeof(m)); _loadname(name, &m); - return(_syscall(VFS_PROC_NR, UNLINK, &m)); + return(_syscall(VFS_PROC_NR, VFS_UNLINK, &m)); } diff --git a/lib/libc/sys-minix/utimensat.c b/lib/libc/sys-minix/utimensat.c index 26a1aa877..f7eeca04c 100644 --- a/lib/libc/sys-minix/utimensat.c +++ b/lib/libc/sys-minix/utimensat.c @@ -25,19 +25,32 @@ int utimensat(int fd, const char *name, const struct timespec tv[2], if (tv == NULL) tv = now; - if (name == NULL) return EINVAL; - if (name[0] == '\0') return ENOENT; /* POSIX requirement */ - if (fd != AT_FDCWD && name[0] != '/') return EINVAL; /* Not supported */ - m.m2_i1 = strlen(name) + 1; - m.m2_p1 = (char *) __UNCONST(name); - m.m2_l1 = tv[0].tv_sec; - m.m2_l2 = tv[1].tv_sec; - m.m2_i2 = tv[0].tv_nsec; - m.m2_i3 = tv[1].tv_nsec; - if ((unsigned)flags > SHRT_MAX) - return EINVAL; - else - m.m2_s1 = flags; + if (name == NULL) { + errno = EINVAL; + return -1; + } + if (name[0] == '\0') { /* POSIX requirement */ + errno = ENOENT; + return -1; + } + if (fd != AT_FDCWD && name[0] != '/') { /* Not supported */ + errno = EINVAL; + return -1; + } - return(_syscall(VFS_PROC_NR, UTIMENS, &m)); + if ((unsigned)flags > SHRT_MAX) { + errno = EINVAL; + return -1; + } + + memset(&m, 0, sizeof(m)); + m.VFS_UTIMENS_LEN = strlen(name) + 1; + m.VFS_UTIMENS_NAME = (char *) __UNCONST(name); + m.VFS_UTIMENS_ATIME = tv[0].tv_sec; + m.VFS_UTIMENS_MTIME = tv[1].tv_sec; + m.VFS_UTIMENS_ANSEC = tv[0].tv_nsec; + m.VFS_UTIMENS_MNSEC = tv[1].tv_nsec; + m.VFS_UTIMENS_FLAGS = flags; + + return(_syscall(VFS_PROC_NR, VFS_UTIMENS, &m)); } diff --git a/lib/libc/sys-minix/utimes.c b/lib/libc/sys-minix/utimes.c index 3e8c16f73..db3005b38 100644 --- a/lib/libc/sys-minix/utimes.c +++ b/lib/libc/sys-minix/utimes.c @@ -15,21 +15,28 @@ int utimes(const char *name, const struct timeval tv[2]) { message m; - if (name == NULL) return EINVAL; - if (name[0] == '\0') return ENOENT; /* X/Open requirement */ - m.m2_i1 = strlen(name) + 1; - m.m2_p1 = (char *) __UNCONST(name); + if (name == NULL) { + errno = EINVAL; + return -1; + } + if (name[0] == '\0') { /* X/Open requirement */ + errno = ENOENT; + return -1; + } + memset(&m, 0, sizeof(m)); + m.VFS_UTIMENS_LEN = strlen(name) + 1; + m.VFS_UTIMENS_NAME = (char *) __UNCONST(name); if (tv == NULL) { - m.m2_l1 = m.m2_l2 = 0; - m.m2_i2 = m.m2_i3 = UTIME_NOW; + m.VFS_UTIMENS_ATIME = m.VFS_UTIMENS_MTIME = 0; + m.VFS_UTIMENS_ANSEC = m.VFS_UTIMENS_MNSEC = UTIME_NOW; } else { - m.m2_l1 = tv[0].tv_sec; - m.m2_l2 = tv[1].tv_sec; - m.m2_i2 = tv[0].tv_usec * 1000; - m.m2_i3 = tv[1].tv_usec * 1000; + m.VFS_UTIMENS_ATIME = tv[0].tv_sec; + m.VFS_UTIMENS_MTIME = tv[1].tv_sec; + m.VFS_UTIMENS_ANSEC = tv[0].tv_usec * 1000; + m.VFS_UTIMENS_MNSEC = tv[1].tv_usec * 1000; } - m.m2_s1 = 0; + m.VFS_UTIMENS_FLAGS = 0; - return(_syscall(VFS_PROC_NR, UTIMENS, &m)); + return(_syscall(VFS_PROC_NR, VFS_UTIMENS, &m)); } diff --git a/lib/libc/sys-minix/vfork.c b/lib/libc/sys-minix/vfork.c index bd489864a..9a3523b36 100644 --- a/lib/libc/sys-minix/vfork.c +++ b/lib/libc/sys-minix/vfork.c @@ -2,15 +2,17 @@ #include "namespace.h" #include +#include #include #ifdef __weak_alias __weak_alias(vfork, __vfork14) #endif -pid_t vfork() +pid_t vfork(void) { message m; - return(_syscall(PM_PROC_NR, FORK, &m)); + memset(&m, 0, sizeof(m)); + return(_syscall(PM_PROC_NR, PM_FORK, &m)); } diff --git a/lib/libc/sys-minix/write.c b/lib/libc/sys-minix/write.c index ce5d844dc..154b05f6a 100644 --- a/lib/libc/sys-minix/write.c +++ b/lib/libc/sys-minix/write.c @@ -2,6 +2,7 @@ #include #include "namespace.h" +#include #include #ifdef __weak_alias @@ -12,9 +13,10 @@ ssize_t write(int fd, const void *buffer, size_t nbytes) { message m; - m.m1_i1 = fd; - m.m1_i2 = nbytes; - m.m1_p1 = (char *) __UNCONST(buffer); - return(_syscall(VFS_PROC_NR, WRITE, &m)); + memset(&m, 0, sizeof(m)); + m.VFS_READWRITE_FD = fd; + m.VFS_READWRITE_LEN = nbytes; + m.VFS_READWRITE_BUF = (char *) __UNCONST(buffer); + return(_syscall(VFS_PROC_NR, VFS_WRITE, &m)); } diff --git a/lib/libexec/exec_general.c b/lib/libexec/exec_general.c index 3a38516b9..66bc57b6d 100644 --- a/lib/libexec/exec_general.c +++ b/lib/libexec/exec_general.c @@ -80,12 +80,13 @@ int libexec_pm_newexec(endpoint_t proc_e, struct exec_info *e) int r; message m; - m.m_type = PM_NEWEXEC; - m.EXC_NM_PROC = proc_e; - m.EXC_NM_PTR = (char *)e; + memset(&m, 0, sizeof(m)); + m.m_type = PM_EXEC_NEW; + m.PM_EXEC_NEW_ENDPT = proc_e; + m.PM_EXEC_NEW_PTR = (char *)e; if ((r = sendrec(PM_PROC_NR, &m)) != OK) return(r); - e->allow_setuid = !!(m.m1_i2 & EXC_NM_RF_ALLOW_SETUID); + e->allow_setuid = !!m.PM_EXEC_NEW_SUID; return(m.m_type); } diff --git a/lib/libminlib/Makefile b/lib/libminlib/Makefile index 3199a04ef..102984a97 100644 --- a/lib/libminlib/Makefile +++ b/lib/libminlib/Makefile @@ -21,9 +21,6 @@ SRCS+= gcov.c gcov_flush.c # Various utils SRCS+= itoa.c u64util.c read_tsc_64.c -# svrctl -SRCS+= svrctl.c - # servxcheck SRCS+= servxcheck.c diff --git a/lib/libminlib/gcov.c b/lib/libminlib/gcov.c index 5ce8a3996..49f868656 100644 --- a/lib/libminlib/gcov.c +++ b/lib/libminlib/gcov.c @@ -4,22 +4,6 @@ #include -int gcov_flush_svr(char *buff, int buff_sz, int server_nr) -{ - message msg; - - msg.GCOV_BUFF_P = buff; - msg.GCOV_BUFF_SZ = buff_sz; - msg.GCOV_PID = server_nr; - - /* Make the call to server. It will call the gcov library, - * buffer the stdio requests, and copy the buffer to this user - * space - */ - return _syscall(VFS_PROC_NR, GCOV_FLUSH, &msg); -} - - /* wrappers for file system calls from gcc libgcov library. Default calls are wrapped. In libsys, an alternative implementation for servers is used. diff --git a/lib/libsys/Makefile b/lib/libsys/Makefile index 73678e198..4827ae746 100644 --- a/lib/libsys/Makefile +++ b/lib/libsys/Makefile @@ -85,7 +85,6 @@ SRCS+= \ taskcall.c \ tickdelay.c \ timers.c \ - vm_brk.c \ vm_cache.c \ vm_exit.c \ vm_fork.c \ diff --git a/lib/libsys/copyfd.c b/lib/libsys/copyfd.c index 70cb9ca03..16960adf0 100644 --- a/lib/libsys/copyfd.c +++ b/lib/libsys/copyfd.c @@ -12,5 +12,5 @@ copyfd(endpoint_t endpt, int fd, int what) m.VFS_COPYFD_FD = fd; m.VFS_COPYFD_WHAT = what; - return _taskcall(VFS_PROC_NR, COPYFD, &m); + return _taskcall(VFS_PROC_NR, VFS_COPYFD, &m); } diff --git a/lib/libsys/getepinfo.c b/lib/libsys/getepinfo.c index fda0a1b46..9e594c92c 100644 --- a/lib/libsys/getepinfo.c +++ b/lib/libsys/getepinfo.c @@ -13,7 +13,7 @@ getepinfo(endpoint_t proc_ep, uid_t *uid, gid_t *gid) memset(&m, 0, sizeof(m)); m.PM_GETEPINFO_ENDPT = proc_ep; - if ((r = _taskcall(PM_PROC_NR, GETEPINFO, &m)) < 0) + if ((r = _taskcall(PM_PROC_NR, PM_GETEPINFO, &m)) < 0) return r; if (uid != NULL) diff --git a/lib/libsys/getprocnr.c b/lib/libsys/getprocnr.c index 92f1badd4..2750aed30 100644 --- a/lib/libsys/getprocnr.c +++ b/lib/libsys/getprocnr.c @@ -11,7 +11,7 @@ getprocnr(pid_t pid, endpoint_t *proc_e) memset(&m, 0, sizeof(m)); m.PM_GETPROCNR_PID = pid; - if ((r = _taskcall(PM_PROC_NR, GETPROCNR, &m)) < 0) + if ((r = _taskcall(PM_PROC_NR, PM_GETPROCNR, &m)) < 0) return r; *proc_e = m.PM_GETPROCNR_ENDPT; diff --git a/lib/libsys/mapdriver.c b/lib/libsys/mapdriver.c index f7a219ba3..e86756088 100644 --- a/lib/libsys/mapdriver.c +++ b/lib/libsys/mapdriver.c @@ -13,5 +13,5 @@ mapdriver(char *label, devmajor_t major) m.VFS_MAPDRIVER_LABELLEN = strlen(label) + 1; m.VFS_MAPDRIVER_MAJOR = major; - return _taskcall(VFS_PROC_NR, MAPDRIVER, &m); + return _taskcall(VFS_PROC_NR, VFS_MAPDRIVER, &m); } diff --git a/lib/libsys/sef.c b/lib/libsys/sef.c index 24ffdf522..fd009bd21 100644 --- a/lib/libsys/sef.c +++ b/lib/libsys/sef.c @@ -231,8 +231,9 @@ void sef_exit(int status) sys_exit(); /* If sys_exit() fails, this is not a system service. Exit through PM. */ - m.m1_i1 = status; - _syscall(PM_PROC_NR, EXIT, &m); + memset(&m, 0, sizeof(m)); + m.PM_EXIT_STATUS = status; + _syscall(PM_PROC_NR, PM_EXIT, &m); /* If everything else fails, hang. */ printf("Warning: system service %d couldn't exit\n", sef_self_endpoint); diff --git a/lib/libsys/srv_fork.c b/lib/libsys/srv_fork.c index 67c40cecb..2ba69378b 100644 --- a/lib/libsys/srv_fork.c +++ b/lib/libsys/srv_fork.c @@ -8,7 +8,7 @@ srv_fork(uid_t reuid, gid_t regid) message m; memset(&m, 0, sizeof(m)); - m.m1_i1 = (int) reuid; - m.m1_i2 = (int) regid; - return _taskcall(PM_PROC_NR, SRV_FORK, &m); + m.PM_SRV_FORK_UID = (int) reuid; + m.PM_SRV_FORK_GID = (int) regid; + return _taskcall(PM_PROC_NR, PM_SRV_FORK, &m); } diff --git a/lib/libsys/srv_kill.c b/lib/libsys/srv_kill.c index 540f87cc3..c4287cf57 100644 --- a/lib/libsys/srv_kill.c +++ b/lib/libsys/srv_kill.c @@ -8,7 +8,7 @@ srv_kill(pid_t pid, int sig) message m; memset(&m, 0, sizeof(m)); - m.m1_i1 = pid; - m.m1_i2 = sig; - return _taskcall(PM_PROC_NR, SRV_KILL, &m); + m.PM_SIG_PID = pid; + m.PM_SIG_NR = sig; + return _taskcall(PM_PROC_NR, PM_SRV_KILL, &m); } diff --git a/lib/libsys/vm_brk.c b/lib/libsys/vm_brk.c deleted file mode 100644 index 67808fe07..000000000 --- a/lib/libsys/vm_brk.c +++ /dev/null @@ -1,20 +0,0 @@ - -#include "syslib.h" - -#include -#include - -/*===========================================================================* - * vm_brk * - *===========================================================================*/ -int vm_brk(endpoint_t ep, char *addr) -{ - message m; - - memset(&m, 0, sizeof(m)); - m.VMB_ENDPOINT = ep; - m.VMB_ADDR = (void *) addr; - - return _taskcall(VM_PROC_NR, VM_BRK, &m); -} - diff --git a/servers/pm/Makefile b/servers/pm/Makefile index 282c89f8c..3bfe93751 100644 --- a/servers/pm/Makefile +++ b/servers/pm/Makefile @@ -2,7 +2,7 @@ # Makefile for Process Manager (PM) PROG= pm -SRCS= main.c forkexit.c break.c exec.c time.c alarm.c \ +SRCS= main.c forkexit.c exec.c time.c alarm.c \ signal.c utility.c table.c trace.c getset.c misc.c \ profile.c mcontext.c schedule.c diff --git a/servers/pm/alarm.c b/servers/pm/alarm.c index 94758644f..93f1e93e7 100644 --- a/servers/pm/alarm.c +++ b/servers/pm/alarm.c @@ -12,8 +12,8 @@ #include #include #include +#include #include "mproc.h" -#include "param.h" #define US 1000000UL /* shortcut for microseconds per second */ @@ -92,18 +92,18 @@ int do_itimer() { struct itimerval ovalue, value; /* old and new interval timers */ int setval, getval; /* set and/or retrieve the values? */ - int r; + int r, which; /* Make sure 'which' is one of the defined timers. */ - if (m_in.which_timer < 0 || m_in.which_timer >= NR_ITIMERS) - return(EINVAL); + which = m_in.PM_ITIMER_WHICH; + if (which < 0 || which >= NR_ITIMERS) return(EINVAL); /* Determine whether to set and/or return the given timer value, based on - * which of the new_val and old_val parameters are nonzero. At least one of + * which of the value and ovalue parameters are nonzero. At least one of * them must be nonzero. */ - setval = (m_in.new_val != NULL); - getval = (m_in.old_val != NULL); + setval = (m_in.PM_ITIMER_VALUE != NULL); + getval = (m_in.PM_ITIMER_OVALUE != NULL); if (!setval && !getval) return(EINVAL); @@ -111,8 +111,8 @@ int do_itimer() * Also, make sure its fields have sane values. */ if (setval) { - r = sys_datacopy(who_e, (vir_bytes) m_in.new_val, - PM_PROC_NR, (vir_bytes) &value, (phys_bytes) sizeof(value)); + r = sys_datacopy(who_e, (vir_bytes) m_in.PM_ITIMER_VALUE, + PM_PROC_NR, (vir_bytes) &value, (phys_bytes) sizeof(value)); if (r != OK) return(r); if (!is_sane_timeval(&value.it_value) || @@ -120,7 +120,7 @@ int do_itimer() return(EINVAL); } - switch (m_in.which_timer) { + switch (which) { case ITIMER_REAL : if (getval) get_realtimer(mp, &ovalue); @@ -131,21 +131,21 @@ int do_itimer() case ITIMER_VIRTUAL : case ITIMER_PROF : - getset_vtimer(mp, m_in.which_timer, - (setval) ? &value : NULL, - (getval) ? &ovalue : NULL); + getset_vtimer(mp, which, (setval) ? &value : NULL, + (getval) ? &ovalue : NULL); r = OK; break; default: - panic("invalid timer type: %d", m_in.which_timer); + panic("invalid timer type: %d", which); } /* If requested, copy the old interval timer to user space. */ if (r == OK && getval) { - r = sys_datacopy(PM_PROC_NR, (vir_bytes) &ovalue, - who_e, (vir_bytes) m_in.old_val, (phys_bytes) sizeof(ovalue)); + r = sys_datacopy(PM_PROC_NR, (vir_bytes) &ovalue, + who_e, (vir_bytes) m_in.PM_ITIMER_OVALUE, + (phys_bytes) sizeof(ovalue)); } return(r); diff --git a/servers/pm/break.c b/servers/pm/break.c deleted file mode 100644 index 9a1a04c35..000000000 --- a/servers/pm/break.c +++ /dev/null @@ -1,20 +0,0 @@ - -#include "pm.h" -#include "param.h" -#include "glo.h" -#include "mproc.h" - -#include - -/*===========================================================================* - * do_brk * - *===========================================================================*/ -int do_brk() -{ - int r; -/* Entry point to brk(addr) system call. */ - r = vm_brk(mp->mp_endpoint, m_in.PMBRK_ADDR); - mp->mp_reply.reply_ptr = (r == OK ? m_in.PMBRK_ADDR : (char *) -1); - return r; -} - diff --git a/servers/pm/exec.c b/servers/pm/exec.c index a62b9ba39..1c4af3099 100644 --- a/servers/pm/exec.c +++ b/servers/pm/exec.c @@ -27,7 +27,6 @@ #include #include #include "mproc.h" -#include "param.h" #define ESCRIPT (-2000) /* Returned by read_header for a #! script. */ #define PTRSIZE sizeof(char *) /* Size of pointers in argv[] and envp[]. */ @@ -43,12 +42,11 @@ int do_exec() memset(&m, 0, sizeof(m)); m.m_type = VFS_PM_EXEC; m.VFS_PM_ENDPT = mp->mp_endpoint; - m.VFS_PM_PATH = m_in.exec_name; - m.VFS_PM_PATH_LEN = m_in.exec_len; - m.VFS_PM_FRAME = m_in.frame_ptr; - m.VFS_PM_FRAME_LEN = m_in.msg_frame_len; - m.VFS_PM_EXECFLAGS = m_in.PMEXEC_FLAGS; - m.VFS_PM_PS_STR = (vir_bytes) m_in.m1_p4; /* strings ptr into frame */ + m.VFS_PM_PATH = m_in.PM_EXEC_NAME; + m.VFS_PM_PATH_LEN = m_in.PM_EXEC_NAMELEN; + m.VFS_PM_FRAME = m_in.PM_EXEC_FRAME; + m.VFS_PM_FRAME_LEN = m_in.PM_EXEC_FRAMELEN; + m.VFS_PM_PS_STR = (vir_bytes) m_in.PM_EXEC_PS_STR; tell_vfs(mp, &m); @@ -66,17 +64,17 @@ int do_newexec(void) char *ptr; struct mproc *rmp; struct exec_info args; - int r, flags = 0; + int r; if (who_e != VFS_PROC_NR && who_e != RS_PROC_NR) return EPERM; - proc_e= m_in.EXC_NM_PROC; + proc_e= m_in.PM_EXEC_NEW_ENDPT; if (pm_isokendpt(proc_e, &proc_n) != OK) { panic("do_newexec: got bad endpoint: %d", proc_e); } rmp= &mproc[proc_n]; - ptr= m_in.EXC_NM_PTR; + ptr= m_in.PM_EXEC_NEW_PTR; r= sys_datacopy(who_e, (vir_bytes)ptr, SELF, (vir_bytes)&args, sizeof(args)); if (r != OK) @@ -117,10 +115,7 @@ int do_newexec(void) /* Kill process if something goes wrong after this point. */ rmp->mp_flags |= PARTIAL_EXEC; - mp->mp_reply.reply_res2= (vir_bytes) rmp->mp_frame_addr; - mp->mp_reply.reply_res3= flags; - if (allow_setuid && args.allow_setuid) - mp->mp_reply.reply_res3 |= EXC_NM_RF_ALLOW_SETUID; + mp->mp_reply.PM_EXEC_NEW_SUID = (allow_setuid && args.allow_setuid); return r; } @@ -137,21 +132,20 @@ int do_execrestart(void) if (who_e != RS_PROC_NR) return EPERM; - proc_e = m_in.EXC_RS_PROC; + proc_e = m_in.PM_EXEC_RESTART_ENDPT; if (pm_isokendpt(proc_e, &proc_n) != OK) { panic("do_execrestart: got bad endpoint: %d", proc_e); } rmp = &mproc[proc_n]; - result = m_in.EXC_RS_RESULT; - pc = (vir_bytes)m_in.EXC_RS_PC; - ps_str = (vir_bytes)m_in.EXC_RS_PS_STR; + result = m_in.PM_EXEC_RESTART_RESULT; + pc = (vir_bytes)m_in.PM_EXEC_RESTART_PC; + ps_str = (vir_bytes)m_in.PM_EXEC_RESTART_PS_STR; exec_restart(rmp, result, pc, rmp->mp_frame_addr, ps_str); return OK; } - /*===========================================================================* * exec_restart * *===========================================================================*/ diff --git a/servers/pm/forkexit.c b/servers/pm/forkexit.c index f697c8bc0..0aa2cabab 100644 --- a/servers/pm/forkexit.c +++ b/servers/pm/forkexit.c @@ -1,10 +1,11 @@ /* This file deals with creating processes (via FORK) and deleting them (via - * EXIT/WAIT). When a process forks, a new slot in the 'mproc' table is + * EXIT/WAITPID). When a process forks, a new slot in the 'mproc' table is * allocated for it, and a copy of the parent's core image is made for the * child. Then the kernel and file system are informed. A process is removed * from the 'mproc' table when two events have occurred: (1) it has exited or - * been killed by a signal, and (2) the parent has done a WAIT. If the process - * exits first, it continues to occupy a slot until the parent does a WAIT. + * been killed by a signal, and (2) the parent has done a WAITPID. If the + * process exits first, it continues to occupy a slot until the parent does a + * WAITPID. * * The entry points into this file are: * do_fork: perform the FORK system call @@ -12,7 +13,7 @@ * do_exit: perform the EXIT system call (by calling exit_proc()) * exit_proc: actually do the exiting, and tell VFS about it * exit_restart: continue exiting a process after VFS has replied - * do_waitpid: perform the WAITPID or WAIT system call + * do_waitpid: perform the WAITPID system call * wait_test: check whether a parent is waiting for a child */ @@ -27,7 +28,6 @@ #include #include #include "mproc.h" -#include "param.h" #define LAST_FEW 2 /* last few slots reserved for superuser */ @@ -194,10 +194,10 @@ int do_srv_fork() rmc->mp_exitstatus = 0; rmc->mp_sigstatus = 0; rmc->mp_endpoint = child_ep; /* passed back by VM */ - rmc->mp_realuid = (uid_t) m_in.m1_i1; - rmc->mp_effuid = (uid_t) m_in.m1_i1; - rmc->mp_realgid = (uid_t) m_in.m1_i2; - rmc->mp_effgid = (uid_t) m_in.m1_i2; + rmc->mp_realuid = (uid_t) m_in.PM_SRV_FORK_UID; + rmc->mp_effuid = (uid_t) m_in.PM_SRV_FORK_UID; + rmc->mp_realgid = (uid_t) m_in.PM_SRV_FORK_GID; + rmc->mp_effgid = (uid_t) m_in.PM_SRV_FORK_GID; for (i = 0; i < NR_ITIMERS; i++) rmc->mp_interval[i] = 0; /* reset timer intervals */ @@ -210,8 +210,8 @@ int do_srv_fork() m.VFS_PM_ENDPT = rmc->mp_endpoint; m.VFS_PM_PENDPT = rmp->mp_endpoint; m.VFS_PM_CPID = rmc->mp_pid; - m.VFS_PM_REUID = m_in.m1_i1; - m.VFS_PM_REGID = m_in.m1_i2; + m.VFS_PM_REUID = m_in.PM_SRV_FORK_UID; + m.VFS_PM_REGID = m_in.PM_SRV_FORK_GID; tell_vfs(rmc, &m); @@ -241,7 +241,7 @@ int do_exit() sys_kill(mp->mp_endpoint, SIGKILL); } else { - exit_proc(mp, m_in.status, FALSE /*dump_core*/); + exit_proc(mp, m_in.PM_EXIT_STATUS, FALSE /*dump_core*/); } return(SUSPEND); /* can't communicate from beyond the grave */ } @@ -437,7 +437,7 @@ int dump_core; /* flag indicating whether to dump core */ if (rmp->mp_flags & TRACE_EXIT) { /* Wake up the tracer, completing the ptrace(T_EXIT) call */ - mproc[rmp->mp_tracer].mp_reply.reply_trace = 0; + mproc[rmp->mp_tracer].mp_reply.PM_PTRACE_DATA = 0; reply(rmp->mp_tracer, OK); } @@ -452,20 +452,19 @@ int dump_core; /* flag indicating whether to dump core */ int do_waitpid() { /* A process wants to wait for a child to terminate. If a child is already - * waiting, go clean it up and let this WAIT call terminate. Otherwise, + * waiting, go clean it up and let this WAITPID call terminate. Otherwise, * really wait. - * A process calling WAIT never gets a reply in the usual way at the end + * A process calling WAITPID never gets a reply in the usual way at the end * of the main loop (unless WNOHANG is set or no qualifying child exists). * If a child has already exited, the routine tell_parent() sends the reply * to awaken the caller. - * Both WAIT and WAITPID are handled by this code. */ register struct mproc *rp; int i, pidarg, options, children; - /* Set internal variables, depending on whether this is WAIT or WAITPID. */ - pidarg = (call_nr == WAIT ? -1 : m_in.pid); /* 1st param of waitpid */ - options = (call_nr == WAIT ? 0 : m_in.sig_nr); /* 3rd param of waitpid */ + /* Set internal variables. */ + pidarg = m_in.PM_WAITPID_PID; /* 1st param */ + options = m_in.PM_WAITPID_OPTIONS; /* 3rd param */ if (pidarg == 0) pidarg = -mp->mp_procgrp; /* pidarg < 0 ==> proc grp */ /* Is there a child waiting to be collected? At this point, pidarg != 0: @@ -500,7 +499,7 @@ int do_waitpid() if (sigismember(&rp->mp_sigtrace, i)) { sigdelset(&rp->mp_sigtrace, i); - mp->mp_reply.reply_res2 = + mp->mp_reply.PM_WAITPID_STATUS = 0177 | (i << 8); return(rp->mp_pid); } @@ -636,7 +635,7 @@ int try_cleanup; /* clean up the child when done? */ static void tell_parent(child) register struct mproc *child; /* tells which process is exiting */ { - int exitstatus, mp_parent; + int mp_parent; struct mproc *parent; mp_parent= child->mp_parent; @@ -649,8 +648,8 @@ register struct mproc *child; /* tells which process is exiting */ parent = &mproc[mp_parent]; /* Wake up the parent by sending the reply message. */ - exitstatus = (child->mp_exitstatus << 8) | (child->mp_sigstatus & 0377); - parent->mp_reply.reply_res2 = exitstatus; + parent->mp_reply.PM_WAITPID_STATUS = + (child->mp_exitstatus << 8) | (child->mp_sigstatus & 0377); reply(child->mp_parent, child->mp_pid); parent->mp_flags &= ~WAITING; /* parent no longer waiting */ child->mp_flags &= ~ZOMBIE; /* child no longer a zombie */ @@ -673,8 +672,8 @@ struct mproc *child; /* tells which process is exiting */ panic("tell_tracer: child not a zombie"); tracer = &mproc[mp_tracer]; - exitstatus = (child->mp_exitstatus << 8) | (child->mp_sigstatus & 0377); - tracer->mp_reply.reply_res2 = exitstatus; + tracer->mp_reply.PM_WAITPID_STATUS = + (child->mp_exitstatus << 8) | (child->mp_sigstatus & 0377); reply(child->mp_tracer, child->mp_pid); tracer->mp_flags &= ~WAITING; /* tracer no longer waiting */ child->mp_flags &= ~TRACE_ZOMBIE; /* child no longer zombie to tracer */ diff --git a/servers/pm/getset.c b/servers/pm/getset.c index f97c90936..347213ebc 100644 --- a/servers/pm/getset.c +++ b/servers/pm/getset.c @@ -11,24 +11,22 @@ #include #include #include "mproc.h" -#include "param.h" /*===========================================================================* * do_get * *===========================================================================*/ int do_get() { -/* Handle GETUID, GETGID, GETGROUPS, MINIX_GETPID, GETPGRP, GETSID, - ISSETUGID. +/* Handle PM_GETUID, PM_GETGID, PM_GETGROUPS, PM_GETPID, PM_GETPGRP, PM_GETSID, + * PM_ISSETUGID. */ - register struct mproc *rmp = mp; int r; int ngroups; switch(call_nr) { - case GETGROUPS: - ngroups = m_in.grp_no; + case PM_GETGROUPS: + ngroups = m_in.PM_GROUPS_NUM; if (ngroups > NGROUPS_MAX || ngroups < 0) return(EINVAL); @@ -42,29 +40,30 @@ int do_get() return(EINVAL); r = sys_datacopy(SELF, (vir_bytes) rmp->mp_sgroups, who_e, - (vir_bytes) m_in.groupsp, ngroups * sizeof(gid_t)); + (vir_bytes) m_in.PM_GROUPS_PTR, + ngroups * sizeof(gid_t)); if (r != OK) return(r); r = rmp->mp_ngroups; break; - case GETUID: + case PM_GETUID: r = rmp->mp_realuid; - rmp->mp_reply.reply_res2 = rmp->mp_effuid; + rmp->mp_reply.PM_GETUID_EUID = rmp->mp_effuid; break; - case GETGID: + case PM_GETGID: r = rmp->mp_realgid; - rmp->mp_reply.reply_res2 = rmp->mp_effgid; + rmp->mp_reply.PM_GETGID_EGID = rmp->mp_effgid; break; - case MINIX_GETPID: + case PM_GETPID: r = mproc[who_p].mp_pid; - rmp->mp_reply.reply_res2 = mproc[rmp->mp_parent].mp_pid; + rmp->mp_reply.PM_GETPID_PARENT = mproc[rmp->mp_parent].mp_pid; break; - case GETPGRP: + case PM_GETPGRP: r = rmp->mp_procgrp; break; @@ -78,7 +77,7 @@ int do_get() r = target->mp_procgrp; break; } - case ISSETUGID: + case PM_ISSETUGID: r = !!(rmp->mp_flags & TAINTED); break; @@ -94,24 +93,27 @@ int do_get() *===========================================================================*/ int do_set() { -/* Handle SETUID, SETEUID, SETGID, SETGROUPS, SETEGID, and SETSID. These calls - * have in common that, if successful, they will be forwarded to VFS as well. +/* Handle PM_SETUID, PM_SETEUID, PM_SETGID, PM_SETGROUPS, PM_SETEGID, and + * SETSID. These calls have in common that, if successful, they will be + * forwarded to VFS as well. */ register struct mproc *rmp = mp; message m; int r, i; int ngroups; + uid_t uid; + gid_t gid; memset(&m, 0, sizeof(m)); switch(call_nr) { - case SETUID: - case SETEUID: - if (rmp->mp_realuid != (uid_t) m_in.usr_id && - rmp->mp_effuid != SUPER_USER) + case PM_SETUID: + case PM_SETEUID: + uid = (uid_t) m_in.PM_SETUID_UID; + if (rmp->mp_realuid != uid && rmp->mp_effuid != SUPER_USER) return(EPERM); - if(call_nr == SETUID) rmp->mp_realuid = (uid_t) m_in.usr_id; - rmp->mp_effuid = (uid_t) m_in.usr_id; + if(call_nr == PM_SETUID) rmp->mp_realuid = uid; + rmp->mp_effuid = uid; m.m_type = VFS_PM_SETUID; m.VFS_PM_ENDPT = rmp->mp_endpoint; @@ -120,13 +122,13 @@ int do_set() break; - case SETGID: - case SETEGID: - if (rmp->mp_realgid != (gid_t) m_in.grp_id && - rmp->mp_effuid != SUPER_USER) + case PM_SETGID: + case PM_SETEGID: + gid = (gid_t) m_in.PM_SETGID_GID; + if (rmp->mp_realgid != gid && rmp->mp_effuid != SUPER_USER) return(EPERM); - if(call_nr == SETGID) rmp->mp_realgid = (gid_t) m_in.grp_id; - rmp->mp_effgid = (gid_t) m_in.grp_id; + if(call_nr == PM_SETGID) rmp->mp_realgid = gid; + rmp->mp_effgid = gid; m.m_type = VFS_PM_SETGID; m.VFS_PM_ENDPT = rmp->mp_endpoint; @@ -134,19 +136,19 @@ int do_set() m.VFS_PM_RID = rmp->mp_realgid; break; - case SETGROUPS: + case PM_SETGROUPS: if (rmp->mp_effuid != SUPER_USER) return(EPERM); - ngroups = m_in.grp_no; + ngroups = m_in.PM_GROUPS_NUM; if (ngroups > NGROUPS_MAX || ngroups < 0) return(EINVAL); - if (m_in.grp_no > 0 && m_in.groupsp == NULL) + if (ngroups > 0 && m_in.PM_GROUPS_PTR == NULL) return(EFAULT); - r = sys_datacopy(who_e, (vir_bytes) m_in.groupsp, SELF, + r = sys_datacopy(who_e, (vir_bytes) m_in.PM_GROUPS_PTR, SELF, (vir_bytes) rmp->mp_sgroups, ngroups * sizeof(gid_t)); if (r != OK) @@ -167,7 +169,7 @@ int do_set() m.VFS_PM_GROUP_ADDR = (char *) rmp->mp_sgroups; break; - case SETSID: + case PM_SETSID: if (rmp->mp_procgrp == rmp->mp_pid) return(EPERM); rmp->mp_procgrp = rmp->mp_pid; diff --git a/servers/pm/glo.h b/servers/pm/glo.h index a27079b82..39720a573 100644 --- a/servers/pm/glo.h +++ b/servers/pm/glo.h @@ -17,7 +17,7 @@ EXTERN message m_in; /* the incoming message itself is kept here. */ EXTERN int who_p, who_e; /* caller's proc number, endpoint */ EXTERN int call_nr; /* system call number */ -extern int(*call_vec[]) (void); +extern int (* const call_vec[])(void); EXTERN sigset_t core_sset; /* which signals cause core images */ EXTERN sigset_t ign_sset; /* which signals are by default ignored */ EXTERN sigset_t noign_sset; /* which signals cannot be ignored */ diff --git a/servers/pm/main.c b/servers/pm/main.c index 3f05cee68..25de057d9 100644 --- a/servers/pm/main.c +++ b/servers/pm/main.c @@ -27,22 +27,18 @@ #include #include #include "mproc.h" -#include "param.h" #include "kernel/const.h" #include "kernel/config.h" #include "kernel/proc.h" #if ENABLE_SYSCALL_STATS -EXTERN unsigned long calls_stats[NCALLS]; +EXTERN unsigned long calls_stats[NR_PM_CALLS]; #endif static int get_nice_value(int queue); static void handle_vfs_reply(void); -#define click_to_round_k(n) \ - ((unsigned) ((((unsigned long) (n) << CLICK_SHIFT) + 512) / 1024)) - /* SEF functions and variables. */ static void sef_local_startup(void); static int sef_cb_init_fresh(int type, sef_init_info_t *info); @@ -53,6 +49,7 @@ static int sef_cb_init_fresh(int type, sef_init_info_t *info); int main() { /* Main routine of the process manager. */ + unsigned int call_index; int ipc_status, result; /* SEF local startup. */ @@ -84,27 +81,24 @@ int main() if (mp->mp_flags & EXITING) continue; - if (IS_VFS_PM_RS(call_nr)) { - if (who_e == VFS_PROC_NR) - { - handle_vfs_reply(); - result= SUSPEND; /* don't reply */ - } - else - result= ENOSYS; - } else { + if (IS_VFS_PM_RS(call_nr) && who_e == VFS_PROC_NR) { + handle_vfs_reply(); + + result = SUSPEND; /* don't reply */ + } else if (IS_PM_CALL(call_nr)) { /* If the system call number is valid, perform the call. */ - if ((unsigned) call_nr >= NCALLS) { - result = ENOSYS; - } else { + call_index = (unsigned int) (call_nr - PM_BASE); + + if (call_index < NR_PM_CALLS && call_vec[call_index] != NULL) { #if ENABLE_SYSCALL_STATS - calls_stats[call_nr]++; + calls_stats[call_index]++; #endif - result = (*call_vec[call_nr])(); - - } - } + result = (*call_vec[call_index])(); + } else + result = ENOSYS; + } else + result = ENOSYS; /* Send reply. */ if (result != SUSPEND) reply(who_p, result); @@ -135,18 +129,7 @@ static void sef_local_startup() *===========================================================================*/ static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info)) { -/* Initialize the process manager. - * Memory use info is collected from the boot monitor, the kernel, and - * all processes compiled into the system image. Initially this information - * is put into an array mem_chunks. Elements of mem_chunks are struct memory, - * and hold base, size pairs in units of clicks. This array is small, there - * should be no more than 8 chunks. After the array of chunks has been built - * the contents are used to initialize the hole list. Space for the hole list - * is reserved as an array with twice as many elements as the maximum number - * of processes allowed. It is managed as a linked list, and elements of the - * array are struct hole, which, in addition to storage for a base and size in - * click units also contain space for a link, a pointer to another element. -*/ +/* Initialize the process manager. */ int s; static struct boot_image image[NR_BOOT_PROCS]; register struct boot_image *ip; @@ -281,7 +264,7 @@ int result; /* result of call (usually OK or error #) */ panic("reply arg out of range: %d", proc_nr); rmp = &mproc[proc_nr]; - rmp->mp_reply.reply_res = result; + rmp->mp_reply.m_type = result; if ((r = sendnb(rmp->mp_endpoint, &rmp->mp_reply)) != OK) printf("PM can't reply to %d (%s): %d\n", rmp->mp_endpoint, diff --git a/servers/pm/mcontext.c b/servers/pm/mcontext.c index 2ade3c67f..beac9e608 100644 --- a/servers/pm/mcontext.c +++ b/servers/pm/mcontext.c @@ -4,7 +4,6 @@ #include #include #include "mproc.h" -#include "param.h" /*===========================================================================* @@ -12,7 +11,7 @@ *===========================================================================*/ int do_setmcontext() { - return sys_setmcontext(who_e, (mcontext_t *) m_in.m1_p1); + return sys_setmcontext(who_e, (mcontext_t *) m_in.PM_MCONTEXT_CTX); } @@ -21,6 +20,6 @@ int do_setmcontext() *===========================================================================*/ int do_getmcontext() { - return sys_getmcontext(who_e, (mcontext_t *) m_in.m1_p1); + return sys_getmcontext(who_e, (mcontext_t *) m_in.PM_MCONTEXT_CTX); } diff --git a/servers/pm/misc.c b/servers/pm/misc.c index 612d78a7b..7676901e4 100644 --- a/servers/pm/misc.c +++ b/servers/pm/misc.c @@ -9,8 +9,6 @@ * do_svrctl: process manager control */ -#define brk _brk - #include "pm.h" #include #include @@ -22,13 +20,11 @@ #include #include #include -#include #include #include #include #include #include "mproc.h" -#include "param.h" #include "kernel/proc.h" struct utsname uts_val = { @@ -59,7 +55,7 @@ static char *uts_tbl[] = { }; #if ENABLE_SYSCALL_STATS -unsigned long calls_stats[NCALLS]; +unsigned long calls_stats[NR_PM_CALLS]; #endif /*===========================================================================* @@ -68,7 +64,6 @@ unsigned long calls_stats[NCALLS]; int do_sysuname() { /* Set or get uname strings. */ - int r; size_t n; char *string; @@ -86,19 +81,19 @@ int do_sysuname() }; #endif - if ((unsigned) m_in.sysuname_field >= _UTS_MAX) return(EINVAL); + if ((unsigned) m_in.PM_SYSUNAME_FIELD >= _UTS_MAX) return(EINVAL); - string = uts_tbl[m_in.sysuname_field]; + string = uts_tbl[m_in.PM_SYSUNAME_FIELD]; if (string == NULL) return EINVAL; /* Unsupported field */ - switch (m_in.sysuname_req) { + switch (m_in.PM_SYSUNAME_REQ) { case _UTS_GET: /* Copy an uname string to the user. */ n = strlen(string) + 1; - if (n > m_in.sysuname_len) n = m_in.sysuname_len; + if (n > m_in.PM_SYSUNAME_LEN) n = m_in.PM_SYSUNAME_LEN; r = sys_vircopy(SELF, (phys_bytes) string, - mp->mp_endpoint, (phys_bytes) m_in.sysuname_value, + mp->mp_endpoint, (phys_bytes) m_in.PM_SYSUNAME_VALUE, (phys_bytes) n); if (r < 0) return(r); break; @@ -106,11 +101,11 @@ int do_sysuname() #if 0 /* no updates yet */ case _UTS_SET: /* Set an uname string, needs root power. */ - len = sizes[m_in.sysuname_field]; + len = sizes[m_in.PM_SYSUNAME_FIELD]; if (mp->mp_effuid != 0 || len == 0) return(EPERM); - n = len < m_in.sysuname_len ? len : m_in.sysuname_len; + n = len < m_in.PM_SYSUNAME_LEN ? len : m_in.PM_SYSUNAME_LEN; if (n <= 0) return(EINVAL); - r = sys_vircopy(mp->mp_endpoint, (phys_bytes) m_in.sysuname_value, + r = sys_vircopy(mp->mp_endpoint, (phys_bytes) m_in.PM_SYSUNAME_VALUE, SELF, (phys_bytes) tmp, (phys_bytes) n); if (r < 0) return(r); tmp[n-1] = 0; @@ -217,7 +212,7 @@ int do_reboot() if (mp->mp_effuid != SUPER_USER) return(EPERM); /* See how the system should be aborted. */ - abort_flag = (unsigned) m_in.reboot_flag; + abort_flag = (unsigned) m_in.PM_REBOOT_HOW; if (abort_flag >= RBT_INVALID) return(EINVAL); /* notify readclock (some arm systems power off via RTC alarms) */ @@ -254,9 +249,9 @@ int do_getsetpriority() int r, arg_which, arg_who, arg_pri; struct mproc *rmp; - arg_which = m_in.m1_i1; - arg_who = m_in.m1_i2; - arg_pri = m_in.m1_i3; /* for SETPRIORITY */ + arg_which = m_in.PM_PRIORITY_WHICH; + arg_who = m_in.PM_PRIORITY_WHO; + arg_pri = m_in.PM_PRIORITY_PRIO; /* for SETPRIORITY */ /* Code common to GETPRIORITY and SETPRIORITY. */ @@ -275,7 +270,7 @@ int do_getsetpriority() return EPERM; /* If GET, that's it. */ - if (call_nr == GETPRIORITY) { + if (call_nr == PM_GETPRIORITY) { return(rmp->mp_nice - PRIO_MIN); } @@ -312,8 +307,8 @@ int do_svrctl() } local_param_overrides[MAX_LOCAL_PARAMS]; static int local_params = 0; - req = m_in.svrctl_req; - ptr = (vir_bytes) m_in.svrctl_argp; + req = m_in.SVRCTL_REQ; + ptr = (vir_bytes) m_in.SVRCTL_ARG; /* Is the request indeed for the PM? */ if (((req >> 8) & 0xFF) != 'M') return(EINVAL); @@ -404,27 +399,6 @@ int do_svrctl() } } -/*===========================================================================* - * _brk * - *===========================================================================*/ - -extern char *_brksize; -int brk(brk_addr) -void *brk_addr; -{ - int r; -/* PM wants to call brk() itself. */ - if((r=vm_brk(PM_PROC_NR, brk_addr)) != OK) { -#if 0 - printf("PM: own brk(%p) failed: vm_brk() returned %d\n", - brk_addr, r); -#endif - return -1; - } - _brksize = brk_addr; - return 0; -} - /*===========================================================================* * do_getrusage * *===========================================================================*/ diff --git a/servers/pm/mproc.h b/servers/pm/mproc.h index 27eb11745..b99a54cfb 100644 --- a/servers/pm/mproc.h +++ b/servers/pm/mproc.h @@ -74,8 +74,8 @@ EXTERN struct mproc { /* Flag values */ #define IN_USE 0x00001 /* set when 'mproc' slot in use */ -#define WAITING 0x00002 /* set by WAIT system call */ -#define ZOMBIE 0x00004 /* waiting for parent to issue WAIT call */ +#define WAITING 0x00002 /* set by WAITPID system call */ +#define ZOMBIE 0x00004 /* waiting for parent to issue WAITPID call */ #define PROC_STOPPED 0x00008 /* process is stopped in the kernel */ #define ALARM_ON 0x00010 /* set when SIGALRM timer started */ #define EXITING 0x00020 /* set by EXIT, process is now exiting */ @@ -88,7 +88,7 @@ EXTERN struct mproc { #define PRIV_PROC 0x02000 /* system process, special privileges */ #define PARTIAL_EXEC 0x04000 /* process got a new map but no content */ #define TRACE_EXIT 0x08000 /* tracer is forcing this process to exit */ -#define TRACE_ZOMBIE 0x10000 /* waiting for tracer to issue WAIT call */ +#define TRACE_ZOMBIE 0x10000 /* waiting for tracer to issue WAITPID call */ #define DELAY_CALL 0x20000 /* waiting for call before sending signal */ #define TAINTED 0x40000 /* process is 'tainted' */ diff --git a/servers/pm/param.h b/servers/pm/param.h deleted file mode 100644 index 234fd2cbc..000000000 --- a/servers/pm/param.h +++ /dev/null @@ -1,53 +0,0 @@ -/* The following names are synonyms for the variables in the input message. */ -#define exec_name m1_p1 -#define exec_len m1_i1 -#define func m6_f1 -#define grp_id m1_i1 -#define grp_no m1_i1 -#define groupsp m1_p1 -#define namelen m1_i2 -#define pid m1_i1 -#define seconds m1_i1 -#define which_timer m1_i1 -#define new_val m1_p1 -#define old_val m1_p2 -#define sig m6_i1 -#define msg_frame_len m1_i2 -#define frame_ptr m1_p2 -#define status m1_i1 -#define usr_id m1_i1 -#define request m2_i2 -#define data m2_l2 -#define sig_nr m1_i2 -#define sig_nsa m1_p1 -#define sig_osa m1_p2 -#define sig_ret m1_p3 -#define stat_nr m2_i1 -#define sig_set m2_l1 -#define sig_how m2_i1 -#define sig_context m2_p1 -#define reboot_flag m1_i1 -#define svrctl_req m2_i1 -#define svrctl_argp m2_p1 -#define stime m2_l1 -#define clk_id m2_i1 -#define settime_now m2_i2 -#define time_sec m2_l1 -#define time_nsec m2_l2 -#define memsize m4_l1 -#define membase m4_l2 -#define sysuname_req m1_i1 -#define sysuname_field m1_i2 -#define sysuname_len m1_i3 -#define sysuname_value m1_p1 - -/* The following names are synonyms for the variables in a reply message. */ -#define reply_res m_type -#define reply_res2 m2_i1 -#define reply_res3 m2_i2 -#define reply_ptr m2_p1 -#define reply_mask m2_l1 -#define reply_trace m2_l2 -#define reply_time m2_l1 -#define reply_utime m2_l2 -#define reply_ntime m2_l2 diff --git a/servers/pm/profile.c b/servers/pm/profile.c index 27ff0c260..67ae14adf 100644 --- a/servers/pm/profile.c +++ b/servers/pm/profile.c @@ -16,7 +16,6 @@ #include #include #include "mproc.h" -#include "param.h" /*===========================================================================* * do_sprofile * diff --git a/servers/pm/proto.h b/servers/pm/proto.h index 68a09f6e4..0d27fc851 100644 --- a/servers/pm/proto.h +++ b/servers/pm/proto.h @@ -1,9 +1,6 @@ /* Function prototypes. */ struct mproc; -struct stat; -struct mem_map; -struct memory; #include @@ -12,9 +9,6 @@ int do_itimer(void); void set_alarm(struct mproc *rmp, clock_t ticks); void check_vtimer(int proc_nr, int sig); -/* break.c */ -int do_brk(void); - /* exec.c */ int do_exec(void); int do_newexec(void); @@ -86,11 +80,10 @@ int do_settime(void); /* trace.c */ int do_trace(void); -void trace_stop(struct mproc *rmp, int sig_nr); +void trace_stop(struct mproc *rmp, int signo); /* utility.c */ pid_t get_free_pid(void); -int no_sys(void); char *find_param(const char *key); struct mproc *find_proc(pid_t lpid); int nice_to_priority(int nice, unsigned *new_q); diff --git a/servers/pm/signal.c b/servers/pm/signal.c index f2e5d1dfc..8d2720a9a 100644 --- a/servers/pm/signal.c +++ b/servers/pm/signal.c @@ -29,7 +29,6 @@ #include #include #include "mproc.h" -#include "param.h" static int unpause(struct mproc *rmp); static int sig_send(struct mproc *rmp, int signo); @@ -40,48 +39,49 @@ static void sig_proc_exit(struct mproc *rmp, int signo); *===========================================================================*/ int do_sigaction(void) { - int r; + int r, sig_nr; struct sigaction svec; struct sigaction *svp; assert(!(mp->mp_flags & (PROC_STOPPED | VFS_CALL | UNPAUSED))); - if (m_in.sig_nr == SIGKILL) return(OK); - if (m_in.sig_nr < 1 || m_in.sig_nr >= _NSIG) return(EINVAL); + sig_nr = m_in.PM_SIG_NR; + if (sig_nr == SIGKILL) return(OK); + if (sig_nr < 1 || sig_nr >= _NSIG) return(EINVAL); - svp = &mp->mp_sigact[m_in.sig_nr]; - if ((struct sigaction *) m_in.sig_osa != (struct sigaction *) NULL) { - r = sys_datacopy(PM_PROC_NR,(vir_bytes) svp, - who_e, (vir_bytes) m_in.sig_osa, (phys_bytes) sizeof(svec)); + svp = &mp->mp_sigact[sig_nr]; + if ((struct sigaction *) m_in.PM_SIG_OACT != (struct sigaction *) NULL) { + r = sys_datacopy(PM_PROC_NR,(vir_bytes) svp, who_e, + (vir_bytes) m_in.PM_SIG_OACT, (phys_bytes) sizeof(svec)); if (r != OK) return(r); } - if ((struct sigaction *) m_in.sig_nsa == (struct sigaction *) NULL) + if ((struct sigaction *) m_in.PM_SIG_ACT == (struct sigaction *) NULL) return(OK); /* Read in the sigaction structure. */ - r = sys_datacopy(who_e, (vir_bytes) m_in.sig_nsa, + r = sys_datacopy(who_e, (vir_bytes) m_in.PM_SIG_ACT, PM_PROC_NR, (vir_bytes) &svec, (phys_bytes) sizeof(svec)); if (r != OK) return(r); if (svec.sa_handler == SIG_IGN) { - sigaddset(&mp->mp_ignore, m_in.sig_nr); - sigdelset(&mp->mp_sigpending, m_in.sig_nr); - sigdelset(&mp->mp_ksigpending, m_in.sig_nr); - sigdelset(&mp->mp_catch, m_in.sig_nr); + sigaddset(&mp->mp_ignore, sig_nr); + sigdelset(&mp->mp_sigpending, sig_nr); + sigdelset(&mp->mp_ksigpending, sig_nr); + sigdelset(&mp->mp_catch, sig_nr); } else if (svec.sa_handler == SIG_DFL) { - sigdelset(&mp->mp_ignore, m_in.sig_nr); - sigdelset(&mp->mp_catch, m_in.sig_nr); + sigdelset(&mp->mp_ignore, sig_nr); + sigdelset(&mp->mp_catch, sig_nr); } else { - sigdelset(&mp->mp_ignore, m_in.sig_nr); - sigaddset(&mp->mp_catch, m_in.sig_nr); + sigdelset(&mp->mp_ignore, sig_nr); + sigaddset(&mp->mp_catch, sig_nr); } - mp->mp_sigact[m_in.sig_nr].sa_handler = svec.sa_handler; + mp->mp_sigact[sig_nr].sa_handler = svec.sa_handler; sigdelset(&svec.sa_mask, SIGKILL); sigdelset(&svec.sa_mask, SIGSTOP); - mp->mp_sigact[m_in.sig_nr].sa_mask = svec.sa_mask; - mp->mp_sigact[m_in.sig_nr].sa_flags = svec.sa_flags; - mp->mp_sigreturn = (vir_bytes) m_in.sig_ret; + mp->mp_sigact[sig_nr].sa_mask = svec.sa_mask; + mp->mp_sigact[sig_nr].sa_flags = svec.sa_flags; + mp->mp_sigreturn = (vir_bytes) m_in.PM_SIG_RET; return(OK); } @@ -92,7 +92,7 @@ int do_sigpending(void) { assert(!(mp->mp_flags & (PROC_STOPPED | VFS_CALL | UNPAUSED))); - mp->mp_reply.reply_mask = (long) mp->mp_sigpending; + mp->mp_reply.PM_SIG_SET = (long) mp->mp_sigpending; return OK; } @@ -111,34 +111,36 @@ int do_sigprocmask(void) * * KILL and STOP can't be masked. */ + sigset_t set; int i; assert(!(mp->mp_flags & (PROC_STOPPED | VFS_CALL | UNPAUSED))); - mp->mp_reply.reply_mask = (long) mp->mp_sigmask; + set = m_in.PM_SIG_SET; + mp->mp_reply.PM_SIG_SET = (long) mp->mp_sigmask; - switch (m_in.sig_how) { + switch (m_in.PM_SIG_HOW) { case SIG_BLOCK: - sigdelset((sigset_t *)&m_in.sig_set, SIGKILL); - sigdelset((sigset_t *)&m_in.sig_set, SIGSTOP); + sigdelset(&set, SIGKILL); + sigdelset(&set, SIGSTOP); for (i = 1; i < _NSIG; i++) { - if (sigismember((sigset_t *)&m_in.sig_set, i)) + if (sigismember(&set, i)) sigaddset(&mp->mp_sigmask, i); } break; case SIG_UNBLOCK: for (i = 1; i < _NSIG; i++) { - if (sigismember((sigset_t *)&m_in.sig_set, i)) + if (sigismember(&set, i)) sigdelset(&mp->mp_sigmask, i); } check_pending(mp); break; case SIG_SETMASK: - sigdelset((sigset_t *) &m_in.sig_set, SIGKILL); - sigdelset((sigset_t *) &m_in.sig_set, SIGSTOP); - mp->mp_sigmask = (sigset_t) m_in.sig_set; + sigdelset(&set, SIGKILL); + sigdelset(&set, SIGSTOP); + mp->mp_sigmask = set; check_pending(mp); break; @@ -160,7 +162,7 @@ int do_sigsuspend(void) assert(!(mp->mp_flags & (PROC_STOPPED | VFS_CALL | UNPAUSED))); mp->mp_sigmask2 = mp->mp_sigmask; /* save the old mask */ - mp->mp_sigmask = (sigset_t) m_in.sig_set; + mp->mp_sigmask = (sigset_t) m_in.PM_SIG_SET; sigdelset(&mp->mp_sigmask, SIGKILL); sigdelset(&mp->mp_sigmask, SIGSTOP); mp->mp_flags |= SIGSUSPENDED; @@ -180,11 +182,11 @@ int do_sigreturn(void) assert(!(mp->mp_flags & (PROC_STOPPED | VFS_CALL | UNPAUSED))); - mp->mp_sigmask = (sigset_t) m_in.sig_set; + mp->mp_sigmask = (sigset_t) m_in.PM_SIG_SET; sigdelset(&mp->mp_sigmask, SIGKILL); sigdelset(&mp->mp_sigmask, SIGSTOP); - r = sys_sigreturn(who_e, (struct sigmsg *) m_in.sig_context); + r = sys_sigreturn(who_e, (struct sigmsg *) m_in.PM_SIG_CTX); check_pending(mp); return(r); } @@ -196,7 +198,7 @@ int do_kill(void) { /* Perform the kill(pid, signo) system call. */ - return check_sig(m_in.pid, m_in.sig_nr, FALSE /* ksig */); + return check_sig(m_in.PM_SIG_PID, m_in.PM_SIG_NR, FALSE /* ksig */); } /*===========================================================================* @@ -214,7 +216,7 @@ int do_srv_kill(void) * to a system process. RS sends a SIGKILL when it wants to perform cleanup. * In that case, ksig == TRUE forces PM to exit the process immediately. */ - return check_sig(m_in.pid, m_in.sig_nr, TRUE /* ksig */); + return check_sig(m_in.PM_SIG_PID, m_in.PM_SIG_NR, TRUE /* ksig */); } /*===========================================================================* diff --git a/servers/pm/table.c b/servers/pm/table.c index d352b18b1..8c8e24aa7 100644 --- a/servers/pm/table.c +++ b/servers/pm/table.c @@ -8,138 +8,55 @@ #include #include #include "mproc.h" -#include "param.h" -int (*call_vec[])(void) = { - no_sys, /* 0 = unused */ - do_exit, /* 1 = exit */ - do_fork, /* 2 = fork */ - no_sys, /* 3 = read */ - no_sys, /* 4 = write */ - no_sys, /* 5 = open */ - no_sys, /* 6 = close */ - do_waitpid, /* 7 = wait */ - no_sys, /* 8 = creat */ - no_sys, /* 9 = link */ - no_sys, /* 10 = unlink */ - do_waitpid, /* 11 = waitpid */ - no_sys, /* 12 = chdir */ - do_time, /* 13 = time */ - no_sys, /* 14 = mknod */ - no_sys, /* 15 = chmod */ - no_sys, /* 16 = chown */ - do_brk, /* 17 = break */ - no_sys, /* 18 = stat */ - no_sys, /* 19 = lseek */ - do_get, /* 20 = getpid */ - no_sys, /* 21 = mount */ - no_sys, /* 22 = umount */ - do_set, /* 23 = setuid */ - do_get, /* 24 = getuid */ - do_stime, /* 25 = stime */ - do_trace, /* 26 = ptrace */ - no_sys, /* 27 = unused */ - no_sys, /* 28 = fstat */ - no_sys, /* 29 = unused */ - no_sys, /* 30 = utime */ - do_getepinfo, /* 31 = getepinfo */ - do_set, /* 32 = setgroups */ - no_sys, /* 33 = access */ - do_get, /* 34 = getgroups */ - no_sys, /* 35 = unused */ - no_sys, /* 36 = sync */ - do_kill, /* 37 = kill */ - no_sys, /* 38 = rename */ - no_sys, /* 39 = mkdir */ - no_sys, /* 40 = rmdir */ - no_sys, /* 41 = dup */ - no_sys, /* 42 = pipe */ - no_sys, /* 43 = unused */ - no_sys, /* 44 = unused */ - no_sys, /* 45 = unused */ - do_set, /* 46 = setgid */ - do_get, /* 47 = getgid */ - no_sys, /* 48 = (signal)*/ - no_sys, /* 49 = unused */ - no_sys, /* 50 = lstat */ - no_sys, /* 51 = (stat) */ - no_sys, /* 52 = (fstat) */ - no_sys, /* 53 = (lstat) */ - no_sys, /* 54 = ioctl */ - no_sys, /* 55 = fcntl */ - no_sys, /* 56 = copyfd */ - no_sys, /* 57 = unused */ - no_sys, /* 58 = unused */ - do_exec, /* 59 = execve */ - no_sys, /* 60 = umask */ - no_sys, /* 61 = chroot */ - do_set, /* 62 = setsid */ - do_get, /* 63 = getpgrp */ - do_itimer, /* 64 = itimer */ - do_get, /* 65 = getgroups */ - do_set, /* 66 = setgroups */ - do_getmcontext, /* 67 = getmcontext */ - do_setmcontext, /* 68 = setmcontext */ - no_sys, /* 69 = unused */ - no_sys, /* 70 = unused */ - do_sigaction, /* 71 = sigaction */ - do_sigsuspend, /* 72 = sigsuspend */ - do_sigpending, /* 73 = sigpending */ - do_sigprocmask, /* 74 = sigprocmask */ - do_sigreturn, /* 75 = sigreturn */ - do_reboot, /* 76 = reboot */ - do_svrctl, /* 77 = pm_svrctl */ - do_sysuname, /* 78 = sysuname */ - no_sys, /* 79 = unused */ - no_sys, /* 80 = (getdents) */ - no_sys, /* 81 = unused */ - no_sys, /* 82 = (getvfsstat) */ - no_sys, /* 83 = unused */ - no_sys, /* 84 = unused */ - no_sys, /* 85 = (select) */ - no_sys, /* 86 = (fchdir) */ - no_sys, /* 87 = (fsync) */ - do_getsetpriority, /* 88 = getpriority */ - do_getsetpriority, /* 89 = setpriority */ - do_time, /* 90 = gettimeofday */ - do_set, /* 91 = seteuid */ - do_set, /* 92 = setegid */ - no_sys, /* 93 = (truncate) */ - no_sys, /* 94 = (ftruncate) */ - no_sys, /* 95 = (fchmod) */ - no_sys, /* 96 = (fchown) */ - no_sys, /* 97 = unused */ - do_sprofile, /* 98 = sprofile */ - do_cprofile, /* 99 = cprofile */ - do_newexec, /* 100 = newexec */ - do_srv_fork, /* 101 = srv_fork */ - do_execrestart, /* 102 = exec_restart */ - no_sys, /* 103 = unused */ - do_getprocnr, /* 104 = getprocnr */ - no_sys, /* 105 = unused */ - do_get, /* 106 = issetugid */ - no_sys, /* 107 = unused */ - no_sys, /* 108 = (utimens) */ - no_sys, /* 109 = unused */ - no_sys, /* 110 = unused */ - do_srv_kill, /* 111 = srv_kill */ - no_sys, /* 112 = gcov_flush */ - do_get, /* 113 = getsid */ - do_getres, /* 114 = clock_getres */ - do_gettime, /* 115 = clock_gettime */ - do_settime, /* 116 = clock_settime */ - no_sys, /* 117 = (vmcall) */ - no_sys, /* 118 = unsused */ - no_sys, /* 119 = unsused */ - no_sys, /* 120 = unsused */ - no_sys, /* 121 = (task reply) */ - no_sys, /* 122 = (map driver ) */ - do_getrusage, /* 123 = pm_getrusage */ - no_sys, /* 124 = (checkperms) */ - do_getsysinfo, /* 125 = pm_getsysinfo */ - no_sys, /* 126 = (vfs_getsysinfo) */ - no_sys, /* 127 = (vfs_getrusage) */ - no_sys, /* 128 = (vfs_svrctl) */ +#define CALL(n) [((n) - PM_BASE)] + +int (* const call_vec[NR_PM_CALLS])(void) = { + CALL(PM_EXIT) = do_exit, /* _exit(2) */ + CALL(PM_FORK) = do_fork, /* fork(2) */ + CALL(PM_WAITPID) = do_waitpid, /* waitpid(2) */ + CALL(PM_GETPID) = do_get, /* get[p]pid(2) */ + CALL(PM_SETUID) = do_set, /* setuid(2) */ + CALL(PM_GETUID) = do_get, /* get[e]uid(2) */ + CALL(PM_STIME) = do_stime, /* stime(2) */ + CALL(PM_PTRACE) = do_trace, /* ptrace(2) */ + CALL(PM_SETGROUPS) = do_set, /* setgroups(2) */ + CALL(PM_GETGROUPS) = do_get, /* getgroups(2) */ + CALL(PM_KILL) = do_kill, /* kill(2) */ + CALL(PM_SETGID) = do_set, /* setgid(2) */ + CALL(PM_GETGID) = do_get, /* get[e]gid(2) */ + CALL(PM_EXEC) = do_exec, /* execve(2) */ + CALL(PM_SETSID) = do_set, /* setsid(2) */ + CALL(PM_GETPGRP) = do_get, /* getpgrp(2) */ + CALL(PM_ITIMER) = do_itimer, /* [gs]etitimer(2) */ + CALL(PM_GETMCONTEXT) = do_getmcontext, /* getmcontext(2) */ + CALL(PM_SETMCONTEXT) = do_setmcontext, /* setmcontext(2) */ + CALL(PM_SIGACTION) = do_sigaction, /* sigaction(2) */ + CALL(PM_SIGSUSPEND) = do_sigsuspend, /* sigsuspend(2) */ + CALL(PM_SIGPENDING) = do_sigpending, /* sigpending(2) */ + CALL(PM_SIGPROCMASK) = do_sigprocmask, /* sigprocmask(2) */ + CALL(PM_SIGRETURN) = do_sigreturn, /* sigreturn(2) */ + CALL(PM_SYSUNAME) = do_sysuname, /* sysuname(2) */ + CALL(PM_GETPRIORITY) = do_getsetpriority, /* getpriority(2) */ + CALL(PM_SETPRIORITY) = do_getsetpriority, /* setpriority(2) */ + CALL(PM_GETTIMEOFDAY) = do_time, /* gettimeofday(2) */ + CALL(PM_SETEUID) = do_set, /* geteuid(2) */ + CALL(PM_SETEGID) = do_set, /* setegid(2) */ + CALL(PM_ISSETUGID) = do_get, /* issetugid */ + CALL(PM_GETSID) = do_get, /* getsid(2) */ + CALL(PM_CLOCK_GETRES) = do_getres, /* clock_getres(2) */ + CALL(PM_CLOCK_GETTIME) = do_gettime, /* clock_gettime(2) */ + CALL(PM_CLOCK_SETTIME) = do_settime, /* clock_settime(2) */ + CALL(PM_GETRUSAGE) = do_getrusage, /* getrusage(2) */ + CALL(PM_REBOOT) = do_reboot, /* reboot(2) */ + CALL(PM_SVRCTL) = do_svrctl, /* svrctl(2) */ + CALL(PM_SPROF) = do_sprofile, /* sprofile(2) */ + CALL(PM_CPROF) = do_cprofile, /* cprofile(2) */ + CALL(PM_SRV_FORK) = do_srv_fork, /* srv_fork(2) */ + CALL(PM_SRV_KILL) = do_srv_kill, /* srv_kill(2) */ + CALL(PM_EXEC_NEW) = do_newexec, + CALL(PM_EXEC_RESTART) = do_execrestart, + CALL(PM_GETEPINFO) = do_getepinfo, /* getepinfo(2) */ + CALL(PM_GETPROCNR) = do_getprocnr, /* getprocnr(2) */ + CALL(PM_GETSYSINFO) = do_getsysinfo /* getsysinfo(2) */ }; -/* This should not fail with "array size is negative": */ -extern int dummy[sizeof(call_vec) == NCALLS * sizeof(call_vec[0]) ? 1 : -1]; diff --git a/servers/pm/time.c b/servers/pm/time.c index 2348206be..cbfd858a9 100644 --- a/servers/pm/time.c +++ b/servers/pm/time.c @@ -4,7 +4,7 @@ * do_getres: perform the CLOCK_GETRES system call * do_gettime: perform the CLOCK_GETTIME system call * do_settime: perform the CLOCK_SETTIME system call - * do_time: perform the TIME system call + * do_time: perform the GETTIMEOFDAY system call * do_stime: perform the STIME system call */ @@ -14,7 +14,6 @@ #include #include #include "mproc.h" -#include "param.h" /*===========================================================================* * do_gettime * @@ -28,7 +27,7 @@ int do_gettime() if ( (s=getuptime(&ticks, &realtime, &boottime)) != OK) panic("do_time couldn't get uptime: %d", s); - switch (m_in.clk_id) { + switch (m_in.PM_TIME_CLK_ID) { case CLOCK_REALTIME: clock = realtime; break; @@ -39,8 +38,8 @@ int do_gettime() return EINVAL; /* invalid/unsupported clock_id */ } - mp->mp_reply.reply_time = (time_t) (boottime + (clock / system_hz)); - mp->mp_reply.reply_ntime = + mp->mp_reply.PM_TIME_SEC = (time_t) (boottime + (clock / system_hz)); + mp->mp_reply.PM_TIME_NSEC = (long) ((clock % system_hz) * 1000000000ULL / system_hz); return(OK); @@ -51,12 +50,12 @@ int do_gettime() *===========================================================================*/ int do_getres() { - switch (m_in.clk_id) { + switch (m_in.PM_TIME_CLK_ID) { case CLOCK_REALTIME: case CLOCK_MONOTONIC: /* tv_sec is always 0 since system_hz is an int */ - mp->mp_reply.reply_time = (time_t) 0; - mp->mp_reply.reply_ntime = 1000000000 / system_hz; + mp->mp_reply.PM_TIME_SEC = (time_t) 0; + mp->mp_reply.PM_TIME_NSEC = 1000000000 / system_hz; return(OK); default: return EINVAL; /* invalid/unsupported clock_id */ @@ -74,10 +73,10 @@ int do_settime() return(EPERM); } - switch (m_in.clk_id) { + switch (m_in.PM_TIME_CLK_ID) { case CLOCK_REALTIME: - s= sys_settime(m_in.settime_now, m_in.clk_id, m_in.time_sec, - m_in.time_nsec); + s= sys_settime(m_in.PM_TIME_NOW, m_in.PM_TIME_CLK_ID, + m_in.PM_TIME_SEC, m_in.PM_TIME_NSEC); return(s); case CLOCK_MONOTONIC: /* monotonic cannot be changed */ default: @@ -102,8 +101,8 @@ int do_time() if ( (s=getuptime(&ticks, &realtime, &boottime)) != OK) panic("do_time couldn't get uptime: %d", s); - mp->mp_reply.reply_time = (time_t) (boottime + (realtime / system_hz)); - mp->mp_reply.reply_utime = + mp->mp_reply.PM_TIME_SEC = (time_t) (boottime + (realtime / system_hz)); + mp->mp_reply.PM_TIME_USEC = (long) ((realtime % system_hz) * 1000000ULL / system_hz); return(OK); } @@ -125,7 +124,7 @@ int do_stime() } if ( (s=getuptime(&uptime, &realtime, &boottime)) != OK) panic("do_stime couldn't get uptime: %d", s); - boottime = (long) m_in.stime - (realtime/system_hz); + boottime = (long) m_in.PM_TIME_SEC - (realtime/system_hz); s= sys_stime(boottime); /* Tell kernel about boottime */ if (s != OK) diff --git a/servers/pm/trace.c b/servers/pm/trace.c index efdc628bf..a25b31466 100644 --- a/servers/pm/trace.c +++ b/servers/pm/trace.c @@ -29,10 +29,10 @@ #include "pm.h" #include +#include #include #include #include "mproc.h" -#include "param.h" /*===========================================================================* * do_trace * @@ -43,7 +43,7 @@ int do_trace() struct ptrace_range pr; int i, r, req; - req = m_in.request; + req = m_in.PM_PTRACE_REQ; /* The T_OK call is made by the child fork of the debugger before it execs * the process to be traced. The T_ATTACH call is made by the debugger itself @@ -54,11 +54,11 @@ int do_trace() if (mp->mp_tracer != NO_TRACER) return(EBUSY); mp->mp_tracer = mp->mp_parent; - mp->mp_reply.reply_trace = 0; + mp->mp_reply.PM_PTRACE_DATA = 0; return(OK); case T_ATTACH: /* attach to an existing process */ - if ((child = find_proc(m_in.pid)) == NULL) return(ESRCH); + if ((child = find_proc(m_in.PM_PTRACE_PID)) == NULL) return(ESRCH); if (child->mp_flags & EXITING) return(ESRCH); /* For non-root processes, user and group ID must match. */ @@ -87,7 +87,7 @@ int do_trace() sig_proc(child, SIGSTOP, TRUE /*trace*/, FALSE /* ksig */); - mp->mp_reply.reply_trace = 0; + mp->mp_reply.PM_PTRACE_DATA = 0; return(OK); case T_STOP: /* stop the process */ @@ -98,18 +98,19 @@ int do_trace() case T_READB_INS: /* special hack for reading text segments */ if (mp->mp_effuid != SUPER_USER) return(EPERM); - if ((child = find_proc(m_in.pid)) == NULL) return(ESRCH); + if ((child = find_proc(m_in.PM_PTRACE_PID)) == NULL) return(ESRCH); if (child->mp_flags & EXITING) return(ESRCH); - r = sys_trace(req, child->mp_endpoint, m_in.PMTRACE_ADDR, &m_in.data); + r = sys_trace(req, child->mp_endpoint, m_in.PM_PTRACE_ADDR, + &m_in.PM_PTRACE_DATA); if (r != OK) return(r); - mp->mp_reply.reply_trace = m_in.data; + mp->mp_reply.PM_PTRACE_DATA = m_in.PM_PTRACE_DATA; return(OK); case T_WRITEB_INS: /* special hack for patching text segments */ if (mp->mp_effuid != SUPER_USER) return(EPERM); - if ((child = find_proc(m_in.pid)) == NULL) return(ESRCH); + if ((child = find_proc(m_in.PM_PTRACE_PID)) == NULL) return(ESRCH); if (child->mp_flags & EXITING) return(ESRCH); #if 0 @@ -123,17 +124,18 @@ int do_trace() child->mp_ctime = 0; #endif - r = sys_trace(req, child->mp_endpoint, m_in.PMTRACE_ADDR, &m_in.data); + r = sys_trace(req, child->mp_endpoint, m_in.PM_PTRACE_ADDR, + &m_in.PM_PTRACE_DATA); if (r != OK) return(r); - mp->mp_reply.reply_trace = m_in.data; + mp->mp_reply.PM_PTRACE_DATA = m_in.PM_PTRACE_DATA; return(OK); } /* All the other calls are made by the tracing process to control execution * of the child. For all these calls, the child must be stopped. */ - if ((child = find_proc(m_in.pid)) == NULL) return(ESRCH); + if ((child = find_proc(m_in.PM_PTRACE_PID)) == NULL) return(ESRCH); if (child->mp_flags & EXITING) return(ESRCH); if (child->mp_tracer != who_p) return(ESRCH); if (!(child->mp_flags & TRACE_STOPPED)) return(EBUSY); @@ -144,9 +146,10 @@ int do_trace() /* Defer the exit if the traced process has an VFS call pending. */ if (child->mp_flags & VFS_CALL) - child->mp_exitstatus = (int) m_in.data; /* save for later */ + child->mp_exitstatus = (int) m_in.PM_PTRACE_DATA; /* save it */ else - exit_proc(child, (int) m_in.data, FALSE /*dump_core*/); + exit_proc(child, (int) m_in.PM_PTRACE_DATA, + FALSE /*dump_core*/); /* Do not reply to the caller until VFS has processed the exit * request. @@ -154,14 +157,14 @@ int do_trace() return(SUSPEND); case T_SETOPT: /* set trace options */ - child->mp_trace_flags = m_in.data; + child->mp_trace_flags = m_in.PM_PTRACE_DATA; - mp->mp_reply.reply_trace = 0; + mp->mp_reply.PM_PTRACE_DATA = 0; return(OK); case T_GETRANGE: case T_SETRANGE: /* get/set range of values */ - r = sys_datacopy(who_e, (vir_bytes) m_in.PMTRACE_ADDR, + r = sys_datacopy(who_e, (vir_bytes) m_in.PM_PTRACE_ADDR, SELF, (vir_bytes) &pr, (phys_bytes) sizeof(pr)); if (r != OK) return(r); @@ -179,11 +182,12 @@ int do_trace() if (r != OK) return(r); - mp->mp_reply.reply_trace = 0; + mp->mp_reply.PM_PTRACE_DATA = 0; return(OK); case T_DETACH: /* detach from traced process */ - if (m_in.data < 0 || m_in.data >= _NSIG) return(EINVAL); + if (m_in.PM_PTRACE_DATA < 0 || m_in.PM_PTRACE_DATA >= _NSIG) + return(EINVAL); child->mp_tracer = NO_TRACER; @@ -195,8 +199,8 @@ int do_trace() } } - if (m_in.data > 0) { /* issue signal */ - sig_proc(child, (int) m_in.data, TRUE /*trace*/, + if (m_in.PM_PTRACE_DATA > 0) { /* issue signal */ + sig_proc(child, (int) m_in.PM_PTRACE_DATA, TRUE /*trace*/, FALSE /* ksig */); } @@ -211,10 +215,11 @@ int do_trace() case T_RESUME: case T_STEP: case T_SYSCALL: /* resume execution */ - if (m_in.data < 0 || m_in.data >= _NSIG) return(EINVAL); + if (m_in.PM_PTRACE_DATA < 0 || m_in.PM_PTRACE_DATA >= _NSIG) + return(EINVAL); - if (m_in.data > 0) { /* issue signal */ - sig_proc(child, (int) m_in.data, FALSE /*trace*/, + if (m_in.PM_PTRACE_DATA > 0) { /* issue signal */ + sig_proc(child, (int) m_in.PM_PTRACE_DATA, FALSE /*trace*/, FALSE /* ksig */); } @@ -223,7 +228,7 @@ int do_trace() */ for (i = 1; i < _NSIG; i++) { if (sigismember(&child->mp_sigtrace, i)) { - mp->mp_reply.reply_trace = 0; + mp->mp_reply.PM_PTRACE_DATA = 0; return(OK); } } @@ -234,10 +239,11 @@ int do_trace() break; } - r = sys_trace(req, child->mp_endpoint, m_in.PMTRACE_ADDR, &m_in.data); + r = sys_trace(req, child->mp_endpoint, m_in.PM_PTRACE_ADDR, + &m_in.PM_PTRACE_DATA); if (r != OK) return(r); - mp->mp_reply.reply_trace = m_in.data; + mp->mp_reply.PM_PTRACE_DATA = m_in.PM_PTRACE_DATA; return(OK); } @@ -261,7 +267,7 @@ int signo; sigdelset(&rmp->mp_sigtrace, signo); rpmp->mp_flags &= ~WAITING; /* parent is no longer waiting */ - rpmp->mp_reply.reply_res2 = 0177 | (signo << 8); + rpmp->mp_reply.PM_WAITPID_STATUS = 0177 | (signo << 8); reply(rmp->mp_tracer, rmp->mp_pid); } } diff --git a/servers/pm/utility.c b/servers/pm/utility.c index ea92f6c06..55c2900b2 100644 --- a/servers/pm/utility.c +++ b/servers/pm/utility.c @@ -2,7 +2,6 @@ * * The entry points are: * get_free_pid: get a free process or group id - * no_sys: called for invalid system call numbers * find_param: look up a boot monitor parameter * find_proc: return process pointer from pid number * nice_to_priority convert nice level to priority queue @@ -19,7 +18,6 @@ #include #include /* needed only because mproc.h needs it */ #include "mproc.h" -#include "param.h" #include #include @@ -51,16 +49,6 @@ pid_t get_free_pid() return(next_pid); } - -/*===========================================================================* - * no_sys * - *===========================================================================*/ -int no_sys() -{ -/* A system call number not implemented by PM has been requested. */ - return(ENOSYS); -} - /*===========================================================================* * find_param * *===========================================================================*/ diff --git a/servers/rs/exec.c b/servers/rs/exec.c index 9e28d5a9e..d154beaa9 100644 --- a/servers/rs/exec.c +++ b/servers/rs/exec.c @@ -127,11 +127,12 @@ static int exec_restart(int proc_e, int result, vir_bytes pc, vir_bytes ps_str) int r; message m; - m.m_type = EXEC_RESTART; - m.EXC_RS_PROC = proc_e; - m.EXC_RS_RESULT = result; - m.EXC_RS_PC = (void *)pc; - m.EXC_RS_PS_STR = (void *)ps_str; + memset(&m, 0, sizeof(m)); + m.m_type = PM_EXEC_RESTART; + m.PM_EXEC_RESTART_ENDPT = proc_e; + m.PM_EXEC_RESTART_RESULT = result; + m.PM_EXEC_RESTART_PC = (void *)pc; + m.PM_EXEC_RESTART_PS_STR = (void *)ps_str; r = sendrec(PM_PROC_NR, &m); if (r != OK) diff --git a/servers/vfs/README b/servers/vfs/README index c2a3d3549..e6ee5f6e7 100644 --- a/servers/vfs/README +++ b/servers/vfs/README @@ -38,9 +38,9 @@ it supports a few calls necessary for libc. The following system calls are handled by VFS: access, chdir, chmod, chown, chroot, close, creat, fchdir, fcntl, fstat, -fstatvfs, fsync, ftruncate, getdents, getvfsstat, ioctl, link, llseek, lseek, -lstat, mkdir, mknod, mount, open, pipe, read, readlink, rename, rmdir, select, -stat, statvfs, symlink, sync, truncate, umask, umount, unlink, utime, write. +fstatvfs, fsync, ftruncate, getdents, getvfsstat, ioctl, link, lseek, +lstat, mkdir, mknod, mount, open, pipe2, read, readlink, rename, rmdir, select, +stat, statvfs, symlink, sync, truncate, umask, umount, unlink, utimes, write. Second, it maintains part of the state belonging to a process (process state is spread out over the kernel, VM, PM, and VFS). For example, it maintains state @@ -373,7 +373,7 @@ requests) do need a vmnt lock. | | unlink, utime | +-------------------+---------------------------------------------------------+ | System calls with | close, fchdir, fcntl, fstat, fstatvfs, ftruncate, | -| a file descriptor | getdents, ioctl, llseek, pipe, read, select, write | +| a file descriptor | getdents, ioctl, lseek, pipe, read, select, write | | argument | | +-------------------+---------------------------------------------------------+ | System calls with | fsync++, getvfsstat, sync, umask | diff --git a/servers/vfs/coredump.c b/servers/vfs/coredump.c index f1a3f800d..a4068d14d 100644 --- a/servers/vfs/coredump.c +++ b/servers/vfs/coredump.c @@ -4,7 +4,6 @@ #include #include #include -#include "param.h" /* Include ELF headers */ #include diff --git a/servers/vfs/device.c b/servers/vfs/device.c index dc07a3e3f..20f9b40da 100644 --- a/servers/vfs/device.c +++ b/servers/vfs/device.c @@ -31,7 +31,6 @@ #include #include "vnode.h" #include "vmnt.h" -#include "param.h" static int cdev_opcl(int op, dev_t dev, int flags); static int block_io(endpoint_t driver_e, message *mess_ptr); @@ -478,7 +477,7 @@ int cdev_close(dev_t dev) *===========================================================================*/ int do_ioctl(void) { -/* Perform the ioctl(ls_fd, request, argx) system call */ +/* Perform the ioctl(2) system call. */ unsigned long ioctlrequest; int r = OK; struct filp *f; diff --git a/servers/vfs/dmap.c b/servers/vfs/dmap.c index 9be6d7b3b..4bc5785ff 100644 --- a/servers/vfs/dmap.c +++ b/servers/vfs/dmap.c @@ -9,9 +9,8 @@ #include #include #include -#include +#include #include -#include "param.h" /* The order of the entries in the table determines the mapping between major * device numbers and device drivers. Character and block devices diff --git a/servers/vfs/exec.c b/servers/vfs/exec.c index 669aa93ff..ca12ddd28 100644 --- a/servers/vfs/exec.c +++ b/servers/vfs/exec.c @@ -28,7 +28,6 @@ #include #include #include "path.h" -#include "param.h" #include "vnode.h" #include "file.h" #include @@ -183,8 +182,7 @@ static int vfs_memmap(struct exec_info *execi, * pm_exec * *===========================================================================*/ int pm_exec(vir_bytes path, size_t path_len, vir_bytes frame, size_t frame_len, - vir_bytes *pc, vir_bytes *newsp, vir_bytes *UNUSED(ps_str), - int user_exec_flags) + vir_bytes *pc, vir_bytes *newsp, vir_bytes *UNUSED(ps_str)) { /* Perform the execve(name, argv, envp) call. The user library builds a * complete stack image, including pointers, args, environ, etc. The stack @@ -214,7 +212,7 @@ int pm_exec(vir_bytes path, size_t path_len, vir_bytes frame, size_t frame_len, execi.vmfd = -1; /* passed from exec() libc code */ - execi.userflags = user_exec_flags; + execi.userflags = 0; execi.args.stack_high = kinfo.user_sp; execi.args.stack_size = DEFAULT_STACK_LIMIT; diff --git a/servers/vfs/filedes.c b/servers/vfs/filedes.c index d027bdd44..81c40557e 100644 --- a/servers/vfs/filedes.c +++ b/servers/vfs/filedes.c @@ -384,7 +384,7 @@ struct filp *f; /* If the inode being closed is a pipe, release everyone hanging on it. */ if (S_ISFIFO(vp->v_mode)) { - rw = (f->filp_mode & R_BIT ? WRITE : READ); + rw = (f->filp_mode & R_BIT ? VFS_WRITE : VFS_READ); release(vp, rw, susp_count); } diff --git a/servers/vfs/glo.h b/servers/vfs/glo.h index 50a4bf259..513d86070 100644 --- a/servers/vfs/glo.h +++ b/servers/vfs/glo.h @@ -43,7 +43,7 @@ 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 (* const call_vec[])(void); EXTERN struct kinfo kinfo; /* kernel information */ diff --git a/servers/vfs/link.c b/servers/vfs/link.c index a1ba296f8..ecfdb1828 100644 --- a/servers/vfs/link.c +++ b/servers/vfs/link.c @@ -22,7 +22,6 @@ #include "file.h" #include "path.h" #include "vnode.h" -#include "param.h" #include "scratchpad.h" /*===========================================================================* @@ -39,10 +38,10 @@ int do_link(void) vir_bytes vname1, vname2; size_t vname1_length, vname2_length; - vname1 = (vir_bytes) job_m_in.name1; - vname1_length = job_m_in.name1_length; - vname2 = (vir_bytes) job_m_in.name2; - vname2_length = job_m_in.name2_length; + vname1 = (vir_bytes) job_m_in.VFS_LINK_NAME1; + vname1_length = job_m_in.VFS_LINK_LEN1; + vname2 = (vir_bytes) job_m_in.VFS_LINK_NAME2; + vname2_length = job_m_in.VFS_LINK_LEN2; lookup_init(&resolve, fullpath, PATH_NOFLAGS, &vmp1, &vp); resolve.l_vmnt_lock = VMNT_WRITE; @@ -102,16 +101,9 @@ int do_unlink(void) int r; char fullpath[PATH_MAX]; struct lookup resolve, stickycheck; - vir_bytes vname; - size_t vname_length; - vname = (vir_bytes) job_m_in.name; - vname_length = job_m_in.name_length; - if (copy_name(vname_length, fullpath) != OK) { - /* Direct copy failed, try fetching from user space */ - if (fetch_name(vname, vname_length, fullpath) != OK) - return(err_code); - } + if (copy_path(fullpath, sizeof(fullpath)) != OK) + return(err_code); lookup_init(&resolve, fullpath, PATH_RET_SYMLINK, &vmp, &dirp_l); resolve.l_vmnt_lock = VMNT_WRITE; @@ -162,7 +154,7 @@ int do_unlink(void) upgrade_vmnt_lock(vmp); - if (job_call_nr == UNLINK) + if (job_call_nr == VFS_UNLINK) r = req_unlink(dirp->v_fs_e, dirp->v_inode_nr, fullpath); else r = req_rmdir(dirp->v_fs_e, dirp->v_inode_nr, fullpath); @@ -187,10 +179,10 @@ int do_rename(void) vir_bytes vname1, vname2; size_t vname1_length, vname2_length; - vname1 = (vir_bytes) job_m_in.name1; - vname1_length = job_m_in.name1_length; - vname2 = (vir_bytes) job_m_in.name2; - vname2_length = job_m_in.name2_length; + vname1 = (vir_bytes) job_m_in.VFS_LINK_NAME1; + vname1_length = job_m_in.VFS_LINK_LEN1; + vname2 = (vir_bytes) job_m_in.VFS_LINK_NAME2; + vname2_length = job_m_in.VFS_LINK_LEN2; lookup_init(&resolve, fullpath, PATH_RET_SYMLINK, &oldvmp, &old_dirp); /* Do not yet request exclusive lock on vmnt to prevent deadlocks later on */ @@ -298,14 +290,15 @@ int do_truncate(void) vir_bytes vname; size_t vname_length; - vname = (vir_bytes) job_m_in.m2_p1; - vname_length = job_m_in.m2_i1; + vname = (vir_bytes) job_m_in.VFS_TRUNCATE_NAME; + vname_length = job_m_in.VFS_TRUNCATE_LEN; lookup_init(&resolve, fullpath, PATH_NOFLAGS, &vmp, &vp); resolve.l_vmnt_lock = VMNT_READ; resolve.l_vnode_lock = VNODE_WRITE; - length = (off_t) make64(job_m_in.m2_l1, job_m_in.m2_l2); + length = (off_t) make64(job_m_in.VFS_TRUNCATE_OFF_LO, + job_m_in.VFS_TRUNCATE_OFF_HI); if (length < 0) return(EINVAL); /* Temporarily open file */ @@ -341,9 +334,10 @@ int do_ftruncate(void) int r; off_t length; - scratch(fp).file.fd_nr = job_m_in.fd; + scratch(fp).file.fd_nr = job_m_in.VFS_TRUNCATE_FD; - length = (off_t) make64(job_m_in.m2_l1, job_m_in.m2_l2); + length = (off_t) make64(job_m_in.VFS_TRUNCATE_OFF_LO, + job_m_in.VFS_TRUNCATE_OFF_HI); if (length < 0) return(EINVAL); /* File is already opened; get a vnode pointer from filp */ @@ -409,10 +403,10 @@ int do_slink(void) resolve.l_vmnt_lock = VMNT_WRITE; resolve.l_vnode_lock = VNODE_WRITE; - vname1 = (vir_bytes) job_m_in.name1; - vname1_length = job_m_in.name1_length; - vname2 = (vir_bytes) job_m_in.name2; - vname2_length = job_m_in.name2_length; + vname1 = (vir_bytes) job_m_in.VFS_LINK_NAME1; + vname1_length = job_m_in.VFS_LINK_LEN1; + vname2 = (vir_bytes) job_m_in.VFS_LINK_NAME2; + vname2_length = job_m_in.VFS_LINK_LEN2; if (vname1_length <= 1) return(ENOENT); if (vname1_length >= SYMLINK_MAX) return(ENAMETOOLONG); @@ -488,10 +482,10 @@ int do_rdlink(void) size_t vname_length, buf_size; vir_bytes buf; - vname = (vir_bytes) job_m_in.name1; - vname_length = job_m_in.name1_length; - buf = (vir_bytes) job_m_in.name2; - buf_size = (size_t) job_m_in.nbytes; + vname = (vir_bytes) job_m_in.VFS_READLINK_NAME; + vname_length = job_m_in.VFS_READLINK_NAMELEN; + buf = (vir_bytes) job_m_in.VFS_READLINK_BUF; + buf_size = (size_t) job_m_in.VFS_READLINK_BUFSIZE; if (buf_size > SSIZE_MAX) return(EINVAL); lookup_init(&resolve, fullpath, PATH_RET_SYMLINK, &vmp, &vp); diff --git a/servers/vfs/lock.c b/servers/vfs/lock.c index 1b9ed021e..30fc30bc5 100644 --- a/servers/vfs/lock.c +++ b/servers/vfs/lock.c @@ -14,7 +14,6 @@ #include "scratchpad.h" #include "lock.h" #include "vnode.h" -#include "param.h" /*===========================================================================* * lock_op * diff --git a/servers/vfs/main.c b/servers/vfs/main.c index 68eb02a37..6bda04548 100644 --- a/servers/vfs/main.c +++ b/servers/vfs/main.c @@ -29,10 +29,9 @@ #include "scratchpad.h" #include "vmnt.h" #include "vnode.h" -#include "param.h" #if ENABLE_SYSCALL_STATS -EXTERN unsigned long calls_stats[NCALLS]; +EXTERN unsigned long calls_stats[NR_VFS_CALLS]; #endif /* Thread related prototypes */ @@ -212,8 +211,8 @@ static void do_pending_pipe(void) assert(f != NULL); scratch(fp).file.filp = NULL; - locktype = (job_call_nr == READ) ? VNODE_READ : VNODE_WRITE; - op = (job_call_nr == READ) ? READING : WRITING; + locktype = (job_call_nr == VFS_READ) ? VNODE_READ : VNODE_WRITE; + op = (job_call_nr == VFS_READ) ? READING : WRITING; lock_filp(f, locktype); r = rw_pipe(op, who_e, f, scratch(fp).io.io_buffer, scratch(fp).io.io_nbytes); @@ -229,8 +228,16 @@ static void do_pending_pipe(void) *===========================================================================*/ static void do_work(void) { + unsigned int call_index; int error; + if (fp->fp_pid == PID_FREE) { + /* Process vanished before we were able to handle request. + * Replying has no use. Just drop it. + */ + return; + } + memset(&job_m_out, 0, sizeof(job_m_out)); /* At this point we assume that we're dealing with a call that has been @@ -239,18 +246,18 @@ static void do_work(void) * such as UDS and VND through here. Call the internal function that * does the work. */ - if (job_call_nr < 0 || job_call_nr >= NCALLS) { - error = ENOSYS; - } else if (fp->fp_pid == PID_FREE) { - /* Process vanished before we were able to handle request. - * Replying has no use. Just drop it. */ - error = SUSPEND; - } else { + if (IS_VFS_CALL(job_call_nr)) { + call_index = (unsigned int) (job_call_nr - VFS_BASE); + + if (call_index < NR_VFS_CALLS && call_vec[call_index] != NULL) { #if ENABLE_SYSCALL_STATS - calls_stats[job_call_nr]++; + calls_stats[call_index]++; #endif - error = (*call_vec[job_call_nr])(); - } + error = (*call_vec[call_index])(); + } else + error = ENOSYS; + } else + error = ENOSYS; /* Copy the results back to the user and send reply. */ if (error != SUSPEND) reply(&job_m_out, fp->fp_endpoint, error); @@ -525,7 +532,7 @@ static 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; + m_out->m_type = result; r = sendnb(whom, m_out); if (r != OK) { printf("VFS: %d couldn't send reply %d to %d: %d\n", mthread_self(), @@ -573,7 +580,7 @@ void service_pm_postponed(void) assert(proc_e == fp->fp_endpoint); r = pm_exec(exec_path, exec_path_len, stack_frame, stack_frame_len, - &pc, &newsp, &ps_str, job_m_in.VFS_PM_EXECFLAGS); + &pc, &newsp, &ps_str); /* Reply status to PM */ m_out.m_type = VFS_PM_EXEC_REPLY; @@ -807,14 +814,28 @@ struct fproc *rfp; blocked_on = rfp->fp_blocked_on; - assert(blocked_on == FP_BLOCKED_ON_PIPE || blocked_on == FP_BLOCKED_ON_LOCK); - - /* READ, WRITE, FCNTL requests all use the same message layout. */ + /* Reconstruct the original request from the saved data. */ + memset(&m_in, 0, sizeof(m_in)); m_in.m_source = rfp->fp_endpoint; m_in.m_type = rfp->fp_block_callnr; - m_in.fd = scratch(rfp).file.fd_nr; - m_in.buffer = scratch(rfp).io.io_buffer; - m_in.nbytes = scratch(rfp).io.io_nbytes; + switch (m_in.m_type) { + case VFS_READ: + case VFS_WRITE: + assert(blocked_on == FP_BLOCKED_ON_PIPE); + m_in.VFS_READWRITE_FD = scratch(rfp).file.fd_nr; + m_in.VFS_READWRITE_BUF = scratch(rfp).io.io_buffer; + m_in.VFS_READWRITE_LEN = scratch(rfp).io.io_nbytes; + break; + case VFS_FCNTL: + assert(blocked_on == FP_BLOCKED_ON_LOCK); + m_in.VFS_FCNTL_FD = scratch(rfp).file.fd_nr; + m_in.VFS_FCNTL_CMD = scratch(rfp).io.io_nbytes; + m_in.VFS_FCNTL_ARG_PTR = scratch(rfp).io.io_buffer; + assert(m_in.VFS_FCNTL_CMD == F_SETLKW); + break; + default: + panic("unblocking call %d blocked on %d ??", m_in.m_type, blocked_on); + } rfp->fp_blocked_on = FP_BLOCKED_ON_NONE; /* no longer blocked */ rfp->fp_flags &= ~FP_REVIVED; diff --git a/servers/vfs/misc.c b/servers/vfs/misc.c index 9c32460ef..c8cd0dc14 100644 --- a/servers/vfs/misc.c +++ b/servers/vfs/misc.c @@ -37,13 +37,12 @@ #include #include "vnode.h" #include "vmnt.h" -#include "param.h" #define CORE_NAME "core" #define CORE_MODE 0777 /* mode to use on core image files */ #if ENABLE_SYSCALL_STATS -unsigned long calls_stats[NCALLS]; +unsigned long calls_stats[NR_VFS_CALLS]; #endif static void free_proc(int flags); @@ -98,17 +97,17 @@ int do_getsysinfo(void) *===========================================================================*/ int do_fcntl(void) { -/* Perform the fcntl(fd, request, ...) system call. */ +/* Perform the fcntl(fd, cmd, ...) system call. */ register struct filp *f; int new_fd, fl, r = OK, fcntl_req, fcntl_argx; tll_access_t locktype; - scratch(fp).file.fd_nr = job_m_in.fd; - scratch(fp).io.io_buffer = job_m_in.buffer; - scratch(fp).io.io_nbytes = job_m_in.nbytes; /* a.k.a. m_in.request */ - fcntl_req = job_m_in.request; - fcntl_argx = job_m_in.addr; + scratch(fp).file.fd_nr = job_m_in.VFS_FCNTL_FD; + scratch(fp).io.io_buffer = job_m_in.VFS_FCNTL_ARG_PTR; + scratch(fp).io.io_nbytes = job_m_in.VFS_FCNTL_CMD; + fcntl_req = job_m_in.VFS_FCNTL_CMD; + fcntl_argx = job_m_in.VFS_FCNTL_ARG_INT; /* Is the file descriptor valid? */ locktype = (fcntl_req == F_FREESP) ? VNODE_WRITE : VNODE_READ; @@ -264,7 +263,7 @@ int do_fsync(void) dev_t dev; int r = OK; - scratch(fp).file.fd_nr = job_m_in.fd; + scratch(fp).file.fd_nr = job_m_in.VFS_FSYNC_FD; if ((rfilp = get_filp(scratch(fp).file.fd_nr, VNODE_READ)) == NULL) return(err_code); @@ -419,7 +418,7 @@ int do_vm_call(void) } case VMVFSREQ_FDIO: { - result = actual_llseek(fp, req_fd, SEEK_SET, offset, + result = actual_lseek(fp, req_fd, SEEK_SET, offset, NULL); if(result == OK) { @@ -763,8 +762,8 @@ int do_svrctl(void) unsigned int svrctl; vir_bytes ptr; - svrctl = job_m_in.svrctl_req; - ptr = (vir_bytes) job_m_in.svrctl_argp; + svrctl = job_m_in.SVRCTL_REQ; + ptr = (vir_bytes) job_m_in.SVRCTL_ARG; if (((svrctl >> 8) & 0xFF) != 'M') return(EINVAL); switch (svrctl) { diff --git a/servers/vfs/mount.c b/servers/vfs/mount.c index 60cd61952..6569eb86d 100644 --- a/servers/vfs/mount.c +++ b/servers/vfs/mount.c @@ -1,7 +1,6 @@ /* This file performs the MOUNT and UMOUNT system calls. * * The entry points into this file are - * do_fsready: perform the FS_READY system call * do_mount: perform the MOUNT system call * do_umount: perform the UMOUNT system call * unmount: unmount a file system @@ -27,7 +26,6 @@ #include "vnode.h" #include "vmnt.h" #include "path.h" -#include "param.h" /* Allow the root to be replaced before the first 'real' mount. */ static int have_root = 0; @@ -80,15 +78,6 @@ static void update_bspec(dev_t dev, endpoint_t fs_e, int send_drv_e) } } -/*===========================================================================* - * do_fsready * - *===========================================================================*/ -int do_fsready(void) -{ - /* deprecated */ - return(SUSPEND); -} - /*===========================================================================* * do_mount * *===========================================================================*/ diff --git a/servers/vfs/open.c b/servers/vfs/open.c index 907cfb706..23db128b7 100644 --- a/servers/vfs/open.c +++ b/servers/vfs/open.c @@ -20,7 +20,6 @@ #include "file.h" #include "scratchpad.h" #include "lock.h" -#include "param.h" #include #include #include @@ -39,39 +38,45 @@ static int pipe_open(struct vnode *vp, mode_t bits, int oflags); *===========================================================================*/ int do_open(void) { -/* Perform the open(name, flags,...) system call. - * syscall might provide 'name' embedded in message when not creating file */ +/* Perform the open(name, flags) system call with O_CREAT *not* set. */ + int open_flags; + char fullpath[PATH_MAX]; - int create_mode; /* is really mode_t but this gives problems */ - int open_mode = 0; /* is really mode_t but this gives problems */ - int r = OK; + open_flags = job_m_in.VFS_PATH_FLAGS; + + if (open_flags & O_CREAT) + return EINVAL; + + if (copy_path(fullpath, sizeof(fullpath)) != OK) + return(err_code); + + return common_open(fullpath, open_flags, 0 /*omode*/); +} + +/*===========================================================================* + * do_creat * + *===========================================================================*/ +int do_creat(void) +{ +/* Perform the open(name, flags, mode) system call with O_CREAT set. */ + int open_flags, create_mode; char fullpath[PATH_MAX]; vir_bytes vname; size_t vname_length; - open_mode = (mode_t) job_m_in.mode; - create_mode = job_m_in.c_mode; + vname = (vir_bytes) job_m_in.VFS_CREAT_NAME; + vname_length = (size_t) job_m_in.VFS_CREAT_LEN; + open_flags = job_m_in.VFS_CREAT_FLAGS; + create_mode = job_m_in.VFS_CREAT_MODE; - /* If O_CREAT is set, open has three parameters, otherwise two. */ - if (open_mode & O_CREAT) { - vname = (vir_bytes) job_m_in.name1; - vname_length = (size_t) job_m_in.name1_length; - r = fetch_name(vname, vname_length, fullpath); - } else { - vname = (vir_bytes) job_m_in.name; - vname_length = (size_t) job_m_in.name_length; - create_mode = 0; - if (copy_name(vname_length, fullpath) != OK) { - /* Direct copy failed, try fetching from user space */ - if (fetch_name(vname, vname_length, fullpath) != OK) - r = err_code; - } - } + if (!(open_flags & O_CREAT)) + return(EINVAL); - if (r != OK) return(err_code); /* name was bad */ - return common_open(fullpath, open_mode, create_mode); -} + if (fetch_name(vname, vname_length, fullpath) != OK) + return(err_code); + return common_open(fullpath, open_flags, create_mode); +} /*===========================================================================* * common_open * @@ -486,7 +491,7 @@ static int pipe_open(struct vnode *vp, mode_t bits, int oflags) return(SUSPEND); } } else if (susp_count > 0) { /* revive blocked processes */ - release(vp, OPEN, susp_count); + release(vp, VFS_OPEN, susp_count); } return(OK); } @@ -508,10 +513,10 @@ int do_mknod(void) size_t vname1_length; dev_t dev; - vname1 = (vir_bytes) job_m_in.name1; - vname1_length = (size_t) job_m_in.name1_length; - mode_bits = (mode_t) job_m_in.mk_mode; /* mode of the inode */ - dev = job_m_in.m1_i3; + vname1 = (vir_bytes) job_m_in.VFS_MKNOD_NAME; + vname1_length = (size_t) job_m_in.VFS_MKNOD_LEN; + mode_bits = (mode_t) job_m_in.VFS_MKNOD_MODE; + dev = job_m_in.VFS_MKNOD_DEV; lookup_init(&resolve, fullpath, PATH_NOFLAGS, &vmp, &vp); resolve.l_vmnt_lock = VMNT_WRITE; @@ -553,19 +558,16 @@ int do_mkdir(void) struct vmnt *vmp; char fullpath[PATH_MAX]; struct lookup resolve; - vir_bytes vname1; - size_t vname1_length; mode_t dirmode; - vname1 = (vir_bytes) job_m_in.name1; - vname1_length = (size_t) job_m_in.name1_length; - dirmode = (mode_t) job_m_in.mode; + if (copy_path(fullpath, sizeof(fullpath)) != OK) + return(err_code); + dirmode = (mode_t) job_m_in.VFS_PATH_MODE; lookup_init(&resolve, fullpath, PATH_NOFLAGS, &vmp, &vp); resolve.l_vmnt_lock = VMNT_WRITE; resolve.l_vnode_lock = VNODE_WRITE; - if (fetch_name(vname1, vname1_length, fullpath) != OK) return(err_code); bits = I_DIRECTORY | (dirmode & RWX_MODES & fp->fp_umask); if ((vp = last_dir(&resolve, fp)) == NULL) return(err_code); @@ -584,12 +586,11 @@ int do_mkdir(void) } /*===========================================================================* - * actual_llseek * + * actual_lseek * *===========================================================================*/ -int actual_llseek(struct fproc *rfp, int seekfd, int seekwhence, off_t offset, +int actual_lseek(struct fproc *rfp, int seekfd, int seekwhence, off_t offset, off_t *newposp) { -/* Perform the llseek(ls_fd, offset, whence) system call. */ register struct filp *rfilp; int r = OK; off_t pos, newpos; @@ -641,18 +642,19 @@ int actual_llseek(struct fproc *rfp, int seekfd, int seekwhence, off_t offset, *===========================================================================*/ int do_lseek(void) { - off_t newpos; - int r; - - if ((r = actual_llseek(fp, job_m_in.ls_fd, job_m_in.whence, - make64(job_m_in.offset_lo, job_m_in.offset_high), - &newpos)) != OK) - return r; - - /* insert the new position into the output message */ - job_m_out.reply_l1 = ex64lo(newpos); - job_m_out.reply_l2 = ex64hi(newpos); - return OK; + /* Perform the lseek(2) system call. */ + off_t newpos; + int r; + + if ((r = actual_lseek(fp, job_m_in.VFS_LSEEK_FD, + job_m_in.VFS_LSEEK_WHENCE, make64(job_m_in.VFS_LSEEK_OFF_LO, + job_m_in.VFS_LSEEK_OFF_HI), &newpos)) != OK) + return r; + + /* insert the new position into the output message */ + job_m_out.VFS_LSEEK_OFF_LO = ex64lo(newpos); + job_m_out.VFS_LSEEK_OFF_HI = ex64hi(newpos); + return OK; } /*===========================================================================* @@ -661,7 +663,7 @@ int do_lseek(void) int do_close(void) { /* Perform the close(fd) system call. */ - int thefd = job_m_in.fd; + int thefd = job_m_in.VFS_CLOSE_FD; return close_fd(fp, thefd); } diff --git a/servers/vfs/param.h b/servers/vfs/param.h deleted file mode 100644 index 1a60c0fa2..000000000 --- a/servers/vfs/param.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef __VFS_PARAM_H__ -#define __VFS_PARAM_H__ - -/* The following names are synonyms for the variables in the input message. */ -#define addr m1_i3 -#define buffer m1_p1 -#define child_endpt m1_i2 -#define co_mode m1_i1 -#define fd m1_i1 -#define fd2 m1_i2 -#define group m1_i3 -#define ls_fd m2_i1 -#define mk_mode m1_i2 -#define mk_z0 m1_i3 -#define mode m3_i2 -#define c_mode m1_i3 -#define c_name m1_p1 -#define name m3_p1 -#define flength m2_l1 -#define name1 m1_p1 -#define name2 m1_p2 -#define name_length m3_i1 -#define name1_length m1_i1 -#define name2_length m1_i2 -#define nbytes m1_i2 -#define owner m1_i2 -#define pathname m3_ca1 -#define pid m1_i3 -#define ENDPT m1_i1 -#define offset_lo m2_l1 -#define offset_high m2_l2 -#define ctl_req m4_l1 -#define pipe_flags m1_i3 -#define request m1_i2 -#define sig m1_i2 -#define tp m2_l1 -#define utime_actime m2_l1 -#define utime_modtime m2_l2 -#define utime_file m2_p1 -#define utime_length m2_i1 -#define utime_strlen m2_i2 -#define utimens_fd m2_i1 -#define utimens_ansec m2_i2 -#define utimens_mnsec m2_i3 -#define utimens_flags m2_s1 -#define whence m2_i2 -#define svrctl_req m2_i1 -#define svrctl_argp m2_p1 - -/* The following names are synonyms for the variables in the output message. */ -#define reply_type m_type -#define reply_l1 m2_l1 -#define reply_l2 m2_l2 -#define reply_i1 m1_i1 -#define reply_i2 m1_i2 - -#endif diff --git a/servers/vfs/path.c b/servers/vfs/path.c index 99ab8155e..727e2b92f 100644 --- a/servers/vfs/path.c +++ b/servers/vfs/path.c @@ -20,7 +20,6 @@ #include "vmnt.h" #include "vnode.h" #include "path.h" -#include "param.h" /* Set to following define to 1 if you really want to use the POSIX definition * (IEEE Std 1003.1, 2004) of pathname resolution. POSIX requires pathnames @@ -437,8 +436,8 @@ struct fproc *rfp; root_ino = 0; /* Set user and group ids according to the system call */ - uid = (job_call_nr == ACCESS ? rfp->fp_realuid : rfp->fp_effuid); - gid = (job_call_nr == ACCESS ? rfp->fp_realgid : rfp->fp_effgid); + uid = (job_call_nr == VFS_ACCESS ? rfp->fp_realuid : rfp->fp_effuid); + gid = (job_call_nr == VFS_ACCESS ? rfp->fp_realgid : rfp->fp_effgid); symloop = 0; /* Number of symlinks seen so far */ diff --git a/servers/vfs/pipe.c b/servers/vfs/pipe.c index b3305e947..ab658d438 100644 --- a/servers/vfs/pipe.c +++ b/servers/vfs/pipe.c @@ -5,7 +5,7 @@ * to continue. * * The entry points into this file are - * do_pipe: perform the PIPE system call + * do_pipe2: perform the PIPE2 system call * pipe_check: check to see that a read or write on a pipe is feasible now * suspend: suspend a process that cannot do a requested read or write * release: check to see if a suspended process can be released and do @@ -28,32 +28,12 @@ #include #include "file.h" #include "scratchpad.h" -#include "param.h" #include #include "vnode.h" #include "vmnt.h" static int create_pipe(int fil_des[2], int flags); -/*===========================================================================* - * do_pipe * - *===========================================================================*/ -int do_pipe(void) -{ -/* Perform the pipe(fil_des[2]) system call. */ - - int r; - int fil_des[2]; /* reply goes here */ - - r = create_pipe(fil_des, 0 /* no flags */); - if (r == OK) { - job_m_out.reply_i1 = fil_des[0]; - job_m_out.reply_i2 = fil_des[1]; - } - - return r; -} - /*===========================================================================* * do_pipe2 * *===========================================================================*/ @@ -63,12 +43,12 @@ int do_pipe2(void) int r, flags; int fil_des[2]; /* reply goes here */ - flags = job_m_in.pipe_flags; + flags = job_m_in.VFS_PIPE2_FLAGS; r = create_pipe(fil_des, flags); if (r == OK) { - job_m_out.reply_i1 = fil_des[0]; - job_m_out.reply_i2 = fil_des[1]; + job_m_out.VFS_PIPE2_FD0 = fil_des[0]; + job_m_out.VFS_PIPE2_FD1 = fil_des[1]; } return r; @@ -247,7 +227,7 @@ int notouch /* check only */ /* If need be, activate sleeping writers. */ if (susp_count > 0) - release(vp, WRITE, susp_count); + release(vp, VFS_WRITE, susp_count); } return(r); } @@ -273,7 +253,7 @@ int notouch /* check only */ if (bytes > 0) { /* Do a partial write. Need to wakeup reader */ if (!notouch) - release(vp, READ, susp_count); + release(vp, VFS_READ, susp_count); return(bytes); } else { /* Pipe is full */ @@ -290,7 +270,7 @@ int notouch /* check only */ * since we'll suspend ourself in read_write() */ if (!notouch) - release(vp, READ, susp_count); + release(vp, VFS_READ, susp_count); return(bytes); } } @@ -301,7 +281,7 @@ int notouch /* check only */ /* Writing to an empty pipe. Search for suspended reader. */ if (pos == 0 && !notouch) - release(vp, READ, susp_count); + release(vp, VFS_READ, susp_count); /* Requested amount fits */ return(bytes); @@ -388,11 +368,11 @@ void unsuspend_by_endpt(endpoint_t proc_e) *===========================================================================*/ void release(vp, op, count) register struct vnode *vp; /* inode of pipe */ -int op; /* READ, WRITE, or OPEN */ +int op; /* VFS_READ, VFS_WRITE, or VFS_OPEN */ int count; /* max number of processes to release */ { /* Check to see if any process is hanging on vnode 'vp'. If one is, and it - * was trying to perform the call indicated by 'call_nr', release it. + * was trying to perform the call indicated by 'op', release it. */ register struct fproc *rp; @@ -402,8 +382,8 @@ int count; /* max number of processes to release */ /* Trying to perform the call also includes SELECTing on it with that * operation. */ - if (op == READ || op == WRITE) { - if (op == READ) + if (op == VFS_READ || op == VFS_WRITE) { + if (op == VFS_READ) selop = SEL_RD; else selop = SEL_WR; diff --git a/servers/vfs/protect.c b/servers/vfs/protect.c index 9255fe7bd..aab23d207 100644 --- a/servers/vfs/protect.c +++ b/servers/vfs/protect.c @@ -15,7 +15,6 @@ #include #include "file.h" #include "path.h" -#include "param.h" #include #include "vnode.h" #include "vmnt.h" @@ -36,29 +35,23 @@ int do_chmod(void) mode_t result_mode; char fullpath[PATH_MAX]; struct lookup resolve; - vir_bytes vname; - size_t vname_length; mode_t new_mode; flp = NULL; - vname = (vir_bytes) job_m_in.name; - vname_length = (size_t) job_m_in.name_length; - rfd = job_m_in.fd; - new_mode = (mode_t) job_m_in.mode; lookup_init(&resolve, fullpath, PATH_NOFLAGS, &vmp, &vp); resolve.l_vmnt_lock = VMNT_READ; resolve.l_vnode_lock = VNODE_WRITE; - if (job_call_nr == CHMOD) { + if (job_call_nr == VFS_CHMOD) { + new_mode = job_m_in.VFS_PATH_MODE; /* Temporarily open the file */ - if (copy_name(vname_length, fullpath) != OK) { - /* Direct copy failed, try fetching from user space */ - if (fetch_name(vname, vname_length, fullpath) != OK) - return(err_code); - } + if (copy_path(fullpath, sizeof(fullpath)) != OK) + return(err_code); if ((vp = eat_path(&resolve, fp)) == NULL) return(err_code); - } else { /* call_nr == FCHMOD */ + } else { /* call_nr == VFS_FCHMOD */ + rfd = job_m_in.VFS_FCHMOD_FD; + new_mode = (mode_t) job_m_in.VFS_FCHMOD_MODE; /* File is already opened; get a pointer to vnode from filp. */ if ((flp = get_filp(rfd, VNODE_WRITE)) == NULL) return(err_code); vp = flp->filp_vno; @@ -87,10 +80,10 @@ int do_chmod(void) vp->v_mode = result_mode; } - if (job_call_nr == CHMOD) { + if (job_call_nr == VFS_CHMOD) { unlock_vnode(vp); unlock_vmnt(vmp); - } else { /* FCHMOD */ + } else { /* VFS_FCHMOD */ unlock_filp(flp); } @@ -119,22 +112,24 @@ int do_chown(void) size_t vname1_length; flp = NULL; - vname1 = (vir_bytes) job_m_in.name1; - vname1_length = (size_t) job_m_in.name1_length; - rfd = job_m_in.fd; - uid = job_m_in.owner; - gid = job_m_in.group; + uid = job_m_in.VFS_CHOWN_OWNER; + gid = job_m_in.VFS_CHOWN_GROUP; - lookup_init(&resolve, fullpath, PATH_NOFLAGS, &vmp, &vp); - resolve.l_vmnt_lock = VMNT_READ; - resolve.l_vnode_lock = VNODE_WRITE; + if (job_call_nr == VFS_CHOWN) { + vname1 = (vir_bytes) job_m_in.VFS_CHOWN_NAME; + vname1_length = (size_t) job_m_in.VFS_CHOWN_LEN; + + lookup_init(&resolve, fullpath, PATH_NOFLAGS, &vmp, &vp); + resolve.l_vmnt_lock = VMNT_READ; + resolve.l_vnode_lock = VNODE_WRITE; - if (job_call_nr == CHOWN) { /* Temporarily open the file. */ if (fetch_name(vname1, vname1_length, fullpath) != OK) return(err_code); if ((vp = eat_path(&resolve, fp)) == NULL) return(err_code); - } else { /* call_nr == FCHOWN */ + } else { /* call_nr == VFS_FCHOWN */ + rfd = job_m_in.VFS_CHOWN_FD; + /* File is already opened; get a pointer to the vnode from filp. */ if ((flp = get_filp(rfd, VNODE_WRITE)) == NULL) return(err_code); @@ -170,10 +165,10 @@ int do_chown(void) } } - if (job_call_nr == CHOWN) { + if (job_call_nr == VFS_CHOWN) { unlock_vnode(vp); unlock_vmnt(vmp); - } else { /* FCHOWN */ + } else { /* VFS_FCHOWN */ unlock_filp(flp); } @@ -186,10 +181,10 @@ int do_chown(void) *===========================================================================*/ int do_umask(void) { -/* Perform the umask(co_mode) system call. */ +/* Perform the umask(2) system call. */ mode_t complement, new_umask; - new_umask = job_m_in.co_mode; + new_umask = job_m_in.VFS_UMASK_MASK; complement = ~fp->fp_umask; /* set 'r' to complement of old mask */ fp->fp_umask = ~(new_umask & RWX_MODES); @@ -210,13 +205,9 @@ int do_access(void) struct vmnt *vmp; char fullpath[PATH_MAX]; struct lookup resolve; - vir_bytes vname; - size_t vname_length; mode_t access; - vname = (vir_bytes) job_m_in.name; - vname_length = (size_t) job_m_in.name_length; - access = job_m_in.mode; + access = job_m_in.VFS_PATH_MODE; lookup_init(&resolve, fullpath, PATH_NOFLAGS, &vmp, &vp); resolve.l_vmnt_lock = VMNT_READ; @@ -227,11 +218,8 @@ int do_access(void) return(EINVAL); /* Temporarily open the file. */ - if (copy_name(vname_length, fullpath) != OK) { - /* Direct copy failed, try fetching from user space */ - if (fetch_name(vname, vname_length, fullpath) != OK) - return(err_code); - } + if (copy_path(fullpath, sizeof(fullpath)) != OK) + return(err_code); if ((vp = eat_path(&resolve, fp)) == NULL) return(err_code); r = forbidden(fp, vp, access); @@ -264,8 +252,8 @@ int forbidden(struct fproc *rfp, struct vnode *vp, mode_t access_desired) /* Isolate the relevant rwx bits from the mode. */ bits = vp->v_mode; - uid = (job_call_nr == ACCESS ? rfp->fp_realuid : rfp->fp_effuid); - gid = (job_call_nr == ACCESS ? rfp->fp_realgid : rfp->fp_effgid); + uid = (job_call_nr == VFS_ACCESS ? rfp->fp_realuid : rfp->fp_effuid); + gid = (job_call_nr == VFS_ACCESS ? rfp->fp_realgid : rfp->fp_effgid); if (uid == SU_UID) { /* Grant read and write permission. Grant search permission for diff --git a/servers/vfs/proto.h b/servers/vfs/proto.h index be4862ad9..941072e07 100644 --- a/servers/vfs/proto.h +++ b/servers/vfs/proto.h @@ -58,7 +58,7 @@ void write_elf_core_file(struct filp *f, int csig, char *exe_name); /* exec.c */ int pm_exec(vir_bytes path, size_t path_len, vir_bytes frame, size_t frame_len, - vir_bytes *pc, vir_bytes *newsp, vir_bytes *ps_str, int flags); + vir_bytes *pc, vir_bytes *newsp, vir_bytes *ps_str); /* filedes.c */ void check_filp_locks(void); @@ -122,7 +122,6 @@ int dupvm(struct fproc *fp, int pfd, int *vmfd, struct filp **f); int do_getrusage(void); /* mount.c */ -int do_fsready(void); int do_mount(void); int do_umount(void); int is_nonedev(dev_t dev); @@ -142,8 +141,9 @@ int do_lseek(void); int do_mknod(void); int do_mkdir(void); int do_open(void); +int do_creat(void); int do_slink(void); -int actual_llseek(struct fproc *rfp, int seekfd, int seekwhence, off_t offset, +int actual_lseek(struct fproc *rfp, int seekfd, int seekwhence, off_t offset, off_t *newposp); /* path.c */ @@ -158,7 +158,6 @@ int canonical_path(char *orig_path, struct fproc *rfp); int do_checkperms(void); /* pipe.c */ -int do_pipe(void); int do_pipe2(void); int map_vnode(struct vnode *vp, endpoint_t fs_e); void unpause(void); @@ -259,7 +258,6 @@ int do_lstat(void); int update_statvfs(struct vmnt *vmp, struct statvfs *buf); /* time.c */ -int do_utime(void); int do_utimens(void); /* tll.c */ @@ -275,11 +273,8 @@ void tll_upgrade(tll_t *tllp); /* utility.c */ struct timespec clock_timespec(void); -unsigned conv2(int norm, int w); -long conv4(int norm, long x); -int copy_name(size_t len, char *dest); +int copy_path(char *dest, size_t size); int fetch_name(vir_bytes path, size_t len, char *dest); -int no_sys(void); int isokendpt_f(const char *f, int l, endpoint_t e, int *p, int ft); int in_group(struct fproc *rfp, gid_t grp); @@ -321,7 +316,7 @@ int do_write(void); /* gcov.c */ int do_gcov_flush(void); #if ! USE_COVERAGE -#define do_gcov_flush no_sys +#define do_gcov_flush NULL #endif /* select.c */ diff --git a/servers/vfs/read.c b/servers/vfs/read.c index c94bf4250..c3c96d05f 100644 --- a/servers/vfs/read.c +++ b/servers/vfs/read.c @@ -20,7 +20,6 @@ #include #include #include "file.h" -#include "param.h" #include "scratchpad.h" #include "vnode.h" #include "vmnt.h" @@ -31,8 +30,8 @@ *===========================================================================*/ int do_read(void) { - return(do_read_write_peek(READING, job_m_in.fd, - job_m_in.buffer, (size_t) job_m_in.nbytes)); + return(do_read_write_peek(READING, job_m_in.VFS_READWRITE_FD, + job_m_in.VFS_READWRITE_BUF, (size_t) job_m_in.VFS_READWRITE_LEN)); } @@ -274,9 +273,9 @@ int do_getdents(void) off_t new_pos; register struct filp *rfilp; - scratch(fp).file.fd_nr = job_m_in.fd; - scratch(fp).io.io_buffer = job_m_in.buffer; - scratch(fp).io.io_nbytes = (size_t) job_m_in.nbytes; + scratch(fp).file.fd_nr = job_m_in.VFS_READWRITE_FD; + scratch(fp).io.io_buffer = job_m_in.VFS_READWRITE_BUF; + scratch(fp).io.io_nbytes = (size_t) job_m_in.VFS_READWRITE_LEN; /* Is the file descriptor valid? */ if ( (rfilp = get_filp(scratch(fp).file.fd_nr, VNODE_READ)) == NULL) diff --git a/servers/vfs/select.c b/servers/vfs/select.c index bb17c737e..fc8b189d4 100644 --- a/servers/vfs/select.c +++ b/servers/vfs/select.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include #include @@ -97,8 +97,8 @@ int do_select(void) struct selectentry *se; vir_bytes vtimeout; - nfds = job_m_in.SEL_NFDS; - vtimeout = (vir_bytes) job_m_in.SEL_TIMEOUT; + nfds = job_m_in.VFS_SELECT_NFDS; + vtimeout = (vir_bytes) job_m_in.VFS_SELECT_TIMEOUT; /* Sane amount of file descriptors? */ if (nfds < 0 || nfds > OPEN_MAX) return(EINVAL); @@ -113,9 +113,9 @@ int do_select(void) wipe_select(se); /* Clear results of previous usage */ se->requestor = fp; se->req_endpt = who_e; - se->vir_readfds = (fd_set *) job_m_in.SEL_READFDS; - se->vir_writefds = (fd_set *) job_m_in.SEL_WRITEFDS; - se->vir_errorfds = (fd_set *) job_m_in.SEL_ERRORFDS; + se->vir_readfds = (fd_set *) job_m_in.VFS_SELECT_READFDS; + se->vir_writefds = (fd_set *) job_m_in.VFS_SELECT_WRITEFDS; + se->vir_errorfds = (fd_set *) job_m_in.VFS_SELECT_ERRORFDS; /* Copy fdsets from the process */ if ((r = copy_fdsets(se, nfds, FROM_PROC)) != OK) { diff --git a/servers/vfs/stadir.c b/servers/vfs/stadir.c index 3324aa8b5..f864dbf27 100644 --- a/servers/vfs/stadir.c +++ b/servers/vfs/stadir.c @@ -19,7 +19,6 @@ #include #include "file.h" #include "path.h" -#include "param.h" #include #include #include "vnode.h" @@ -36,7 +35,7 @@ int do_fchdir(void) struct filp *rfilp; int r, rfd; - rfd = job_m_in.fd; + rfd = job_m_in.VFS_FCHDIR_FD; /* Is the file descriptor valid? */ if ((rfilp = get_filp(rfd, VNODE_READ)) == NULL) return(err_code); @@ -59,17 +58,9 @@ int do_chdir(void) struct vmnt *vmp; char fullpath[PATH_MAX]; struct lookup resolve; - vir_bytes vname; - size_t vname_length; - vname = (vir_bytes) job_m_in.name; - vname_length = (size_t) job_m_in.name_length; - - if (copy_name(vname_length, fullpath) != OK) { - /* Direct copy failed, try fetching from user space */ - if (fetch_name(vname, vname_length, fullpath) != OK) - return(err_code); - } + if (copy_path(fullpath, sizeof(fullpath)) != OK) + return(err_code); /* Try to open the directory */ lookup_init(&resolve, fullpath, PATH_NOFLAGS, &vmp, &vp); @@ -99,19 +90,11 @@ int do_chroot(void) struct vmnt *vmp; char fullpath[PATH_MAX]; struct lookup resolve; - vir_bytes vname; - size_t vname_length; - - vname = (vir_bytes) job_m_in.name; - vname_length = (size_t) job_m_in.name_length; if (!super_user) return(EPERM); /* only su may chroot() */ - if (copy_name(vname_length, fullpath) != OK) { - /* Direct copy failed, try fetching from user space */ - if (fetch_name(vname, vname_length, fullpath) != OK) - return(err_code); - } + if (copy_path(fullpath, sizeof(fullpath)) != OK) + return(err_code); /* Try to open the directory */ lookup_init(&resolve, fullpath, PATH_NOFLAGS, &vmp, &vp); @@ -165,9 +148,9 @@ int do_stat(void) vir_bytes vname1, statbuf; size_t vname1_length; - vname1 = (vir_bytes) job_m_in.name1; - vname1_length = (size_t) job_m_in.name1_length; - statbuf = (vir_bytes) job_m_in.m1_p2; + vname1 = (vir_bytes) job_m_in.VFS_STAT_NAME; + vname1_length = (size_t) job_m_in.VFS_STAT_LEN; + statbuf = (vir_bytes) job_m_in.VFS_STAT_BUF; lookup_init(&resolve, fullpath, PATH_NOFLAGS, &vmp, &vp); resolve.l_vmnt_lock = VMNT_READ; @@ -194,8 +177,8 @@ int do_fstat(void) int r, rfd; vir_bytes statbuf; - statbuf = (vir_bytes) job_m_in.buffer; - rfd = job_m_in.fd; + statbuf = (vir_bytes) job_m_in.VFS_FSTAT_BUF; + rfd = job_m_in.VFS_FSTAT_FD; /* Is the file descriptor valid? */ if ((rfilp = get_filp(rfd, VNODE_READ)) == NULL) return(err_code); @@ -348,9 +331,9 @@ int do_fstatvfs(void) int r, rfd, flags; vir_bytes statbuf; - rfd = job_m_in.VFS_FSTATVFS1_FD; - statbuf = (vir_bytes) job_m_in.VFS_FSTATVFS1_BUF; - flags = job_m_in.VFS_FSTATVFS1_FLAGS; + rfd = job_m_in.VFS_STATVFS1_FD; + statbuf = (vir_bytes) job_m_in.VFS_STATVFS1_BUF; + flags = job_m_in.VFS_STATVFS1_FLAGS; /* Is the file descriptor valid? */ if ((rfilp = get_filp(rfd, VNODE_READ)) == NULL) return(err_code); @@ -373,7 +356,7 @@ int do_getvfsstat(void) int r, flags, count, do_lock; buf = (vir_bytes) job_m_in.VFS_GETVFSSTAT_BUF; - bufsize = job_m_in.VFS_GETVFSSTAT_SIZE; + bufsize = job_m_in.VFS_GETVFSSTAT_LEN; flags = job_m_in.VFS_GETVFSSTAT_FLAGS; count = 0; @@ -442,9 +425,9 @@ int do_lstat(void) vir_bytes vname1, statbuf; size_t vname1_length; - vname1 = (vir_bytes) job_m_in.name1; - vname1_length = (size_t) job_m_in.name1_length; - statbuf = (vir_bytes) job_m_in.name2; + vname1 = (vir_bytes) job_m_in.VFS_STAT_NAME; + vname1_length = (size_t) job_m_in.VFS_STAT_LEN; + statbuf = (vir_bytes) job_m_in.VFS_STAT_BUF; lookup_init(&resolve, fullpath, PATH_RET_SYMLINK, &vmp, &vp); resolve.l_vmnt_lock = VMNT_READ; diff --git a/servers/vfs/table.c b/servers/vfs/table.c index a1163ea8b..8cec7c177 100644 --- a/servers/vfs/table.c +++ b/servers/vfs/table.c @@ -13,136 +13,56 @@ #include "vnode.h" #include "vmnt.h" -int (*call_vec[])(void) = { - no_sys, /* 0 = unused */ - no_sys, /* 1 = (exit) */ - no_sys, /* 2 = (fork) */ - do_read, /* 3 = read */ - do_write, /* 4 = write */ - do_open, /* 5 = open */ - do_close, /* 6 = close */ - no_sys, /* 7 = wait */ - no_sys, /* 8 = unused */ - do_link, /* 9 = link */ - do_unlink, /* 10 = unlink */ - no_sys, /* 11 = waitpid */ - do_chdir, /* 12 = chdir */ - no_sys, /* 13 = time */ - do_mknod, /* 14 = mknod */ - do_chmod, /* 15 = chmod */ - do_chown, /* 16 = chown */ - no_sys, /* 17 = break */ - no_sys, /* 18 = unused (was old stat)*/ - no_sys, /* 19 = unused */ - no_sys, /* 20 = getpid */ - do_mount, /* 21 = mount */ - do_umount, /* 22 = umount */ - no_sys, /* 23 = (setuid) */ - no_sys, /* 24 = getuid */ - no_sys, /* 25 = (stime) */ - no_sys, /* 26 = ptrace */ - no_sys, /* 27 = unused */ - no_sys, /* 28 = unused (was old fstat)*/ - no_sys, /* 29 = unused */ - do_utime, /* 30 = utime */ - no_sys, /* 31 = (stty) */ - no_sys, /* 32 = (gtty) */ - do_access, /* 33 = access */ - no_sys, /* 34 = (nice) */ - no_sys, /* 35 = (ftime) */ - do_sync, /* 36 = sync */ - no_sys, /* 37 = kill */ - do_rename, /* 38 = rename */ - do_mkdir, /* 39 = mkdir */ - do_unlink, /* 40 = rmdir */ - no_sys, /* 41 = unused */ - do_pipe, /* 42 = pipe */ - no_sys, /* 43 = unused */ - no_sys, /* 44 = (prof) */ - do_slink, /* 45 = symlink */ - no_sys, /* 46 = (setgid)*/ - no_sys, /* 47 = getgid */ - no_sys, /* 48 = (signal)*/ - do_rdlink, /* 49 = readlink*/ - no_sys, /* 50 = unused (was old lstat)*/ - do_stat, /* 51 = stat */ - do_fstat, /* 52 = fstat */ - do_lstat, /* 53 = lstat */ - do_ioctl, /* 54 = ioctl */ - do_fcntl, /* 55 = fcntl */ - do_copyfd, /* 56 = copyfd */ - do_fsready, /* 57 = FS proc ready */ - do_pipe2, /* 58 = pipe2 */ - no_sys, /* 59 = (execve)*/ - do_umask, /* 60 = umask */ - do_chroot, /* 61 = chroot */ - no_sys, /* 62 = (setsid)*/ - no_sys, /* 63 = (getpgrp)*/ - no_sys, /* 64 = (itimer)*/ - do_stat, /* 65 = stat - badly numbered, being phased out */ - do_fstat, /* 66 = fstat - badly numbered, being phased out */ - do_lstat, /* 67 = lstat - badly numbered, being phased out */ - no_sys, /* 68 = (setmcontext) */ - do_getdents, /* 69 = getdents */ - do_ftruncate, /* 70 = ftruncate */ - no_sys, /* 71 = (sigaction) */ - no_sys, /* 72 = (sigsuspend) */ - no_sys, /* 73 = (sigpending) */ - no_sys, /* 74 = (sigprocmask) */ - no_sys, /* 75 = (sigreturn) */ - no_sys, /* 76 = (reboot) */ - no_sys, /* 77 = (pm_svrctl) */ - no_sys, /* 78 = (sysuname) */ - no_sys, /* 79 = unused */ - no_sys, /* 80 = unused */ - do_lseek, /* 81 = llseek */ - do_getvfsstat, /* 82 = getvfsstat */ - do_statvfs, /* 83 = fstatvfs */ - do_fstatvfs, /* 84 = statvfs */ - do_select, /* 85 = select */ - do_fchdir, /* 86 = fchdir */ - do_fsync, /* 87 = fsync */ - no_sys, /* 88 = (getpriority) */ - no_sys, /* 89 = (setpriority) */ - no_sys, /* 90 = (gettimeofday) */ - no_sys, /* 91 = (seteuid) */ - no_sys, /* 92 = (setegid) */ - no_sys, /* 93 = unused */ - no_sys, /* 94 = unused */ - do_chmod, /* 95 = fchmod */ - do_chown, /* 96 = fchown */ - do_lseek, /* 97 = lseek */ - no_sys, /* 98 = (sprofile) */ - no_sys, /* 99 = (cprofile) */ - no_sys, /* 100 = (newexec) */ - no_sys, /* 101 = (srv_fork) */ - no_sys, /* 102 = (exec_restart) */ - no_sys, /* 103 = unused */ - no_sys, /* 104 = (getprocnr) */ - no_sys, /* 105 = unused */ - no_sys, /* 106 = unused */ - no_sys, /* 107 = (getepinfo) */ - do_utimens, /* 108 = utimens */ - do_fcntl, /* 109 = fcntl */ - do_truncate, /* 110 = unused */ - no_sys, /* 111 = (srv_kill) */ - do_gcov_flush, /* 112 = gcov_flush */ - no_sys, /* 113 = (getsid) */ - no_sys, /* 114 = (clock_getres) */ - no_sys, /* 115 = (clock_gettime) */ - no_sys, /* 116 = (clock_settime) */ - do_vm_call, /* 117 = call from vm */ - no_sys, /* 118 = unsused */ - no_sys, /* 119 = unsused */ - no_sys, /* 120 = unsused */ - no_sys, /* 121 = (task reply) */ - do_mapdriver, /* 122 = mapdriver */ - no_sys, /* 123 = (pm_getrusage) */ - do_checkperms, /* 124 = checkperms */ - no_sys, /* 125 = (pm_getsysinfo) */ - do_getsysinfo, /* 126 = vfs_getsysinfo */ - do_getrusage, /* 127 = vfs_getrusage */ - do_svrctl, /* 128 = vfs_svrctl */ +#define CALL(n) [((n) - VFS_BASE)] + +int (* const call_vec[NR_VFS_CALLS])(void) = { + CALL(VFS_READ) = do_read, /* read(2) */ + CALL(VFS_WRITE) = do_write, /* write(2) */ + CALL(VFS_LSEEK) = do_lseek, /* lseek(2) */ + CALL(VFS_OPEN) = do_open, /* open(2) */ + CALL(VFS_CREAT) = do_creat, /* creat(2) */ + CALL(VFS_CLOSE) = do_close, /* close(2) */ + CALL(VFS_LINK) = do_link, /* link(2) */ + CALL(VFS_UNLINK) = do_unlink, /* unlink(2) */ + CALL(VFS_CHDIR) = do_chdir, /* chdir(2) */ + CALL(VFS_MKDIR) = do_mkdir, /* mkdir(2) */ + CALL(VFS_MKNOD) = do_mknod, /* mknod(2) */ + CALL(VFS_CHMOD) = do_chmod, /* chmod(2) */ + CALL(VFS_CHOWN) = do_chown, /* chown(2) */ + CALL(VFS_MOUNT) = do_mount, /* mount(2) */ + CALL(VFS_UMOUNT) = do_umount, /* umount(2) */ + CALL(VFS_ACCESS) = do_access, /* access(2) */ + CALL(VFS_SYNC) = do_sync, /* sync(2) */ + CALL(VFS_RENAME) = do_rename, /* rename(2) */ + CALL(VFS_RMDIR) = do_unlink, /* rmdir(2) */ + CALL(VFS_SYMLINK) = do_slink, /* symlink(2) */ + CALL(VFS_READLINK) = do_rdlink, /* readlink(2) */ + CALL(VFS_STAT) = do_stat, /* stat(2) */ + CALL(VFS_FSTAT) = do_fstat, /* fstat(2) */ + CALL(VFS_LSTAT) = do_lstat, /* lstat(2) */ + CALL(VFS_IOCTL) = do_ioctl, /* ioctl(2) */ + CALL(VFS_FCNTL) = do_fcntl, /* fcntl(2) */ + CALL(VFS_PIPE2) = do_pipe2, /* pipe2(2) */ + CALL(VFS_UMASK) = do_umask, /* umask(2) */ + CALL(VFS_CHROOT) = do_chroot, /* chroot(2) */ + CALL(VFS_GETDENTS) = do_getdents, /* getdents(2) */ + CALL(VFS_SELECT) = do_select, /* select(2) */ + CALL(VFS_FCHDIR) = do_fchdir, /* fchdir(2) */ + CALL(VFS_FSYNC) = do_fsync, /* fsync(2) */ + CALL(VFS_TRUNCATE) = do_truncate, /* truncate(2) */ + CALL(VFS_FTRUNCATE) = do_ftruncate, /* ftruncate(2) */ + CALL(VFS_FCHMOD) = do_chmod, /* fchmod(2) */ + CALL(VFS_FCHOWN) = do_chown, /* fchown(2) */ + CALL(VFS_UTIMENS) = do_utimens, /* [fl]utime[n]s(2) */ + CALL(VFS_VMCALL) = do_vm_call, + CALL(VFS_GETVFSSTAT) = do_getvfsstat, /* getvfsstat(2) */ + CALL(VFS_STATVFS1) = do_statvfs, /* statvfs(2) */ + CALL(VFS_FSTATVFS1) = do_fstatvfs, /* fstatvfs(2) */ + CALL(VFS_GETRUSAGE) = do_getrusage, /* getrusage(2) */ + CALL(VFS_SVRCTL) = do_svrctl, /* svrctl(2) */ + CALL(VFS_GCOV_FLUSH) = do_gcov_flush, /* gcov_flush(2) */ + CALL(VFS_MAPDRIVER) = do_mapdriver, /* mapdriver(2) */ + CALL(VFS_COPYFD) = do_copyfd, /* copyfd(2) */ + CALL(VFS_CHECKPERMS) = do_checkperms, /* checkperms(2) */ + CALL(VFS_GETSYSINFO) = do_getsysinfo, /* getsysinfo(2) */ }; -/* This should not fail with "array size is negative": */ -extern int dummy[sizeof(call_vec) == NCALLS * sizeof(call_vec[0]) ? 1 : -1]; diff --git a/servers/vfs/time.c b/servers/vfs/time.c index 028eab044..01952760b 100644 --- a/servers/vfs/time.c +++ b/servers/vfs/time.c @@ -1,7 +1,6 @@ /* This file takes care of those system calls that deal with time. * * The entry points into this file are - * do_utime: perform the UTIME system call * do_utimens: perform the UTIMENS system call */ @@ -14,7 +13,6 @@ #include #include "file.h" #include "path.h" -#include "param.h" #include "vnode.h" #include #include "vmnt.h" @@ -22,64 +20,6 @@ #define UTIMENS_STYLE 0 /* utimes(2)/utimensat(2) style, named file */ #define FUTIMENS_STYLE 1 /* futimens(2)/futimes(2) style, file desc. */ -/*===========================================================================* - * do_utime * - *===========================================================================*/ -int do_utime(void) -{ -/* Perform the utime(name, timep) system call. */ - int r; - struct timespec actim, modtim, newactim, newmodtim; - struct vnode *vp; - struct vmnt *vmp; - char fullpath[PATH_MAX]; - struct lookup resolve; - vir_bytes vname; - size_t vname_length, len; - - vname = (vir_bytes) job_m_in.utime_file; - vname_length = (size_t) job_m_in.utime_length; - actim.tv_sec = job_m_in.utime_actime; - modtim.tv_sec = job_m_in.utime_modtime; - actim.tv_nsec = modtim.tv_nsec = 0; - - /* Adjust for case of 'timep' being NULL; - * utime_strlen then holds the actual size: strlen(name)+1 */ - len = vname_length; - if (len == 0) len = (size_t) job_m_in.utime_strlen; - - lookup_init(&resolve, fullpath, PATH_NOFLAGS, &vmp, &vp); - resolve.l_vmnt_lock = VMNT_READ; - resolve.l_vnode_lock = VNODE_READ; - - /* Temporarily open the file */ - if (fetch_name(vname, len, fullpath) != OK) return(err_code); - if ((vp = eat_path(&resolve, fp)) == NULL) return(err_code); - - /* Only the owner of a file or the super user can change timestamps. */ - r = OK; - if (vp->v_uid != fp->fp_effuid && fp->fp_effuid != SU_UID) r = EPERM; - if (vname_length == 0 && r != OK) r = forbidden(fp, vp, W_BIT); - if (read_only(vp) != OK) r = EROFS; /* Not even su can touch if R/O */ - if (r == OK) { - /* Issue request */ - if (vname_length == 0) { - newactim = newmodtim = clock_timespec(); - } else { - newactim = actim; - newmodtim = modtim; - } - r = req_utime(vp->v_fs_e, vp->v_inode_nr, &newactim, &newmodtim); - } - - unlock_vnode(vp); - unlock_vmnt(vmp); - - put_vnode(vp); - return(r); -} - - /*===========================================================================* * do_utimens * *===========================================================================*/ @@ -111,19 +51,19 @@ int do_utimens(void) 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; - modtim.tv_sec = job_m_in.utime_modtime; - modtim.tv_nsec = job_m_in.utimens_mnsec; + actim.tv_sec = job_m_in.VFS_UTIMENS_ATIME; + actim.tv_nsec = job_m_in.VFS_UTIMENS_ANSEC; + modtim.tv_sec = job_m_in.VFS_UTIMENS_MTIME; + modtim.tv_nsec = job_m_in.VFS_UTIMENS_MNSEC; - if (job_m_in.utime_file != NULL) { + if (job_m_in.VFS_UTIMENS_NAME != NULL) { kind = UTIMENS_STYLE; - if (job_m_in.utimens_flags & ~AT_SYMLINK_NOFOLLOW) + if (job_m_in.VFS_UTIMENS_FLAGS & ~AT_SYMLINK_NOFOLLOW) return EINVAL; /* unknown flag */ /* Temporarily open the file */ - vname = (vir_bytes) job_m_in.utime_file; - vname_length = (size_t) job_m_in.utime_length; - if (job_m_in.utimens_flags & AT_SYMLINK_NOFOLLOW) + vname = (vir_bytes) job_m_in.VFS_UTIMENS_NAME; + vname_length = (size_t) job_m_in.VFS_UTIMENS_LEN; + if (job_m_in.VFS_UTIMENS_FLAGS & AT_SYMLINK_NOFOLLOW) lookup_flags = PATH_RET_SYMLINK; else lookup_flags = PATH_NOFLAGS; @@ -137,9 +77,9 @@ int do_utimens(void) else { kind = FUTIMENS_STYLE; /* Change timestamps on already-opened fd. Is it valid? */ - if (job_m_in.utimens_flags != 0) + if (job_m_in.VFS_UTIMENS_FLAGS != 0) return EINVAL; /* unknown flag */ - if ((filp = get_filp(job_m_in.utimens_fd, VNODE_READ)) == NULL) + if ((filp = get_filp(job_m_in.VFS_UTIMENS_FD, VNODE_READ)) == NULL) return err_code; vp = filp->filp_vno; } diff --git a/servers/vfs/utility.c b/servers/vfs/utility.c index 0975f5b2c..91a93f5e5 100644 --- a/servers/vfs/utility.c +++ b/servers/vfs/utility.c @@ -2,17 +2,14 @@ * * The entry points into this file are * clock_timespec: ask the clock task for the real time - * copy: copy a block of data + * copy_path: copy a path name from a path request from userland * fetch_name: go get a path name from user space - * no_sys: reject a system call that FS does not handle * panic: something awful has occurred; MINIX cannot continue - * conv2: do byte swapping on a 16-bit int - * conv4: do byte swapping on a 32-bit long * in_group: determines if group 'grp' is in rfp->fp_sgroups[] */ #include "fs.h" -#include +#include #include #include #include @@ -20,35 +17,35 @@ #include #include #include "file.h" -#include "param.h" #include "vmnt.h" /*===========================================================================* - * copy_name * + * copy_path * *===========================================================================*/ -inline int copy_name( size_t len, char *dest) +int copy_path(char *dest, size_t size) { -/* Go get path and put it in 'dest'. +/* Go get the path for a path request. Put the result in in 'dest', which + * should be at least PATH_MAX in size. */ - if (len > PATH_MAX) { /* 'len' includes terminating-nul */ + vir_bytes name; + size_t len; + + assert(size >= PATH_MAX); + + name = (vir_bytes) job_m_in.VFS_PATH_NAME; + len = job_m_in.VFS_PATH_LEN; + + if (len > size) { /* 'len' includes terminating-nul */ err_code = ENAMETOOLONG; return(EGENERIC); } - /* Check name length for validity. */ - if (len > SSIZE_MAX) { - err_code = EINVAL; - return(EGENERIC); - } + /* Is the string contained in the message? If not, perform a normal copy. */ + if (len > M3_STRING) + return fetch_name(name, len, dest); - if (len <= M3_STRING) { - /* Just copy the path from the message */ - strncpy(dest, job_m_in.pathname, len); - } else { - /* String is not contained in the message. */ - err_code = EINVAL; - return(EGENERIC); - } + /* Just copy the path from the message */ + strncpy(dest, job_m_in.VFS_PATH_BUF, len); if (dest[len - 1] != '\0') { err_code = ENAMETOOLONG; @@ -92,17 +89,6 @@ int fetch_name(vir_bytes path, size_t len, char *dest) return(OK); } - -/*===========================================================================* - * no_sys * - *===========================================================================*/ -int no_sys(void) -{ -/* Somebody has used an illegal system call number */ - return(ENOSYS); -} - - /*===========================================================================* * isokendpt_f * *===========================================================================*/ diff --git a/servers/vfs/write.c b/servers/vfs/write.c index c56fe14c0..430f0f5ab 100644 --- a/servers/vfs/write.c +++ b/servers/vfs/write.c @@ -7,8 +7,7 @@ #include "fs.h" #include "file.h" -#include "param.h" - +#include /*===========================================================================* * do_write * @@ -16,6 +15,6 @@ int do_write(void) { /* Perform the write(fd, buffer, nbytes) system call. */ - return(do_read_write_peek(WRITING, job_m_in.fd, - job_m_in.buffer, (size_t) job_m_in.nbytes)); + return(do_read_write_peek(WRITING, job_m_in.VFS_READWRITE_FD, + job_m_in.VFS_READWRITE_BUF, (size_t) job_m_in.VFS_READWRITE_LEN)); } diff --git a/servers/vm/break.c b/servers/vm/break.c index d35349199..cc5cb7d8c 100644 --- a/servers/vm/break.c +++ b/servers/vm/break.c @@ -49,8 +49,8 @@ int do_brk(message *msg) */ int proc; - if(vm_isokendpt(msg->VMB_ENDPOINT, &proc) != OK) { - printf("VM: bogus endpoint VM_BRK %d\n", msg->VMB_ENDPOINT); + if (vm_isokendpt(msg->m_source, &proc) != OK) { + printf("VM: bogus endpoint VM_BRK %d\n", msg->m_source); return EINVAL; } diff --git a/servers/vm/vfs.c b/servers/vm/vfs.c index 92b2fb6ff..9e7ceede1 100644 --- a/servers/vm/vfs.c +++ b/servers/vm/vfs.c @@ -80,6 +80,7 @@ int vfs_request(int reqno, int fd, struct vmproc *vmp, u64_t offset, u32_t len, } m = &reqnode->reqmsg; + memset(m, 0, sizeof(*m)); m->m_type = VFS_VMCALL; m->VFS_VMCALL_REQ = reqno; m->VFS_VMCALL_FD = fd; diff --git a/test/test5.c b/test/test5.c index ac72eb455..7a7757d96 100644 --- a/test/test5.c +++ b/test/test5.c @@ -208,7 +208,7 @@ void test5d() void test5e() { -/* When a signal knocks a processes out of WAIT or PAUSE, it is supposed to +/* When a signal knocks a processes out of WAITPID or PAUSE, it is supposed to * get EINTR as error status. Check that. */ int n; -- 2.44.0