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/capability.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;
206 CHECKALTEXIST(td, uap->path, &path);
208 error = exec_copyin_args(&eargs, path, UIO_SYSSPACE, uap->argp, NULL);
211 error = kern_execve(td, &eargs, NULL);
216 ibcs2_execve(td, uap)
218 struct ibcs2_execve_args *uap;
220 struct image_args eargs;
224 CHECKALTEXIST(td, uap->path, &path);
226 error = exec_copyin_args(&eargs, path, UIO_SYSSPACE, uap->argp,
230 error = kern_execve(td, &eargs, NULL);
235 ibcs2_umount(td, uap)
237 struct ibcs2_umount_args *uap;
239 struct unmount_args um;
243 return sys_unmount(td, &um);
249 struct ibcs2_mount_args *uap;
252 int oflags = uap->flags, nflags, error;
253 char fsname[MFSNAMELEN];
255 if (oflags & (IBCS2_MS_NOSUB | IBCS2_MS_SYS5))
257 if ((oflags & IBCS2_MS_NEWTYPE) == 0)
260 if (oflags & IBCS2_MS_RDONLY)
261 nflags |= MNT_RDONLY;
262 if (oflags & IBCS2_MS_NOSUID)
263 nflags |= MNT_NOSUID;
264 if (oflags & IBCS2_MS_REMOUNT)
265 nflags |= MNT_UPDATE;
268 if (error = copyinstr((caddr_t)uap->type, fsname, sizeof fsname,
272 if (strcmp(fsname, "4.2") == 0) {
273 uap->type = (caddr_t)STACK_ALLOC();
274 if (error = copyout("ufs", uap->type, sizeof("ufs")))
276 } else if (strcmp(fsname, "nfs") == 0) {
277 struct ibcs2_nfs_args sna;
278 struct sockaddr_in sain;
282 if (error = copyin(uap->data, &sna, sizeof sna))
284 if (error = copyin(sna.addr, &sain, sizeof sain))
286 bcopy(&sain, &sa, sizeof sa);
287 sa.sa_len = sizeof(sain);
288 uap->data = (caddr_t)STACK_ALLOC();
289 na.addr = (struct sockaddr *)((int)uap->data + sizeof na);
290 na.sotype = SOCK_DGRAM;
291 na.proto = IPPROTO_UDP;
292 na.fh = (nfsv2fh_t *)sna.fh;
293 na.flags = sna.flags;
294 na.wsize = sna.wsize;
295 na.rsize = sna.rsize;
296 na.timeo = sna.timeo;
297 na.retrans = sna.retrans;
298 na.hostname = sna.hostname;
300 if (error = copyout(&sa, na.addr, sizeof sa))
302 if (error = copyout(&na, uap->data, sizeof na))
305 return (mount(td, uap));
312 * Read iBCS2-style directory entries. We suck them into kernel space so
313 * that they can be massaged before being copied out to user code. Like
314 * SunOS, we squish out `empty' entries.
316 * This is quite ugly, but what do you expect from compatibility code?
320 ibcs2_getdents(td, uap)
322 register struct ibcs2_getdents_args *uap;
324 register struct vnode *vp;
325 register caddr_t inp, buf; /* BSD-format */
326 register int len, reclen; /* BSD-format */
327 register caddr_t outp; /* iBCS2-format */
328 register int resid; /* iBCS2-format */
333 struct ibcs2_dirent idb;
334 off_t off; /* true file offset */
335 int buflen, error, eofflag;
336 u_long *cookies = NULL, *cookiep;
338 #define BSD_DIRENT(cp) ((struct dirent *)(cp))
339 #define IBCS2_RECLEN(reclen) (reclen + sizeof(u_short))
341 error = getvnode(td->td_proc->p_fd, uap->fd,
342 cap_rights_init(&rights, CAP_READ), &fp);
345 if ((fp->f_flag & FREAD) == 0) {
350 if (vp->v_type != VDIR) { /* XXX vnode readdir op should do this */
356 #define DIRBLKSIZ 512 /* XXX we used to use ufs's DIRBLKSIZ */
357 buflen = max(DIRBLKSIZ, uap->nbytes);
358 buflen = min(buflen, MAXBSIZE);
359 buf = malloc(buflen, M_TEMP, M_WAITOK);
360 vn_lock(vp, LK_SHARED | LK_RETRY);
363 aiov.iov_len = buflen;
364 auio.uio_iov = &aiov;
366 auio.uio_rw = UIO_READ;
367 auio.uio_segflg = UIO_SYSSPACE;
369 auio.uio_resid = buflen;
370 auio.uio_offset = off;
373 free(cookies, M_TEMP);
378 error = mac_vnode_check_readdir(td->td_ucred, vp);
384 * First we read into the malloc'ed buffer, then
385 * we massage it into user space, one record at a time.
387 if ((error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, &ncookies, &cookies)) != 0)
392 if ((len = buflen - auio.uio_resid) <= 0)
399 * When using cookies, the vfs has the option of reading from
400 * a different offset than that supplied (UFS truncates the
401 * offset to a block boundary to make sure that it never reads
402 * partway through a directory entry, even if the directory
403 * has been compacted).
405 while (len > 0 && ncookies > 0 && *cookiep <= off) {
406 len -= BSD_DIRENT(inp)->d_reclen;
407 inp += BSD_DIRENT(inp)->d_reclen;
413 for (; len > 0; len -= reclen) {
414 if (cookiep && ncookies == 0)
416 reclen = BSD_DIRENT(inp)->d_reclen;
418 printf("ibcs2_getdents: reclen=%d\n", reclen);
422 if (BSD_DIRENT(inp)->d_fileno == 0) {
423 inp += reclen; /* it is a hole; squish it out */
431 if (reclen > len || resid < IBCS2_RECLEN(reclen)) {
432 /* entry too big for buffer, so just stop */
437 * Massage in place to make an iBCS2-shaped dirent (otherwise
438 * we have to worry about touching user memory outside of
439 * the copyout() call).
441 idb.d_ino = (ibcs2_ino_t)BSD_DIRENT(inp)->d_fileno;
442 idb.d_off = (ibcs2_off_t)off;
443 idb.d_reclen = (u_short)IBCS2_RECLEN(reclen);
444 if ((error = copyout((caddr_t)&idb, outp, 10)) != 0 ||
445 (error = copyout(BSD_DIRENT(inp)->d_name, outp + 10,
446 BSD_DIRENT(inp)->d_namlen + 1)) != 0)
448 /* advance past this real entry */
455 /* advance output past iBCS2-shaped entry */
456 outp += IBCS2_RECLEN(reclen);
457 resid -= IBCS2_RECLEN(reclen);
459 /* if we squished out the whole block, try again */
460 if (outp == uap->buf)
462 fp->f_offset = off; /* update the vnode offset */
464 td->td_retval[0] = uap->nbytes - resid;
469 free(cookies, M_TEMP);
477 struct ibcs2_read_args *uap;
479 register struct vnode *vp;
480 register caddr_t inp, buf; /* BSD-format */
481 register int len, reclen; /* BSD-format */
482 register caddr_t outp; /* iBCS2-format */
483 register int resid; /* iBCS2-format */
488 struct ibcs2_direct {
492 off_t off; /* true file offset */
493 int buflen, error, eofflag, size;
494 u_long *cookies = NULL, *cookiep;
497 error = getvnode(td->td_proc->p_fd, uap->fd,
498 cap_rights_init(&rights, CAP_READ), &fp);
501 return sys_read(td, (struct read_args *)uap);
505 if ((fp->f_flag & FREAD) == 0) {
510 if (vp->v_type != VDIR) {
512 return sys_read(td, (struct read_args *)uap);
517 DPRINTF(("ibcs2_read: read directory\n"));
519 buflen = max(DIRBLKSIZ, uap->nbytes);
520 buflen = min(buflen, MAXBSIZE);
521 buf = malloc(buflen, M_TEMP, M_WAITOK);
522 vn_lock(vp, LK_SHARED | LK_RETRY);
525 aiov.iov_len = buflen;
526 auio.uio_iov = &aiov;
528 auio.uio_rw = UIO_READ;
529 auio.uio_segflg = UIO_SYSSPACE;
531 auio.uio_resid = buflen;
532 auio.uio_offset = off;
535 free(cookies, M_TEMP);
540 error = mac_vnode_check_readdir(td->td_ucred, vp);
546 * First we read into the malloc'ed buffer, then
547 * we massage it into user space, one record at a time.
549 if ((error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, &ncookies, &cookies)) != 0) {
550 DPRINTF(("VOP_READDIR failed: %d\n", error));
556 if ((len = buflen - auio.uio_resid) <= 0)
563 * When using cookies, the vfs has the option of reading from
564 * a different offset than that supplied (UFS truncates the
565 * offset to a block boundary to make sure that it never reads
566 * partway through a directory entry, even if the directory
567 * has been compacted).
569 while (len > 0 && ncookies > 0 && *cookiep <= off) {
570 len -= BSD_DIRENT(inp)->d_reclen;
571 inp += BSD_DIRENT(inp)->d_reclen;
577 for (; len > 0 && resid > 0; len -= reclen) {
578 if (cookiep && ncookies == 0)
580 reclen = BSD_DIRENT(inp)->d_reclen;
582 printf("ibcs2_read: reclen=%d\n", reclen);
586 if (BSD_DIRENT(inp)->d_fileno == 0) {
587 inp += reclen; /* it is a hole; squish it out */
595 if (reclen > len || resid < sizeof(struct ibcs2_direct)) {
596 /* entry too big for buffer, so just stop */
601 * Massage in place to make an iBCS2-shaped dirent (otherwise
602 * we have to worry about touching user memory outside of
603 * the copyout() call).
605 * TODO: if length(filename) > 14, then break filename into
606 * multiple entries and set inode = 0xffff except last
608 idb.ino = (BSD_DIRENT(inp)->d_fileno > 0xfffe) ? 0xfffe :
609 BSD_DIRENT(inp)->d_fileno;
610 (void)copystr(BSD_DIRENT(inp)->d_name, idb.name, 14, &size);
611 bzero(idb.name + size, 14 - size);
612 if ((error = copyout(&idb, outp, sizeof(struct ibcs2_direct))) != 0)
614 /* advance past this real entry */
621 /* advance output past iBCS2-shaped entry */
622 outp += sizeof(struct ibcs2_direct);
623 resid -= sizeof(struct ibcs2_direct);
625 /* if we squished out the whole block, try again */
626 if (outp == uap->buf)
628 fp->f_offset = off; /* update the vnode offset */
630 td->td_retval[0] = uap->nbytes - resid;
635 free(cookies, M_TEMP);
643 struct ibcs2_mknod_args *uap;
648 CHECKALTCREAT(td, uap->path, &path);
649 if (S_ISFIFO(uap->mode))
650 error = kern_mkfifo(td, path, UIO_SYSSPACE, uap->mode);
652 error = kern_mknod(td, path, UIO_SYSSPACE, uap->mode, uap->dev);
658 ibcs2_getgroups(td, uap)
660 struct ibcs2_getgroups_args *uap;
667 if (uap->gidsetsize < td->td_ucred->cr_ngroups) {
668 if (uap->gidsetsize == 0)
673 ngrp = td->td_ucred->cr_ngroups;
674 gp = malloc(ngrp * sizeof(*gp), M_TEMP, M_WAITOK);
675 error = kern_getgroups(td, &ngrp, gp);
678 if (uap->gidsetsize > 0) {
679 iset = malloc(ngrp * sizeof(*iset), M_TEMP, M_WAITOK);
680 for (i = 0; i < ngrp; i++)
681 iset[i] = (ibcs2_gid_t)gp[i];
682 error = copyout(iset, uap->gidset, ngrp * sizeof(ibcs2_gid_t));
686 td->td_retval[0] = ngrp;
693 ibcs2_setgroups(td, uap)
695 struct ibcs2_setgroups_args *uap;
701 if (uap->gidsetsize < 0 || uap->gidsetsize > ngroups_max + 1)
703 if (uap->gidsetsize && uap->gidset == NULL)
705 gp = malloc(uap->gidsetsize * sizeof(*gp), M_TEMP, M_WAITOK);
706 if (uap->gidsetsize) {
707 iset = malloc(uap->gidsetsize * sizeof(*iset), M_TEMP, M_WAITOK);
708 error = copyin(uap->gidset, iset, sizeof(ibcs2_gid_t) *
714 for (i = 0; i < uap->gidsetsize; i++)
715 gp[i] = (gid_t)iset[i];
718 error = kern_setgroups(td, uap->gidsetsize, gp);
725 ibcs2_setuid(td, uap)
727 struct ibcs2_setuid_args *uap;
729 struct setuid_args sa;
731 sa.uid = (uid_t)uap->uid;
732 return sys_setuid(td, &sa);
736 ibcs2_setgid(td, uap)
738 struct ibcs2_setgid_args *uap;
740 struct setgid_args sa;
742 sa.gid = (gid_t)uap->gid;
743 return sys_setgid(td, &sa);
749 struct ibcs2_time_args *uap;
754 td->td_retval[0] = tv.tv_sec;
756 return copyout((caddr_t)&tv.tv_sec, (caddr_t)uap->tp,
757 sizeof(ibcs2_time_t));
763 ibcs2_pathconf(td, uap)
765 struct ibcs2_pathconf_args *uap;
770 CHECKALTEXIST(td, uap->path, &path);
771 uap->name++; /* iBCS2 _PC_* defines are offset by one */
772 error = kern_pathconf(td, path, UIO_SYSSPACE, uap->name, FOLLOW);
778 ibcs2_fpathconf(td, uap)
780 struct ibcs2_fpathconf_args *uap;
782 uap->name++; /* iBCS2 _PC_* defines are offset by one */
783 return sys_fpathconf(td, (struct fpathconf_args *)uap);
787 ibcs2_sysconf(td, uap)
789 struct ibcs2_sysconf_args *uap;
791 int mib[2], value, len, error;
796 case IBCS2_SC_ARG_MAX:
797 mib[1] = KERN_ARGMAX;
800 case IBCS2_SC_CHILD_MAX:
802 td->td_retval[0] = lim_cur(td->td_proc, RLIMIT_NPROC);
806 case IBCS2_SC_CLK_TCK:
807 td->td_retval[0] = hz;
810 case IBCS2_SC_NGROUPS_MAX:
811 mib[1] = KERN_NGROUPS;
814 case IBCS2_SC_OPEN_MAX:
816 td->td_retval[0] = lim_cur(td->td_proc, RLIMIT_NOFILE);
820 case IBCS2_SC_JOB_CONTROL:
821 mib[1] = KERN_JOB_CONTROL;
824 case IBCS2_SC_SAVED_IDS:
825 mib[1] = KERN_SAVED_IDS;
828 case IBCS2_SC_VERSION:
829 mib[1] = KERN_POSIX1;
832 case IBCS2_SC_PASS_MAX:
833 td->td_retval[0] = 128; /* XXX - should we create PASS_MAX ? */
836 case IBCS2_SC_XOPEN_VERSION:
837 td->td_retval[0] = 2; /* XXX: What should that be? */
846 error = kernel_sysctl(td, mib, 2, &value, &len, NULL, 0, NULL, 0);
849 td->td_retval[0] = value;
856 struct ibcs2_alarm_args *uap;
858 struct itimerval itv, oitv;
861 timevalclear(&itv.it_interval);
862 itv.it_value.tv_sec = uap->sec;
863 itv.it_value.tv_usec = 0;
864 error = kern_setitimer(td, ITIMER_REAL, &itv, &oitv);
867 if (oitv.it_value.tv_usec != 0)
868 oitv.it_value.tv_sec++;
869 td->td_retval[0] = oitv.it_value.tv_sec;
876 struct ibcs2_times_args *uap;
883 #define CONVTCK(r) (r.tv_sec * hz + r.tv_usec / (1000000 / hz))
885 error = kern_getrusage(td, RUSAGE_SELF, &ru);
888 tms.tms_utime = CONVTCK(ru.ru_utime);
889 tms.tms_stime = CONVTCK(ru.ru_stime);
891 error = kern_getrusage(td, RUSAGE_CHILDREN, &ru);
894 tms.tms_cutime = CONVTCK(ru.ru_utime);
895 tms.tms_cstime = CONVTCK(ru.ru_stime);
898 td->td_retval[0] = CONVTCK(t);
900 return (copyout(&tms, uap->tp, sizeof(struct tms)));
906 struct ibcs2_stime_args *uap;
912 error = copyin(uap->timep, &secs, sizeof(long));
917 error = kern_settimeofday(td, &tv, NULL);
926 struct ibcs2_utime_args *uap;
928 struct ibcs2_utimbuf ubuf;
929 struct timeval tbuf[2], *tp;
934 error = copyin(uap->buf, &ubuf, sizeof(ubuf));
937 tbuf[0].tv_sec = ubuf.actime;
939 tbuf[1].tv_sec = ubuf.modtime;
945 CHECKALTEXIST(td, uap->path, &path);
946 error = kern_utimes(td, path, UIO_SYSSPACE, tp, UIO_SYSSPACE);
954 struct ibcs2_nice_args *uap;
957 struct setpriority_args sa;
959 sa.which = PRIO_PROCESS;
961 sa.prio = td->td_proc->p_nice + uap->incr;
962 if ((error = sys_setpriority(td, &sa)) != 0)
964 td->td_retval[0] = td->td_proc->p_nice;
969 * iBCS2 getpgrp, setpgrp, setsid, and setpgid
973 ibcs2_pgrpsys(td, uap)
975 struct ibcs2_pgrpsys_args *uap;
977 struct proc *p = td->td_proc;
979 case 0: /* getpgrp */
981 td->td_retval[0] = p->p_pgrp->pg_id;
985 case 1: /* setpgrp */
987 struct setpgid_args sa;
991 sys_setpgid(td, &sa);
993 td->td_retval[0] = p->p_pgrp->pg_id;
998 case 2: /* setpgid */
1000 struct setpgid_args sa;
1003 sa.pgid = uap->pgid;
1004 return sys_setpgid(td, &sa);
1007 case 3: /* setsid */
1008 return sys_setsid(td, NULL);
1016 * XXX - need to check for nested calls
1020 ibcs2_plock(td, uap)
1022 struct ibcs2_plock_args *uap;
1025 #define IBCS2_UNLOCK 0
1026 #define IBCS2_PROCLOCK 1
1027 #define IBCS2_TEXTLOCK 2
1028 #define IBCS2_DATALOCK 4
1033 error = priv_check(td, PRIV_VM_MUNLOCK);
1039 case IBCS2_PROCLOCK:
1040 case IBCS2_TEXTLOCK:
1041 case IBCS2_DATALOCK:
1042 error = priv_check(td, PRIV_VM_MLOCK);
1052 ibcs2_uadmin(td, uap)
1054 struct ibcs2_uadmin_args *uap;
1056 #define SCO_A_REBOOT 1
1057 #define SCO_A_SHUTDOWN 2
1058 #define SCO_A_REMOUNT 4
1059 #define SCO_A_CLOCK 8
1060 #define SCO_A_SETCONFIG 128
1061 #define SCO_A_GETDEV 130
1063 #define SCO_AD_HALT 0
1064 #define SCO_AD_BOOT 1
1065 #define SCO_AD_IBOOT 2
1066 #define SCO_AD_PWRDOWN 3
1067 #define SCO_AD_PWRNAP 4
1069 #define SCO_AD_PANICBOOT 1
1071 #define SCO_AD_GETBMAJ 0
1072 #define SCO_AD_GETCMAJ 1
1076 case SCO_A_SHUTDOWN:
1078 struct reboot_args r;
1080 case SCO_AD_PWRDOWN:
1083 return (sys_reboot(td, &r));
1086 r.opt = RB_AUTOBOOT;
1087 return (sys_reboot(td, &r));
1092 case SCO_A_SETCONFIG:
1095 return EINVAL; /* XXX - TODO */
1101 ibcs2_sysfs(td, uap)
1103 struct ibcs2_sysfs_args *uap;
1105 #define IBCS2_GETFSIND 1
1106 #define IBCS2_GETFSTYP 2
1107 #define IBCS2_GETNFSTYP 3
1110 case IBCS2_GETFSIND:
1111 case IBCS2_GETFSTYP:
1112 case IBCS2_GETNFSTYP:
1115 return EINVAL; /* XXX - TODO */
1119 ibcs2_unlink(td, uap)
1121 struct ibcs2_unlink_args *uap;
1126 CHECKALTEXIST(td, uap->path, &path);
1127 error = kern_unlink(td, path, UIO_SYSSPACE);
1133 ibcs2_chdir(td, uap)
1135 struct ibcs2_chdir_args *uap;
1140 CHECKALTEXIST(td, uap->path, &path);
1141 error = kern_chdir(td, path, UIO_SYSSPACE);
1147 ibcs2_chmod(td, uap)
1149 struct ibcs2_chmod_args *uap;
1154 CHECKALTEXIST(td, uap->path, &path);
1155 error = kern_chmod(td, path, UIO_SYSSPACE, uap->mode);
1161 ibcs2_chown(td, uap)
1163 struct ibcs2_chown_args *uap;
1168 CHECKALTEXIST(td, uap->path, &path);
1169 error = kern_chown(td, path, UIO_SYSSPACE, uap->uid, uap->gid);
1175 ibcs2_rmdir(td, uap)
1177 struct ibcs2_rmdir_args *uap;
1182 CHECKALTEXIST(td, uap->path, &path);
1183 error = kern_rmdir(td, path, UIO_SYSSPACE);
1189 ibcs2_mkdir(td, uap)
1191 struct ibcs2_mkdir_args *uap;
1196 CHECKALTEXIST(td, uap->path, &path);
1197 error = kern_mkdir(td, path, UIO_SYSSPACE, uap->mode);
1203 ibcs2_symlink(td, uap)
1205 struct ibcs2_symlink_args *uap;
1210 CHECKALTEXIST(td, uap->path, &path);
1213 * Have to expand CHECKALTCREAT() so that 'path' can be freed on
1216 error = ibcs2_emul_find(td, uap->link, UIO_USERSPACE, &link, 1);
1221 error = kern_symlink(td, path, link, UIO_SYSSPACE);
1228 ibcs2_rename(td, uap)
1230 struct ibcs2_rename_args *uap;
1235 CHECKALTEXIST(td, uap->from, &from);
1238 * Have to expand CHECKALTCREAT() so that 'from' can be freed on
1241 error = ibcs2_emul_find(td, uap->to, UIO_USERSPACE, &to, 1);
1246 error = kern_rename(td, from, to, UIO_SYSSPACE);
1253 ibcs2_readlink(td, uap)
1255 struct ibcs2_readlink_args *uap;
1260 CHECKALTEXIST(td, uap->path, &path);
1261 error = kern_readlink(td, path, UIO_SYSSPACE, uap->buf, UIO_USERSPACE,