2 * SPDX-License-Identifier: BSD-4-Clause
4 * Copyright (c) 1995 Steven Wallace
5 * Copyright (c) 1994, 1995 Scott Bartram
6 * Copyright (c) 1992, 1993
7 * The Regents of the University of California. All rights reserved.
9 * This software was developed by the Computer Systems Engineering group
10 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
11 * contributed to Berkeley.
13 * All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Lawrence Berkeley Laboratory.
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions
21 * 1. Redistributions of source code must retain the above copyright
22 * notice, this list of conditions and the following disclaimer.
23 * 2. Redistributions in binary form must reproduce the above copyright
24 * notice, this list of conditions and the following disclaimer in the
25 * documentation and/or other materials provided with the distribution.
26 * 3. All advertising materials mentioning features or use of this software
27 * must display the following acknowledgement:
28 * This product includes software developed by the University of
29 * California, Berkeley and its contributors.
30 * 4. Neither the name of the University nor the names of its contributors
31 * may be used to endorse or promote products derived from this software
32 * without specific prior written permission.
34 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
35 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
36 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
37 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
38 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
39 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
40 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
41 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
42 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
43 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
46 * from: Header: sun_misc.c,v 1.16 93/04/07 02:46:27 torek Exp
48 * @(#)sun_misc.c 8.1 (Berkeley) 6/18/93
51 #include <sys/cdefs.h>
52 __FBSDID("$FreeBSD$");
55 * IBCS2 compatibility module.
57 * IBCS2 system calls that are implemented differently in BSD are
60 #include <sys/param.h>
61 #include <sys/systm.h>
62 #include <sys/capsicum.h>
63 #include <sys/dirent.h>
64 #include <sys/fcntl.h>
65 #include <sys/filedesc.h>
66 #include <sys/imgact.h>
67 #include <sys/kernel.h>
69 #include <sys/malloc.h>
70 #include <sys/file.h> /* Must come after sys/malloc.h */
71 #include <sys/mutex.h>
72 #include <sys/namei.h>
74 #include <sys/reboot.h>
75 #include <sys/resourcevar.h>
77 #include <sys/sysctl.h>
78 #include <sys/syscallsubr.h>
79 #include <sys/sysproto.h>
81 #include <sys/times.h>
82 #include <sys/vnode.h>
85 #include <machine/cpu.h>
87 #include <i386/ibcs2/ibcs2_dirent.h>
88 #include <i386/ibcs2/ibcs2_signal.h>
89 #include <i386/ibcs2/ibcs2_proto.h>
90 #include <i386/ibcs2/ibcs2_unistd.h>
91 #include <i386/ibcs2/ibcs2_util.h>
92 #include <i386/ibcs2/ibcs2_utime.h>
93 #include <i386/ibcs2/ibcs2_xenix.h>
95 #include <security/mac/mac_framework.h>
98 ibcs2_ulimit(struct thread *td, struct ibcs2_ulimit_args *uap)
102 #define IBCS2_GETFSIZE 1
103 #define IBCS2_SETFSIZE 2
104 #define IBCS2_GETPSIZE 3
105 #define IBCS2_GETDTABLESIZE 4
109 td->td_retval[0] = lim_cur(td, RLIMIT_FSIZE);
110 if (td->td_retval[0] == -1)
111 td->td_retval[0] = 0x7fffffff;
114 rl.rlim_max = lim_max(td, RLIMIT_FSIZE);
115 rl.rlim_cur = uap->newlimit;
116 error = kern_setrlimit(td, RLIMIT_FSIZE, &rl);
118 td->td_retval[0] = lim_cur(td, RLIMIT_FSIZE);
120 DPRINTF(("failed "));
124 td->td_retval[0] = lim_cur(td, RLIMIT_RSS); /* XXX */
126 case IBCS2_GETDTABLESIZE:
127 uap->cmd = IBCS2_SC_OPEN_MAX;
128 return ibcs2_sysconf(td, (struct ibcs2_sysconf_args *)uap);
134 #define IBCS2_WSTOPPED 0177
135 #define IBCS2_STOPCODE(sig) ((sig) << 8 | IBCS2_WSTOPPED)
137 ibcs2_wait(struct thread *td, struct ibcs2_wait_args *uap)
139 int error, options, status;
142 struct trapframe *tf = td->td_frame;
144 if ((tf->tf_eflags & (PSL_Z|PSL_PF|PSL_N|PSL_V))
145 == (PSL_Z|PSL_PF|PSL_N|PSL_V)) {
148 statusp = (int *)uap->a2;
153 statusp = (int *)uap->a1;
156 error = kern_wait(td, pid, &status, options, NULL);
161 * Convert status/signal result.
163 if (WIFSTOPPED(status)) {
164 if (WSTOPSIG(status) <= 0 ||
165 WSTOPSIG(status) > IBCS2_SIGTBLSZ)
168 IBCS2_STOPCODE(bsd_to_ibcs2_sig[_SIG_IDX(WSTOPSIG(status))]);
169 } else if (WIFSIGNALED(status)) {
170 if (WTERMSIG(status) <= 0 ||
171 WTERMSIG(status) > IBCS2_SIGTBLSZ)
173 status = bsd_to_ibcs2_sig[_SIG_IDX(WTERMSIG(status))];
175 /* else exit status -- identical */
177 /* record result/status */
178 td->td_retval[1] = status;
179 return copyout(&status, statusp, sizeof(status));
186 ibcs2_execv(struct thread *td, struct ibcs2_execv_args *uap)
188 struct image_args eargs;
189 struct vmspace *oldvmspace;
193 CHECKALTEXIST(td, uap->path, &path);
195 error = pre_execve(td, &oldvmspace);
200 error = exec_copyin_args(&eargs, path, UIO_SYSSPACE, uap->argp, NULL);
203 error = kern_execve(td, &eargs, NULL);
204 post_execve(td, error, oldvmspace);
209 ibcs2_execve(struct thread *td, struct ibcs2_execve_args *uap)
211 struct image_args eargs;
212 struct vmspace *oldvmspace;
216 CHECKALTEXIST(td, uap->path, &path);
218 error = pre_execve(td, &oldvmspace);
223 error = exec_copyin_args(&eargs, path, UIO_SYSSPACE, uap->argp,
227 error = kern_execve(td, &eargs, NULL);
228 post_execve(td, error, oldvmspace);
233 ibcs2_umount(struct thread *td, struct ibcs2_umount_args *uap)
235 struct unmount_args um;
239 return sys_unmount(td, &um);
243 ibcs2_mount(struct thread *td, struct ibcs2_mount_args *uap)
246 int oflags = uap->flags, nflags, error;
247 char fsname[MFSNAMELEN];
249 if (oflags & (IBCS2_MS_NOSUB | IBCS2_MS_SYS5))
251 if ((oflags & IBCS2_MS_NEWTYPE) == 0)
254 if (oflags & IBCS2_MS_RDONLY)
255 nflags |= MNT_RDONLY;
256 if (oflags & IBCS2_MS_NOSUID)
257 nflags |= MNT_NOSUID;
258 if (oflags & IBCS2_MS_REMOUNT)
259 nflags |= MNT_UPDATE;
262 if (error = copyinstr((caddr_t)uap->type, fsname, sizeof fsname,
266 if (strcmp(fsname, "4.2") == 0) {
267 uap->type = (caddr_t)STACK_ALLOC();
268 if (error = copyout("ufs", uap->type, sizeof("ufs")))
270 } else if (strcmp(fsname, "nfs") == 0) {
271 struct ibcs2_nfs_args sna;
272 struct sockaddr_in sain;
276 if (error = copyin(uap->data, &sna, sizeof sna))
278 if (error = copyin(sna.addr, &sain, sizeof sain))
280 bcopy(&sain, &sa, sizeof sa);
281 sa.sa_len = sizeof(sain);
282 uap->data = (caddr_t)STACK_ALLOC();
283 na.addr = (struct sockaddr *)((int)uap->data + sizeof na);
284 na.sotype = SOCK_DGRAM;
285 na.proto = IPPROTO_UDP;
286 na.fh = (nfsv2fh_t *)sna.fh;
287 na.flags = sna.flags;
288 na.wsize = sna.wsize;
289 na.rsize = sna.rsize;
290 na.timeo = sna.timeo;
291 na.retrans = sna.retrans;
292 na.hostname = sna.hostname;
294 if (error = copyout(&sa, na.addr, sizeof sa))
296 if (error = copyout(&na, uap->data, sizeof na))
299 return (mount(td, uap));
306 * Read iBCS2-style directory entries. We suck them into kernel space so
307 * that they can be massaged before being copied out to user code. Like
308 * SunOS, we squish out `empty' entries.
310 * This is quite ugly, but what do you expect from compatibility code?
314 ibcs2_getdents(struct thread *td, struct ibcs2_getdents_args *uap)
317 caddr_t inp, buf; /* BSD-format */
318 int len, reclen; /* BSD-format */
319 caddr_t outp; /* iBCS2-format */
320 int resid; /* iBCS2-format */
325 struct ibcs2_dirent idb;
326 off_t off; /* true file offset */
327 int buflen, error, eofflag;
328 u_long *cookies = NULL, *cookiep;
330 #define BSD_DIRENT(cp) ((struct dirent *)(cp))
331 #define IBCS2_RECLEN(reclen) (reclen + sizeof(u_short))
333 memset(&idb, 0, sizeof(idb));
334 error = getvnode(td, uap->fd, cap_rights_init(&rights, CAP_READ), &fp);
337 if ((fp->f_flag & FREAD) == 0) {
342 if (vp->v_type != VDIR) { /* XXX vnode readdir op should do this */
348 #define DIRBLKSIZ 512 /* XXX we used to use ufs's DIRBLKSIZ */
349 buflen = max(DIRBLKSIZ, uap->nbytes);
350 buflen = min(buflen, MAXBSIZE);
351 buf = malloc(buflen, M_TEMP, M_WAITOK);
352 vn_lock(vp, LK_SHARED | LK_RETRY);
355 aiov.iov_len = buflen;
356 auio.uio_iov = &aiov;
358 auio.uio_rw = UIO_READ;
359 auio.uio_segflg = UIO_SYSSPACE;
361 auio.uio_resid = buflen;
362 auio.uio_offset = off;
365 free(cookies, M_TEMP);
370 error = mac_vnode_check_readdir(td->td_ucred, vp);
376 * First we read into the malloc'ed buffer, then
377 * we massage it into user space, one record at a time.
379 if ((error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, &ncookies, &cookies)) != 0)
384 if ((len = buflen - auio.uio_resid) <= 0)
391 * When using cookies, the vfs has the option of reading from
392 * a different offset than that supplied (UFS truncates the
393 * offset to a block boundary to make sure that it never reads
394 * partway through a directory entry, even if the directory
395 * has been compacted).
397 while (len > 0 && ncookies > 0 && *cookiep <= off) {
398 len -= BSD_DIRENT(inp)->d_reclen;
399 inp += BSD_DIRENT(inp)->d_reclen;
405 for (; len > 0; len -= reclen) {
406 if (cookiep && ncookies == 0)
408 reclen = BSD_DIRENT(inp)->d_reclen;
410 printf("ibcs2_getdents: reclen=%d\n", reclen);
414 if (BSD_DIRENT(inp)->d_fileno == 0) {
415 inp += reclen; /* it is a hole; squish it out */
423 if (reclen > len || resid < IBCS2_RECLEN(reclen)) {
424 /* entry too big for buffer, so just stop */
429 * Massage in place to make an iBCS2-shaped dirent (otherwise
430 * we have to worry about touching user memory outside of
431 * the copyout() call).
433 idb.d_ino = (ibcs2_ino_t)BSD_DIRENT(inp)->d_fileno;
434 idb.d_off = (ibcs2_off_t)off;
435 idb.d_reclen = (u_short)IBCS2_RECLEN(reclen);
436 if ((error = copyout((caddr_t)&idb, outp, 10)) != 0 ||
437 (error = copyout(BSD_DIRENT(inp)->d_name, outp + 10,
438 BSD_DIRENT(inp)->d_namlen + 1)) != 0)
440 /* advance past this real entry */
447 /* advance output past iBCS2-shaped entry */
448 outp += IBCS2_RECLEN(reclen);
449 resid -= IBCS2_RECLEN(reclen);
451 /* if we squished out the whole block, try again */
452 if (outp == uap->buf)
454 fp->f_offset = off; /* update the vnode offset */
456 td->td_retval[0] = uap->nbytes - resid;
461 free(cookies, M_TEMP);
467 ibcs2_read(struct thread *td, struct ibcs2_read_args *uap)
470 caddr_t inp, buf; /* BSD-format */
471 int len, reclen; /* BSD-format */
472 caddr_t outp; /* iBCS2-format */
473 int resid; /* iBCS2-format */
478 struct ibcs2_direct {
482 off_t off; /* true file offset */
483 int buflen, error, eofflag, size;
484 u_long *cookies = NULL, *cookiep;
487 error = getvnode(td, uap->fd, cap_rights_init(&rights, CAP_READ), &fp);
490 return sys_read(td, (struct read_args *)uap);
494 if ((fp->f_flag & FREAD) == 0) {
499 if (vp->v_type != VDIR) {
501 return sys_read(td, (struct read_args *)uap);
506 DPRINTF(("ibcs2_read: read directory\n"));
508 buflen = max(DIRBLKSIZ, uap->nbytes);
509 buflen = min(buflen, MAXBSIZE);
510 buf = malloc(buflen, M_TEMP, M_WAITOK);
511 vn_lock(vp, LK_SHARED | LK_RETRY);
514 aiov.iov_len = buflen;
515 auio.uio_iov = &aiov;
517 auio.uio_rw = UIO_READ;
518 auio.uio_segflg = UIO_SYSSPACE;
520 auio.uio_resid = buflen;
521 auio.uio_offset = off;
524 free(cookies, M_TEMP);
529 error = mac_vnode_check_readdir(td->td_ucred, vp);
535 * First we read into the malloc'ed buffer, then
536 * we massage it into user space, one record at a time.
538 if ((error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, &ncookies, &cookies)) != 0) {
539 DPRINTF(("VOP_READDIR failed: %d\n", error));
545 if ((len = buflen - auio.uio_resid) <= 0)
552 * When using cookies, the vfs has the option of reading from
553 * a different offset than that supplied (UFS truncates the
554 * offset to a block boundary to make sure that it never reads
555 * partway through a directory entry, even if the directory
556 * has been compacted).
558 while (len > 0 && ncookies > 0 && *cookiep <= off) {
559 len -= BSD_DIRENT(inp)->d_reclen;
560 inp += BSD_DIRENT(inp)->d_reclen;
566 for (; len > 0 && resid > 0; len -= reclen) {
567 if (cookiep && ncookies == 0)
569 reclen = BSD_DIRENT(inp)->d_reclen;
571 printf("ibcs2_read: reclen=%d\n", reclen);
575 if (BSD_DIRENT(inp)->d_fileno == 0) {
576 inp += reclen; /* it is a hole; squish it out */
584 if (reclen > len || resid < sizeof(struct ibcs2_direct)) {
585 /* entry too big for buffer, so just stop */
590 * Massage in place to make an iBCS2-shaped dirent (otherwise
591 * we have to worry about touching user memory outside of
592 * the copyout() call).
594 * TODO: if length(filename) > 14, then break filename into
595 * multiple entries and set inode = 0xffff except last
597 idb.ino = (BSD_DIRENT(inp)->d_fileno > 0xfffe) ? 0xfffe :
598 BSD_DIRENT(inp)->d_fileno;
599 (void)copystr(BSD_DIRENT(inp)->d_name, idb.name, 14, &size);
600 bzero(idb.name + size, 14 - size);
601 if ((error = copyout(&idb, outp, sizeof(struct ibcs2_direct))) != 0)
603 /* advance past this real entry */
610 /* advance output past iBCS2-shaped entry */
611 outp += sizeof(struct ibcs2_direct);
612 resid -= sizeof(struct ibcs2_direct);
614 /* if we squished out the whole block, try again */
615 if (outp == uap->buf)
617 fp->f_offset = off; /* update the vnode offset */
619 td->td_retval[0] = uap->nbytes - resid;
624 free(cookies, M_TEMP);
630 ibcs2_mknod(struct thread *td, struct ibcs2_mknod_args *uap)
635 CHECKALTCREAT(td, uap->path, &path);
636 if (S_ISFIFO(uap->mode)) {
637 error = kern_mkfifoat(td, AT_FDCWD, path,
638 UIO_SYSSPACE, uap->mode);
640 error = kern_mknodat(td, AT_FDCWD, path, UIO_SYSSPACE,
641 uap->mode, uap->dev);
648 ibcs2_getgroups(struct thread *td, struct ibcs2_getgroups_args *uap)
656 ngrp = cred->cr_ngroups;
658 if (uap->gidsetsize == 0) {
662 if (uap->gidsetsize < ngrp)
665 iset = malloc(ngrp * sizeof(*iset), M_TEMP, M_WAITOK);
666 for (i = 0; i < ngrp; i++)
667 iset[i] = (ibcs2_gid_t)cred->cr_groups[i];
668 error = copyout(iset, uap->gidset, ngrp * sizeof(ibcs2_gid_t));
671 td->td_retval[0] = ngrp;
676 ibcs2_setgroups(struct thread *td, struct ibcs2_setgroups_args *uap)
682 if (uap->gidsetsize < 0 || uap->gidsetsize > ngroups_max + 1)
684 if (uap->gidsetsize && uap->gidset == NULL)
686 gp = malloc(uap->gidsetsize * sizeof(*gp), M_TEMP, M_WAITOK);
687 if (uap->gidsetsize) {
688 iset = malloc(uap->gidsetsize * sizeof(*iset), M_TEMP, M_WAITOK);
689 error = copyin(uap->gidset, iset, sizeof(ibcs2_gid_t) *
695 for (i = 0; i < uap->gidsetsize; i++)
696 gp[i] = (gid_t)iset[i];
699 error = kern_setgroups(td, uap->gidsetsize, gp);
706 ibcs2_setuid(struct thread *td, struct ibcs2_setuid_args *uap)
708 struct setuid_args sa;
710 sa.uid = (uid_t)uap->uid;
711 return sys_setuid(td, &sa);
715 ibcs2_setgid(struct thread *td, struct ibcs2_setgid_args *uap)
717 struct setgid_args sa;
719 sa.gid = (gid_t)uap->gid;
720 return sys_setgid(td, &sa);
724 ibcs2_time(struct thread *td, struct ibcs2_time_args *uap)
729 td->td_retval[0] = tv.tv_sec;
731 return copyout((caddr_t)&tv.tv_sec, (caddr_t)uap->tp,
732 sizeof(ibcs2_time_t));
738 ibcs2_pathconf(struct thread *td, struct ibcs2_pathconf_args *uap)
744 CHECKALTEXIST(td, uap->path, &path);
745 uap->name++; /* iBCS2 _PC_* defines are offset by one */
746 error = kern_pathconf(td, path, UIO_SYSSPACE, uap->name, FOLLOW,
750 td->td_retval[0] = value;
755 ibcs2_fpathconf(struct thread *td, struct ibcs2_fpathconf_args *uap)
757 uap->name++; /* iBCS2 _PC_* defines are offset by one */
758 return sys_fpathconf(td, (struct fpathconf_args *)uap);
762 ibcs2_sysconf(struct thread *td, struct ibcs2_sysconf_args *uap)
764 int mib[2], value, len, error;
767 case IBCS2_SC_ARG_MAX:
768 mib[1] = KERN_ARGMAX;
771 case IBCS2_SC_CHILD_MAX:
772 td->td_retval[0] = lim_cur(td, RLIMIT_NPROC);
775 case IBCS2_SC_CLK_TCK:
776 td->td_retval[0] = hz;
779 case IBCS2_SC_NGROUPS_MAX:
780 mib[1] = KERN_NGROUPS;
783 case IBCS2_SC_OPEN_MAX:
784 td->td_retval[0] = lim_cur(td, RLIMIT_NOFILE);
787 case IBCS2_SC_JOB_CONTROL:
788 mib[1] = KERN_JOB_CONTROL;
791 case IBCS2_SC_SAVED_IDS:
792 mib[1] = KERN_SAVED_IDS;
795 case IBCS2_SC_VERSION:
796 mib[1] = KERN_POSIX1;
799 case IBCS2_SC_PASS_MAX:
800 td->td_retval[0] = 128; /* XXX - should we create PASS_MAX ? */
803 case IBCS2_SC_XOPEN_VERSION:
804 td->td_retval[0] = 2; /* XXX: What should that be? */
813 error = kernel_sysctl(td, mib, 2, &value, &len, NULL, 0, NULL, 0);
816 td->td_retval[0] = value;
821 ibcs2_alarm(struct thread *td, struct ibcs2_alarm_args *uap)
823 struct itimerval itv, oitv;
826 timevalclear(&itv.it_interval);
827 itv.it_value.tv_sec = uap->sec;
828 itv.it_value.tv_usec = 0;
829 error = kern_setitimer(td, ITIMER_REAL, &itv, &oitv);
832 if (oitv.it_value.tv_usec != 0)
833 oitv.it_value.tv_sec++;
834 td->td_retval[0] = oitv.it_value.tv_sec;
839 ibcs2_times(struct thread *td, struct ibcs2_times_args *uap)
846 #define CONVTCK(r) (r.tv_sec * hz + r.tv_usec / (1000000 / hz))
848 error = kern_getrusage(td, RUSAGE_SELF, &ru);
851 tms.tms_utime = CONVTCK(ru.ru_utime);
852 tms.tms_stime = CONVTCK(ru.ru_stime);
854 error = kern_getrusage(td, RUSAGE_CHILDREN, &ru);
857 tms.tms_cutime = CONVTCK(ru.ru_utime);
858 tms.tms_cstime = CONVTCK(ru.ru_stime);
861 td->td_retval[0] = CONVTCK(t);
863 return (copyout(&tms, uap->tp, sizeof(struct tms)));
867 ibcs2_stime(struct thread *td, struct ibcs2_stime_args *uap)
873 error = copyin(uap->timep, &secs, sizeof(long));
878 error = kern_settimeofday(td, &tv, NULL);
885 ibcs2_utime(struct thread *td, struct ibcs2_utime_args *uap)
887 struct ibcs2_utimbuf ubuf;
888 struct timeval tbuf[2], *tp;
893 error = copyin(uap->buf, &ubuf, sizeof(ubuf));
896 tbuf[0].tv_sec = ubuf.actime;
898 tbuf[1].tv_sec = ubuf.modtime;
904 CHECKALTEXIST(td, uap->path, &path);
905 error = kern_utimesat(td, AT_FDCWD, path, UIO_SYSSPACE,
912 ibcs2_nice(struct thread *td, struct ibcs2_nice_args *uap)
915 struct setpriority_args sa;
917 sa.which = PRIO_PROCESS;
919 sa.prio = td->td_proc->p_nice + uap->incr;
920 if ((error = sys_setpriority(td, &sa)) != 0)
922 td->td_retval[0] = td->td_proc->p_nice;
927 * iBCS2 getpgrp, setpgrp, setsid, and setpgid
931 ibcs2_pgrpsys(struct thread *td, struct ibcs2_pgrpsys_args *uap)
933 struct proc *p = td->td_proc;
935 case 0: /* getpgrp */
937 td->td_retval[0] = p->p_pgrp->pg_id;
941 case 1: /* setpgrp */
943 struct setpgid_args sa;
947 sys_setpgid(td, &sa);
949 td->td_retval[0] = p->p_pgrp->pg_id;
954 case 2: /* setpgid */
956 struct setpgid_args sa;
960 return sys_setpgid(td, &sa);
964 return sys_setsid(td, NULL);
972 * XXX - need to check for nested calls
976 ibcs2_plock(struct thread *td, struct ibcs2_plock_args *uap)
979 #define IBCS2_UNLOCK 0
980 #define IBCS2_PROCLOCK 1
981 #define IBCS2_TEXTLOCK 2
982 #define IBCS2_DATALOCK 4
987 error = priv_check(td, PRIV_VM_MUNLOCK);
996 error = priv_check(td, PRIV_VM_MLOCK);
1006 ibcs2_uadmin(struct thread *td, struct ibcs2_uadmin_args *uap)
1008 #define SCO_A_REBOOT 1
1009 #define SCO_A_SHUTDOWN 2
1010 #define SCO_A_REMOUNT 4
1011 #define SCO_A_CLOCK 8
1012 #define SCO_A_SETCONFIG 128
1013 #define SCO_A_GETDEV 130
1015 #define SCO_AD_HALT 0
1016 #define SCO_AD_BOOT 1
1017 #define SCO_AD_IBOOT 2
1018 #define SCO_AD_PWRDOWN 3
1019 #define SCO_AD_PWRNAP 4
1021 #define SCO_AD_PANICBOOT 1
1023 #define SCO_AD_GETBMAJ 0
1024 #define SCO_AD_GETCMAJ 1
1028 case SCO_A_SHUTDOWN:
1030 struct reboot_args r;
1032 case SCO_AD_PWRDOWN:
1035 return (sys_reboot(td, &r));
1038 r.opt = RB_AUTOBOOT;
1039 return (sys_reboot(td, &r));
1044 case SCO_A_SETCONFIG:
1047 return EINVAL; /* XXX - TODO */
1053 ibcs2_sysfs(struct thread *td, struct ibcs2_sysfs_args *uap)
1055 #define IBCS2_GETFSIND 1
1056 #define IBCS2_GETFSTYP 2
1057 #define IBCS2_GETNFSTYP 3
1060 case IBCS2_GETFSIND:
1061 case IBCS2_GETFSTYP:
1062 case IBCS2_GETNFSTYP:
1065 return EINVAL; /* XXX - TODO */
1069 ibcs2_unlink(struct thread *td, struct ibcs2_unlink_args *uap)
1074 CHECKALTEXIST(td, uap->path, &path);
1075 error = kern_unlinkat(td, AT_FDCWD, path, UIO_SYSSPACE, 0);
1081 ibcs2_chdir(struct thread *td, struct ibcs2_chdir_args *uap)
1086 CHECKALTEXIST(td, uap->path, &path);
1087 error = kern_chdir(td, path, UIO_SYSSPACE);
1093 ibcs2_chmod(struct thread *td, struct ibcs2_chmod_args *uap)
1098 CHECKALTEXIST(td, uap->path, &path);
1099 error = kern_fchmodat(td, AT_FDCWD, path, UIO_SYSSPACE, uap->mode, 0);
1105 ibcs2_chown(struct thread *td, struct ibcs2_chown_args *uap)
1110 CHECKALTEXIST(td, uap->path, &path);
1111 error = kern_fchownat(td, AT_FDCWD, path, UIO_SYSSPACE, uap->uid,
1118 ibcs2_rmdir(struct thread *td, struct ibcs2_rmdir_args *uap)
1123 CHECKALTEXIST(td, uap->path, &path);
1124 error = kern_rmdirat(td, AT_FDCWD, path, UIO_SYSSPACE);
1130 ibcs2_mkdir(struct thread *td, struct ibcs2_mkdir_args *uap)
1135 CHECKALTEXIST(td, uap->path, &path);
1136 error = kern_mkdirat(td, AT_FDCWD, path, UIO_SYSSPACE, uap->mode);
1142 ibcs2_symlink(struct thread *td, struct ibcs2_symlink_args *uap)
1147 CHECKALTEXIST(td, uap->path, &path);
1150 * Have to expand CHECKALTCREAT() so that 'path' can be freed on
1153 error = ibcs2_emul_find(td, uap->link, UIO_USERSPACE, &link, 1);
1158 error = kern_symlinkat(td, path, AT_FDCWD, link, UIO_SYSSPACE);
1165 ibcs2_rename(struct thread *td, struct ibcs2_rename_args *uap)
1170 CHECKALTEXIST(td, uap->from, &from);
1173 * Have to expand CHECKALTCREAT() so that 'from' can be freed on
1176 error = ibcs2_emul_find(td, uap->to, UIO_USERSPACE, &to, 1);
1181 error = kern_renameat(td, AT_FDCWD, from, AT_FDCWD, to, UIO_SYSSPACE);
1188 ibcs2_readlink(struct thread *td, struct ibcs2_readlink_args *uap)
1193 CHECKALTEXIST(td, uap->path, &path);
1194 error = kern_readlinkat(td, AT_FDCWD, path, UIO_SYSSPACE,
1195 uap->buf, UIO_USERSPACE, uap->count);