Index: stable/4/sys/alpha/linux/syscalls.master =================================================================== --- stable/4/sys/alpha/linux/syscalls.master (revision 82402) +++ stable/4/sys/alpha/linux/syscalls.master (revision 82403) @@ -1,481 +1,481 @@ $FreeBSD$ ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93 ; System call name/number master file (or rather, slave, from LINUX). ; Processed to created linux_sysent.c, linux_syscalls.c and linux_syscall.h. ; Columns: number type nargs namespc name alt{name,tag,rtyp}/comments ; number system call number, must be in order ; type one of STD, OBSOL, UNIMPL, COMPAT, CPT_NOA, LIBCOMPAT, ; NODEF, NOARGS, NOPROTO ; namespc one of POSIX, BSD, STD, NOHIDE (I dont care :-) -Peter ; name psuedo-prototype of syscall routine ; If one of the following alts is different, then all appear: ; altname name of system call if different ; alttag name of args struct tag if different from [o]`name'"_args" ; altrtyp return type if not int (bogus - syscalls always return int) ; for UNIMPL/OBSOL, name continues with comments ; types: ; STD always included ; COMPAT included on COMPAT #ifdef ; CPT_NOA combines COMPAT with NOARGS ; LIBCOMPAT included on COMPAT #ifdef, and placed in syscall.h ; NOARGS same as STD except do not create structure in sys/sysproto.h ; NODEF ?? ; NOPROTO same as STD except do not create structure or function in ; sys/sysproto.h ; OBSOL obsolete, not included in system, only specifies name ; UNIMPL not implemented, placeholder only #include "opt_compat.h" #include #include #include #include #include ; #ifdef's, etc. may be included, and are copied to the output files. 0 UNIMPL LINUX 1 NOPROTO LINUX { void exit(int rval); } exit rexit_args void 2 STD LINUX { int linux_fork(void); } 3 NOPROTO LINUX { int read(int fd, char *buf, u_int nbyte); } 4 NOPROTO LINUX { int write(int fd, char *buf, u_int nbyte); } 5 UNIMPL LINUX 6 NOPROTO LINUX { int close(int fd); } 7 STD OSF1 { int osf1_wait4(int pid, int *status, int options, \ struct osf1_rusage *rusage); } 8 UNIMPL LINUX 9 STD LINUX { int linux_link(char *path, char *to); } 10 STD LINUX { int linux_unlink(char *path); } 11 UNIMPL LINUX 12 STD LINUX { int linux_chdir(char *path); } 13 NOPROTO LINUX { int fchdir(int fd); } 14 STD LINUX { int linux_mknod(char *path, int mode, int dev); } 15 STD LINUX { int linux_chmod(char *path, int mode); } 16 STD LINUX { int linux_chown(char *path, int uid, int gid); } 17 STD LINUX { int linux_brk(char *dsend); } 18 UNIMPL LINUX 19 STD LINUX { int linux_lseek(int fdes, long off, int whence); } 20 NOPROTO LINUX { int getpid(void); } 21 UNIMPL LINUX 22 STD LINUX { int linux_umount(void); } 23 NOPROTO LINUX { int setuid(uid_t uid); } 24 NOPROTO LINUX { int getuid(void); } 25 UNIMPL LINUX 26 STD LINUX { int linux_ptrace(void); } 27 UNIMPL LINUX 28 UNIMPL LINUX 29 UNIMPL LINUX 30 UNIMPL LINUX 31 UNIMPL LINUX 32 UNIMPL LINUX 33 STD LINUX { int linux_access(char *path, int flags); } 34 UNIMPL LINUX 35 UNIMPL LINUX 36 NOPROTO LINUX { int sync(void); } 37 STD LINUX { int linux_kill(int pid, int signum); } 38 UNIMPL LINUX 39 NOPROTO LINUX { int setpgid(int pid, int pgid); } 40 UNIMPL LINUX 41 NOPROTO LINUX { int dup(u_int fd); } 42 NOPROTO LINUX { int pipe(void); } 43 UNIMPL LINUX 44 UNIMPL LINUX 45 STD LINUX { int linux_open(char *path, int flags, int mode); } 46 UNIMPL LINUX 47 NOPROTO LINUX { int getgid(void); } 48 STD LINUX { int osf1_sigprocmask(int how, u_long mask); } 49 UNIMPL LINUX 50 UNIMPL LINUX 51 NOPROTO LINUX { int acct(char *path); } 52 UNIMPL LINUX 53 UNIMPL LINUX 54 STD LINUX { int linux_ioctl(int fd, u_long cmd, u_long arg); } 55 UNIMPL LINUX 56 UNIMPL LINUX 57 STD LINUX { int linux_symlink(char *path, char *to); } 58 STD LINUX { int linux_readlink(char *name, char *buf, \ int count); } 59 STD LINUX { int linux_execve(char *path, char **argp, \ char **envp); } 60 NOPROTO LINUX { int umask(int newmask); } 61 NOPROTO LINUX { int chroot(char *path); } 62 UNIMPL LINUX 63 NOPROTO LINUX { int getpgrp(void); } 64 UNIMPL LINUX getpagesize 65 UNIMPL LINUX 66 STD LINUX { int linux_vfork(void); } 67 STD LINUX { int linux_newstat(char *path, \ struct linux_newstat *buf); } 68 STD LINUX { int linux_newlstat(char *path, \ struct linux_newstat *buf); } 69 UNIMPL LINUX 70 UNIMPL LINUX 71 STD LINUX { int linux_mmap (caddr_t addr, size_t len, \ int prot, int flags, int fd, off_t pos); } 72 UNIMPL LINUX 73 STD LINUX { int linux_munmap(caddr_t addr, u_long len); } 74 STD LINUX { int linux_mprotect(caddr_t addr, size_t len, \ int prot); } 75 UNIMPL LINUX madvise 76 STD LINUX { int linux_vhangup(void); } 77 UNIMPL LINUX 78 UNIMPL LINUX 79 STD LINUX { int linux_setgroups(u_int gidsetsize, \ linux_gid_t *gidset); } 80 STD LINUX { int linux_getgroups(u_int gidsetsize, \ linux_gid_t *gidset); } 81 UNIMPL LINUX 82 STD LINUX { int linux_setpgid(int pid, int pgid); } 83 STD LINUX { int osf1_setitimer(u_int which, \ struct itimerval *itv, struct itimerval *oitv); } 84 UNIMPL LINUX 85 UNIMPL LINUX 86 UNIMPL LINUX 87 UNIMPL LINUX gethostname 88 NOPROTO LINUX { int osethostname(char *hostname, u_int len); } \ osethostname sethostname_args int 89 UNIMPL LINUX getdtablesize 90 NOPROTO LINUX { int dup2(u_int from, u_int to); } 91 STD LINUX { int linux_newfstat(int fd, \ struct linux_newstat *buf); } 92 STD LINUX { int linux_fcntl(int fd, int cmd, u_long arg); } 93 STD LINUX { int osf1_select(u_int nd, fd_set *in, fd_set *ou, \ fd_set *ex, struct timeval *tv); } 94 NOPROTO LINUX { int poll(struct pollfd*, unsigned int nfds, \ long timeout); } 95 NOPROTO LINUX { int fsync(int fd); } 96 NOPROTO LINUX { int setpriority(int which, int who, int prio); } 97 STD LINUX { int osf1_socket(int domain, int type, \ int protocol); } 98 STD LINUX { int linux_connect(int s, caddr_t name, \ int namelen); } 99 NOPROTO LINUX { int oaccept(int s, caddr_t name, int *anamelen); } \ accept accept_args int 100 UNIMPL LINUX 101 NOPROTO LINUX { int osend(int s, caddr_t buf, int len, \ int flags); } 102 NOPROTO LINUX { int orecv(int s, caddr_t buf, int len, \ int flags); } 103 STD OSF1 { int osf1_sigreturn(struct osigcontext *sigcntxp); } 104 NOPROTO LINUX { int bind(int s, caddr_t name, int namelen); } 105 NOPROTO LINUX { int setsockopt(int s, int level, int name, \ caddr_t val, int valsize); } 106 NOPROTO LINUX { int listen(int s, int backlog); } 107 UNIMPL LINUX 108 UNIMPL LINUX 109 UNIMPL LINUX 110 UNIMPL LINUX 111 STD OSF1 { int osf1_sigsuspend(unsigned long ss); } 112 UNIMPL LINUX 113 UNIMPL LINUX recvmsg 114 UNIMPL LINUX sendmsg 115 UNIMPL LINUX 116 STD LINUX { int osf1_gettimeofday(struct timeval *tp, \ struct timezone *tzp); } 117 STD OSF1 { int osf1_getrusage(long who, void *rusage); } 118 NOPROTO LINUX { int getsockopt(int s, int level, int name, \ caddr_t val, int *avalsize); } 119 UNIMPL LINUX 120 NOPROTO LINUX { int readv(int fd, struct iovec *iovp, \ u_int iovcnt); } 121 NOPROTO LINUX { int writev(int fd, struct iovec *iovp, \ u_int iovcnt); } 122 UNIMPL LINUX 123 NOPROTO LINUX { int fchown(int fd, int uid, int gid); } 124 NOPROTO LINUX { int fchmod(int fd, int mode); } 125 NOPROTO LINUX { int orecvfrom(int s, caddr_t buf, \ size_t len, int flags, caddr_t from, \ int *fromlenaddr); } \ recvfrom recvfrom_args int 126 NOPROTO LINUX { int setreuid(int ruid, int euid); } 127 NOPROTO LINUX { int setregid(int rgid, int egid); } 128 STD LINUX { int linux_rename(char *from, char *to); } 129 STD LINUX { int linux_truncate(char *path, long length); } 130 NOPROTO LINUX { int oftruncate(int fd, long length); } 131 NOPROTO LINUX { int flock(int fd, int how); } 132 NOPROTO LINUX { int setgid(gid_t gid); } 133 STD LINUX { int osf1_sendto(int s, caddr_t buf, size_t len, \ int flags, struct sockaddr *to, int tolen); } 134 NOPROTO LINUX { int shutdown(int s, int how); } 135 UNIMPL LINUX socketpair 136 STD LINUX { int linux_mkdir(char *path, int mode); } 137 STD LINUX { int linux_rmdir(char *path); } 138 NOPROTO LINUX { int utimes(char *path, struct timeval *tptr); } 139 UNIMPL LINUX 140 UNIMPL LINUX 141 NOPROTO LINUX { int ogetpeername(int fdes, caddr_t asa, int *alen); } 142 UNIMPL LINUX 143 UNIMPL LINUX 144 STD LINUX { int linux_getrlimit(u_int resource, \ struct rlimit *rlim); } 145 STD LINUX { int linux_setrlimit(u_int resource, \ struct rlimit *rlim); } 146 UNIMPL LINUX 147 NOPROTO LINUX { int setsid(void); } 148 STD LINUX { int linux_quotactl(void); } 149 UNIMPL LINUX 150 NOPROTO LINUX { int ogetsockname(int fdec, caddr_t asa, int *alen);} \ getsockname getsockname_args int 151 UNIMPL LINUX 152 UNIMPL LINUX 153 UNIMPL LINUX 154 UNIMPL LINUX 155 UNIMPL LINUX 156 STD LINUX { int osf1_sigaction(int sig,\ struct osf1_sigaction *nsa, \ struct osf1_sigaction *osa); } 157 UNIMPL LINUX 158 UNIMPL LINUX 159 UNIMPL LINUX 160 UNIMPL LINUX 161 UNIMPL LINUX 162 UNIMPL LINUX 163 UNIMPL LINUX 164 UNIMPL LINUX 165 UNIMPL LINUX 166 NOPROTO LINUX { int setdomainname(char *name, int len); } 167 UNIMPL LINUX 168 UNIMPL LINUX 169 UNIMPL LINUX 170 UNIMPL LINUX 171 UNIMPL LINUX 172 UNIMPL LINUX 173 UNIMPL LINUX 174 UNIMPL LINUX 175 UNIMPL LINUX 176 UNIMPL LINUX 177 UNIMPL LINUX 178 UNIMPL LINUX 179 UNIMPL LINUX 180 UNIMPL LINUX 181 UNIMPL LINUX 182 UNIMPL LINUX 183 UNIMPL LINUX 184 UNIMPL LINUX 185 UNIMPL LINUX 186 UNIMPL LINUX 187 UNIMPL LINUX 188 UNIMPL LINUX 189 UNIMPL LINUX 190 UNIMPL LINUX 191 UNIMPL LINUX 192 UNIMPL LINUX 193 UNIMPL LINUX 194 UNIMPL LINUX 195 UNIMPL LINUX 196 UNIMPL LINUX 197 UNIMPL LINUX 198 UNIMPL LINUX 199 UNIMPL LINUX 200 STD LINUX { int linux_msgctl(int arg1, int arg2, \ caddr_t ptr); } 201 STD LINUX { int linux_msgget(int arg1, int arg2); } 202 STD LINUX { int linux_msgrcv(int arg1, caddr_t ptr, \ size_t arg2, long arg3, int arg4); } 203 STD LINUX { int linux_msgsnd(int arg1, caddr_t ptr, \ size_t arg2, long arg3, int arg4); } 204 STD LINUX { int linux_semctl(int arg1, int arg2, \ int arg3, caddr_t ptr); } 205 STD LINUX { int linux_semget(int arg1, int arg2, int arg3); } 206 STD LINUX { int linux_semop(int arg1, caddr_t ptr, \ int arg2); } 207 UNIMPL LINUX 208 STD LINUX { int linux_lchown(char *path, int uid, int gid); } 209 STD LINUX { int linux_shmat(int arg1, caddr_t ptr, \ int arg2, caddr_t arg3); } 210 STD LINUX { int linux_shmctl(int arg1, int arg2, \ caddr_t ptr); } 211 STD LINUX { int linux_shmdt(caddr_t ptr); } 212 STD LINUX { int linux_shmget(int arg1, size_t arg2, \ int arg3); } 213 UNIMPL LINUX 214 UNIMPL LINUX 215 UNIMPL LINUX 216 UNIMPL LINUX 217 STD LINUX { int linux_msync(caddr_t addr, int len, int fl); } 218 UNIMPL LINUX 219 UNIMPL LINUX 220 UNIMPL LINUX 221 UNIMPL LINUX 222 UNIMPL LINUX 223 UNIMPL LINUX 224 UNIMPL LINUX 225 UNIMPL LINUX 226 UNIMPL LINUX 227 UNIMPL LINUX 228 UNIMPL LINUX 229 UNIMPL LINUX 230 UNIMPL LINUX 231 UNIMPL LINUX 232 UNIMPL LINUX 233 STD LINUX { int linux_getpgid(int pid); } 234 STD LINUX { int linux_getsid(linux_pid_t pid); } 235 UNIMPL LINUX sigaltstack 236 UNIMPL LINUX 237 UNIMPL LINUX 238 UNIMPL LINUX 239 UNIMPL LINUX 240 UNIMPL LINUX 241 STD OSF1 { int osf1_sysinfo(int cmd, char *buf, long count); } 242 UNIMPL LINUX 243 UNIMPL LINUX 244 UNIMPL LINUX 245 UNIMPL LINUX 246 UNIMPL LINUX 247 UNIMPL LINUX 248 UNIMPL LINUX 249 UNIMPL LINUX 250 UNIMPL LINUX 251 UNIMPL LINUX 252 UNIMPL LINUX 253 UNIMPL LINUX 254 UNIMPL LINUX 255 STD LINUX { int linux_sysfs(int option, u_long arg1, \ u_long arg2); } 256 STD OSF1 { int osf1_getsysinfo(u_long op, caddr_t buffer, \ u_long nbytes, caddr_t arg, u_long flag); } 257 STD OSF1 { int osf1_setsysinfo(u_long op, caddr_t buffer, \ u_long nbytes, caddr_t arg, u_long flag); } 258 STD LINUX { int linux_afs_syscall(void); } 259 UNIMPL LINUX 260 UNIMPL LINUX 261 UNIMPL LINUX 262 UNIMPL LINUX 263 UNIMPL LINUX 264 UNIMPL LINUX 265 UNIMPL LINUX 266 UNIMPL LINUX 267 UNIMPL LINUX 268 UNIMPL LINUX 269 UNIMPL LINUX 270 UNIMPL LINUX 271 UNIMPL LINUX 272 UNIMPL LINUX 273 UNIMPL LINUX 274 UNIMPL LINUX 275 UNIMPL LINUX 276 UNIMPL LINUX 277 UNIMPL LINUX 278 UNIMPL LINUX 279 UNIMPL LINUX 280 UNIMPL LINUX 281 UNIMPL LINUX 282 UNIMPL LINUX 283 UNIMPL LINUX 284 UNIMPL LINUX 285 UNIMPL LINUX 286 UNIMPL LINUX 287 UNIMPL LINUX 288 UNIMPL LINUX 289 UNIMPL LINUX 290 UNIMPL LINUX 291 UNIMPL LINUX 292 UNIMPL LINUX 293 UNIMPL LINUX 294 UNIMPL LINUX 295 UNIMPL LINUX 296 UNIMPL LINUX 297 UNIMPL LINUX 298 UNIMPL LINUX 299 UNIMPL LINUX 300 STD LINUX { int linux_bdflush(void); } 301 UNIMPL LINUX sethae 302 STD LINUX { int linux_mount(void); } 303 UNIMPL LINUX old_adjtimex 304 STD LINUX { int linux_swapoff(void); } 305 STD LINUX { int linux_getdents(int fd, void *dent, \ unsigned count); } 306 STD LINUX { int linux_create_module(void); } 307 STD LINUX { int linux_init_module(void); } 308 STD LINUX { int linux_delete_module(void); } 309 STD LINUX { int linux_get_kernel_syms(void); } 310 STD LINUX { int linux_ksyslog(int what); } 311 NOPROTO LINUX { int reboot(int opt); } 312 STD LINUX { int linux_clone(int flags, void *stack); } 313 STD LINUX { int linux_uselib(char *library); } 314 NOPROTO BSD { int mlock(const void *addr, size_t len); } 315 NOPROTO BSD { int munlock(const void *addr, size_t len); } 316 NOPROTO BSD { int mlockall(int how); } 317 NOPROTO BSD { int munlockall(void); } 318 STD LINUX { int linux_sysinfo(void); } 319 STD LINUX { int linux_sysctl(void); } 320 STD LINUX { int linux_idle(void); } 321 UNIMPL LINUX old_umount 322 NOPROTO LINUX { int swapon(char *name); } 323 STD LINUX { int linux_times(struct linux_times_argv *buf); } 324 STD LINUX { int linux_personality(int per); } 325 STD LINUX { int linux_setfsuid(linux_uid_t uid); } 326 STD LINUX { int linux_setfsgid(linux_gid_t gid); } 327 STD LINUX { int linux_ustat(linux_dev_t dev, \ struct linux_ustat *ubuf); } 328 STD LINUX { int linux_statfs(char *path, \ struct linux_statfs_buf *buf); } 329 STD LINUX { int linux_fstatfs(int fd, \ struct linux_statfs_buf *buf); } 330 NOPROTO POSIX { int sched_setparam (pid_t pid, \ const struct sched_param *param); } 331 NOPROTO POSIX { int sched_getparam (pid_t pid, \ struct sched_param *param); } 332 STD POSIX { int linux_sched_setscheduler(pid_t pid, int policy, \ const struct sched_param *param); } 333 STD POSIX { int linux_sched_getscheduler (pid_t pid); } 334 NOPROTO POSIX { int sched_yield (void); } -335 NOPROTO POSIX { int sched_get_priority_max (int policy); } -336 NOPROTO POSIX { int sched_get_priority_min (int policy); } +335 STD POSIX { int linux_sched_get_priority_max (int policy); } +336 STD POSIX { int linux_sched_get_priority_min (int policy); } 337 NOPROTO POSIX { int sched_rr_get_interval (pid_t pid, \ struct timespec *interval); } 338 UNIMPL LINUX afs_syscall 339 STD LINUX { int linux_newuname(struct linux_newuname_t *buf); } 340 NOPROTO POSIX { int nanosleep(const struct timespec *rqtp, \ struct timespec *rmtp); } 341 STD LINUX { int linux_mremap(caddr_t addr, u_long old_len, \ u_long new_len, u_long flags); } 342 STD LINUX { int linux_nfsservctl(void); } 343 NOPROTO LINUX { int setresgid(int rgid, int egid, int sgid); } 344 STD LINUX { int linux_getresgid(linux_gid_t *rgid, \ linux_gid_t *egid, linux_gid_t *sgid); } 345 UNIMPL LINUX pciconfig_read 346 UNIMPL LINUX pciconfig_write 347 STD LINUX { int linux_query_module(void); } 348 STD LINUX { int linux_prctl(void); } 349 STD LINUX { int linux_pread(int fd, char *buf, size_t nbyte, \ off_t offset); } 350 STD LINUX { int linux_pwrite(int fd, const char *buf, \ size_t nbyte, off_t offset); } 351 STD LINUX { int linux_rt_sigreturn(void); } 352 STD LINUX { int linux_rt_sigaction(int sig, \ linux_sigaction_t *act, \ linux_sigaction_t *oact, \ size_t sigsetsize); } 353 STD LINUX { int linux_rt_sigprocmask(int how, \ linux_sigset_t *mask, linux_sigset_t *omask, \ size_t sigsetsize); } 354 STD LINUX { int linux_rt_sigpending(void); } 355 STD LINUX { int linux_rt_sigtimedwait(void); } 356 STD LINUX { int linux_rt_sigqueueinfo(void); } 357 STD LINUX { int linux_rt_sigsuspend(linux_sigset_t *newset, \ size_t sigsetsize); } 358 STD LINUX { int linux_newselect(int nfds, fd_set *readfds, \ fd_set *writefds, fd_set *exceptfds, \ struct timeval *timeout); } 359 NOPROTO LINUX { int gettimeofday(struct timeval *tp, \ struct timezone *tzp); } 360 NOPROTO LINUX { int settimeofday(struct timeval *tp, \ struct timezone *tzp); } 361 STD LINUX { int linux_getitimer(u_int which, \ struct itimerval *itv); } 362 STD LINUX { int linux_setitimer(u_int which, \ struct itimerval *itv, struct itimerval *oitv); } 363 STD LINUX { int linux_utime(char *fname, \ struct linux_utimbuf *times); } 364 NOPROTO LINUX { int getrusage(int who, struct rusage *rusage); } 365 STD LINUX { int linux_wait4(int pid, int *status, \ int options, struct rusage *rusage); } 366 STD LINUX { int linux_adjtimex(void); } 367 STD LINUX { int linux_getcwd(char *buf, unsigned long bufsize); } 368 STD LINUX { int linux_capget(void); } 369 STD LINUX { int linux_capset(void); } 370 STD LINUX { int linux_sendfile(void); } Index: stable/4/sys/compat/linux/linux_misc.c =================================================================== --- stable/4/sys/compat/linux/linux_misc.c (revision 82402) +++ stable/4/sys/compat/linux/linux_misc.c (revision 82403) @@ -1,1228 +1,1284 @@ /*- * Copyright (c) 1994-1995 Søren Schmidt * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer * in this position and unchanged. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software withough specific prior written permission * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD$ */ #include "opt_compat.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef __i386__ #include #endif #include #include #ifdef __alpha__ #include #else #include #endif #include #include #ifdef __alpha__ #define BSD_TO_LINUX_SIGNAL(sig) (sig) #else #define BSD_TO_LINUX_SIGNAL(sig) \ (((sig) <= LINUX_SIGTBLSZ) ? bsd_to_linux_signal[_SIG_IDX(sig)] : sig) #endif struct linux_rlimit { unsigned long rlim_cur; unsigned long rlim_max; }; #ifndef __alpha__ static unsigned int linux_to_bsd_resource[LINUX_RLIM_NLIMITS] = { RLIMIT_CPU, RLIMIT_FSIZE, RLIMIT_DATA, RLIMIT_STACK, RLIMIT_CORE, RLIMIT_RSS, RLIMIT_NPROC, RLIMIT_NOFILE, RLIMIT_MEMLOCK, -1 }; #endif /*!__alpha__*/ struct linux_sysinfo { long uptime; /* Seconds since boot */ unsigned long loads[3]; /* 1, 5, and 15 minute load averages */ unsigned long totalram; /* Total usable main memory size */ unsigned long freeram; /* Available memory size */ unsigned long sharedram; /* Amount of shared memory */ unsigned long bufferram; /* Memory used by buffers */ unsigned long totalswap; /* Total swap space size */ unsigned long freeswap; /* swap space still available */ unsigned short procs; /* Number of current processes */ char _f[22]; /* Pads structure to 64 bytes */ }; #ifndef __alpha__ int linux_sysinfo(struct proc *p, struct linux_sysinfo_args *args) { struct linux_sysinfo sysinfo; vm_object_t object; int i; struct timespec ts; /* Uptime is copied out of print_uptime() procedure in kern_shutdown.c */ getnanouptime(&ts); i = 0; if (ts.tv_sec >= 86400) { ts.tv_sec %= 86400; i = 1; } if (i || ts.tv_sec >= 3600) { ts.tv_sec %= 3600; i = 1; } if (i || ts.tv_sec >= 60) { ts.tv_sec %= 60; i = 1; } sysinfo.uptime=ts.tv_sec; /* Use the information from the mib to get our load averages */ for (i = 0; i < 3; i++) sysinfo.loads[i] = averunnable.ldavg[i]; sysinfo.totalram = physmem * PAGE_SIZE; sysinfo.freeram = sysinfo.totalram - cnt.v_wire_count * PAGE_SIZE; sysinfo.sharedram = 0; for (object = TAILQ_FIRST(&vm_object_list); object != NULL; object = TAILQ_NEXT(object, object_list)) if (object->shadow_count > 1) sysinfo.sharedram += object->resident_page_count; sysinfo.sharedram *= PAGE_SIZE; sysinfo.bufferram = 0; if (swapblist == NULL) { sysinfo.totalswap= 0; sysinfo.freeswap = 0; } else { sysinfo.totalswap = swapblist->bl_blocks * 1024; sysinfo.freeswap = swapblist->bl_root->u.bmu_avail * PAGE_SIZE; } sysinfo.procs = 20; /* Hack */ return copyout((caddr_t)&sysinfo, (caddr_t)args->info, sizeof(struct linux_sysinfo)); } #endif /*!__alpha__*/ #ifndef __alpha__ int linux_alarm(struct proc *p, struct linux_alarm_args *args) { struct itimerval it, old_it; struct timeval tv; int s; #ifdef DEBUG printf("Linux-emul(%ld): alarm(%u)\n", (long)p->p_pid, args->secs); #endif if (args->secs > 100000000) return EINVAL; it.it_value.tv_sec = (long)args->secs; it.it_value.tv_usec = 0; it.it_interval.tv_sec = 0; it.it_interval.tv_usec = 0; s = splsoftclock(); old_it = p->p_realtimer; getmicrouptime(&tv); if (timevalisset(&old_it.it_value)) untimeout(realitexpire, (caddr_t)p, p->p_ithandle); if (it.it_value.tv_sec != 0) { p->p_ithandle = timeout(realitexpire, (caddr_t)p, tvtohz(&it.it_value)); timevaladd(&it.it_value, &tv); } p->p_realtimer = it; splx(s); if (timevalcmp(&old_it.it_value, &tv, >)) { timevalsub(&old_it.it_value, &tv); if (old_it.it_value.tv_usec != 0) old_it.it_value.tv_sec++; p->p_retval[0] = old_it.it_value.tv_sec; } return 0; } #endif /*!__alpha__*/ int linux_brk(struct proc *p, struct linux_brk_args *args) { #if 0 struct vmspace *vm = p->p_vmspace; vm_offset_t new, old; int error; if ((vm_offset_t)args->dsend < (vm_offset_t)vm->vm_daddr) return EINVAL; if (((caddr_t)args->dsend - (caddr_t)vm->vm_daddr) > p->p_rlimit[RLIMIT_DATA].rlim_cur) return ENOMEM; old = round_page((vm_offset_t)vm->vm_daddr) + ctob(vm->vm_dsize); new = round_page((vm_offset_t)args->dsend); p->p_retval[0] = old; if ((new-old) > 0) { if (swap_pager_full) return ENOMEM; error = vm_map_find(&vm->vm_map, NULL, 0, &old, (new-old), FALSE, VM_PROT_ALL, VM_PROT_ALL, 0); if (error) return error; vm->vm_dsize += btoc((new-old)); p->p_retval[0] = (int)(vm->vm_daddr + ctob(vm->vm_dsize)); } return 0; #else struct vmspace *vm = p->p_vmspace; vm_offset_t new, old; struct obreak_args /* { char * nsize; } */ tmp; #ifdef DEBUG printf("Linux-emul(%ld): brk(%p)\n", (long)p->p_pid, (void *)args->dsend); #endif old = (vm_offset_t)vm->vm_daddr + ctob(vm->vm_dsize); new = (vm_offset_t)args->dsend; tmp.nsize = (char *) new; if (((caddr_t)new > vm->vm_daddr) && !obreak(p, &tmp)) p->p_retval[0] = (long)new; else p->p_retval[0] = (long)old; return 0; #endif } int linux_uselib(struct proc *p, struct linux_uselib_args *args) { struct nameidata ni; struct vnode *vp; struct exec *a_out; struct vattr attr; vm_offset_t vmaddr; unsigned long file_offset; vm_offset_t buffer; unsigned long bss_size; int error; caddr_t sg; int locked; sg = stackgap_init(); CHECKALTEXIST(p, &sg, args->library); #ifdef DEBUG printf("Linux-emul(%ld): uselib(%s)\n", (long)p->p_pid, args->library); #endif a_out = NULL; locked = 0; vp = NULL; NDINIT(&ni, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, args->library, p); error = namei(&ni); if (error) goto cleanup; vp = ni.ni_vp; /* * XXX This looks like a bogus check - a LOCKLEAF namei should not succeed * without returning a vnode. */ if (vp == NULL) { error = ENOEXEC; /* ?? */ goto cleanup; } NDFREE(&ni, NDF_ONLY_PNBUF); /* * From here on down, we have a locked vnode that must be unlocked. */ locked++; /* * Writable? */ if (vp->v_writecount) { error = ETXTBSY; goto cleanup; } /* * Executable? */ error = VOP_GETATTR(vp, &attr, p->p_ucred, p); if (error) goto cleanup; if ((vp->v_mount->mnt_flag & MNT_NOEXEC) || ((attr.va_mode & 0111) == 0) || (attr.va_type != VREG)) { error = ENOEXEC; goto cleanup; } /* * Sensible size? */ if (attr.va_size == 0) { error = ENOEXEC; goto cleanup; } /* * Can we access it? */ error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p); if (error) goto cleanup; error = VOP_OPEN(vp, FREAD, p->p_ucred, p); if (error) goto cleanup; /* * Lock no longer needed */ VOP_UNLOCK(vp, 0, p); locked = 0; /* * Pull in executable header into kernel_map */ error = vm_mmap(kernel_map, (vm_offset_t *)&a_out, PAGE_SIZE, VM_PROT_READ, VM_PROT_READ, 0, (caddr_t)vp, 0); if (error) goto cleanup; /* * Is it a Linux binary ? */ if (((a_out->a_magic >> 16) & 0xff) != 0x64) { error = ENOEXEC; goto cleanup; } /* While we are here, we should REALLY do some more checks */ /* * Set file/virtual offset based on a.out variant. */ switch ((int)(a_out->a_magic & 0xffff)) { case 0413: /* ZMAGIC */ file_offset = 1024; break; case 0314: /* QMAGIC */ file_offset = 0; break; default: error = ENOEXEC; goto cleanup; } bss_size = round_page(a_out->a_bss); /* * Check various fields in header for validity/bounds. */ if (a_out->a_text & PAGE_MASK || a_out->a_data & PAGE_MASK) { error = ENOEXEC; goto cleanup; } /* text + data can't exceed file size */ if (a_out->a_data + a_out->a_text > attr.va_size) { error = EFAULT; goto cleanup; } /* * text/data/bss must not exceed limits * XXX: this is not complete. it should check current usage PLUS * the resources needed by this library. */ if (a_out->a_text > MAXTSIZ || a_out->a_data + bss_size > p->p_rlimit[RLIMIT_DATA].rlim_cur) { error = ENOMEM; goto cleanup; } /* * prevent more writers */ vp->v_flag |= VTEXT; /* * Check if file_offset page aligned,. * Currently we cannot handle misalinged file offsets, * and so we read in the entire image (what a waste). */ if (file_offset & PAGE_MASK) { #ifdef DEBUG printf("uselib: Non page aligned binary %lu\n", file_offset); #endif /* * Map text+data read/write/execute */ /* a_entry is the load address and is page aligned */ vmaddr = trunc_page(a_out->a_entry); /* get anon user mapping, read+write+execute */ error = vm_map_find(&p->p_vmspace->vm_map, NULL, 0, &vmaddr, a_out->a_text + a_out->a_data, FALSE, VM_PROT_ALL, VM_PROT_ALL, 0); if (error) goto cleanup; /* map file into kernel_map */ error = vm_mmap(kernel_map, &buffer, round_page(a_out->a_text + a_out->a_data + file_offset), VM_PROT_READ, VM_PROT_READ, 0, (caddr_t)vp, trunc_page(file_offset)); if (error) goto cleanup; /* copy from kernel VM space to user space */ error = copyout((caddr_t)(void *)(uintptr_t)(buffer + file_offset), (caddr_t)vmaddr, a_out->a_text + a_out->a_data); /* release temporary kernel space */ vm_map_remove(kernel_map, buffer, buffer + round_page(a_out->a_text + a_out->a_data + file_offset)); if (error) goto cleanup; } else { #ifdef DEBUG printf("uselib: Page aligned binary %lu\n", file_offset); #endif /* * for QMAGIC, a_entry is 20 bytes beyond the load address * to skip the executable header */ vmaddr = trunc_page(a_out->a_entry); /* * Map it all into the process's space as a single copy-on-write * "data" segment. */ error = vm_mmap(&p->p_vmspace->vm_map, &vmaddr, a_out->a_text + a_out->a_data, VM_PROT_ALL, VM_PROT_ALL, MAP_PRIVATE | MAP_FIXED, (caddr_t)vp, file_offset); if (error) goto cleanup; } #ifdef DEBUG printf("mem=%08lx = %08lx %08lx\n", vmaddr, ((long*)vmaddr)[0], ((long*)vmaddr)[1]); #endif if (bss_size != 0) { /* * Calculate BSS start address */ vmaddr = trunc_page(a_out->a_entry) + a_out->a_text + a_out->a_data; /* * allocate some 'anon' space */ error = vm_map_find(&p->p_vmspace->vm_map, NULL, 0, &vmaddr, bss_size, FALSE, VM_PROT_ALL, VM_PROT_ALL, 0); if (error) goto cleanup; } cleanup: /* * Unlock vnode if needed */ if (locked) VOP_UNLOCK(vp, 0, p); /* * Release the kernel mapping. */ if (a_out) vm_map_remove(kernel_map, (vm_offset_t)a_out, (vm_offset_t)a_out + PAGE_SIZE); return error; } int linux_newselect(struct proc *p, struct linux_newselect_args *args) { struct select_args bsa; struct timeval tv0, tv1, utv, *tvp; caddr_t sg; int error; #ifdef DEBUG printf("Linux-emul(%ld): newselect(%d, %p, %p, %p, %p)\n", (long)p->p_pid, args->nfds, (void *)args->readfds, (void *)args->writefds, (void *)args->exceptfds, (void *)args->timeout); #endif error = 0; bsa.nd = args->nfds; bsa.in = args->readfds; bsa.ou = args->writefds; bsa.ex = args->exceptfds; bsa.tv = args->timeout; /* * Store current time for computation of the amount of * time left. */ if (args->timeout) { if ((error = copyin(args->timeout, &utv, sizeof(utv)))) goto select_out; #ifdef DEBUG printf("Linux-emul(%ld): incoming timeout (%ld/%ld)\n", (long)p->p_pid, utv.tv_sec, utv.tv_usec); #endif if (itimerfix(&utv)) { /* * The timeval was invalid. Convert it to something * valid that will act as it does under Linux. */ sg = stackgap_init(); tvp = stackgap_alloc(&sg, sizeof(utv)); utv.tv_sec += utv.tv_usec / 1000000; utv.tv_usec %= 1000000; if (utv.tv_usec < 0) { utv.tv_sec -= 1; utv.tv_usec += 1000000; } if (utv.tv_sec < 0) timevalclear(&utv); if ((error = copyout(&utv, tvp, sizeof(utv)))) goto select_out; bsa.tv = tvp; } microtime(&tv0); } error = select(p, &bsa); #ifdef DEBUG printf("Linux-emul(%ld): real select returns %d\n", (long)p->p_pid, error); #endif if (error) { /* * See fs/select.c in the Linux kernel. Without this, * Maelstrom doesn't work. */ if (error == ERESTART) error = EINTR; goto select_out; } if (args->timeout) { if (p->p_retval[0]) { /* * Compute how much time was left of the timeout, * by subtracting the current time and the time * before we started the call, and subtracting * that result from the user-supplied value. */ microtime(&tv1); timevalsub(&tv1, &tv0); timevalsub(&utv, &tv1); if (utv.tv_sec < 0) timevalclear(&utv); } else timevalclear(&utv); #ifdef DEBUG printf("Linux-emul(%ld): outgoing timeout (%ld/%ld)\n", (long)p->p_pid, utv.tv_sec, utv.tv_usec); #endif if ((error = copyout(&utv, args->timeout, sizeof(utv)))) goto select_out; } select_out: #ifdef DEBUG printf("Linux-emul(%ld): newselect_out -> %d\n", (long)p->p_pid, error); #endif return error; } int linux_getpgid(struct proc *p, struct linux_getpgid_args *args) { struct proc *curp; #ifdef DEBUG printf("Linux-emul(%ld): getpgid(%d)\n", (long)p->p_pid, args->pid); #endif if (args->pid != p->p_pid) { if (!(curp = pfind(args->pid))) return ESRCH; } else curp = p; p->p_retval[0] = curp->p_pgid; return 0; } int linux_mremap(struct proc *p, struct linux_mremap_args *args) { struct munmap_args /* { void *addr; size_t len; } */ bsd_args; int error = 0; #ifdef DEBUG printf("Linux-emul(%ld): mremap(%p, %08lx, %08lx, %08lx)\n", (long)p->p_pid, (void *)args->addr, (unsigned long)args->old_len, (unsigned long)args->new_len, (unsigned long)args->flags); #endif args->new_len = round_page(args->new_len); args->old_len = round_page(args->old_len); if (args->new_len > args->old_len) { p->p_retval[0] = 0; return ENOMEM; } if (args->new_len < args->old_len) { bsd_args.addr = args->addr + args->new_len; bsd_args.len = args->old_len - args->new_len; error = munmap(p, &bsd_args); } p->p_retval[0] = error ? 0 : (u_long)args->addr; return error; } int linux_msync(struct proc *p, struct linux_msync_args *args) { struct msync_args bsd_args; bsd_args.addr = args->addr; bsd_args.len = args->len; bsd_args.flags = 0; /* XXX ignore */ return msync(p, &bsd_args); } #ifndef __alpha__ int linux_time(struct proc *p, struct linux_time_args *args) { struct timeval tv; linux_time_t tm; int error; #ifdef DEBUG printf("Linux-emul(%ld): time(*)\n", (long)p->p_pid); #endif microtime(&tv); tm = tv.tv_sec; if (args->tm && (error = copyout(&tm, args->tm, sizeof(linux_time_t)))) return error; p->p_retval[0] = tm; return 0; } #endif /*!__alpha__*/ struct linux_times_argv { long tms_utime; long tms_stime; long tms_cutime; long tms_cstime; }; #ifdef __alpha__ #define CLK_TCK 1024 /* Linux uses 1024 on alpha */ #else #define CLK_TCK 100 /* Linux uses 100 */ #endif #define CONVTCK(r) (r.tv_sec * CLK_TCK + r.tv_usec / (1000000 / CLK_TCK)) int linux_times(struct proc *p, struct linux_times_args *args) { struct timeval tv; struct linux_times_argv tms; struct rusage ru; int error; #ifdef DEBUG printf("Linux-emul(%ld): times(*)\n", (long)p->p_pid); #endif calcru(p, &ru.ru_utime, &ru.ru_stime, NULL); tms.tms_utime = CONVTCK(ru.ru_utime); tms.tms_stime = CONVTCK(ru.ru_stime); tms.tms_cutime = CONVTCK(p->p_stats->p_cru.ru_utime); tms.tms_cstime = CONVTCK(p->p_stats->p_cru.ru_stime); if ((error = copyout((caddr_t)&tms, (caddr_t)args->buf, sizeof(struct linux_times_argv)))) return error; microuptime(&tv); p->p_retval[0] = (int)CONVTCK(tv); return 0; } int linux_newuname(struct proc *p, struct linux_newuname_args *args) { struct linux_new_utsname utsname; char *osrelease, *osname; #ifdef DEBUG printf("Linux-emul(%ld): newuname(*)\n", (long)p->p_pid); #endif osname = linux_get_osname(p); osrelease = linux_get_osrelease(p); bzero(&utsname, sizeof(struct linux_new_utsname)); strncpy(utsname.sysname, osname, LINUX_MAX_UTSNAME-1); strncpy(utsname.nodename, hostname, LINUX_MAX_UTSNAME-1); strncpy(utsname.release, osrelease, LINUX_MAX_UTSNAME-1); strncpy(utsname.version, version, LINUX_MAX_UTSNAME-1); strncpy(utsname.machine, machine, LINUX_MAX_UTSNAME-1); strncpy(utsname.domainname, domainname, LINUX_MAX_UTSNAME-1); return (copyout((caddr_t)&utsname, (caddr_t)args->buf, sizeof(struct linux_new_utsname))); } struct linux_utimbuf { linux_time_t l_actime; linux_time_t l_modtime; }; int linux_utime(struct proc *p, struct linux_utime_args *args) { struct utimes_args /* { char *path; struct timeval *tptr; } */ bsdutimes; struct timeval tv[2], *tvp; struct linux_utimbuf lut; int error; caddr_t sg; sg = stackgap_init(); CHECKALTEXIST(p, &sg, args->fname); #ifdef DEBUG printf("Linux-emul(%ld): utime(%s, *)\n", (long)p->p_pid, args->fname); #endif if (args->times) { if ((error = copyin(args->times, &lut, sizeof lut))) return error; tv[0].tv_sec = lut.l_actime; tv[0].tv_usec = 0; tv[1].tv_sec = lut.l_modtime; tv[1].tv_usec = 0; /* so that utimes can copyin */ tvp = (struct timeval *)stackgap_alloc(&sg, sizeof(tv)); if (tvp == NULL) return (ENAMETOOLONG); if ((error = copyout(tv, tvp, sizeof(tv)))) return error; bsdutimes.tptr = tvp; } else bsdutimes.tptr = NULL; bsdutimes.path = args->fname; return utimes(p, &bsdutimes); } #define __WCLONE 0x80000000 #ifndef __alpha__ int linux_waitpid(struct proc *p, struct linux_waitpid_args *args) { struct wait_args /* { int pid; int *status; int options; struct rusage *rusage; } */ tmp; int error, tmpstat; #ifdef DEBUG printf("Linux-emul(%ld): waitpid(%d, %p, %d)\n", (long)p->p_pid, args->pid, (void *)args->status, args->options); #endif tmp.pid = args->pid; tmp.status = args->status; tmp.options = (args->options & (WNOHANG | WUNTRACED)); /* WLINUXCLONE should be equal to __WCLONE, but we make sure */ if (args->options & __WCLONE) tmp.options |= WLINUXCLONE; tmp.rusage = NULL; if ((error = wait4(p, &tmp)) != 0) return error; if (args->status) { if ((error = copyin(args->status, &tmpstat, sizeof(int))) != 0) return error; tmpstat &= 0xffff; if (WIFSIGNALED(tmpstat)) tmpstat = (tmpstat & 0xffffff80) | BSD_TO_LINUX_SIGNAL(WTERMSIG(tmpstat)); else if (WIFSTOPPED(tmpstat)) tmpstat = (tmpstat & 0xffff00ff) | (BSD_TO_LINUX_SIGNAL(WSTOPSIG(tmpstat)) << 8); return copyout(&tmpstat, args->status, sizeof(int)); } else return 0; } #endif /*!__alpha__*/ int linux_wait4(struct proc *p, struct linux_wait4_args *args) { struct wait_args /* { int pid; int *status; int options; struct rusage *rusage; } */ tmp; int error, tmpstat; #ifdef DEBUG printf("Linux-emul(%ld): wait4(%d, %p, %d, %p)\n", (long)p->p_pid, args->pid, (void *)args->status, args->options, (void *)args->rusage); #endif tmp.pid = args->pid; tmp.status = args->status; tmp.options = (args->options & (WNOHANG | WUNTRACED)); /* WLINUXCLONE should be equal to __WCLONE, but we make sure */ if (args->options & __WCLONE) tmp.options |= WLINUXCLONE; tmp.rusage = args->rusage; if ((error = wait4(p, &tmp)) != 0) return error; SIGDELSET(p->p_siglist, SIGCHLD); if (args->status) { if ((error = copyin(args->status, &tmpstat, sizeof(int))) != 0) return error; tmpstat &= 0xffff; if (WIFSIGNALED(tmpstat)) tmpstat = (tmpstat & 0xffffff80) | BSD_TO_LINUX_SIGNAL(WTERMSIG(tmpstat)); else if (WIFSTOPPED(tmpstat)) tmpstat = (tmpstat & 0xffff00ff) | (BSD_TO_LINUX_SIGNAL(WSTOPSIG(tmpstat)) << 8); return copyout(&tmpstat, args->status, sizeof(int)); } else return 0; } int linux_mknod(struct proc *p, struct linux_mknod_args *args) { caddr_t sg; struct mknod_args bsd_mknod; struct mkfifo_args bsd_mkfifo; sg = stackgap_init(); CHECKALTCREAT(p, &sg, args->path); #ifdef DEBUG printf("Linux-emul(%ld): mknod(%s, %d, %d)\n", (long)p->p_pid, args->path, args->mode, args->dev); #endif if (args->mode & S_IFIFO) { bsd_mkfifo.path = args->path; bsd_mkfifo.mode = args->mode; return mkfifo(p, &bsd_mkfifo); } else { bsd_mknod.path = args->path; bsd_mknod.mode = args->mode; bsd_mknod.dev = args->dev; return mknod(p, &bsd_mknod); } } /* * UGH! This is just about the dumbest idea I've ever heard!! */ int linux_personality(struct proc *p, struct linux_personality_args *args) { #ifdef DEBUG printf("Linux-emul(%ld): personality(%d)\n", (long)p->p_pid, args->per); #endif #ifndef __alpha__ if (args->per != 0) return EINVAL; #endif /* Yes Jim, it's still a Linux... */ p->p_retval[0] = 0; return 0; } /* * Wrappers for get/setitimer for debugging.. */ int linux_setitimer(struct proc *p, struct linux_setitimer_args *args) { struct setitimer_args bsa; struct itimerval foo; int error; #ifdef DEBUG printf("Linux-emul(%ld): setitimer(%p, %p)\n", (long)p->p_pid, (void *)args->itv, (void *)args->oitv); #endif bsa.which = args->which; bsa.itv = args->itv; bsa.oitv = args->oitv; if (args->itv) { if ((error = copyin((caddr_t)args->itv, (caddr_t)&foo, sizeof(foo)))) return error; #ifdef DEBUG printf("setitimer: value: sec: %ld, usec: %ld\n", foo.it_value.tv_sec, foo.it_value.tv_usec); printf("setitimer: interval: sec: %ld, usec: %ld\n", foo.it_interval.tv_sec, foo.it_interval.tv_usec); #endif } return setitimer(p, &bsa); } int linux_getitimer(struct proc *p, struct linux_getitimer_args *args) { struct getitimer_args bsa; #ifdef DEBUG printf("Linux-emul(%ld): getitimer(%p)\n", (long)p->p_pid, (void *)args->itv); #endif bsa.which = args->which; bsa.itv = args->itv; return getitimer(p, &bsa); } #ifndef __alpha__ int linux_nice(struct proc *p, struct linux_nice_args *args) { struct setpriority_args bsd_args; bsd_args.which = PRIO_PROCESS; bsd_args.who = 0; /* current process */ bsd_args.prio = args->inc; return setpriority(p, &bsd_args); } #endif /*!__alpha__*/ int linux_setgroups(p, uap) struct proc *p; struct linux_setgroups_args *uap; { struct pcred *pc; linux_gid_t linux_gidset[NGROUPS]; gid_t *bsd_gidset; int ngrp, error; pc = p->p_cred; ngrp = uap->gidsetsize; /* * cr_groups[0] holds egid. Setting the whole set from * the supplied set will cause egid to be changed too. * Keep cr_groups[0] unchanged to prevent that. */ if ((error = suser(p)) != 0) return (error); if (ngrp >= NGROUPS) return (EINVAL); pc->pc_ucred = crcopy(pc->pc_ucred); if (ngrp > 0) { error = copyin((caddr_t)uap->gidset, (caddr_t)linux_gidset, ngrp * sizeof(linux_gid_t)); if (error) return (error); pc->pc_ucred->cr_ngroups = ngrp + 1; bsd_gidset = pc->pc_ucred->cr_groups; ngrp--; while (ngrp >= 0) { bsd_gidset[ngrp + 1] = linux_gidset[ngrp]; ngrp--; } } else pc->pc_ucred->cr_ngroups = 1; setsugid(p); return (0); } int linux_getgroups(p, uap) struct proc *p; struct linux_getgroups_args *uap; { struct pcred *pc; linux_gid_t linux_gidset[NGROUPS]; gid_t *bsd_gidset; int bsd_gidsetsz, ngrp, error; pc = p->p_cred; bsd_gidset = pc->pc_ucred->cr_groups; bsd_gidsetsz = pc->pc_ucred->cr_ngroups - 1; /* * cr_groups[0] holds egid. Returning the whole set * here will cause a duplicate. Exclude cr_groups[0] * to prevent that. */ if ((ngrp = uap->gidsetsize) == 0) { p->p_retval[0] = bsd_gidsetsz; return (0); } if (ngrp < bsd_gidsetsz) return (EINVAL); ngrp = 0; while (ngrp < bsd_gidsetsz) { linux_gidset[ngrp] = bsd_gidset[ngrp + 1]; ngrp++; } if ((error = copyout((caddr_t)linux_gidset, (caddr_t)uap->gidset, ngrp * sizeof(linux_gid_t)))) return (error); p->p_retval[0] = ngrp; return (0); } #ifndef __alpha__ int linux_setrlimit(p, uap) struct proc *p; struct linux_setrlimit_args *uap; { struct __setrlimit_args bsd; struct linux_rlimit rlim; int error; caddr_t sg = stackgap_init(); #ifdef DEBUG printf("Linux-emul(%ld): setrlimit(%d, %p)\n", (long)p->p_pid, uap->resource, (void *)uap->rlim); #endif if (uap->resource >= LINUX_RLIM_NLIMITS) return (EINVAL); bsd.which = linux_to_bsd_resource[uap->resource]; if (bsd.which == -1) return (EINVAL); error = copyin(uap->rlim, &rlim, sizeof(rlim)); if (error) return (error); bsd.rlp = stackgap_alloc(&sg, sizeof(struct rlimit)); bsd.rlp->rlim_cur = (rlim_t)rlim.rlim_cur; bsd.rlp->rlim_max = (rlim_t)rlim.rlim_max; return (setrlimit(p, &bsd)); } int linux_getrlimit(p, uap) struct proc *p; struct linux_getrlimit_args *uap; { struct __getrlimit_args bsd; struct linux_rlimit rlim; int error; caddr_t sg = stackgap_init(); #ifdef DEBUG printf("Linux-emul(%ld): getrlimit(%d, %p)\n", (long)p->p_pid, uap->resource, (void *)uap->rlim); #endif if (uap->resource >= LINUX_RLIM_NLIMITS) return (EINVAL); bsd.which = linux_to_bsd_resource[uap->resource]; if (bsd.which == -1) return (EINVAL); bsd.rlp = stackgap_alloc(&sg, sizeof(struct rlimit)); error = getrlimit(p, &bsd); if (error) return (error); rlim.rlim_cur = (unsigned long)bsd.rlp->rlim_cur; if (rlim.rlim_cur == ULONG_MAX) rlim.rlim_cur = LONG_MAX; rlim.rlim_max = (unsigned long)bsd.rlp->rlim_max; if (rlim.rlim_max == ULONG_MAX) rlim.rlim_max = LONG_MAX; return (copyout(&rlim, uap->rlim, sizeof(rlim))); } #endif /*!__alpha__*/ int linux_sched_setscheduler(p, uap) struct proc *p; struct linux_sched_setscheduler_args *uap; { struct sched_setscheduler_args bsd; #ifdef DEBUG printf("Linux-emul(%ld): sched_setscheduler(%d, %d, %p)\n", (long)p->p_pid, uap->pid, uap->policy, (const void *)uap->param); #endif switch (uap->policy) { case LINUX_SCHED_OTHER: bsd.policy = SCHED_OTHER; break; case LINUX_SCHED_FIFO: bsd.policy = SCHED_FIFO; break; case LINUX_SCHED_RR: bsd.policy = SCHED_RR; break; default: return EINVAL; } bsd.pid = uap->pid; bsd.param = uap->param; return sched_setscheduler(p, &bsd); } int linux_sched_getscheduler(p, uap) struct proc *p; struct linux_sched_getscheduler_args *uap; { struct sched_getscheduler_args bsd; int error; #ifdef DEBUG printf("Linux-emul(%ld): sched_getscheduler(%d)\n", (long)p->p_pid, uap->pid); #endif bsd.pid = uap->pid; error = sched_getscheduler(p, &bsd); switch (p->p_retval[0]) { case SCHED_OTHER: p->p_retval[0] = LINUX_SCHED_OTHER; break; case SCHED_FIFO: p->p_retval[0] = LINUX_SCHED_FIFO; break; case SCHED_RR: p->p_retval[0] = LINUX_SCHED_RR; break; } return error; } + +int +linux_sched_get_priority_max(p, uap) + struct proc *p; + struct linux_sched_get_priority_max_args *uap; +{ + struct sched_get_priority_max_args bsd; + +#ifdef DEBUG + printf("Linux-emul(%ld): sched_get_priority_max(%d)\n", + (long)p->p_pid, uap->policy); +#endif + + switch (uap->policy) { + case LINUX_SCHED_OTHER: + bsd.policy = SCHED_OTHER; + break; + case LINUX_SCHED_FIFO: + bsd.policy = SCHED_FIFO; + break; + case LINUX_SCHED_RR: + bsd.policy = SCHED_RR; + break; + default: + return EINVAL; + } + return sched_get_priority_max(p, &bsd); +} + +int +linux_sched_get_priority_min(p, uap) + struct proc *p; + struct linux_sched_get_priority_min_args *uap; +{ + struct sched_get_priority_min_args bsd; + +#ifdef DEBUG + printf("Linux-emul(%ld): sched_get_priority_min(%d)\n", + (long)p->p_pid, uap->policy); +#endif + + switch (uap->policy) { + case LINUX_SCHED_OTHER: + bsd.policy = SCHED_OTHER; + break; + case LINUX_SCHED_FIFO: + bsd.policy = SCHED_FIFO; + break; + case LINUX_SCHED_RR: + bsd.policy = SCHED_RR; + break; + default: + return EINVAL; + } + return sched_get_priority_min(p, &bsd); +} Index: stable/4/sys/i386/linux/syscalls.master =================================================================== --- stable/4/sys/i386/linux/syscalls.master (revision 82402) +++ stable/4/sys/i386/linux/syscalls.master (revision 82403) @@ -1,289 +1,289 @@ $FreeBSD$ ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93 ; System call name/number master file (or rather, slave, from LINUX). ; Processed to create linux_sysent.c, linux_proto.h and linux_syscall.h. ; Columns: number type nargs namespc name alt{name,tag,rtyp}/comments ; number system call number, must be in order ; type one of STD, OBSOL, UNIMPL, COMPAT ; namespc one of POSIX, BSD, STD, NOHIDE (I dont care :-) -Peter ; name psuedo-prototype of syscall routine ; If one of the following alts is different, then all appear: ; altname name of system call if different ; alttag name of args struct tag if different from [o]`name'"_args" ; altrtyp return type if not int (bogus - syscalls always return int) ; for UNIMPL/OBSOL, name continues with comments ; types: ; STD always included ; COMPAT included on COMPAT #ifdef ; LIBCOMPAT included on COMPAT #ifdef, and placed in syscall.h ; OBSOL obsolete, not included in system, only specifies name ; UNIMPL not implemented, placeholder only #include "opt_compat.h" #include #include #include #include #include ; #ifdef's, etc. may be included, and are copied to the output files. 0 STD LINUX { int linux_setup(void); } 1 NOPROTO LINUX { void exit(int rval); } exit rexit_args void 2 STD LINUX { int linux_fork(void); } 3 NOPROTO LINUX { int read(int fd, char *buf, u_int nbyte); } 4 NOPROTO LINUX { int write(int fd, char *buf, u_int nbyte); } 5 STD LINUX { int linux_open(char *path, int flags, int mode); } 6 NOPROTO LINUX { int close(int fd); } 7 STD LINUX { int linux_waitpid(int pid, int *status, \ int options); } 8 STD LINUX { int linux_creat(char *path, int mode); } 9 STD LINUX { int linux_link(char *path, char *to); } 10 STD LINUX { int linux_unlink(char *path); } 11 STD LINUX { int linux_execve(char *path, char **argp, \ char **envp); } 12 STD LINUX { int linux_chdir(char *path); } 13 STD LINUX { int linux_time(linux_time_t *tm); } 14 STD LINUX { int linux_mknod(char *path, int mode, int dev); } 15 STD LINUX { int linux_chmod(char *path, int mode); } 16 STD LINUX { int linux_lchown(char *path, int uid, int gid); } 17 STD LINUX { int linux_break(char *nsize); } 18 STD LINUX { int linux_stat(char *path, struct ostat *up); } 19 STD LINUX { int linux_lseek(int fdes, long off, int whence); } 20 NOPROTO LINUX { int getpid(void); } 21 STD LINUX { int linux_mount(void); } 22 STD LINUX { int linux_umount(void); } 23 NOPROTO LINUX { int setuid(uid_t uid); } 24 NOPROTO LINUX { int getuid(void); } 25 STD LINUX { int linux_stime(void); } 26 STD LINUX { int linux_ptrace(void); } 27 STD LINUX { int linux_alarm(unsigned int secs); } 28 STD LINUX { int linux_fstat(int fd, struct ostat *up); } 29 STD LINUX { int linux_pause(void); } 30 STD LINUX { int linux_utime(char *fname, \ struct linux_utimbuf *times); } 31 STD LINUX { int linux_stty(void); } 32 STD LINUX { int linux_gtty(void); } 33 STD LINUX { int linux_access(char *path, int flags); } 34 STD LINUX { int linux_nice(int inc); } 35 STD LINUX { int linux_ftime(void); } 36 NOPROTO LINUX { int sync(void); } 37 STD LINUX { int linux_kill(int pid, int signum); } 38 STD LINUX { int linux_rename(char *from, char *to); } 39 STD LINUX { int linux_mkdir(char *path, int mode); } 40 STD LINUX { int linux_rmdir(char *path); } 41 NOPROTO LINUX { int dup(u_int fd); } 42 STD LINUX { int linux_pipe(int *pipefds); } 43 STD LINUX { int linux_times(struct linux_times_argv *buf); } 44 STD LINUX { int linux_prof(void); } 45 STD LINUX { int linux_brk(char *dsend); } 46 NOPROTO LINUX { int setgid(gid_t gid); } 47 NOPROTO LINUX { int getgid(void); } 48 STD LINUX { int linux_signal(int sig, linux_handler_t handler); } 49 NOPROTO LINUX { int geteuid(void); } 50 NOPROTO LINUX { int getegid(void); } 51 NOPROTO LINUX { int acct(char *path); } 52 STD LINUX { int linux_umount2(void); } 53 STD LINUX { int linux_lock(void); } 54 STD LINUX { int linux_ioctl(int fd, u_long cmd, int arg); } 55 STD LINUX { int linux_fcntl(int fd, int cmd, int arg); } 56 STD LINUX { int linux_mpx(void); } 57 NOPROTO LINUX { int setpgid(int pid, int pgid); } 58 STD LINUX { int linux_ulimit(void); } 59 STD LINUX { int linux_olduname(void); } 60 NOPROTO LINUX { int umask(int newmask); } 61 NOPROTO LINUX { int chroot(char *path); } 62 STD LINUX { int linux_ustat(linux_dev_t dev, \ struct linux_ustat *ubuf); } 63 NOPROTO LINUX { int dup2(u_int from, u_int to); } 64 NOPROTO LINUX { int getppid(void); } 65 NOPROTO LINUX { int getpgrp(void); } 66 NOPROTO LINUX { int setsid(void); } 67 STD LINUX { int linux_sigaction(int sig, \ linux_osigaction_t *nsa, \ linux_osigaction_t *osa); } 68 STD LINUX { int linux_siggetmask(void); } 69 STD LINUX { int linux_sigsetmask(linux_osigset_t mask); } 70 NOPROTO LINUX { int setreuid(int ruid, int euid); } 71 NOPROTO LINUX { int setregid(int rgid, int egid); } 72 STD LINUX { int linux_sigsuspend(int restart, \ linux_osigset_t oldmask, \ linux_osigset_t mask); } 73 STD LINUX { int linux_sigpending(linux_osigset_t *mask); } 74 NOPROTO LINUX { int osethostname(char *hostname, u_int len); } \ osethostname sethostname_args int 75 STD LINUX { int linux_setrlimit(u_int resource, \ struct ogetrlimit *rlim); } 76 STD LINUX { int linux_getrlimit(u_int resource, \ struct ogetrlimit *rlim); } 77 NOPROTO LINUX { int getrusage(int who, struct rusage *rusage); } 78 NOPROTO LINUX { int gettimeofday(struct timeval *tp, \ struct timezone *tzp); } 79 NOPROTO LINUX { int settimeofday(struct timeval *tp, \ struct timezone *tzp); } 80 STD LINUX { int linux_getgroups(u_int gidsetsize, \ linux_gid_t *gidset); } 81 STD LINUX { int linux_setgroups(u_int gidsetsize, \ linux_gid_t *gidset); } 82 STD LINUX { int linux_select(struct linux_select_argv *ptr); } 83 STD LINUX { int linux_symlink(char *path, char *to); } 84 NOPROTO LINUX { int ostat(char *path, struct ostat *up); } 85 STD LINUX { int linux_readlink(char *name, char *buf, \ int count); } 86 STD LINUX { int linux_uselib(char *library); } 87 NOPROTO LINUX { int swapon(char *name); } 88 NOPROTO LINUX { int reboot(int opt); } 89 STD LINUX { int linux_readdir(int fd, \ struct linux_dirent *dent, \ unsigned int count); } 90 STD LINUX { int linux_mmap(struct linux_mmap_argv *ptr); } 91 NOPROTO LINUX { int munmap(caddr_t addr, int len); } 92 STD LINUX { int linux_truncate(char *path, long length); } 93 NOPROTO LINUX { int oftruncate(int fd, long length); } 94 NOPROTO LINUX { int fchmod(int fd, int mode); } 95 NOPROTO LINUX { int fchown(int fd, int uid, int gid); } 96 NOPROTO LINUX { int getpriority(int which, int who); } 97 NOPROTO LINUX { int setpriority(int which, int who, int prio); } 98 NOPROTO LINUX { int profil(caddr_t samples, u_int size, \ u_int offset, u_int scale); } 99 STD LINUX { int linux_statfs(char *path, \ struct linux_statfs_buf *buf); } 100 STD LINUX { int linux_fstatfs(int fd, \ struct linux_statfs_buf *buf); } 101 STD LINUX { int linux_ioperm(unsigned int start, \ unsigned int length, int enable); } 102 STD LINUX { int linux_socketcall(int what, void *args); } 103 STD LINUX { int linux_ksyslog(int what); } 104 STD LINUX { int linux_setitimer(u_int which, \ struct itimerval *itv, \ struct itimerval *oitv); } 105 STD LINUX { int linux_getitimer(u_int which, \ struct itimerval *itv); } 106 STD LINUX { int linux_newstat(char *path, \ struct linux_newstat *buf); } 107 STD LINUX { int linux_newlstat(char *path, \ struct linux_newstat *buf); } 108 STD LINUX { int linux_newfstat(int fd, \ struct linux_newstat *buf); } 109 STD LINUX { int linux_uname(void); } 110 STD LINUX { int linux_iopl(int level); } 111 STD LINUX { int linux_vhangup(void); } 112 STD LINUX { int linux_idle(void); } 113 STD LINUX { int linux_vm86old(void); } 114 STD LINUX { int linux_wait4(int pid, int *status, \ int options, struct rusage *rusage); } 115 STD LINUX { int linux_swapoff(void); } 116 STD LINUX { int linux_sysinfo(struct sysinfo *info); } 117 STD LINUX { int linux_ipc(int what, int arg1, int arg2, \ int arg3, caddr_t ptr); } 118 NOPROTO LINUX { int fsync(int fd); } 119 STD LINUX { int linux_sigreturn(struct linux_sigframe *sfp); } 120 STD LINUX { int linux_clone(int flags, void *stack); } 121 NOPROTO LINUX { int setdomainname(char *name, int len); } 122 STD LINUX { int linux_newuname(struct linux_new_utsname *buf); } 123 STD LINUX { int linux_modify_ldt(int func, void *ptr, \ size_t bytecount); } 124 STD LINUX { int linux_adjtimex(void); } 125 NOPROTO LINUX { int mprotect(caddr_t addr, int len, int prot); } 126 STD LINUX { int linux_sigprocmask(int how, \ linux_osigset_t *mask, \ linux_osigset_t *omask); } 127 STD LINUX { int linux_create_module(void); } 128 STD LINUX { int linux_init_module(void); } 129 STD LINUX { int linux_delete_module(void); } 130 STD LINUX { int linux_get_kernel_syms(void); } 131 STD LINUX { int linux_quotactl(void); } 132 STD LINUX { int linux_getpgid(int pid); } 133 NOPROTO LINUX { int fchdir(int fd); } 134 STD LINUX { int linux_bdflush(void); } 135 STD LINUX { int linux_sysfs(int option, u_long arg1, \ u_long arg2); } 136 STD LINUX { int linux_personality(int per); } 137 STD LINUX { int linux_afs_syscall(void); } 138 STD LINUX { int linux_setfsuid(linux_uid_t uid); } 139 STD LINUX { int linux_setfsgid(linux_gid_t gid); } 140 STD LINUX { int linux_llseek(int fd, u_int32_t ohigh, \ u_int32_t olow, caddr_t res, int whence); } 141 STD LINUX { int linux_getdents(int fd, void *dent, \ unsigned count); } 142 STD LINUX { int linux_newselect(int nfds, fd_set *readfds, \ fd_set *writefds, fd_set *exceptfds, \ struct timeval *timeout); } 143 NOPROTO LINUX { int flock(int fd, int how); } 144 STD LINUX { int linux_msync(caddr_t addr, int len, int fl); } 145 NOPROTO LINUX { int readv(int fd, struct iovec *iovp, \ u_int iovcnt); } 146 NOPROTO LINUX { int writev(int fd, struct iovec *iovp, \ u_int iovcnt); } 147 STD LINUX { int linux_getsid(linux_pid_t pid); } 148 STD LINUX { int linux_fdatasync(int fd); } 149 STD LINUX { int linux_sysctl(void); } 150 NOPROTO BSD { int mlock(const void *addr, size_t len); } 151 NOPROTO BSD { int munlock(const void *addr, size_t len); } 152 NOPROTO BSD { int mlockall(int how); } 153 NOPROTO BSD { int munlockall(void); } 154 NOPROTO POSIX { int sched_setparam (pid_t pid, \ const struct sched_param *param); } 155 NOPROTO POSIX { int sched_getparam (pid_t pid, \ struct sched_param *param); } 156 STD POSIX { int linux_sched_setscheduler(pid_t pid, int policy, \ const struct sched_param *param); } 157 STD POSIX { int linux_sched_getscheduler(pid_t pid); } 158 NOPROTO POSIX { int sched_yield (void); } -159 NOPROTO POSIX { int sched_get_priority_max (int policy); } -160 NOPROTO POSIX { int sched_get_priority_min (int policy); } +159 STD POSIX { int linux_sched_get_priority_max(int policy); } +160 STD POSIX { int linux_sched_get_priority_min(int policy); } 161 NOPROTO POSIX { int sched_rr_get_interval (pid_t pid, \ struct timespec *interval); } 162 NOPROTO POSIX { int nanosleep(const struct timespec *rqtp, \ struct timespec *rmtp); } 163 STD LINUX { int linux_mremap(caddr_t addr, int old_len, \ int new_len, int flags); } 164 NOPROTO LINUX { int setresuid(int ruid, int euid, int suid); } 165 STD LINUX { int linux_getresuid(linux_uid_t *ruid, \ linux_uid_t *euid, linux_uid_t *suid); } 166 STD LINUX { int linux_vm86(void); } 167 STD LINUX { int linux_query_module(void); } 168 NOPROTO LINUX { int poll(struct pollfd*, unsigned int nfds, \ long timeout); } 169 STD LINUX { int linux_nfsservctl(void); } 170 NOPROTO LINUX { int setresgid(int rgid, int egid, int sgid); } 171 STD LINUX { int linux_getresgid(linux_gid_t *rgid, \ linux_gid_t *egid, linux_gid_t *sgid); } 172 STD LINUX { int linux_prctl(void); } 173 STD LINUX { int linux_rt_sigreturn(struct linux_ucontext *ucp); } 174 STD LINUX { int linux_rt_sigaction(int sig, \ linux_sigaction_t *act, \ linux_sigaction_t *oact, \ size_t sigsetsize); } 175 STD LINUX { int linux_rt_sigprocmask(int how, \ linux_sigset_t *mask, linux_sigset_t *omask, \ size_t sigsetsize); } 176 STD LINUX { int linux_rt_sigpending(void); } 177 STD LINUX { int linux_rt_sigtimedwait(void); } 178 STD LINUX { int linux_rt_sigqueueinfo(void); } 179 STD LINUX { int linux_rt_sigsuspend(linux_sigset_t *newset, \ size_t sigsetsize); } 180 STD LINUX { int linux_pread(int fd, char *buf, size_t nbyte, \ off_t offset); } 181 STD LINUX { int linux_pwrite(int fd, const char *buf, \ size_t nbyte, off_t offset); } 182 STD LINUX { int linux_chown(char *path, int uid, int gid); } 183 STD LINUX { int linux_getcwd(char *buf, unsigned long bufsize); } 184 STD LINUX { int linux_capget(void); } 185 STD LINUX { int linux_capset(void); } 186 STD LINUX { int linux_sigaltstack(const linux_stack_t *uss, \ linux_stack_t *uoss); } 187 STD LINUX { int linux_sendfile(void); } 188 STD LINUX { int linux_getpmsg(void); } 189 STD LINUX { int linux_putpmsg(void); } 190 STD LINUX { int linux_vfork(void); } 191 STD LINUX { int linux_ugetrlimit(void); } 192 STD LINUX { int linux_mmap2(void); } 193 STD LINUX { int linux_truncate64(void); } 194 STD LINUX { int linux_ftruncate64(void); } 195 STD LINUX { int linux_stat64(void); } 196 STD LINUX { int linux_lstat64(void); } 197 STD LINUX { int linux_fstat64(void); }