#include <lib.h>
#include <sys/types.h>
#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
#include <stdio.h>
#include <time.h>
exit(1);
}
+ memset(&m, 0, sizeof(m));
m.RTCDEV_TM = (char *) t;
m.RTCDEV_FLAGS = flags;
{
{ "EXIT", VM_EXIT },
{ "FORK", VM_FORK },
- { "BRK", VM_BRK },
{ "EXEC_NEWMEM", VM_EXEC_NEWMEM },
{ "PUSH_SIG", 0 },
{ "WILLEXIT", VM_WILLEXIT },
* 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;
vm # Extra VM calls allowed:
EXIT # 00
FORK # 01
- BRK # 02
EXEC_NEWMEM # 03
WILLEXIT # 05
NOTIFY_SIG # 39
-#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 */
* 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.
*/
#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
*/
# 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 */
/* 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 *
*===========================================================================*/
# 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 *
*===========================================================================*/
# 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
/* 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 *
* 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)
*===========================================================================*/
/* 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)
#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 *
*===========================================================================*/
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 */
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);
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/^# /#/' | \
+++ /dev/null
-/* utime(2) for POSIX Authors: Terrence W. Holm & Edwin L. Froese */
-
-#include <sys/cdefs.h>
-#include "namespace.h"
-#include <lib.h>
-
-#include <string.h>
-#include <utime.h>
-
-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
#include <lib.h>
#include "namespace.h"
+#include <string.h>
#include <sys/wait.h>
#ifdef __weak_alias
{
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);
}
#include <lib.h>
#include "namespace.h"
+#include <string.h>
#include <sys/wait.h>
#ifdef __weak_alias
{
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;
}
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 \
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 \
#include "namespace.h"
#include <lib.h>
+#include <string.h>
#include <unistd.h>
#ifdef __weak_alias
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.
#include <lib.h>
#include <namespace.h>
+#include <string.h>
#include <ucontext.h>
#include <unistd.h>
{
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));
}
{
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));
}
#include "namespace.h"
#include <lib.h>
+#include <string.h>
#include <unistd.h>
#ifdef __weak_alias
{
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));
}
#include <lib.h>
#include "namespace.h"
+#include <string.h>
#include <sys/time.h>
#include <time.h>
{
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) {
#include "namespace.h"
#include <lib.h>
+#include <string.h>
#include <unistd.h>
#ifdef __weak_alias
/* 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
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);
}
#include "namespace.h"
#include <lib.h>
+#include <string.h>
#include <unistd.h>
#ifdef __weak_alias
{
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)
{
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));
}
#include "namespace.h"
#include <lib.h>
+#include <string.h>
#include <sys/stat.h>
#ifdef __weak_alias
{
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));
}
{
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));
}
#include "namespace.h"
#include <lib.h>
+#include <string.h>
#include <unistd.h>
#ifdef __weak_alias
{
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));
}
#include <lib.h>
#include "namespace.h"
+#include <string.h>
#include <sys/time.h>
#ifdef __weak_alias
{
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;
}
#include <lib.h>
#include "namespace.h"
+#include <string.h>
#include <sys/time.h>
#ifdef __weak_alias
{
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;
}
#include <lib.h>
#include "namespace.h"
+#include <string.h>
#include <time.h>
#ifdef __weak_alias
{
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;
#include "namespace.h"
#include <lib.h>
+#include <string.h>
#include <unistd.h>
#ifdef __weak_alias
{
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));
}
#endif
#include <lib.h>
+#include <string.h>
#include <minix/profile.h>
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);
}
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);
#include "namespace.h"
#include <lib.h>
+#include <string.h>
#include <sys/stat.h>
#ifdef __weak_alias
{
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));
}
{
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));
}
#include "namespace.h"
#include <lib.h>
+#include <string.h>
#include <fcntl.h>
#include <stdarg.h>
/* 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));
}
#include "namespace.h"
#include <lib.h>
+#include <string.h>
#include <unistd.h>
#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));
}
#include "namespace.h"
#include <lib.h>
+#include <string.h>
#include <sys/statvfs.h>
#ifdef __weak_alias
{
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)
#include "namespace.h"
#include <lib.h>
+#include <string.h>
#include <unistd.h>
#ifdef __weak_alias
{
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));
}
{
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));
}
#include "namespace.h"
#include <lib.h>
+#include <string.h>
#include <sys/stat.h>
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));
}
#include "namespace.h"
#include <lib.h>
+#include <string.h>
#include <sys/stat.h>
#include <sys/time.h>
{
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));
}
--- /dev/null
+#include <lib.h>
+#include <string.h>
+#include <minix/gcov.h>
+
+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);
+}
#include "namespace.h"
#include <lib.h>
+#include <string.h>
#include <dirent.h>
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)
#include "namespace.h"
#include <lib.h>
+#include <string.h>
#include <unistd.h>
#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);
}
#include "namespace.h"
#include <lib.h>
+#include <string.h>
#include <unistd.h>
#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);
}
#include "namespace.h"
#include <lib.h>
+#include <string.h>
#include <unistd.h>
#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));
}
#include "namespace.h"
#include <lib.h>
+#include <string.h>
#include <unistd.h>
#ifdef __weak_alias
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));
}
#include "namespace.h"
#include <lib.h>
+#include <string.h>
#include <sys/time.h>
/*
{
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)
#include "namespace.h"
#include <lib.h>
+#include <string.h>
#include <unistd.h>
#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));
}
#include "namespace.h"
#include <lib.h>
+#include <string.h>
#include <unistd.h>
#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));
}
#include "namespace.h"
#include <lib.h>
+#include <string.h>
#include <unistd.h>
#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);
}
#include "namespace.h"
#include <lib.h>
+#include <string.h>
#include <unistd.h>
#include <sys/resource.h>
{
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;
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);
}
#include "namespace.h"
#include <lib.h>
+#include <string.h>
#include <sys/time.h>
#ifdef __weak_alias
{
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;
}
#include "namespace.h"
#include <lib.h>
+#include <string.h>
#include <unistd.h>
#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));
}
#include <lib.h>
#include "namespace.h"
+#include <string.h>
#include <sys/statvfs.h>
#ifdef __weak_alias
{
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));
}
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) {
#include "namespace.h"
#include <lib.h>
+#include <string.h>
#include <unistd.h>
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);
}
#include "namespace.h"
#include <lib.h>
+#include <string.h>
#include <signal.h>
#ifdef __weak_alias
#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));
}
{
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));
}
* 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);
}
#include "namespace.h"
#include <lib.h>
+#include <string.h>
#include <minix/u64.h>
#include <unistd.h>
{
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));
}
#include "namespace.h"
#include <lib.h>
+#include <string.h>
#include <unistd.h>
#include <minix/u64.h>
{
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;
}
{
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));
}
#include <sys/cdefs.h>
-#include <minix/callnr.h>
#include <minix/com.h>
#include <minix/config.h>
#include <minix/ipc.h>
len_key = strlen(name)+1;
+ memset(&m, 0, sizeof(m));
m.RS_NAME = (char *) __UNCONST(name);
m.RS_NAME_LEN = len_key;
{
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));
}
{
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)
message m;
int r;
+ memset(&m, 0, sizeof(m));
m.VMM_ADDR = (vir_bytes) addr;
m.VMM_LEN = len;
m.VMM_PROT = prot;
{
message m;
+ memset(&m, 0, sizeof(m));
m.VMUM_ADDR = addr;
m.VMUM_LEN = len;
message m;
int r;
+ memset(&m, 0, sizeof(m));
m.VMRE_D = d;
m.VMRE_S = s;
m.VMRE_DA = (char *) da;
message m;
int r;
+ memset(&m, 0, sizeof(m));
m.VMRE_D = d;
m.VMRE_S = s;
m.VMRE_DA = (char *) da;
{
message m;
+ memset(&m, 0, sizeof(m));
m.VMUN_ENDPT = endpt;
m.VMUN_ADDR = (long) addr;
message m;
int r;
+ memset(&m, 0, sizeof(m));
m.VMPHYS_ENDPT = endpt;
m.VMPHYS_ADDR = (long) addr;
message m;
int r;
+ memset(&m, 0, sizeof(m));
m.VMREFCNT_ENDPT = endpt;
m.VMREFCNT_ADDR = (long) addr;
}
/* 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;
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.
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)) {
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;
{
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));
}
#include "namespace.h"
#include <lib.h>
+#include <string.h>
#include <unistd.h>
#ifdef __weak_alias
#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);
}
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
* 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;
}
{
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);
}
#include "namespace.h"
#include <lib.h>
+#include <string.h>
#include <sys/ptrace.h>
#ifdef __weak_alias
{
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);
}
#include <lib.h>
#include "namespace.h"
+#include <string.h>
#include <unistd.h>
#ifdef __weak_alias
{
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));
}
{
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));
}
-/* reboot.c - Systemcall interface to mm/signal.c::do_reboot()
+/* reboot.c
author: Edvard Tuinder v892231@si.hhs.NL
*/
#include <unistd.h>
#include "namespace.h"
-#include <unistd.h>
+#include <string.h>
#include <sys/reboot.h>
-#include <stdarg.h>
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);
}
{
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));
}
__weak_alias(rmdir, _rmdir)
#endif
+#include <string.h>
#include <unistd.h>
int rmdir(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));
}
#include <lib.h>
#include "namespace.h"
+#include <string.h>
#include <sys/time.h>
#include <sys/select.h>
{
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));
}
#include <stdlib.h>
#include <stdarg.h>
#include <errno.h>
+#include <string.h>
static int get_ipc_endpt(endpoint_t *pt)
{
return -1;
}
+ memset(&m, 0, sizeof(m));
m.SEMGET_KEY = key;
m.SEMGET_NR = nsems;
m.SEMGET_FLAG = semflag;
return -1;
}
+ memset(&m, 0, sizeof(m));
m.SEMCTL_ID = semid;
m.SEMCTL_NUM = semnum;
m.SEMCTL_CMD = cmd;
return -1;
}
+ memset(&m, 0, sizeof(m));
m.SEMOP_ID = semid;
m.SEMOP_OPS = (long) sops;
m.SEMOP_SIZE = nsops;
#include <lib.h>
#include "namespace.h"
+#include <string.h>
+
#ifdef __weak_alias
__weak_alias(setgid, _setgid)
__weak_alias(setegid, _setegid)
{
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));
}
#include <lib.h>
#include "namespace.h"
+#include <string.h>
+
#ifdef __weak_alias
__weak_alias(setgroups, _setgroups)
#endif
{
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));
}
-
-
#include "namespace.h"
#include <lib.h>
+#include <string.h>
#include <sys/time.h>
/*
/* 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)
#include <lib.h>
#include "namespace.h"
+#include <string.h>
#include <unistd.h>
#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));
}
#include <lib.h>
#include "namespace.h"
+#include <string.h>
#include <unistd.h>
#ifdef __weak_alias
{
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));
}
#include <sys/shm.h>
#include <stdlib.h>
#include <errno.h>
+#include <string.h>
#ifdef __weak_alias
__weak_alias(shmat, _shmat)
return NULL;
}
+ memset(&m, 0, sizeof(m));
m.SHMAT_ID = shmid;
m.SHMAT_ADDR = (long) shmaddr;
m.SHMAT_FLAG = shmflg;
return -1;
}
+ memset(&m, 0, sizeof(m));
m.SHMDT_ADDR = (long) shmaddr;
return _syscall(ipc_pt, IPC_SHMDT, &m);
#include <sys/shm.h>
#include <stdlib.h>
#include <errno.h>
+#include <string.h>
static int get_ipc_endpt(endpoint_t *pt)
{
return -1;
}
+ memset(&m, 0, sizeof(m));
m.SHMCTL_ID = shmid;
m.SHMCTL_CMD = cmd;
m.SHMCTL_BUF = (long) buf;
#include <sys/shm.h>
#include <stdlib.h>
#include <errno.h>
-
+#include <string.h>
#ifdef __weak_alias
__weak_alias(shmget, _shmget)
return -1;
}
+ memset(&m, 0, sizeof(m));
m.SHMGET_KEY = key;
m.SHMGET_SIZE = size;
m.SHMGET_FLAG = shmflg;
#include <lib.h>
#include "namespace.h"
+#include <string.h>
#include <signal.h>
int __sigreturn(void);
{
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)
#include <lib.h>
#include "namespace.h"
+#include <string.h>
#include <signal.h>
int sigpending(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);
}
#include <lib.h>
#include "namespace.h"
+#include <string.h>
#include <signal.h>
int sigprocmask(how, set, 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);
}
#include <lib.h>
#include "namespace.h"
+#include <string.h>
#include <signal.h>
#include <sys/signal.h>
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 */
}
#include <lib.h>
#include "namespace.h"
+#include <string.h>
#include <signal.h>
int sigsuspend(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)
#endif
#include <lib.h>
+#include <string.h>
#include <minix/profile.h>
int sprofile(int action,
{
message m;
+ memset(&m, 0, sizeof(m));
m.PROF_ACTION = action;
m.PROF_MEM_SIZE = size;
m.PROF_FREQ = freq;
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);
}
{
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); }
{
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); }
{
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);
}
{
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)
#include <lib.h>
#include "namespace.h"
+#include <string.h>
#include <time.h>
#ifdef __weak_alias
{
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));
}
*/
#include <lib.h>
#include <stdio.h>
+#include <string.h>
#include <sys/svrctl.h>
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':
{
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));
}
#include <lib.h>
#include "namespace.h"
+#include <string.h>
+
#ifdef __weak_alias
__weak_alias(sync, _sync)
#endif
#include <unistd.h>
-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));
}
#include <sys/cdefs.h>
#include "namespace.h"
#include <lib.h>
+#include <string.h>
#include <sys/utsname.h>
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);
}
/*
{
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));
}
#include <lib.h>
#include "namespace.h"
+#include <string.h>
#include <sys/stat.h>
#ifdef __weak_alias
{
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));
}
#include <lib.h>
#include "namespace.h"
+#include <string.h>
#include <unistd.h>
#ifdef __weak_alias
{
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));
}
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));
}
{
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));
}
#include "namespace.h"
#include <lib.h>
+#include <string.h>
#include <unistd.h>
#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));
}
#include <lib.h>
#include "namespace.h"
+#include <string.h>
#include <unistd.h>
#ifdef __weak_alias
{
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));
}
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);
}
# Various utils
SRCS+= itoa.c u64util.c read_tsc_64.c
-# svrctl
-SRCS+= svrctl.c
-
# servxcheck
SRCS+= servxcheck.c
#include <minix/gcov.h>
-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.
taskcall.c \
tickdelay.c \
timers.c \
- vm_brk.c \
vm_cache.c \
vm_exit.c \
vm_fork.c \
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);
}
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)
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;
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);
}
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);
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);
}
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);
}
+++ /dev/null
-
-#include "syslib.h"
-
-#include <string.h>
-#include <minix/vm.h>
-
-/*===========================================================================*
- * 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);
-}
-
# 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
#include <signal.h>
#include <sys/time.h>
#include <minix/com.h>
+#include <minix/callnr.h>
#include "mproc.h"
-#include "param.h"
#define US 1000000UL /* shortcut for microseconds per second */
{
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);
* 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) ||
return(EINVAL);
}
- switch (m_in.which_timer) {
+ switch (which) {
case ITIMER_REAL :
if (getval) get_realtimer(mp, &ovalue);
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);
+++ /dev/null
-
-#include "pm.h"
-#include "param.h"
-#include "glo.h"
-#include "mproc.h"
-
-#include <minix/vm.h>
-
-/*===========================================================================*
- * 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;
-}
-
#include <libexec.h>
#include <sys/ptrace.h>
#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[]. */
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);
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)
/* 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;
}
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 *
*===========================================================================*/
/* 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
* 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
*/
#include <sys/resource.h>
#include <signal.h>
#include "mproc.h"
-#include "param.h"
#define LAST_FEW 2 /* last few slots reserved for superuser */
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 */
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);
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 */
}
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);
}
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:
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);
}
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;
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 */
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 */
#include <minix/com.h>
#include <signal.h>
#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);
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;
r = target->mp_procgrp;
break;
}
- case ISSETUGID:
+ case PM_ISSETUGID:
r = !!(rmp->mp_flags & TAINTED);
break;
*===========================================================================*/
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;
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;
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)
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;
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 */
#include <env.h>
#include <assert.h>
#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);
int main()
{
/* Main routine of the process manager. */
+ unsigned int call_index;
int ipc_status, result;
/* SEF local startup. */
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);
*===========================================================================*/
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;
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,
#include <minix/com.h>
#include <minix/vm.h>
#include "mproc.h"
-#include "param.h"
/*===========================================================================*
*===========================================================================*/
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);
}
*===========================================================================*/
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);
}
* do_svrctl: process manager control
*/
-#define brk _brk
-
#include "pm.h"
#include <minix/callnr.h>
#include <signal.h>
#include <minix/reboot.h>
#include <minix/sysinfo.h>
#include <minix/type.h>
-#include <minix/vm.h>
#include <minix/ds.h>
#include <machine/archtypes.h>
#include <lib.h>
#include <assert.h>
#include "mproc.h"
-#include "param.h"
#include "kernel/proc.h"
struct utsname uts_val = {
};
#if ENABLE_SYSCALL_STATS
-unsigned long calls_stats[NCALLS];
+unsigned long calls_stats[NR_PM_CALLS];
#endif
/*===========================================================================*
int do_sysuname()
{
/* Set or get uname strings. */
-
int r;
size_t n;
char *string;
};
#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;
#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;
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) */
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. */
return EPERM;
/* If GET, that's it. */
- if (call_nr == GETPRIORITY) {
+ if (call_nr == PM_GETPRIORITY) {
return(rmp->mp_nice - PRIO_MIN);
}
} 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);
}
}
-/*===========================================================================*
- * _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 *
*===========================================================================*/
/* 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 */
#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' */
+++ /dev/null
-/* 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
#include <minix/com.h>
#include <signal.h>
#include "mproc.h"
-#include "param.h"
/*===========================================================================*
* do_sprofile *
/* Function prototypes. */
struct mproc;
-struct stat;
-struct mem_map;
-struct memory;
#include <minix/timers.h>
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);
/* 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);
#include <sys/resource.h>
#include <assert.h>
#include "mproc.h"
-#include "param.h"
static int unpause(struct mproc *rmp);
static int sig_send(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);
}
{
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;
}
*
* 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;
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;
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);
}
{
/* 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 */);
}
/*===========================================================================*
* 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 */);
}
/*===========================================================================*
#include <minix/callnr.h>
#include <signal.h>
#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];
* 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
*/
#include <signal.h>
#include <sys/time.h>
#include "mproc.h"
-#include "param.h"
/*===========================================================================*
* 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;
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);
*===========================================================================*/
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 */
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:
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);
}
}
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)
#include "pm.h"
#include <minix/com.h>
+#include <minix/callnr.h>
#include <sys/ptrace.h>
#include <signal.h>
#include "mproc.h"
-#include "param.h"
/*===========================================================================*
* 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
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. */
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 */
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
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);
/* 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.
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);
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;
}
}
- 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 */);
}
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 */);
}
*/
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);
}
}
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);
}
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);
}
}
*
* 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
#include <fcntl.h>
#include <signal.h> /* needed only because mproc.h needs it */
#include "mproc.h"
-#include "param.h"
#include <minix/config.h>
#include <minix/timers.h>
return(next_pid);
}
-
-/*===========================================================================*
- * no_sys *
- *===========================================================================*/
-int no_sys()
-{
-/* A system call number not implemented by PM has been requested. */
- return(ENOSYS);
-}
-
/*===========================================================================*
* find_param *
*===========================================================================*/
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)
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
| | 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 |
#include <minix/vm.h>
#include <sys/mman.h>
#include <sys/exec_elf.h>
-#include "param.h"
/* Include ELF headers */
#include <sys/elf_core.h>
#include <minix/vfsif.h>
#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);
*===========================================================================*/
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;
#include <stdlib.h>
#include <ctype.h>
#include <unistd.h>
-#include <minix/com.h>
+#include <minix/callnr.h>
#include <minix/ds.h>
-#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
#include <sys/exec.h>
#include <sys/param.h>
#include "path.h"
-#include "param.h"
#include "vnode.h"
#include "file.h"
#include <minix/vfsif.h>
* 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
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;
/* 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);
}
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 */
#include "file.h"
#include "path.h"
#include "vnode.h"
-#include "param.h"
#include "scratchpad.h"
/*===========================================================================*
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;
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;
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);
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 */
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 */
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 */
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);
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);
#include "scratchpad.h"
#include "lock.h"
#include "vnode.h"
-#include "param.h"
/*===========================================================================*
* lock_op *
#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 */
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);
*===========================================================================*/
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
* 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);
/* 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(),
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;
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;
#include <minix/vfsif.h>
#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);
*===========================================================================*/
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;
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);
}
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) {
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) {
/* 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
#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;
}
}
-/*===========================================================================*
- * do_fsready *
- *===========================================================================*/
-int do_fsready(void)
-{
- /* deprecated */
- return(SUSPEND);
-}
-
/*===========================================================================*
* do_mount *
*===========================================================================*/
#include "file.h"
#include "scratchpad.h"
#include "lock.h"
-#include "param.h"
#include <sys/dirent.h>
#include <assert.h>
#include <minix/vfsif.h>
*===========================================================================*/
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 *
return(SUSPEND);
}
} else if (susp_count > 0) { /* revive blocked processes */
- release(vp, OPEN, susp_count);
+ release(vp, VFS_OPEN, susp_count);
}
return(OK);
}
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;
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);
}
/*===========================================================================*
- * 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;
*===========================================================================*/
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;
}
/*===========================================================================*
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);
}
+++ /dev/null
-#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
#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
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 */
* 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
#include <sys/time.h>
#include "file.h"
#include "scratchpad.h"
-#include "param.h"
#include <minix/vfsif.h>
#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 *
*===========================================================================*/
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;
/* If need be, activate sleeping writers. */
if (susp_count > 0)
- release(vp, WRITE, susp_count);
+ release(vp, VFS_WRITE, susp_count);
}
return(r);
}
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 */
* since we'll suspend ourself in read_write()
*/
if (!notouch)
- release(vp, READ, susp_count);
+ release(vp, VFS_READ, susp_count);
return(bytes);
}
}
/* 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);
*===========================================================================*/
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;
/* 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;
#include <minix/callnr.h>
#include "file.h"
#include "path.h"
-#include "param.h"
#include <minix/vfsif.h>
#include "vnode.h"
#include "vmnt.h"
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;
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);
}
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);
}
}
- 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);
}
*===========================================================================*/
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);
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;
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);
/* 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
/* 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);
int do_getrusage(void);
/* mount.c */
-int do_fsready(void);
int do_mount(void);
int do_umount(void);
int is_nonedev(dev_t dev);
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 */
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);
int update_statvfs(struct vmnt *vmp, struct statvfs *buf);
/* time.c */
-int do_utime(void);
int do_utimens(void);
/* tll.c */
/* 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);
/* gcov.c */
int do_gcov_flush(void);
#if ! USE_COVERAGE
-#define do_gcov_flush no_sys
+#define do_gcov_flush NULL
#endif
/* select.c */
#include <fcntl.h>
#include <unistd.h>
#include "file.h"
-#include "param.h"
#include "scratchpad.h"
#include "vnode.h"
#include "vmnt.h"
*===========================================================================*/
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));
}
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)
#include <sys/time.h>
#include <sys/select.h>
#include <sys/stat.h>
-#include <minix/com.h>
+#include <minix/callnr.h>
#include <minix/u64.h>
#include <string.h>
#include <assert.h>
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);
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) {
#include <string.h>
#include "file.h"
#include "path.h"
-#include "param.h"
#include <minix/vfsif.h>
#include <minix/callnr.h>
#include "vnode.h"
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);
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);
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);
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;
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);
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);
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;
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;
#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];
/* 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
*/
#include <fcntl.h>
#include "file.h"
#include "path.h"
-#include "param.h"
#include "vnode.h"
#include <minix/vfsif.h>
#include "vmnt.h"
#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 *
*===========================================================================*/
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;
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;
}
*
* 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 <minix/com.h>
+#include <minix/callnr.h>
#include <minix/endpoint.h>
#include <unistd.h>
#include <stdlib.h>
#include <assert.h>
#include <time.h>
#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;
return(OK);
}
-
-/*===========================================================================*
- * no_sys *
- *===========================================================================*/
-int no_sys(void)
-{
-/* Somebody has used an illegal system call number */
- return(ENOSYS);
-}
-
-
/*===========================================================================*
* isokendpt_f *
*===========================================================================*/
#include "fs.h"
#include "file.h"
-#include "param.h"
-
+#include <minix/callnr.h>
/*===========================================================================*
* do_write *
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));
}
*/
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;
}
}
m = &reqnode->reqmsg;
+ memset(m, 0, sizeof(*m));
m->m_type = VFS_VMCALL;
m->VFS_VMCALL_REQ = reqno;
m->VFS_VMCALL_FD = fd;
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;