2 * Copyright (c) 1995 Steven Wallace
3 * Copyright (c) 1994, 1995 Scott Bartram
4 * Copyright (c) 1992, 1993
5 * The Regents of the University of California. All rights reserved.
7 * This software was developed by the Computer Systems Engineering group
8 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
9 * contributed to Berkeley.
11 * All advertising materials mentioning features or use of this software
12 * must display the following acknowledgement:
13 * This product includes software developed by the University of
14 * California, Lawrence Berkeley Laboratory.
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
19 * 1. Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution.
24 * 3. All advertising materials mentioning features or use of this software
25 * must display the following acknowledgement:
26 * This product includes software developed by the University of
27 * California, Berkeley and its contributors.
28 * 4. Neither the name of the University nor the names of its contributors
29 * may be used to endorse or promote products derived from this software
30 * without specific prior written permission.
32 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
33 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
34 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
35 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
36 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
40 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
41 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
44 * from: Header: sun_misc.c,v 1.16 93/04/07 02:46:27 torek Exp
46 * @(#)sun_misc.c 8.1 (Berkeley) 6/18/93
49 #include <sys/cdefs.h>
50 __FBSDID("$FreeBSD$");
53 * IBCS2 compatibility module.
55 * IBCS2 system calls that are implemented differently in BSD are
58 #include <sys/param.h>
59 #include <sys/systm.h>
60 #include <sys/capsicum.h>
61 #include <sys/dirent.h>
62 #include <sys/fcntl.h>
63 #include <sys/filedesc.h>
64 #include <sys/imgact.h>
65 #include <sys/kernel.h>
67 #include <sys/malloc.h>
68 #include <sys/file.h> /* Must come after sys/malloc.h */
69 #include <sys/mutex.h>
70 #include <sys/namei.h>
72 #include <sys/reboot.h>
73 #include <sys/resourcevar.h>
75 #include <sys/sysctl.h>
76 #include <sys/syscallsubr.h>
77 #include <sys/sysproto.h>
79 #include <sys/times.h>
80 #include <sys/vnode.h>
83 #include <machine/cpu.h>
85 #include <i386/ibcs2/ibcs2_dirent.h>
86 #include <i386/ibcs2/ibcs2_signal.h>
87 #include <i386/ibcs2/ibcs2_proto.h>
88 #include <i386/ibcs2/ibcs2_unistd.h>
89 #include <i386/ibcs2/ibcs2_util.h>
90 #include <i386/ibcs2/ibcs2_utime.h>
91 #include <i386/ibcs2/ibcs2_xenix.h>
93 #include <security/mac/mac_framework.h>
98 struct ibcs2_ulimit_args *uap;
103 #define IBCS2_GETFSIZE 1
104 #define IBCS2_SETFSIZE 2
105 #define IBCS2_GETPSIZE 3
106 #define IBCS2_GETDTABLESIZE 4
112 td->td_retval[0] = lim_cur(p, RLIMIT_FSIZE);
114 if (td->td_retval[0] == -1)
115 td->td_retval[0] = 0x7fffffff;
119 rl.rlim_max = lim_max(p, RLIMIT_FSIZE);
121 rl.rlim_cur = uap->newlimit;
122 error = kern_setrlimit(td, RLIMIT_FSIZE, &rl);
125 td->td_retval[0] = lim_cur(p, RLIMIT_FSIZE);
128 DPRINTF(("failed "));
133 td->td_retval[0] = lim_cur(p, RLIMIT_RSS); /* XXX */
136 case IBCS2_GETDTABLESIZE:
137 uap->cmd = IBCS2_SC_OPEN_MAX;
138 return ibcs2_sysconf(td, (struct ibcs2_sysconf_args *)uap);
144 #define IBCS2_WSTOPPED 0177
145 #define IBCS2_STOPCODE(sig) ((sig) << 8 | IBCS2_WSTOPPED)
149 struct ibcs2_wait_args *uap;
151 int error, options, status;
154 struct trapframe *tf = td->td_frame;
156 if ((tf->tf_eflags & (PSL_Z|PSL_PF|PSL_N|PSL_V))
157 == (PSL_Z|PSL_PF|PSL_N|PSL_V)) {
160 statusp = (int *)uap->a2;
165 statusp = (int *)uap->a1;
168 error = kern_wait(td, pid, &status, options, NULL);
173 * Convert status/signal result.
175 if (WIFSTOPPED(status)) {
176 if (WSTOPSIG(status) <= 0 ||
177 WSTOPSIG(status) > IBCS2_SIGTBLSZ)
180 IBCS2_STOPCODE(bsd_to_ibcs2_sig[_SIG_IDX(WSTOPSIG(status))]);
181 } else if (WIFSIGNALED(status)) {
182 if (WTERMSIG(status) <= 0 ||
183 WTERMSIG(status) > IBCS2_SIGTBLSZ)
185 status = bsd_to_ibcs2_sig[_SIG_IDX(WTERMSIG(status))];
187 /* else exit status -- identical */
189 /* record result/status */
190 td->td_retval[1] = status;
191 return copyout(&status, statusp, sizeof(status));
200 struct ibcs2_execv_args *uap;
202 struct image_args eargs;
203 struct vmspace *oldvmspace;
207 CHECKALTEXIST(td, uap->path, &path);
209 error = pre_execve(td, &oldvmspace);
214 error = exec_copyin_args(&eargs, path, UIO_SYSSPACE, uap->argp, NULL);
217 error = kern_execve(td, &eargs, NULL);
218 post_execve(td, error, oldvmspace);
223 ibcs2_execve(td, uap)
225 struct ibcs2_execve_args *uap;
227 struct image_args eargs;
228 struct vmspace *oldvmspace;
232 CHECKALTEXIST(td, uap->path, &path);
234 error = pre_execve(td, &oldvmspace);
239 error = exec_copyin_args(&eargs, path, UIO_SYSSPACE, uap->argp,
243 error = kern_execve(td, &eargs, NULL);
244 post_execve(td, error, oldvmspace);
249 ibcs2_umount(td, uap)
251 struct ibcs2_umount_args *uap;
253 struct unmount_args um;
257 return sys_unmount(td, &um);
263 struct ibcs2_mount_args *uap;
266 int oflags = uap->flags, nflags, error;
267 char fsname[MFSNAMELEN];
269 if (oflags & (IBCS2_MS_NOSUB | IBCS2_MS_SYS5))
271 if ((oflags & IBCS2_MS_NEWTYPE) == 0)
274 if (oflags & IBCS2_MS_RDONLY)
275 nflags |= MNT_RDONLY;
276 if (oflags & IBCS2_MS_NOSUID)
277 nflags |= MNT_NOSUID;
278 if (oflags & IBCS2_MS_REMOUNT)
279 nflags |= MNT_UPDATE;
282 if (error = copyinstr((caddr_t)uap->type, fsname, sizeof fsname,
286 if (strcmp(fsname, "4.2") == 0) {
287 uap->type = (caddr_t)STACK_ALLOC();
288 if (error = copyout("ufs", uap->type, sizeof("ufs")))
290 } else if (strcmp(fsname, "nfs") == 0) {
291 struct ibcs2_nfs_args sna;
292 struct sockaddr_in sain;
296 if (error = copyin(uap->data, &sna, sizeof sna))
298 if (error = copyin(sna.addr, &sain, sizeof sain))
300 bcopy(&sain, &sa, sizeof sa);
301 sa.sa_len = sizeof(sain);
302 uap->data = (caddr_t)STACK_ALLOC();
303 na.addr = (struct sockaddr *)((int)uap->data + sizeof na);
304 na.sotype = SOCK_DGRAM;
305 na.proto = IPPROTO_UDP;
306 na.fh = (nfsv2fh_t *)sna.fh;
307 na.flags = sna.flags;
308 na.wsize = sna.wsize;
309 na.rsize = sna.rsize;
310 na.timeo = sna.timeo;
311 na.retrans = sna.retrans;
312 na.hostname = sna.hostname;
314 if (error = copyout(&sa, na.addr, sizeof sa))
316 if (error = copyout(&na, uap->data, sizeof na))
319 return (mount(td, uap));
326 * Read iBCS2-style directory entries. We suck them into kernel space so
327 * that they can be massaged before being copied out to user code. Like
328 * SunOS, we squish out `empty' entries.
330 * This is quite ugly, but what do you expect from compatibility code?
334 ibcs2_getdents(td, uap)
336 register struct ibcs2_getdents_args *uap;
338 register struct vnode *vp;
339 register caddr_t inp, buf; /* BSD-format */
340 register int len, reclen; /* BSD-format */
341 register caddr_t outp; /* iBCS2-format */
342 register int resid; /* iBCS2-format */
347 struct ibcs2_dirent idb;
348 off_t off; /* true file offset */
349 int buflen, error, eofflag;
350 u_long *cookies = NULL, *cookiep;
352 #define BSD_DIRENT(cp) ((struct dirent *)(cp))
353 #define IBCS2_RECLEN(reclen) (reclen + sizeof(u_short))
355 memset(&idb, 0, sizeof(idb));
356 error = getvnode(td->td_proc->p_fd, uap->fd,
357 cap_rights_init(&rights, CAP_READ), &fp);
360 if ((fp->f_flag & FREAD) == 0) {
365 if (vp->v_type != VDIR) { /* XXX vnode readdir op should do this */
371 #define DIRBLKSIZ 512 /* XXX we used to use ufs's DIRBLKSIZ */
372 buflen = max(DIRBLKSIZ, uap->nbytes);
373 buflen = min(buflen, MAXBSIZE);
374 buf = malloc(buflen, M_TEMP, M_WAITOK);
375 vn_lock(vp, LK_SHARED | LK_RETRY);
378 aiov.iov_len = buflen;
379 auio.uio_iov = &aiov;
381 auio.uio_rw = UIO_READ;
382 auio.uio_segflg = UIO_SYSSPACE;
384 auio.uio_resid = buflen;
385 auio.uio_offset = off;
388 free(cookies, M_TEMP);
393 error = mac_vnode_check_readdir(td->td_ucred, vp);
399 * First we read into the malloc'ed buffer, then
400 * we massage it into user space, one record at a time.
402 if ((error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, &ncookies, &cookies)) != 0)
407 if ((len = buflen - auio.uio_resid) <= 0)
414 * When using cookies, the vfs has the option of reading from
415 * a different offset than that supplied (UFS truncates the
416 * offset to a block boundary to make sure that it never reads
417 * partway through a directory entry, even if the directory
418 * has been compacted).
420 while (len > 0 && ncookies > 0 && *cookiep <= off) {
421 len -= BSD_DIRENT(inp)->d_reclen;
422 inp += BSD_DIRENT(inp)->d_reclen;
428 for (; len > 0; len -= reclen) {
429 if (cookiep && ncookies == 0)
431 reclen = BSD_DIRENT(inp)->d_reclen;
433 printf("ibcs2_getdents: reclen=%d\n", reclen);
437 if (BSD_DIRENT(inp)->d_fileno == 0) {
438 inp += reclen; /* it is a hole; squish it out */
446 if (reclen > len || resid < IBCS2_RECLEN(reclen)) {
447 /* entry too big for buffer, so just stop */
452 * Massage in place to make an iBCS2-shaped dirent (otherwise
453 * we have to worry about touching user memory outside of
454 * the copyout() call).
456 idb.d_ino = (ibcs2_ino_t)BSD_DIRENT(inp)->d_fileno;
457 idb.d_off = (ibcs2_off_t)off;
458 idb.d_reclen = (u_short)IBCS2_RECLEN(reclen);
459 if ((error = copyout((caddr_t)&idb, outp, 10)) != 0 ||
460 (error = copyout(BSD_DIRENT(inp)->d_name, outp + 10,
461 BSD_DIRENT(inp)->d_namlen + 1)) != 0)
463 /* advance past this real entry */
470 /* advance output past iBCS2-shaped entry */
471 outp += IBCS2_RECLEN(reclen);
472 resid -= IBCS2_RECLEN(reclen);
474 /* if we squished out the whole block, try again */
475 if (outp == uap->buf)
477 fp->f_offset = off; /* update the vnode offset */
479 td->td_retval[0] = uap->nbytes - resid;
484 free(cookies, M_TEMP);
492 struct ibcs2_read_args *uap;
494 register struct vnode *vp;
495 register caddr_t inp, buf; /* BSD-format */
496 register int len, reclen; /* BSD-format */
497 register caddr_t outp; /* iBCS2-format */
498 register int resid; /* iBCS2-format */
503 struct ibcs2_direct {
507 off_t off; /* true file offset */
508 int buflen, error, eofflag, size;
509 u_long *cookies = NULL, *cookiep;
512 error = getvnode(td->td_proc->p_fd, uap->fd,
513 cap_rights_init(&rights, CAP_READ), &fp);
516 return sys_read(td, (struct read_args *)uap);
520 if ((fp->f_flag & FREAD) == 0) {
525 if (vp->v_type != VDIR) {
527 return sys_read(td, (struct read_args *)uap);
532 DPRINTF(("ibcs2_read: read directory\n"));
534 buflen = max(DIRBLKSIZ, uap->nbytes);
535 buflen = min(buflen, MAXBSIZE);
536 buf = malloc(buflen, M_TEMP, M_WAITOK);
537 vn_lock(vp, LK_SHARED | LK_RETRY);
540 aiov.iov_len = buflen;
541 auio.uio_iov = &aiov;
543 auio.uio_rw = UIO_READ;
544 auio.uio_segflg = UIO_SYSSPACE;
546 auio.uio_resid = buflen;
547 auio.uio_offset = off;
550 free(cookies, M_TEMP);
555 error = mac_vnode_check_readdir(td->td_ucred, vp);
561 * First we read into the malloc'ed buffer, then
562 * we massage it into user space, one record at a time.
564 if ((error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, &ncookies, &cookies)) != 0) {
565 DPRINTF(("VOP_READDIR failed: %d\n", error));
571 if ((len = buflen - auio.uio_resid) <= 0)
578 * When using cookies, the vfs has the option of reading from
579 * a different offset than that supplied (UFS truncates the
580 * offset to a block boundary to make sure that it never reads
581 * partway through a directory entry, even if the directory
582 * has been compacted).
584 while (len > 0 && ncookies > 0 && *cookiep <= off) {
585 len -= BSD_DIRENT(inp)->d_reclen;
586 inp += BSD_DIRENT(inp)->d_reclen;
592 for (; len > 0 && resid > 0; len -= reclen) {
593 if (cookiep && ncookies == 0)
595 reclen = BSD_DIRENT(inp)->d_reclen;
597 printf("ibcs2_read: reclen=%d\n", reclen);
601 if (BSD_DIRENT(inp)->d_fileno == 0) {
602 inp += reclen; /* it is a hole; squish it out */
610 if (reclen > len || resid < sizeof(struct ibcs2_direct)) {
611 /* entry too big for buffer, so just stop */
616 * Massage in place to make an iBCS2-shaped dirent (otherwise
617 * we have to worry about touching user memory outside of
618 * the copyout() call).
620 * TODO: if length(filename) > 14, then break filename into
621 * multiple entries and set inode = 0xffff except last
623 idb.ino = (BSD_DIRENT(inp)->d_fileno > 0xfffe) ? 0xfffe :
624 BSD_DIRENT(inp)->d_fileno;
625 (void)copystr(BSD_DIRENT(inp)->d_name, idb.name, 14, &size);
626 bzero(idb.name + size, 14 - size);
627 if ((error = copyout(&idb, outp, sizeof(struct ibcs2_direct))) != 0)
629 /* advance past this real entry */
636 /* advance output past iBCS2-shaped entry */
637 outp += sizeof(struct ibcs2_direct);
638 resid -= sizeof(struct ibcs2_direct);
640 /* if we squished out the whole block, try again */
641 if (outp == uap->buf)
643 fp->f_offset = off; /* update the vnode offset */
645 td->td_retval[0] = uap->nbytes - resid;
650 free(cookies, M_TEMP);
658 struct ibcs2_mknod_args *uap;
663 CHECKALTCREAT(td, uap->path, &path);
664 if (S_ISFIFO(uap->mode))
665 error = kern_mkfifo(td, path, UIO_SYSSPACE, uap->mode);
667 error = kern_mknod(td, path, UIO_SYSSPACE, uap->mode, uap->dev);
673 ibcs2_getgroups(td, uap)
675 struct ibcs2_getgroups_args *uap;
682 if (uap->gidsetsize < td->td_ucred->cr_ngroups) {
683 if (uap->gidsetsize == 0)
688 ngrp = td->td_ucred->cr_ngroups;
689 gp = malloc(ngrp * sizeof(*gp), M_TEMP, M_WAITOK);
690 error = kern_getgroups(td, &ngrp, gp);
693 if (uap->gidsetsize > 0) {
694 iset = malloc(ngrp * sizeof(*iset), M_TEMP, M_WAITOK);
695 for (i = 0; i < ngrp; i++)
696 iset[i] = (ibcs2_gid_t)gp[i];
697 error = copyout(iset, uap->gidset, ngrp * sizeof(ibcs2_gid_t));
701 td->td_retval[0] = ngrp;
708 ibcs2_setgroups(td, uap)
710 struct ibcs2_setgroups_args *uap;
716 if (uap->gidsetsize < 0 || uap->gidsetsize > ngroups_max + 1)
718 if (uap->gidsetsize && uap->gidset == NULL)
720 gp = malloc(uap->gidsetsize * sizeof(*gp), M_TEMP, M_WAITOK);
721 if (uap->gidsetsize) {
722 iset = malloc(uap->gidsetsize * sizeof(*iset), M_TEMP, M_WAITOK);
723 error = copyin(uap->gidset, iset, sizeof(ibcs2_gid_t) *
729 for (i = 0; i < uap->gidsetsize; i++)
730 gp[i] = (gid_t)iset[i];
733 error = kern_setgroups(td, uap->gidsetsize, gp);
740 ibcs2_setuid(td, uap)
742 struct ibcs2_setuid_args *uap;
744 struct setuid_args sa;
746 sa.uid = (uid_t)uap->uid;
747 return sys_setuid(td, &sa);
751 ibcs2_setgid(td, uap)
753 struct ibcs2_setgid_args *uap;
755 struct setgid_args sa;
757 sa.gid = (gid_t)uap->gid;
758 return sys_setgid(td, &sa);
764 struct ibcs2_time_args *uap;
769 td->td_retval[0] = tv.tv_sec;
771 return copyout((caddr_t)&tv.tv_sec, (caddr_t)uap->tp,
772 sizeof(ibcs2_time_t));
778 ibcs2_pathconf(td, uap)
780 struct ibcs2_pathconf_args *uap;
785 CHECKALTEXIST(td, uap->path, &path);
786 uap->name++; /* iBCS2 _PC_* defines are offset by one */
787 error = kern_pathconf(td, path, UIO_SYSSPACE, uap->name, FOLLOW);
793 ibcs2_fpathconf(td, uap)
795 struct ibcs2_fpathconf_args *uap;
797 uap->name++; /* iBCS2 _PC_* defines are offset by one */
798 return sys_fpathconf(td, (struct fpathconf_args *)uap);
802 ibcs2_sysconf(td, uap)
804 struct ibcs2_sysconf_args *uap;
806 int mib[2], value, len, error;
811 case IBCS2_SC_ARG_MAX:
812 mib[1] = KERN_ARGMAX;
815 case IBCS2_SC_CHILD_MAX:
817 td->td_retval[0] = lim_cur(td->td_proc, RLIMIT_NPROC);
821 case IBCS2_SC_CLK_TCK:
822 td->td_retval[0] = hz;
825 case IBCS2_SC_NGROUPS_MAX:
826 mib[1] = KERN_NGROUPS;
829 case IBCS2_SC_OPEN_MAX:
831 td->td_retval[0] = lim_cur(td->td_proc, RLIMIT_NOFILE);
835 case IBCS2_SC_JOB_CONTROL:
836 mib[1] = KERN_JOB_CONTROL;
839 case IBCS2_SC_SAVED_IDS:
840 mib[1] = KERN_SAVED_IDS;
843 case IBCS2_SC_VERSION:
844 mib[1] = KERN_POSIX1;
847 case IBCS2_SC_PASS_MAX:
848 td->td_retval[0] = 128; /* XXX - should we create PASS_MAX ? */
851 case IBCS2_SC_XOPEN_VERSION:
852 td->td_retval[0] = 2; /* XXX: What should that be? */
861 error = kernel_sysctl(td, mib, 2, &value, &len, NULL, 0, NULL, 0);
864 td->td_retval[0] = value;
871 struct ibcs2_alarm_args *uap;
873 struct itimerval itv, oitv;
876 timevalclear(&itv.it_interval);
877 itv.it_value.tv_sec = uap->sec;
878 itv.it_value.tv_usec = 0;
879 error = kern_setitimer(td, ITIMER_REAL, &itv, &oitv);
882 if (oitv.it_value.tv_usec != 0)
883 oitv.it_value.tv_sec++;
884 td->td_retval[0] = oitv.it_value.tv_sec;
891 struct ibcs2_times_args *uap;
898 #define CONVTCK(r) (r.tv_sec * hz + r.tv_usec / (1000000 / hz))
900 error = kern_getrusage(td, RUSAGE_SELF, &ru);
903 tms.tms_utime = CONVTCK(ru.ru_utime);
904 tms.tms_stime = CONVTCK(ru.ru_stime);
906 error = kern_getrusage(td, RUSAGE_CHILDREN, &ru);
909 tms.tms_cutime = CONVTCK(ru.ru_utime);
910 tms.tms_cstime = CONVTCK(ru.ru_stime);
913 td->td_retval[0] = CONVTCK(t);
915 return (copyout(&tms, uap->tp, sizeof(struct tms)));
921 struct ibcs2_stime_args *uap;
927 error = copyin(uap->timep, &secs, sizeof(long));
932 error = kern_settimeofday(td, &tv, NULL);
941 struct ibcs2_utime_args *uap;
943 struct ibcs2_utimbuf ubuf;
944 struct timeval tbuf[2], *tp;
949 error = copyin(uap->buf, &ubuf, sizeof(ubuf));
952 tbuf[0].tv_sec = ubuf.actime;
954 tbuf[1].tv_sec = ubuf.modtime;
960 CHECKALTEXIST(td, uap->path, &path);
961 error = kern_utimes(td, path, UIO_SYSSPACE, tp, UIO_SYSSPACE);
969 struct ibcs2_nice_args *uap;
972 struct setpriority_args sa;
974 sa.which = PRIO_PROCESS;
976 sa.prio = td->td_proc->p_nice + uap->incr;
977 if ((error = sys_setpriority(td, &sa)) != 0)
979 td->td_retval[0] = td->td_proc->p_nice;
984 * iBCS2 getpgrp, setpgrp, setsid, and setpgid
988 ibcs2_pgrpsys(td, uap)
990 struct ibcs2_pgrpsys_args *uap;
992 struct proc *p = td->td_proc;
994 case 0: /* getpgrp */
996 td->td_retval[0] = p->p_pgrp->pg_id;
1000 case 1: /* setpgrp */
1002 struct setpgid_args sa;
1006 sys_setpgid(td, &sa);
1008 td->td_retval[0] = p->p_pgrp->pg_id;
1013 case 2: /* setpgid */
1015 struct setpgid_args sa;
1018 sa.pgid = uap->pgid;
1019 return sys_setpgid(td, &sa);
1022 case 3: /* setsid */
1023 return sys_setsid(td, NULL);
1031 * XXX - need to check for nested calls
1035 ibcs2_plock(td, uap)
1037 struct ibcs2_plock_args *uap;
1040 #define IBCS2_UNLOCK 0
1041 #define IBCS2_PROCLOCK 1
1042 #define IBCS2_TEXTLOCK 2
1043 #define IBCS2_DATALOCK 4
1048 error = priv_check(td, PRIV_VM_MUNLOCK);
1054 case IBCS2_PROCLOCK:
1055 case IBCS2_TEXTLOCK:
1056 case IBCS2_DATALOCK:
1057 error = priv_check(td, PRIV_VM_MLOCK);
1067 ibcs2_uadmin(td, uap)
1069 struct ibcs2_uadmin_args *uap;
1071 #define SCO_A_REBOOT 1
1072 #define SCO_A_SHUTDOWN 2
1073 #define SCO_A_REMOUNT 4
1074 #define SCO_A_CLOCK 8
1075 #define SCO_A_SETCONFIG 128
1076 #define SCO_A_GETDEV 130
1078 #define SCO_AD_HALT 0
1079 #define SCO_AD_BOOT 1
1080 #define SCO_AD_IBOOT 2
1081 #define SCO_AD_PWRDOWN 3
1082 #define SCO_AD_PWRNAP 4
1084 #define SCO_AD_PANICBOOT 1
1086 #define SCO_AD_GETBMAJ 0
1087 #define SCO_AD_GETCMAJ 1
1091 case SCO_A_SHUTDOWN:
1093 struct reboot_args r;
1095 case SCO_AD_PWRDOWN:
1098 return (sys_reboot(td, &r));
1101 r.opt = RB_AUTOBOOT;
1102 return (sys_reboot(td, &r));
1107 case SCO_A_SETCONFIG:
1110 return EINVAL; /* XXX - TODO */
1116 ibcs2_sysfs(td, uap)
1118 struct ibcs2_sysfs_args *uap;
1120 #define IBCS2_GETFSIND 1
1121 #define IBCS2_GETFSTYP 2
1122 #define IBCS2_GETNFSTYP 3
1125 case IBCS2_GETFSIND:
1126 case IBCS2_GETFSTYP:
1127 case IBCS2_GETNFSTYP:
1130 return EINVAL; /* XXX - TODO */
1134 ibcs2_unlink(td, uap)
1136 struct ibcs2_unlink_args *uap;
1141 CHECKALTEXIST(td, uap->path, &path);
1142 error = kern_unlink(td, path, UIO_SYSSPACE);
1148 ibcs2_chdir(td, uap)
1150 struct ibcs2_chdir_args *uap;
1155 CHECKALTEXIST(td, uap->path, &path);
1156 error = kern_chdir(td, path, UIO_SYSSPACE);
1162 ibcs2_chmod(td, uap)
1164 struct ibcs2_chmod_args *uap;
1169 CHECKALTEXIST(td, uap->path, &path);
1170 error = kern_chmod(td, path, UIO_SYSSPACE, uap->mode);
1176 ibcs2_chown(td, uap)
1178 struct ibcs2_chown_args *uap;
1183 CHECKALTEXIST(td, uap->path, &path);
1184 error = kern_chown(td, path, UIO_SYSSPACE, uap->uid, uap->gid);
1190 ibcs2_rmdir(td, uap)
1192 struct ibcs2_rmdir_args *uap;
1197 CHECKALTEXIST(td, uap->path, &path);
1198 error = kern_rmdir(td, path, UIO_SYSSPACE);
1204 ibcs2_mkdir(td, uap)
1206 struct ibcs2_mkdir_args *uap;
1211 CHECKALTEXIST(td, uap->path, &path);
1212 error = kern_mkdir(td, path, UIO_SYSSPACE, uap->mode);
1218 ibcs2_symlink(td, uap)
1220 struct ibcs2_symlink_args *uap;
1225 CHECKALTEXIST(td, uap->path, &path);
1228 * Have to expand CHECKALTCREAT() so that 'path' can be freed on
1231 error = ibcs2_emul_find(td, uap->link, UIO_USERSPACE, &link, 1);
1236 error = kern_symlink(td, path, link, UIO_SYSSPACE);
1243 ibcs2_rename(td, uap)
1245 struct ibcs2_rename_args *uap;
1250 CHECKALTEXIST(td, uap->from, &from);
1253 * Have to expand CHECKALTCREAT() so that 'from' can be freed on
1256 error = ibcs2_emul_find(td, uap->to, UIO_USERSPACE, &to, 1);
1261 error = kern_rename(td, from, to, UIO_SYSSPACE);
1268 ibcs2_readlink(td, uap)
1270 struct ibcs2_readlink_args *uap;
1275 CHECKALTEXIST(td, uap->path, &path);
1276 error = kern_readlink(td, path, UIO_SYSSPACE, uap->buf, UIO_USERSPACE,