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/dirent.h>
61 #include <sys/fcntl.h>
62 #include <sys/filedesc.h>
63 #include <sys/imgact.h>
64 #include <sys/kernel.h>
66 #include <sys/malloc.h>
67 #include <sys/file.h> /* Must come after sys/malloc.h */
68 #include <sys/mutex.h>
69 #include <sys/namei.h>
71 #include <sys/reboot.h>
72 #include <sys/resourcevar.h>
74 #include <sys/sysctl.h>
75 #include <sys/syscallsubr.h>
76 #include <sys/sysproto.h>
78 #include <sys/times.h>
79 #include <sys/vnode.h>
82 #include <machine/cpu.h>
84 #include <i386/ibcs2/ibcs2_dirent.h>
85 #include <i386/ibcs2/ibcs2_signal.h>
86 #include <i386/ibcs2/ibcs2_proto.h>
87 #include <i386/ibcs2/ibcs2_unistd.h>
88 #include <i386/ibcs2/ibcs2_util.h>
89 #include <i386/ibcs2/ibcs2_utime.h>
90 #include <i386/ibcs2/ibcs2_xenix.h>
92 #include <security/mac/mac_framework.h>
97 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
111 td->td_retval[0] = lim_cur(p, RLIMIT_FSIZE);
113 if (td->td_retval[0] == -1)
114 td->td_retval[0] = 0x7fffffff;
118 rl.rlim_max = lim_max(p, RLIMIT_FSIZE);
120 rl.rlim_cur = uap->newlimit;
121 error = kern_setrlimit(td, RLIMIT_FSIZE, &rl);
124 td->td_retval[0] = lim_cur(p, RLIMIT_FSIZE);
127 DPRINTF(("failed "));
132 td->td_retval[0] = lim_cur(p, RLIMIT_RSS); /* XXX */
135 case IBCS2_GETDTABLESIZE:
136 uap->cmd = IBCS2_SC_OPEN_MAX;
137 return ibcs2_sysconf(td, (struct ibcs2_sysconf_args *)uap);
143 #define IBCS2_WSTOPPED 0177
144 #define IBCS2_STOPCODE(sig) ((sig) << 8 | IBCS2_WSTOPPED)
148 struct ibcs2_wait_args *uap;
150 int error, options, status;
153 struct trapframe *tf = td->td_frame;
155 if ((tf->tf_eflags & (PSL_Z|PSL_PF|PSL_N|PSL_V))
156 == (PSL_Z|PSL_PF|PSL_N|PSL_V)) {
159 statusp = (int *)uap->a2;
164 statusp = (int *)uap->a1;
167 error = kern_wait(td, pid, &status, options, NULL);
172 * Convert status/signal result.
174 if (WIFSTOPPED(status)) {
175 if (WSTOPSIG(status) <= 0 ||
176 WSTOPSIG(status) > IBCS2_SIGTBLSZ)
179 IBCS2_STOPCODE(bsd_to_ibcs2_sig[_SIG_IDX(WSTOPSIG(status))]);
180 } else if (WIFSIGNALED(status)) {
181 if (WTERMSIG(status) <= 0 ||
182 WTERMSIG(status) > IBCS2_SIGTBLSZ)
184 status = bsd_to_ibcs2_sig[_SIG_IDX(WTERMSIG(status))];
186 /* else exit status -- identical */
188 /* record result/status */
189 td->td_retval[1] = status;
190 return copyout(&status, statusp, sizeof(status));
199 struct ibcs2_execv_args *uap;
201 struct image_args eargs;
205 CHECKALTEXIST(td, uap->path, &path);
207 error = exec_copyin_args(&eargs, path, UIO_SYSSPACE, uap->argp, NULL);
210 error = kern_execve(td, &eargs, NULL);
215 ibcs2_execve(td, uap)
217 struct ibcs2_execve_args *uap;
219 struct image_args eargs;
223 CHECKALTEXIST(td, uap->path, &path);
225 error = exec_copyin_args(&eargs, path, UIO_SYSSPACE, uap->argp,
229 error = kern_execve(td, &eargs, NULL);
234 ibcs2_umount(td, uap)
236 struct ibcs2_umount_args *uap;
238 struct unmount_args um;
242 return unmount(td, &um);
248 struct ibcs2_mount_args *uap;
251 int oflags = uap->flags, nflags, error;
252 char fsname[MFSNAMELEN];
254 if (oflags & (IBCS2_MS_NOSUB | IBCS2_MS_SYS5))
256 if ((oflags & IBCS2_MS_NEWTYPE) == 0)
259 if (oflags & IBCS2_MS_RDONLY)
260 nflags |= MNT_RDONLY;
261 if (oflags & IBCS2_MS_NOSUID)
262 nflags |= MNT_NOSUID;
263 if (oflags & IBCS2_MS_REMOUNT)
264 nflags |= MNT_UPDATE;
267 if (error = copyinstr((caddr_t)uap->type, fsname, sizeof fsname,
271 if (strcmp(fsname, "4.2") == 0) {
272 uap->type = (caddr_t)STACK_ALLOC();
273 if (error = copyout("ufs", uap->type, sizeof("ufs")))
275 } else if (strcmp(fsname, "nfs") == 0) {
276 struct ibcs2_nfs_args sna;
277 struct sockaddr_in sain;
281 if (error = copyin(uap->data, &sna, sizeof sna))
283 if (error = copyin(sna.addr, &sain, sizeof sain))
285 bcopy(&sain, &sa, sizeof sa);
286 sa.sa_len = sizeof(sain);
287 uap->data = (caddr_t)STACK_ALLOC();
288 na.addr = (struct sockaddr *)((int)uap->data + sizeof na);
289 na.sotype = SOCK_DGRAM;
290 na.proto = IPPROTO_UDP;
291 na.fh = (nfsv2fh_t *)sna.fh;
292 na.flags = sna.flags;
293 na.wsize = sna.wsize;
294 na.rsize = sna.rsize;
295 na.timeo = sna.timeo;
296 na.retrans = sna.retrans;
297 na.hostname = sna.hostname;
299 if (error = copyout(&sa, na.addr, sizeof sa))
301 if (error = copyout(&na, uap->data, sizeof na))
304 return (mount(td, uap));
311 * Read iBCS2-style directory entries. We suck them into kernel space so
312 * that they can be massaged before being copied out to user code. Like
313 * SunOS, we squish out `empty' entries.
315 * This is quite ugly, but what do you expect from compatibility code?
319 ibcs2_getdents(td, uap)
321 register struct ibcs2_getdents_args *uap;
323 register struct vnode *vp;
324 register caddr_t inp, buf; /* BSD-format */
325 register int len, reclen; /* BSD-format */
326 register caddr_t outp; /* iBCS2-format */
327 register int resid; /* iBCS2-format */
331 struct ibcs2_dirent idb;
332 off_t off; /* true file offset */
333 int buflen, error, eofflag, vfslocked;
334 u_long *cookies = NULL, *cookiep;
336 #define BSD_DIRENT(cp) ((struct dirent *)(cp))
337 #define IBCS2_RECLEN(reclen) (reclen + sizeof(u_short))
339 if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)) != 0)
341 if ((fp->f_flag & FREAD) == 0) {
346 vfslocked = VFS_LOCK_GIANT(vp->v_mount);
347 if (vp->v_type != VDIR) { /* XXX vnode readdir op should do this */
348 VFS_UNLOCK_GIANT(vfslocked);
354 #define DIRBLKSIZ 512 /* XXX we used to use ufs's DIRBLKSIZ */
355 buflen = max(DIRBLKSIZ, uap->nbytes);
356 buflen = min(buflen, MAXBSIZE);
357 buf = malloc(buflen, M_TEMP, M_WAITOK);
358 vn_lock(vp, LK_SHARED | LK_RETRY);
361 aiov.iov_len = buflen;
362 auio.uio_iov = &aiov;
364 auio.uio_rw = UIO_READ;
365 auio.uio_segflg = UIO_SYSSPACE;
367 auio.uio_resid = buflen;
368 auio.uio_offset = off;
371 free(cookies, M_TEMP);
376 error = mac_vnode_check_readdir(td->td_ucred, vp);
382 * First we read into the malloc'ed buffer, then
383 * we massage it into user space, one record at a time.
385 if ((error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, &ncookies, &cookies)) != 0)
390 if ((len = buflen - auio.uio_resid) <= 0)
397 * When using cookies, the vfs has the option of reading from
398 * a different offset than that supplied (UFS truncates the
399 * offset to a block boundary to make sure that it never reads
400 * partway through a directory entry, even if the directory
401 * has been compacted).
403 while (len > 0 && ncookies > 0 && *cookiep <= off) {
404 len -= BSD_DIRENT(inp)->d_reclen;
405 inp += BSD_DIRENT(inp)->d_reclen;
411 for (; len > 0; len -= reclen) {
412 if (cookiep && ncookies == 0)
414 reclen = BSD_DIRENT(inp)->d_reclen;
416 printf("ibcs2_getdents: reclen=%d\n", reclen);
420 if (BSD_DIRENT(inp)->d_fileno == 0) {
421 inp += reclen; /* it is a hole; squish it out */
429 if (reclen > len || resid < IBCS2_RECLEN(reclen)) {
430 /* entry too big for buffer, so just stop */
435 * Massage in place to make an iBCS2-shaped dirent (otherwise
436 * we have to worry about touching user memory outside of
437 * the copyout() call).
439 idb.d_ino = (ibcs2_ino_t)BSD_DIRENT(inp)->d_fileno;
440 idb.d_off = (ibcs2_off_t)off;
441 idb.d_reclen = (u_short)IBCS2_RECLEN(reclen);
442 if ((error = copyout((caddr_t)&idb, outp, 10)) != 0 ||
443 (error = copyout(BSD_DIRENT(inp)->d_name, outp + 10,
444 BSD_DIRENT(inp)->d_namlen + 1)) != 0)
446 /* advance past this real entry */
453 /* advance output past iBCS2-shaped entry */
454 outp += IBCS2_RECLEN(reclen);
455 resid -= IBCS2_RECLEN(reclen);
457 /* if we squished out the whole block, try again */
458 if (outp == uap->buf)
460 fp->f_offset = off; /* update the vnode offset */
462 td->td_retval[0] = uap->nbytes - resid;
465 VFS_UNLOCK_GIANT(vfslocked);
468 free(cookies, M_TEMP);
476 struct ibcs2_read_args *uap;
478 register struct vnode *vp;
479 register caddr_t inp, buf; /* BSD-format */
480 register int len, reclen; /* BSD-format */
481 register caddr_t outp; /* iBCS2-format */
482 register int resid; /* iBCS2-format */
486 struct ibcs2_direct {
490 off_t off; /* true file offset */
491 int buflen, error, eofflag, size, vfslocked;
492 u_long *cookies = NULL, *cookiep;
495 if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)) != 0) {
497 return read(td, (struct read_args *)uap);
501 if ((fp->f_flag & FREAD) == 0) {
506 vfslocked = VFS_LOCK_GIANT(vp->v_mount);
507 if (vp->v_type != VDIR) {
508 VFS_UNLOCK_GIANT(vfslocked);
510 return read(td, (struct read_args *)uap);
515 DPRINTF(("ibcs2_read: read directory\n"));
517 buflen = max(DIRBLKSIZ, uap->nbytes);
518 buflen = min(buflen, MAXBSIZE);
519 buf = malloc(buflen, M_TEMP, M_WAITOK);
520 vn_lock(vp, LK_SHARED | LK_RETRY);
523 aiov.iov_len = buflen;
524 auio.uio_iov = &aiov;
526 auio.uio_rw = UIO_READ;
527 auio.uio_segflg = UIO_SYSSPACE;
529 auio.uio_resid = buflen;
530 auio.uio_offset = off;
533 free(cookies, M_TEMP);
538 error = mac_vnode_check_readdir(td->td_ucred, vp);
544 * First we read into the malloc'ed buffer, then
545 * we massage it into user space, one record at a time.
547 if ((error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, &ncookies, &cookies)) != 0) {
548 DPRINTF(("VOP_READDIR failed: %d\n", error));
554 if ((len = buflen - auio.uio_resid) <= 0)
561 * When using cookies, the vfs has the option of reading from
562 * a different offset than that supplied (UFS truncates the
563 * offset to a block boundary to make sure that it never reads
564 * partway through a directory entry, even if the directory
565 * has been compacted).
567 while (len > 0 && ncookies > 0 && *cookiep <= off) {
568 len -= BSD_DIRENT(inp)->d_reclen;
569 inp += BSD_DIRENT(inp)->d_reclen;
575 for (; len > 0 && resid > 0; len -= reclen) {
576 if (cookiep && ncookies == 0)
578 reclen = BSD_DIRENT(inp)->d_reclen;
580 printf("ibcs2_read: reclen=%d\n", reclen);
584 if (BSD_DIRENT(inp)->d_fileno == 0) {
585 inp += reclen; /* it is a hole; squish it out */
593 if (reclen > len || resid < sizeof(struct ibcs2_direct)) {
594 /* entry too big for buffer, so just stop */
599 * Massage in place to make an iBCS2-shaped dirent (otherwise
600 * we have to worry about touching user memory outside of
601 * the copyout() call).
603 * TODO: if length(filename) > 14, then break filename into
604 * multiple entries and set inode = 0xffff except last
606 idb.ino = (BSD_DIRENT(inp)->d_fileno > 0xfffe) ? 0xfffe :
607 BSD_DIRENT(inp)->d_fileno;
608 (void)copystr(BSD_DIRENT(inp)->d_name, idb.name, 14, &size);
609 bzero(idb.name + size, 14 - size);
610 if ((error = copyout(&idb, outp, sizeof(struct ibcs2_direct))) != 0)
612 /* advance past this real entry */
619 /* advance output past iBCS2-shaped entry */
620 outp += sizeof(struct ibcs2_direct);
621 resid -= sizeof(struct ibcs2_direct);
623 /* if we squished out the whole block, try again */
624 if (outp == uap->buf)
626 fp->f_offset = off; /* update the vnode offset */
628 td->td_retval[0] = uap->nbytes - resid;
631 VFS_UNLOCK_GIANT(vfslocked);
634 free(cookies, M_TEMP);
642 struct ibcs2_mknod_args *uap;
647 CHECKALTCREAT(td, uap->path, &path);
648 if (S_ISFIFO(uap->mode))
649 error = kern_mkfifo(td, path, UIO_SYSSPACE, uap->mode);
651 error = kern_mknod(td, path, UIO_SYSSPACE, uap->mode, uap->dev);
657 ibcs2_getgroups(td, uap)
659 struct ibcs2_getgroups_args *uap;
666 if (uap->gidsetsize < td->td_ucred->cr_ngroups) {
667 if (uap->gidsetsize == 0)
672 ngrp = td->td_ucred->cr_ngroups;
673 gp = malloc(ngrp * sizeof(*gp), M_TEMP, M_WAITOK);
674 error = kern_getgroups(td, &ngrp, gp);
677 if (uap->gidsetsize > 0) {
678 iset = malloc(ngrp * sizeof(*iset), M_TEMP, M_WAITOK);
679 for (i = 0; i < ngrp; i++)
680 iset[i] = (ibcs2_gid_t)gp[i];
681 error = copyout(iset, uap->gidset, ngrp * sizeof(ibcs2_gid_t));
685 td->td_retval[0] = ngrp;
692 ibcs2_setgroups(td, uap)
694 struct ibcs2_setgroups_args *uap;
700 if (uap->gidsetsize < 0 || uap->gidsetsize > ngroups_max + 1)
702 if (uap->gidsetsize && uap->gidset == NULL)
704 gp = malloc(uap->gidsetsize * sizeof(*gp), M_TEMP, M_WAITOK);
705 if (uap->gidsetsize) {
706 iset = malloc(uap->gidsetsize * sizeof(*iset), M_TEMP, M_WAITOK);
707 error = copyin(uap->gidset, iset, sizeof(ibcs2_gid_t) *
713 for (i = 0; i < uap->gidsetsize; i++)
714 gp[i] = (gid_t)iset[i];
717 error = kern_setgroups(td, uap->gidsetsize, gp);
724 ibcs2_setuid(td, uap)
726 struct ibcs2_setuid_args *uap;
728 struct setuid_args sa;
730 sa.uid = (uid_t)uap->uid;
731 return setuid(td, &sa);
735 ibcs2_setgid(td, uap)
737 struct ibcs2_setgid_args *uap;
739 struct setgid_args sa;
741 sa.gid = (gid_t)uap->gid;
742 return setgid(td, &sa);
748 struct ibcs2_time_args *uap;
753 td->td_retval[0] = tv.tv_sec;
755 return copyout((caddr_t)&tv.tv_sec, (caddr_t)uap->tp,
756 sizeof(ibcs2_time_t));
762 ibcs2_pathconf(td, uap)
764 struct ibcs2_pathconf_args *uap;
769 CHECKALTEXIST(td, uap->path, &path);
770 uap->name++; /* iBCS2 _PC_* defines are offset by one */
771 error = kern_pathconf(td, path, UIO_SYSSPACE, uap->name, FOLLOW);
777 ibcs2_fpathconf(td, uap)
779 struct ibcs2_fpathconf_args *uap;
781 uap->name++; /* iBCS2 _PC_* defines are offset by one */
782 return fpathconf(td, (struct fpathconf_args *)uap);
786 ibcs2_sysconf(td, uap)
788 struct ibcs2_sysconf_args *uap;
790 int mib[2], value, len, error;
795 case IBCS2_SC_ARG_MAX:
796 mib[1] = KERN_ARGMAX;
799 case IBCS2_SC_CHILD_MAX:
801 td->td_retval[0] = lim_cur(td->td_proc, RLIMIT_NPROC);
805 case IBCS2_SC_CLK_TCK:
806 td->td_retval[0] = hz;
809 case IBCS2_SC_NGROUPS_MAX:
810 mib[1] = KERN_NGROUPS;
813 case IBCS2_SC_OPEN_MAX:
815 td->td_retval[0] = lim_cur(td->td_proc, RLIMIT_NOFILE);
819 case IBCS2_SC_JOB_CONTROL:
820 mib[1] = KERN_JOB_CONTROL;
823 case IBCS2_SC_SAVED_IDS:
824 mib[1] = KERN_SAVED_IDS;
827 case IBCS2_SC_VERSION:
828 mib[1] = KERN_POSIX1;
831 case IBCS2_SC_PASS_MAX:
832 td->td_retval[0] = 128; /* XXX - should we create PASS_MAX ? */
835 case IBCS2_SC_XOPEN_VERSION:
836 td->td_retval[0] = 2; /* XXX: What should that be? */
845 error = kernel_sysctl(td, mib, 2, &value, &len, NULL, 0, NULL, 0);
848 td->td_retval[0] = value;
855 struct ibcs2_alarm_args *uap;
857 struct itimerval itv, oitv;
860 timevalclear(&itv.it_interval);
861 itv.it_value.tv_sec = uap->sec;
862 itv.it_value.tv_usec = 0;
863 error = kern_setitimer(td, ITIMER_REAL, &itv, &oitv);
866 if (oitv.it_value.tv_usec != 0)
867 oitv.it_value.tv_sec++;
868 td->td_retval[0] = oitv.it_value.tv_sec;
875 struct ibcs2_times_args *uap;
882 #define CONVTCK(r) (r.tv_sec * hz + r.tv_usec / (1000000 / hz))
884 error = kern_getrusage(td, RUSAGE_SELF, &ru);
887 tms.tms_utime = CONVTCK(ru.ru_utime);
888 tms.tms_stime = CONVTCK(ru.ru_stime);
890 error = kern_getrusage(td, RUSAGE_CHILDREN, &ru);
893 tms.tms_cutime = CONVTCK(ru.ru_utime);
894 tms.tms_cstime = CONVTCK(ru.ru_stime);
897 td->td_retval[0] = CONVTCK(t);
899 return (copyout(&tms, uap->tp, sizeof(struct tms)));
905 struct ibcs2_stime_args *uap;
911 error = copyin(uap->timep, &secs, sizeof(long));
916 error = kern_settimeofday(td, &tv, NULL);
925 struct ibcs2_utime_args *uap;
927 struct ibcs2_utimbuf ubuf;
928 struct timeval tbuf[2], *tp;
933 error = copyin(uap->buf, &ubuf, sizeof(ubuf));
936 tbuf[0].tv_sec = ubuf.actime;
938 tbuf[1].tv_sec = ubuf.modtime;
944 CHECKALTEXIST(td, uap->path, &path);
945 error = kern_utimes(td, path, UIO_SYSSPACE, tp, UIO_SYSSPACE);
953 struct ibcs2_nice_args *uap;
956 struct setpriority_args sa;
958 sa.which = PRIO_PROCESS;
960 sa.prio = td->td_proc->p_nice + uap->incr;
961 if ((error = setpriority(td, &sa)) != 0)
963 td->td_retval[0] = td->td_proc->p_nice;
968 * iBCS2 getpgrp, setpgrp, setsid, and setpgid
972 ibcs2_pgrpsys(td, uap)
974 struct ibcs2_pgrpsys_args *uap;
976 struct proc *p = td->td_proc;
978 case 0: /* getpgrp */
980 td->td_retval[0] = p->p_pgrp->pg_id;
984 case 1: /* setpgrp */
986 struct setpgid_args sa;
992 td->td_retval[0] = p->p_pgrp->pg_id;
997 case 2: /* setpgid */
999 struct setpgid_args sa;
1002 sa.pgid = uap->pgid;
1003 return setpgid(td, &sa);
1006 case 3: /* setsid */
1007 return setsid(td, NULL);
1015 * XXX - need to check for nested calls
1019 ibcs2_plock(td, uap)
1021 struct ibcs2_plock_args *uap;
1024 #define IBCS2_UNLOCK 0
1025 #define IBCS2_PROCLOCK 1
1026 #define IBCS2_TEXTLOCK 2
1027 #define IBCS2_DATALOCK 4
1032 error = priv_check(td, PRIV_VM_MUNLOCK);
1038 case IBCS2_PROCLOCK:
1039 case IBCS2_TEXTLOCK:
1040 case IBCS2_DATALOCK:
1041 error = priv_check(td, PRIV_VM_MLOCK);
1051 ibcs2_uadmin(td, uap)
1053 struct ibcs2_uadmin_args *uap;
1055 #define SCO_A_REBOOT 1
1056 #define SCO_A_SHUTDOWN 2
1057 #define SCO_A_REMOUNT 4
1058 #define SCO_A_CLOCK 8
1059 #define SCO_A_SETCONFIG 128
1060 #define SCO_A_GETDEV 130
1062 #define SCO_AD_HALT 0
1063 #define SCO_AD_BOOT 1
1064 #define SCO_AD_IBOOT 2
1065 #define SCO_AD_PWRDOWN 3
1066 #define SCO_AD_PWRNAP 4
1068 #define SCO_AD_PANICBOOT 1
1070 #define SCO_AD_GETBMAJ 0
1071 #define SCO_AD_GETCMAJ 1
1075 case SCO_A_SHUTDOWN:
1077 struct reboot_args r;
1079 case SCO_AD_PWRDOWN:
1082 return (reboot(td, &r));
1085 r.opt = RB_AUTOBOOT;
1086 return (reboot(td, &r));
1091 case SCO_A_SETCONFIG:
1094 return EINVAL; /* XXX - TODO */
1100 ibcs2_sysfs(td, uap)
1102 struct ibcs2_sysfs_args *uap;
1104 #define IBCS2_GETFSIND 1
1105 #define IBCS2_GETFSTYP 2
1106 #define IBCS2_GETNFSTYP 3
1109 case IBCS2_GETFSIND:
1110 case IBCS2_GETFSTYP:
1111 case IBCS2_GETNFSTYP:
1114 return EINVAL; /* XXX - TODO */
1118 ibcs2_unlink(td, uap)
1120 struct ibcs2_unlink_args *uap;
1125 CHECKALTEXIST(td, uap->path, &path);
1126 error = kern_unlink(td, path, UIO_SYSSPACE);
1132 ibcs2_chdir(td, uap)
1134 struct ibcs2_chdir_args *uap;
1139 CHECKALTEXIST(td, uap->path, &path);
1140 error = kern_chdir(td, path, UIO_SYSSPACE);
1146 ibcs2_chmod(td, uap)
1148 struct ibcs2_chmod_args *uap;
1153 CHECKALTEXIST(td, uap->path, &path);
1154 error = kern_chmod(td, path, UIO_SYSSPACE, uap->mode);
1160 ibcs2_chown(td, uap)
1162 struct ibcs2_chown_args *uap;
1167 CHECKALTEXIST(td, uap->path, &path);
1168 error = kern_chown(td, path, UIO_SYSSPACE, uap->uid, uap->gid);
1174 ibcs2_rmdir(td, uap)
1176 struct ibcs2_rmdir_args *uap;
1181 CHECKALTEXIST(td, uap->path, &path);
1182 error = kern_rmdir(td, path, UIO_SYSSPACE);
1188 ibcs2_mkdir(td, uap)
1190 struct ibcs2_mkdir_args *uap;
1195 CHECKALTEXIST(td, uap->path, &path);
1196 error = kern_mkdir(td, path, UIO_SYSSPACE, uap->mode);
1202 ibcs2_symlink(td, uap)
1204 struct ibcs2_symlink_args *uap;
1209 CHECKALTEXIST(td, uap->path, &path);
1212 * Have to expand CHECKALTCREAT() so that 'path' can be freed on
1215 error = ibcs2_emul_find(td, uap->link, UIO_USERSPACE, &link, 1);
1220 error = kern_symlink(td, path, link, UIO_SYSSPACE);
1227 ibcs2_rename(td, uap)
1229 struct ibcs2_rename_args *uap;
1234 CHECKALTEXIST(td, uap->from, &from);
1237 * Have to expand CHECKALTCREAT() so that 'from' can be freed on
1240 error = ibcs2_emul_find(td, uap->to, UIO_USERSPACE, &to, 1);
1245 error = kern_rename(td, from, to, UIO_SYSSPACE);
1252 ibcs2_readlink(td, uap)
1254 struct ibcs2_readlink_args *uap;
1259 CHECKALTEXIST(td, uap->path, &path);
1260 error = kern_readlink(td, path, UIO_SYSSPACE, uap->buf, UIO_USERSPACE,