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>
96 ibcs2_ulimit(struct thread *td, struct ibcs2_ulimit_args *uap)
100 #define IBCS2_GETFSIZE 1
101 #define IBCS2_SETFSIZE 2
102 #define IBCS2_GETPSIZE 3
103 #define IBCS2_GETDTABLESIZE 4
107 td->td_retval[0] = lim_cur(td, RLIMIT_FSIZE);
108 if (td->td_retval[0] == -1)
109 td->td_retval[0] = 0x7fffffff;
112 rl.rlim_max = lim_max(td, RLIMIT_FSIZE);
113 rl.rlim_cur = uap->newlimit;
114 error = kern_setrlimit(td, RLIMIT_FSIZE, &rl);
116 td->td_retval[0] = lim_cur(td, RLIMIT_FSIZE);
118 DPRINTF(("failed "));
122 td->td_retval[0] = lim_cur(td, RLIMIT_RSS); /* XXX */
124 case IBCS2_GETDTABLESIZE:
125 uap->cmd = IBCS2_SC_OPEN_MAX;
126 return ibcs2_sysconf(td, (struct ibcs2_sysconf_args *)uap);
132 #define IBCS2_WSTOPPED 0177
133 #define IBCS2_STOPCODE(sig) ((sig) << 8 | IBCS2_WSTOPPED)
135 ibcs2_wait(struct thread *td, struct ibcs2_wait_args *uap)
137 int error, options, status;
140 struct trapframe *tf = td->td_frame;
142 if ((tf->tf_eflags & (PSL_Z|PSL_PF|PSL_N|PSL_V))
143 == (PSL_Z|PSL_PF|PSL_N|PSL_V)) {
146 statusp = (int *)uap->a2;
151 statusp = (int *)uap->a1;
154 error = kern_wait(td, pid, &status, options, NULL);
159 * Convert status/signal result.
161 if (WIFSTOPPED(status)) {
162 if (WSTOPSIG(status) <= 0 ||
163 WSTOPSIG(status) > IBCS2_SIGTBLSZ)
166 IBCS2_STOPCODE(bsd_to_ibcs2_sig[_SIG_IDX(WSTOPSIG(status))]);
167 } else if (WIFSIGNALED(status)) {
168 if (WTERMSIG(status) <= 0 ||
169 WTERMSIG(status) > IBCS2_SIGTBLSZ)
171 status = bsd_to_ibcs2_sig[_SIG_IDX(WTERMSIG(status))];
173 /* else exit status -- identical */
175 /* record result/status */
176 td->td_retval[1] = status;
177 return copyout(&status, statusp, sizeof(status));
184 ibcs2_execv(struct thread *td, struct ibcs2_execv_args *uap)
186 struct image_args eargs;
187 struct vmspace *oldvmspace;
191 CHECKALTEXIST(td, uap->path, &path);
193 error = pre_execve(td, &oldvmspace);
198 error = exec_copyin_args(&eargs, path, UIO_SYSSPACE, uap->argp, NULL);
201 error = kern_execve(td, &eargs, NULL);
202 post_execve(td, error, oldvmspace);
207 ibcs2_execve(struct thread *td, struct ibcs2_execve_args *uap)
209 struct image_args eargs;
210 struct vmspace *oldvmspace;
214 CHECKALTEXIST(td, uap->path, &path);
216 error = pre_execve(td, &oldvmspace);
221 error = exec_copyin_args(&eargs, path, UIO_SYSSPACE, uap->argp,
225 error = kern_execve(td, &eargs, NULL);
226 post_execve(td, error, oldvmspace);
231 ibcs2_umount(struct thread *td, struct ibcs2_umount_args *uap)
233 struct unmount_args um;
237 return sys_unmount(td, &um);
241 ibcs2_mount(struct thread *td, struct ibcs2_mount_args *uap)
244 int oflags = uap->flags, nflags, error;
245 char fsname[MFSNAMELEN];
247 if (oflags & (IBCS2_MS_NOSUB | IBCS2_MS_SYS5))
249 if ((oflags & IBCS2_MS_NEWTYPE) == 0)
252 if (oflags & IBCS2_MS_RDONLY)
253 nflags |= MNT_RDONLY;
254 if (oflags & IBCS2_MS_NOSUID)
255 nflags |= MNT_NOSUID;
256 if (oflags & IBCS2_MS_REMOUNT)
257 nflags |= MNT_UPDATE;
260 if (error = copyinstr((caddr_t)uap->type, fsname, sizeof fsname,
264 if (strcmp(fsname, "4.2") == 0) {
265 uap->type = (caddr_t)STACK_ALLOC();
266 if (error = copyout("ufs", uap->type, sizeof("ufs")))
268 } else if (strcmp(fsname, "nfs") == 0) {
269 struct ibcs2_nfs_args sna;
270 struct sockaddr_in sain;
274 if (error = copyin(uap->data, &sna, sizeof sna))
276 if (error = copyin(sna.addr, &sain, sizeof sain))
278 bcopy(&sain, &sa, sizeof sa);
279 sa.sa_len = sizeof(sain);
280 uap->data = (caddr_t)STACK_ALLOC();
281 na.addr = (struct sockaddr *)((int)uap->data + sizeof na);
282 na.sotype = SOCK_DGRAM;
283 na.proto = IPPROTO_UDP;
284 na.fh = (nfsv2fh_t *)sna.fh;
285 na.flags = sna.flags;
286 na.wsize = sna.wsize;
287 na.rsize = sna.rsize;
288 na.timeo = sna.timeo;
289 na.retrans = sna.retrans;
290 na.hostname = sna.hostname;
292 if (error = copyout(&sa, na.addr, sizeof sa))
294 if (error = copyout(&na, uap->data, sizeof na))
297 return (mount(td, uap));
304 * Read iBCS2-style directory entries. We suck them into kernel space so
305 * that they can be massaged before being copied out to user code. Like
306 * SunOS, we squish out `empty' entries.
308 * This is quite ugly, but what do you expect from compatibility code?
312 ibcs2_getdents(struct thread *td, struct ibcs2_getdents_args *uap)
315 caddr_t inp, buf; /* BSD-format */
316 int len, reclen; /* BSD-format */
317 caddr_t outp; /* iBCS2-format */
318 int resid; /* iBCS2-format */
323 struct ibcs2_dirent idb;
324 off_t off; /* true file offset */
325 int buflen, error, eofflag;
326 u_long *cookies = NULL, *cookiep;
328 #define BSD_DIRENT(cp) ((struct dirent *)(cp))
329 #define IBCS2_RECLEN(reclen) (reclen + sizeof(u_short))
331 error = getvnode(td, uap->fd, cap_rights_init(&rights, CAP_READ), &fp);
334 if ((fp->f_flag & FREAD) == 0) {
339 if (vp->v_type != VDIR) { /* XXX vnode readdir op should do this */
345 #define DIRBLKSIZ 512 /* XXX we used to use ufs's DIRBLKSIZ */
346 buflen = max(DIRBLKSIZ, uap->nbytes);
347 buflen = min(buflen, MAXBSIZE);
348 buf = malloc(buflen, M_TEMP, M_WAITOK);
349 vn_lock(vp, LK_SHARED | LK_RETRY);
352 aiov.iov_len = buflen;
353 auio.uio_iov = &aiov;
355 auio.uio_rw = UIO_READ;
356 auio.uio_segflg = UIO_SYSSPACE;
358 auio.uio_resid = buflen;
359 auio.uio_offset = off;
362 free(cookies, M_TEMP);
367 error = mac_vnode_check_readdir(td->td_ucred, vp);
373 * First we read into the malloc'ed buffer, then
374 * we massage it into user space, one record at a time.
376 if ((error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, &ncookies, &cookies)) != 0)
381 if ((len = buflen - auio.uio_resid) <= 0)
388 * When using cookies, the vfs has the option of reading from
389 * a different offset than that supplied (UFS truncates the
390 * offset to a block boundary to make sure that it never reads
391 * partway through a directory entry, even if the directory
392 * has been compacted).
394 while (len > 0 && ncookies > 0 && *cookiep <= off) {
395 len -= BSD_DIRENT(inp)->d_reclen;
396 inp += BSD_DIRENT(inp)->d_reclen;
402 for (; len > 0; len -= reclen) {
403 if (cookiep && ncookies == 0)
405 reclen = BSD_DIRENT(inp)->d_reclen;
407 printf("ibcs2_getdents: reclen=%d\n", reclen);
411 if (BSD_DIRENT(inp)->d_fileno == 0) {
412 inp += reclen; /* it is a hole; squish it out */
420 if (reclen > len || resid < IBCS2_RECLEN(reclen)) {
421 /* entry too big for buffer, so just stop */
426 * Massage in place to make an iBCS2-shaped dirent (otherwise
427 * we have to worry about touching user memory outside of
428 * the copyout() call).
430 idb.d_ino = (ibcs2_ino_t)BSD_DIRENT(inp)->d_fileno;
431 idb.d_off = (ibcs2_off_t)off;
432 idb.d_reclen = (u_short)IBCS2_RECLEN(reclen);
433 if ((error = copyout((caddr_t)&idb, outp, 10)) != 0 ||
434 (error = copyout(BSD_DIRENT(inp)->d_name, outp + 10,
435 BSD_DIRENT(inp)->d_namlen + 1)) != 0)
437 /* advance past this real entry */
444 /* advance output past iBCS2-shaped entry */
445 outp += IBCS2_RECLEN(reclen);
446 resid -= IBCS2_RECLEN(reclen);
448 /* if we squished out the whole block, try again */
449 if (outp == uap->buf)
451 fp->f_offset = off; /* update the vnode offset */
453 td->td_retval[0] = uap->nbytes - resid;
458 free(cookies, M_TEMP);
464 ibcs2_read(struct thread *td, struct ibcs2_read_args *uap)
467 caddr_t inp, buf; /* BSD-format */
468 int len, reclen; /* BSD-format */
469 caddr_t outp; /* iBCS2-format */
470 int resid; /* iBCS2-format */
475 struct ibcs2_direct {
479 off_t off; /* true file offset */
480 int buflen, error, eofflag, size;
481 u_long *cookies = NULL, *cookiep;
484 error = getvnode(td, uap->fd, cap_rights_init(&rights, CAP_READ), &fp);
487 return sys_read(td, (struct read_args *)uap);
491 if ((fp->f_flag & FREAD) == 0) {
496 if (vp->v_type != VDIR) {
498 return sys_read(td, (struct read_args *)uap);
503 DPRINTF(("ibcs2_read: read directory\n"));
505 buflen = max(DIRBLKSIZ, uap->nbytes);
506 buflen = min(buflen, MAXBSIZE);
507 buf = malloc(buflen, M_TEMP, M_WAITOK);
508 vn_lock(vp, LK_SHARED | LK_RETRY);
511 aiov.iov_len = buflen;
512 auio.uio_iov = &aiov;
514 auio.uio_rw = UIO_READ;
515 auio.uio_segflg = UIO_SYSSPACE;
517 auio.uio_resid = buflen;
518 auio.uio_offset = off;
521 free(cookies, M_TEMP);
526 error = mac_vnode_check_readdir(td->td_ucred, vp);
532 * First we read into the malloc'ed buffer, then
533 * we massage it into user space, one record at a time.
535 if ((error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, &ncookies, &cookies)) != 0) {
536 DPRINTF(("VOP_READDIR failed: %d\n", error));
542 if ((len = buflen - auio.uio_resid) <= 0)
549 * When using cookies, the vfs has the option of reading from
550 * a different offset than that supplied (UFS truncates the
551 * offset to a block boundary to make sure that it never reads
552 * partway through a directory entry, even if the directory
553 * has been compacted).
555 while (len > 0 && ncookies > 0 && *cookiep <= off) {
556 len -= BSD_DIRENT(inp)->d_reclen;
557 inp += BSD_DIRENT(inp)->d_reclen;
563 for (; len > 0 && resid > 0; len -= reclen) {
564 if (cookiep && ncookies == 0)
566 reclen = BSD_DIRENT(inp)->d_reclen;
568 printf("ibcs2_read: reclen=%d\n", reclen);
572 if (BSD_DIRENT(inp)->d_fileno == 0) {
573 inp += reclen; /* it is a hole; squish it out */
581 if (reclen > len || resid < sizeof(struct ibcs2_direct)) {
582 /* entry too big for buffer, so just stop */
587 * Massage in place to make an iBCS2-shaped dirent (otherwise
588 * we have to worry about touching user memory outside of
589 * the copyout() call).
591 * TODO: if length(filename) > 14, then break filename into
592 * multiple entries and set inode = 0xffff except last
594 idb.ino = (BSD_DIRENT(inp)->d_fileno > 0xfffe) ? 0xfffe :
595 BSD_DIRENT(inp)->d_fileno;
596 (void)copystr(BSD_DIRENT(inp)->d_name, idb.name, 14, &size);
597 bzero(idb.name + size, 14 - size);
598 if ((error = copyout(&idb, outp, sizeof(struct ibcs2_direct))) != 0)
600 /* advance past this real entry */
607 /* advance output past iBCS2-shaped entry */
608 outp += sizeof(struct ibcs2_direct);
609 resid -= sizeof(struct ibcs2_direct);
611 /* if we squished out the whole block, try again */
612 if (outp == uap->buf)
614 fp->f_offset = off; /* update the vnode offset */
616 td->td_retval[0] = uap->nbytes - resid;
621 free(cookies, M_TEMP);
627 ibcs2_mknod(struct thread *td, struct ibcs2_mknod_args *uap)
632 CHECKALTCREAT(td, uap->path, &path);
633 if (S_ISFIFO(uap->mode)) {
634 error = kern_mkfifoat(td, AT_FDCWD, path,
635 UIO_SYSSPACE, uap->mode);
637 error = kern_mknodat(td, AT_FDCWD, path, UIO_SYSSPACE,
638 uap->mode, uap->dev);
645 ibcs2_getgroups(struct thread *td, struct ibcs2_getgroups_args *uap)
653 ngrp = cred->cr_ngroups;
655 if (uap->gidsetsize == 0) {
659 if (uap->gidsetsize < ngrp)
662 iset = malloc(ngrp * sizeof(*iset), M_TEMP, M_WAITOK);
663 for (i = 0; i < ngrp; i++)
664 iset[i] = (ibcs2_gid_t)cred->cr_groups[i];
665 error = copyout(iset, uap->gidset, ngrp * sizeof(ibcs2_gid_t));
668 td->td_retval[0] = ngrp;
673 ibcs2_setgroups(struct thread *td, struct ibcs2_setgroups_args *uap)
679 if (uap->gidsetsize < 0 || uap->gidsetsize > ngroups_max + 1)
681 if (uap->gidsetsize && uap->gidset == NULL)
683 gp = malloc(uap->gidsetsize * sizeof(*gp), M_TEMP, M_WAITOK);
684 if (uap->gidsetsize) {
685 iset = malloc(uap->gidsetsize * sizeof(*iset), M_TEMP, M_WAITOK);
686 error = copyin(uap->gidset, iset, sizeof(ibcs2_gid_t) *
692 for (i = 0; i < uap->gidsetsize; i++)
693 gp[i] = (gid_t)iset[i];
696 error = kern_setgroups(td, uap->gidsetsize, gp);
703 ibcs2_setuid(struct thread *td, struct ibcs2_setuid_args *uap)
705 struct setuid_args sa;
707 sa.uid = (uid_t)uap->uid;
708 return sys_setuid(td, &sa);
712 ibcs2_setgid(struct thread *td, struct ibcs2_setgid_args *uap)
714 struct setgid_args sa;
716 sa.gid = (gid_t)uap->gid;
717 return sys_setgid(td, &sa);
721 ibcs2_time(struct thread *td, struct ibcs2_time_args *uap)
726 td->td_retval[0] = tv.tv_sec;
728 return copyout((caddr_t)&tv.tv_sec, (caddr_t)uap->tp,
729 sizeof(ibcs2_time_t));
735 ibcs2_pathconf(struct thread *td, struct ibcs2_pathconf_args *uap)
740 CHECKALTEXIST(td, uap->path, &path);
741 uap->name++; /* iBCS2 _PC_* defines are offset by one */
742 error = kern_pathconf(td, path, UIO_SYSSPACE, uap->name, FOLLOW);
748 ibcs2_fpathconf(struct thread *td, struct ibcs2_fpathconf_args *uap)
750 uap->name++; /* iBCS2 _PC_* defines are offset by one */
751 return sys_fpathconf(td, (struct fpathconf_args *)uap);
755 ibcs2_sysconf(struct thread *td, struct ibcs2_sysconf_args *uap)
757 int mib[2], value, len, error;
760 case IBCS2_SC_ARG_MAX:
761 mib[1] = KERN_ARGMAX;
764 case IBCS2_SC_CHILD_MAX:
765 td->td_retval[0] = lim_cur(td, RLIMIT_NPROC);
768 case IBCS2_SC_CLK_TCK:
769 td->td_retval[0] = hz;
772 case IBCS2_SC_NGROUPS_MAX:
773 mib[1] = KERN_NGROUPS;
776 case IBCS2_SC_OPEN_MAX:
777 td->td_retval[0] = lim_cur(td, RLIMIT_NOFILE);
780 case IBCS2_SC_JOB_CONTROL:
781 mib[1] = KERN_JOB_CONTROL;
784 case IBCS2_SC_SAVED_IDS:
785 mib[1] = KERN_SAVED_IDS;
788 case IBCS2_SC_VERSION:
789 mib[1] = KERN_POSIX1;
792 case IBCS2_SC_PASS_MAX:
793 td->td_retval[0] = 128; /* XXX - should we create PASS_MAX ? */
796 case IBCS2_SC_XOPEN_VERSION:
797 td->td_retval[0] = 2; /* XXX: What should that be? */
806 error = kernel_sysctl(td, mib, 2, &value, &len, NULL, 0, NULL, 0);
809 td->td_retval[0] = value;
814 ibcs2_alarm(struct thread *td, struct ibcs2_alarm_args *uap)
816 struct itimerval itv, oitv;
819 timevalclear(&itv.it_interval);
820 itv.it_value.tv_sec = uap->sec;
821 itv.it_value.tv_usec = 0;
822 error = kern_setitimer(td, ITIMER_REAL, &itv, &oitv);
825 if (oitv.it_value.tv_usec != 0)
826 oitv.it_value.tv_sec++;
827 td->td_retval[0] = oitv.it_value.tv_sec;
832 ibcs2_times(struct thread *td, struct ibcs2_times_args *uap)
839 #define CONVTCK(r) (r.tv_sec * hz + r.tv_usec / (1000000 / hz))
841 error = kern_getrusage(td, RUSAGE_SELF, &ru);
844 tms.tms_utime = CONVTCK(ru.ru_utime);
845 tms.tms_stime = CONVTCK(ru.ru_stime);
847 error = kern_getrusage(td, RUSAGE_CHILDREN, &ru);
850 tms.tms_cutime = CONVTCK(ru.ru_utime);
851 tms.tms_cstime = CONVTCK(ru.ru_stime);
854 td->td_retval[0] = CONVTCK(t);
856 return (copyout(&tms, uap->tp, sizeof(struct tms)));
860 ibcs2_stime(struct thread *td, struct ibcs2_stime_args *uap)
866 error = copyin(uap->timep, &secs, sizeof(long));
871 error = kern_settimeofday(td, &tv, NULL);
878 ibcs2_utime(struct thread *td, struct ibcs2_utime_args *uap)
880 struct ibcs2_utimbuf ubuf;
881 struct timeval tbuf[2], *tp;
886 error = copyin(uap->buf, &ubuf, sizeof(ubuf));
889 tbuf[0].tv_sec = ubuf.actime;
891 tbuf[1].tv_sec = ubuf.modtime;
897 CHECKALTEXIST(td, uap->path, &path);
898 error = kern_utimesat(td, AT_FDCWD, path, UIO_SYSSPACE,
905 ibcs2_nice(struct thread *td, struct ibcs2_nice_args *uap)
908 struct setpriority_args sa;
910 sa.which = PRIO_PROCESS;
912 sa.prio = td->td_proc->p_nice + uap->incr;
913 if ((error = sys_setpriority(td, &sa)) != 0)
915 td->td_retval[0] = td->td_proc->p_nice;
920 * iBCS2 getpgrp, setpgrp, setsid, and setpgid
924 ibcs2_pgrpsys(struct thread *td, struct ibcs2_pgrpsys_args *uap)
926 struct proc *p = td->td_proc;
928 case 0: /* getpgrp */
930 td->td_retval[0] = p->p_pgrp->pg_id;
934 case 1: /* setpgrp */
936 struct setpgid_args sa;
940 sys_setpgid(td, &sa);
942 td->td_retval[0] = p->p_pgrp->pg_id;
947 case 2: /* setpgid */
949 struct setpgid_args sa;
953 return sys_setpgid(td, &sa);
957 return sys_setsid(td, NULL);
965 * XXX - need to check for nested calls
969 ibcs2_plock(struct thread *td, struct ibcs2_plock_args *uap)
972 #define IBCS2_UNLOCK 0
973 #define IBCS2_PROCLOCK 1
974 #define IBCS2_TEXTLOCK 2
975 #define IBCS2_DATALOCK 4
980 error = priv_check(td, PRIV_VM_MUNLOCK);
989 error = priv_check(td, PRIV_VM_MLOCK);
999 ibcs2_uadmin(struct thread *td, struct ibcs2_uadmin_args *uap)
1001 #define SCO_A_REBOOT 1
1002 #define SCO_A_SHUTDOWN 2
1003 #define SCO_A_REMOUNT 4
1004 #define SCO_A_CLOCK 8
1005 #define SCO_A_SETCONFIG 128
1006 #define SCO_A_GETDEV 130
1008 #define SCO_AD_HALT 0
1009 #define SCO_AD_BOOT 1
1010 #define SCO_AD_IBOOT 2
1011 #define SCO_AD_PWRDOWN 3
1012 #define SCO_AD_PWRNAP 4
1014 #define SCO_AD_PANICBOOT 1
1016 #define SCO_AD_GETBMAJ 0
1017 #define SCO_AD_GETCMAJ 1
1021 case SCO_A_SHUTDOWN:
1023 struct reboot_args r;
1025 case SCO_AD_PWRDOWN:
1028 return (sys_reboot(td, &r));
1031 r.opt = RB_AUTOBOOT;
1032 return (sys_reboot(td, &r));
1037 case SCO_A_SETCONFIG:
1040 return EINVAL; /* XXX - TODO */
1046 ibcs2_sysfs(struct thread *td, struct ibcs2_sysfs_args *uap)
1048 #define IBCS2_GETFSIND 1
1049 #define IBCS2_GETFSTYP 2
1050 #define IBCS2_GETNFSTYP 3
1053 case IBCS2_GETFSIND:
1054 case IBCS2_GETFSTYP:
1055 case IBCS2_GETNFSTYP:
1058 return EINVAL; /* XXX - TODO */
1062 ibcs2_unlink(struct thread *td, struct ibcs2_unlink_args *uap)
1067 CHECKALTEXIST(td, uap->path, &path);
1068 error = kern_unlinkat(td, AT_FDCWD, path, UIO_SYSSPACE, 0);
1074 ibcs2_chdir(struct thread *td, struct ibcs2_chdir_args *uap)
1079 CHECKALTEXIST(td, uap->path, &path);
1080 error = kern_chdir(td, path, UIO_SYSSPACE);
1086 ibcs2_chmod(struct thread *td, struct ibcs2_chmod_args *uap)
1091 CHECKALTEXIST(td, uap->path, &path);
1092 error = kern_fchmodat(td, AT_FDCWD, path, UIO_SYSSPACE, uap->mode, 0);
1098 ibcs2_chown(struct thread *td, struct ibcs2_chown_args *uap)
1103 CHECKALTEXIST(td, uap->path, &path);
1104 error = kern_fchownat(td, AT_FDCWD, path, UIO_SYSSPACE, uap->uid,
1111 ibcs2_rmdir(struct thread *td, struct ibcs2_rmdir_args *uap)
1116 CHECKALTEXIST(td, uap->path, &path);
1117 error = kern_rmdirat(td, AT_FDCWD, path, UIO_SYSSPACE);
1123 ibcs2_mkdir(struct thread *td, struct ibcs2_mkdir_args *uap)
1128 CHECKALTEXIST(td, uap->path, &path);
1129 error = kern_mkdirat(td, AT_FDCWD, path, UIO_SYSSPACE, uap->mode);
1135 ibcs2_symlink(struct thread *td, struct ibcs2_symlink_args *uap)
1140 CHECKALTEXIST(td, uap->path, &path);
1143 * Have to expand CHECKALTCREAT() so that 'path' can be freed on
1146 error = ibcs2_emul_find(td, uap->link, UIO_USERSPACE, &link, 1);
1151 error = kern_symlinkat(td, path, AT_FDCWD, link, UIO_SYSSPACE);
1158 ibcs2_rename(struct thread *td, struct ibcs2_rename_args *uap)
1163 CHECKALTEXIST(td, uap->from, &from);
1166 * Have to expand CHECKALTCREAT() so that 'from' can be freed on
1169 error = ibcs2_emul_find(td, uap->to, UIO_USERSPACE, &to, 1);
1174 error = kern_renameat(td, AT_FDCWD, from, AT_FDCWD, to, UIO_SYSSPACE);
1181 ibcs2_readlink(struct thread *td, struct ibcs2_readlink_args *uap)
1186 CHECKALTEXIST(td, uap->path, &path);
1187 error = kern_readlinkat(td, AT_FDCWD, path, UIO_SYSSPACE,
1188 uap->buf, UIO_USERSPACE, uap->count);