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
60 #include <sys/param.h>
61 #include <sys/systm.h>
62 #include <sys/dirent.h>
63 #include <sys/fcntl.h>
64 #include <sys/filedesc.h>
65 #include <sys/kernel.h>
68 #include <sys/malloc.h>
69 #include <sys/file.h> /* Must come after sys/malloc.h */
70 #include <sys/mutex.h>
71 #include <sys/reboot.h>
72 #include <sys/resourcevar.h>
74 #include <sys/sysctl.h>
75 #include <sys/sysproto.h>
77 #include <sys/times.h>
78 #include <sys/vnode.h>
81 #include <machine/cpu.h>
83 #include <i386/ibcs2/ibcs2_dirent.h>
84 #include <i386/ibcs2/ibcs2_signal.h>
85 #include <i386/ibcs2/ibcs2_proto.h>
86 #include <i386/ibcs2/ibcs2_unistd.h>
87 #include <i386/ibcs2/ibcs2_util.h>
88 #include <i386/ibcs2/ibcs2_utime.h>
89 #include <i386/ibcs2/ibcs2_xenix.h>
94 struct ibcs2_ulimit_args *uap;
99 #define IBCS2_GETFSIZE 1
100 #define IBCS2_SETFSIZE 2
101 #define IBCS2_GETPSIZE 3
102 #define IBCS2_GETDTABLESIZE 4
108 td->td_retval[0] = lim_cur(p, RLIMIT_FSIZE);
110 if (td->td_retval[0] == -1)
111 td->td_retval[0] = 0x7fffffff;
115 rl.rlim_max = lim_max(p, RLIMIT_FSIZE);
117 rl.rlim_cur = uap->newlimit;
118 error = kern_setrlimit(td, RLIMIT_FSIZE, &rl);
121 td->td_retval[0] = lim_cur(p, RLIMIT_FSIZE);
124 DPRINTF(("failed "));
129 td->td_retval[0] = lim_cur(p, RLIMIT_RSS); /* XXX */
132 case IBCS2_GETDTABLESIZE:
133 uap->cmd = IBCS2_SC_OPEN_MAX;
134 return ibcs2_sysconf(td, (struct ibcs2_sysconf_args *)uap);
140 #define IBCS2_WSTOPPED 0177
141 #define IBCS2_STOPCODE(sig) ((sig) << 8 | IBCS2_WSTOPPED)
145 struct ibcs2_wait_args *uap;
149 struct trapframe *tf = td->td_frame;
152 if ((tf->tf_eflags & (PSL_Z|PSL_PF|PSL_N|PSL_V))
153 == (PSL_Z|PSL_PF|PSL_N|PSL_V)) {
156 w4.status = (int *)uap->a2;
157 w4.options = uap->a3;
161 w4.status = (int *)uap->a1;
164 if ((error = wait4(td, &w4)) != 0)
166 if (w4.status) { /* this is real iBCS brain-damage */
167 error = copyin((caddr_t)w4.status, (caddr_t)&status,
173 * Convert status/signal result. We must validate the
174 * signal number stored in the exit status in case
175 * the user changed it between wait4()'s copyout()
178 if (WIFSTOPPED(status)) {
179 if (WSTOPSIG(status) <= 0 ||
180 WSTOPSIG(status) > IBCS2_SIGTBLSZ)
183 IBCS2_STOPCODE(bsd_to_ibcs2_sig[_SIG_IDX(WSTOPSIG(status))]);
184 } else if (WIFSIGNALED(status)) {
185 if (WTERMSIG(status) <= 0 ||
186 WTERMSIG(status) > IBCS2_SIGTBLSZ)
188 status = bsd_to_ibcs2_sig[_SIG_IDX(WTERMSIG(status))];
190 /* else exit status -- identical */
192 /* record result/status */
193 td->td_retval[1] = status;
194 return copyout((caddr_t)&status, (caddr_t)w4.status,
204 struct ibcs2_execv_args *uap;
206 struct execve_args ea;
207 caddr_t sg = stackgap_init();
209 CHECKALTEXIST(td, &sg, uap->path);
210 ea.fname = uap->path;
213 return execve(td, &ea);
217 ibcs2_execve(td, uap)
219 struct ibcs2_execve_args *uap;
221 caddr_t sg = stackgap_init();
222 CHECKALTEXIST(td, &sg, uap->path);
223 return execve(td, (struct execve_args *)uap);
227 ibcs2_umount(td, uap)
229 struct ibcs2_umount_args *uap;
231 struct unmount_args um;
235 return unmount(td, &um);
241 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(td, uap)
314 register struct ibcs2_getdents_args *uap;
316 register struct vnode *vp;
317 register caddr_t inp, buf; /* BSD-format */
318 register int len, reclen; /* BSD-format */
319 register caddr_t outp; /* iBCS2-format */
320 register int resid; /* iBCS2-format */
324 struct ibcs2_dirent idb;
325 off_t off; /* true file offset */
326 int buflen, error, eofflag;
327 u_long *cookies = NULL, *cookiep;
329 #define BSD_DIRENT(cp) ((struct dirent *)(cp))
330 #define IBCS2_RECLEN(reclen) (reclen + sizeof(u_short))
332 if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)) != 0)
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_EXCLUSIVE | LK_RETRY, td);
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_check_vnode_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;
455 VOP_UNLOCK(vp, 0, td);
458 free(cookies, M_TEMP);
466 struct ibcs2_read_args *uap;
468 register struct vnode *vp;
469 register caddr_t inp, buf; /* BSD-format */
470 register int len, reclen; /* BSD-format */
471 register caddr_t outp; /* iBCS2-format */
472 register int resid; /* iBCS2-format */
476 struct ibcs2_direct {
480 off_t off; /* true file offset */
481 int buflen, error, eofflag, size;
482 u_long *cookies = NULL, *cookiep;
485 if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)) != 0) {
487 return read(td, (struct read_args *)uap);
491 if ((fp->f_flag & FREAD) == 0) {
496 if (vp->v_type != VDIR) {
498 return read(td, (struct read_args *)uap);
502 if (vp->v_type != VDIR)
503 return read(td, (struct read_args *)uap);
505 DPRINTF(("ibcs2_read: read directory\n"));
507 buflen = max(DIRBLKSIZ, uap->nbytes);
508 buflen = min(buflen, MAXBSIZE);
509 buf = malloc(buflen, M_TEMP, M_WAITOK);
510 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td);
513 aiov.iov_len = buflen;
514 auio.uio_iov = &aiov;
516 auio.uio_rw = UIO_READ;
517 auio.uio_segflg = UIO_SYSSPACE;
519 auio.uio_resid = buflen;
520 auio.uio_offset = off;
523 free(cookies, M_TEMP);
528 error = mac_check_vnode_readdir(td->td_ucred, vp);
534 * First we read into the malloc'ed buffer, then
535 * we massage it into user space, one record at a time.
537 if ((error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, &ncookies, &cookies)) != 0) {
538 DPRINTF(("VOP_READDIR failed: %d\n", error));
544 if ((len = buflen - auio.uio_resid) <= 0)
551 * When using cookies, the vfs has the option of reading from
552 * a different offset than that supplied (UFS truncates the
553 * offset to a block boundary to make sure that it never reads
554 * partway through a directory entry, even if the directory
555 * has been compacted).
557 while (len > 0 && ncookies > 0 && *cookiep <= off) {
558 len -= BSD_DIRENT(inp)->d_reclen;
559 inp += BSD_DIRENT(inp)->d_reclen;
565 for (; len > 0 && resid > 0; len -= reclen) {
566 if (cookiep && ncookies == 0)
568 reclen = BSD_DIRENT(inp)->d_reclen;
570 printf("ibcs2_read: reclen=%d\n", reclen);
574 if (BSD_DIRENT(inp)->d_fileno == 0) {
575 inp += reclen; /* it is a hole; squish it out */
583 if (reclen > len || resid < sizeof(struct ibcs2_direct)) {
584 /* entry too big for buffer, so just stop */
589 * Massage in place to make an iBCS2-shaped dirent (otherwise
590 * we have to worry about touching user memory outside of
591 * the copyout() call).
593 * TODO: if length(filename) > 14, then break filename into
594 * multiple entries and set inode = 0xffff except last
596 idb.ino = (BSD_DIRENT(inp)->d_fileno > 0xfffe) ? 0xfffe :
597 BSD_DIRENT(inp)->d_fileno;
598 (void)copystr(BSD_DIRENT(inp)->d_name, idb.name, 14, &size);
599 bzero(idb.name + size, 14 - size);
600 if ((error = copyout(&idb, outp, sizeof(struct ibcs2_direct))) != 0)
602 /* advance past this real entry */
609 /* advance output past iBCS2-shaped entry */
610 outp += sizeof(struct ibcs2_direct);
611 resid -= sizeof(struct ibcs2_direct);
613 /* if we squished out the whole block, try again */
614 if (outp == uap->buf)
616 fp->f_offset = off; /* update the vnode offset */
618 td->td_retval[0] = uap->nbytes - resid;
620 VOP_UNLOCK(vp, 0, td);
623 free(cookies, M_TEMP);
631 struct ibcs2_mknod_args *uap;
633 caddr_t sg = stackgap_init();
635 CHECKALTCREAT(td, &sg, uap->path);
636 if (S_ISFIFO(uap->mode)) {
637 struct mkfifo_args ap;
640 return mkfifo(td, &ap);
642 struct mknod_args ap;
646 return mknod(td, &ap);
651 ibcs2_getgroups(td, uap)
653 struct ibcs2_getgroups_args *uap;
656 ibcs2_gid_t *iset = NULL;
657 struct getgroups_args sa;
659 caddr_t sg = stackgap_init();
661 if (uap->gidsetsize < 0)
663 if (uap->gidsetsize > NGROUPS_MAX)
664 uap->gidsetsize = NGROUPS_MAX;
665 sa.gidsetsize = uap->gidsetsize;
666 if (uap->gidsetsize) {
667 sa.gidset = stackgap_alloc(&sg, NGROUPS_MAX *
669 iset = stackgap_alloc(&sg, uap->gidsetsize *
670 sizeof(ibcs2_gid_t));
672 if ((error = getgroups(td, &sa)) != 0)
674 if (uap->gidsetsize == 0)
677 for (i = 0, gp = sa.gidset; i < td->td_retval[0]; i++)
678 iset[i] = (ibcs2_gid_t)*gp++;
679 if (td->td_retval[0] && (error = copyout((caddr_t)iset,
680 (caddr_t)uap->gidset,
681 sizeof(ibcs2_gid_t) * td->td_retval[0])))
687 ibcs2_setgroups(td, uap)
689 struct ibcs2_setgroups_args *uap;
693 struct setgroups_args sa;
695 caddr_t sg = stackgap_init();
697 if (uap->gidsetsize < 0 || uap->gidsetsize > NGROUPS_MAX)
699 sa.gidsetsize = uap->gidsetsize;
700 sa.gidset = stackgap_alloc(&sg, sa.gidsetsize *
702 iset = stackgap_alloc(&sg, sa.gidsetsize *
703 sizeof(ibcs2_gid_t *));
705 if ((error = copyin((caddr_t)uap->gidset, (caddr_t)iset,
706 sizeof(ibcs2_gid_t *) *
707 uap->gidsetsize)) != 0)
710 for (i = 0, gp = sa.gidset; i < sa.gidsetsize; i++)
711 *gp++ = (gid_t)iset[i];
712 return setgroups(td, &sa);
716 ibcs2_setuid(td, uap)
718 struct ibcs2_setuid_args *uap;
720 struct setuid_args sa;
722 sa.uid = (uid_t)uap->uid;
723 return setuid(td, &sa);
727 ibcs2_setgid(td, uap)
729 struct ibcs2_setgid_args *uap;
731 struct setgid_args sa;
733 sa.gid = (gid_t)uap->gid;
734 return setgid(td, &sa);
740 struct ibcs2_time_args *uap;
745 td->td_retval[0] = tv.tv_sec;
747 return copyout((caddr_t)&tv.tv_sec, (caddr_t)uap->tp,
748 sizeof(ibcs2_time_t));
754 ibcs2_pathconf(td, uap)
756 struct ibcs2_pathconf_args *uap;
758 uap->name++; /* iBCS2 _PC_* defines are offset by one */
759 return pathconf(td, (struct pathconf_args *)uap);
763 ibcs2_fpathconf(td, uap)
765 struct ibcs2_fpathconf_args *uap;
767 uap->name++; /* iBCS2 _PC_* defines are offset by one */
768 return fpathconf(td, (struct fpathconf_args *)uap);
772 ibcs2_sysconf(td, uap)
774 struct ibcs2_sysconf_args *uap;
776 int mib[2], value, len, error;
781 case IBCS2_SC_ARG_MAX:
782 mib[1] = KERN_ARGMAX;
785 case IBCS2_SC_CHILD_MAX:
787 td->td_retval[0] = lim_cur(td->td_proc, RLIMIT_NPROC);
791 case IBCS2_SC_CLK_TCK:
792 td->td_retval[0] = hz;
795 case IBCS2_SC_NGROUPS_MAX:
796 mib[1] = KERN_NGROUPS;
799 case IBCS2_SC_OPEN_MAX:
801 td->td_retval[0] = lim_cur(td->td_proc, RLIMIT_NOFILE);
805 case IBCS2_SC_JOB_CONTROL:
806 mib[1] = KERN_JOB_CONTROL;
809 case IBCS2_SC_SAVED_IDS:
810 mib[1] = KERN_SAVED_IDS;
813 case IBCS2_SC_VERSION:
814 mib[1] = KERN_POSIX1;
817 case IBCS2_SC_PASS_MAX:
818 td->td_retval[0] = 128; /* XXX - should we create PASS_MAX ? */
821 case IBCS2_SC_XOPEN_VERSION:
822 td->td_retval[0] = 2; /* XXX: What should that be? */
831 error = kernel_sysctl(td, mib, 2, &value, &len, NULL, 0, NULL);
834 td->td_retval[0] = value;
841 struct ibcs2_alarm_args *uap;
844 struct itimerval *itp, *oitp;
845 struct setitimer_args sa;
846 caddr_t sg = stackgap_init();
848 itp = stackgap_alloc(&sg, sizeof(*itp));
849 oitp = stackgap_alloc(&sg, sizeof(*oitp));
850 timevalclear(&itp->it_interval);
851 itp->it_value.tv_sec = uap->sec;
852 itp->it_value.tv_usec = 0;
854 sa.which = ITIMER_REAL;
857 error = setitimer(td, &sa);
860 if (oitp->it_value.tv_usec)
861 oitp->it_value.tv_sec++;
862 td->td_retval[0] = oitp->it_value.tv_sec;
869 struct ibcs2_times_args *uap;
872 struct getrusage_args ga;
875 caddr_t sg = stackgap_init();
876 struct rusage *ru = stackgap_alloc(&sg, sizeof(*ru));
877 #define CONVTCK(r) (r.tv_sec * hz + r.tv_usec / (1000000 / hz))
879 ga.who = RUSAGE_SELF;
881 error = getrusage(td, &ga);
884 tms.tms_utime = CONVTCK(ru->ru_utime);
885 tms.tms_stime = CONVTCK(ru->ru_stime);
887 ga.who = RUSAGE_CHILDREN;
888 error = getrusage(td, &ga);
891 tms.tms_cutime = CONVTCK(ru->ru_utime);
892 tms.tms_cstime = CONVTCK(ru->ru_stime);
895 td->td_retval[0] = CONVTCK(t);
897 return copyout((caddr_t)&tms, (caddr_t)uap->tp,
904 struct ibcs2_stime_args *uap;
907 struct settimeofday_args sa;
908 caddr_t sg = stackgap_init();
910 sa.tv = stackgap_alloc(&sg, sizeof(*sa.tv));
912 if ((error = copyin((caddr_t)uap->timep,
913 &(sa.tv->tv_sec), sizeof(long))) != 0)
916 if ((error = settimeofday(td, &sa)) != 0)
924 struct ibcs2_utime_args *uap;
927 struct utimes_args sa;
929 caddr_t sg = stackgap_init();
931 CHECKALTEXIST(td, &sg, uap->path);
934 struct ibcs2_utimbuf ubuf;
936 if ((error = copyin((caddr_t)uap->buf, (caddr_t)&ubuf,
939 sa.tptr = stackgap_alloc(&sg,
940 2 * sizeof(struct timeval *));
941 tp = (struct timeval *)sa.tptr;
942 tp->tv_sec = ubuf.actime;
945 tp->tv_sec = ubuf.modtime;
949 return utimes(td, &sa);
955 struct ibcs2_nice_args *uap;
958 struct setpriority_args sa;
960 sa.which = PRIO_PROCESS;
962 sa.prio = td->td_ksegrp->kg_nice + uap->incr;
963 if ((error = setpriority(td, &sa)) != 0)
965 td->td_retval[0] = td->td_ksegrp->kg_nice;
970 * iBCS2 getpgrp, setpgrp, setsid, and setpgid
974 ibcs2_pgrpsys(td, uap)
976 struct ibcs2_pgrpsys_args *uap;
978 struct proc *p = td->td_proc;
980 case 0: /* getpgrp */
982 td->td_retval[0] = p->p_pgrp->pg_id;
986 case 1: /* setpgrp */
988 struct setpgid_args sa;
994 td->td_retval[0] = p->p_pgrp->pg_id;
999 case 2: /* setpgid */
1001 struct setpgid_args sa;
1004 sa.pgid = uap->pgid;
1005 return setpgid(td, &sa);
1008 case 3: /* setsid */
1009 return setsid(td, NULL);
1017 * XXX - need to check for nested calls
1021 ibcs2_plock(td, uap)
1023 struct ibcs2_plock_args *uap;
1026 #define IBCS2_UNLOCK 0
1027 #define IBCS2_PROCLOCK 1
1028 #define IBCS2_TEXTLOCK 2
1029 #define IBCS2_DATALOCK 4
1032 if ((error = suser(td)) != 0)
1036 case IBCS2_PROCLOCK:
1037 case IBCS2_TEXTLOCK:
1038 case IBCS2_DATALOCK:
1039 return 0; /* XXX - TODO */
1045 ibcs2_uadmin(td, uap)
1047 struct ibcs2_uadmin_args *uap;
1049 #define SCO_A_REBOOT 1
1050 #define SCO_A_SHUTDOWN 2
1051 #define SCO_A_REMOUNT 4
1052 #define SCO_A_CLOCK 8
1053 #define SCO_A_SETCONFIG 128
1054 #define SCO_A_GETDEV 130
1056 #define SCO_AD_HALT 0
1057 #define SCO_AD_BOOT 1
1058 #define SCO_AD_IBOOT 2
1059 #define SCO_AD_PWRDOWN 3
1060 #define SCO_AD_PWRNAP 4
1062 #define SCO_AD_PANICBOOT 1
1064 #define SCO_AD_GETBMAJ 0
1065 #define SCO_AD_GETCMAJ 1
1072 case SCO_A_SHUTDOWN:
1074 struct reboot_args r;
1076 case SCO_AD_PWRDOWN:
1082 r.opt = RB_AUTOBOOT;
1088 case SCO_A_SETCONFIG:
1091 return EINVAL; /* XXX - TODO */
1097 ibcs2_sysfs(td, uap)
1099 struct ibcs2_sysfs_args *uap;
1101 #define IBCS2_GETFSIND 1
1102 #define IBCS2_GETFSTYP 2
1103 #define IBCS2_GETNFSTYP 3
1106 case IBCS2_GETFSIND:
1107 case IBCS2_GETFSTYP:
1108 case IBCS2_GETNFSTYP:
1111 return EINVAL; /* XXX - TODO */
1115 ibcs2_unlink(td, uap)
1117 struct ibcs2_unlink_args *uap;
1119 caddr_t sg = stackgap_init();
1121 CHECKALTEXIST(td, &sg, uap->path);
1122 return unlink(td, (struct unlink_args *)uap);
1126 ibcs2_chdir(td, uap)
1128 struct ibcs2_chdir_args *uap;
1130 caddr_t sg = stackgap_init();
1132 CHECKALTEXIST(td, &sg, uap->path);
1133 return chdir(td, (struct chdir_args *)uap);
1137 ibcs2_chmod(td, uap)
1139 struct ibcs2_chmod_args *uap;
1141 caddr_t sg = stackgap_init();
1143 CHECKALTEXIST(td, &sg, uap->path);
1144 return chmod(td, (struct chmod_args *)uap);
1148 ibcs2_chown(td, uap)
1150 struct ibcs2_chown_args *uap;
1152 caddr_t sg = stackgap_init();
1154 CHECKALTEXIST(td, &sg, uap->path);
1155 return chown(td, (struct chown_args *)uap);
1159 ibcs2_rmdir(td, uap)
1161 struct ibcs2_rmdir_args *uap;
1163 caddr_t sg = stackgap_init();
1165 CHECKALTEXIST(td, &sg, uap->path);
1166 return rmdir(td, (struct rmdir_args *)uap);
1170 ibcs2_mkdir(td, uap)
1172 struct ibcs2_mkdir_args *uap;
1174 caddr_t sg = stackgap_init();
1176 CHECKALTCREAT(td, &sg, uap->path);
1177 return mkdir(td, (struct mkdir_args *)uap);
1181 ibcs2_symlink(td, uap)
1183 struct ibcs2_symlink_args *uap;
1185 caddr_t sg = stackgap_init();
1187 CHECKALTEXIST(td, &sg, uap->path);
1188 CHECKALTCREAT(td, &sg, uap->link);
1189 return symlink(td, (struct symlink_args *)uap);
1193 ibcs2_rename(td, uap)
1195 struct ibcs2_rename_args *uap;
1197 caddr_t sg = stackgap_init();
1199 CHECKALTEXIST(td, &sg, uap->from);
1200 CHECKALTCREAT(td, &sg, uap->to);
1201 return rename(td, (struct rename_args *)uap);
1205 ibcs2_readlink(td, uap)
1207 struct ibcs2_readlink_args *uap;
1209 caddr_t sg = stackgap_init();
1211 CHECKALTEXIST(td, &sg, uap->path);
1212 return readlink(td, (struct readlink_args *) uap);