Deleted Added
full compact
svr4_misc.c (107839) svr4_misc.c (107849)
1/*
2 * Copyright (c) 1998 Mark Newton
3 * Copyright (c) 1994 Christos Zoulas
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 11 unchanged lines hidden (view full) ---

20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
1/*
2 * Copyright (c) 1998 Mark Newton
3 * Copyright (c) 1994 Christos Zoulas
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 11 unchanged lines hidden (view full) ---

20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * $FreeBSD: head/sys/compat/svr4/svr4_misc.c 107839 2002-12-13 22:41:47Z alfred $
28 * $FreeBSD: head/sys/compat/svr4/svr4_misc.c 107849 2002-12-14 01:56:26Z alfred $
29 */
30
31/*
32 * SVR4 compatibility module.
33 *
34 * SVR4 system calls that are implemented differently in BSD are
35 * handled here.
36 */

--- 90 unchanged lines hidden (view full) ---

127
128int
129svr4_sys_wait(td, uap)
130 struct thread *td;
131 struct svr4_sys_wait_args *uap;
132{
133 struct wait_args w4;
134 int error, *retval = td->td_retval, st, sig;
29 */
30
31/*
32 * SVR4 compatibility module.
33 *
34 * SVR4 system calls that are implemented differently in BSD are
35 * handled here.
36 */

--- 90 unchanged lines hidden (view full) ---

127
128int
129svr4_sys_wait(td, uap)
130 struct thread *td;
131 struct svr4_sys_wait_args *uap;
132{
133 struct wait_args w4;
134 int error, *retval = td->td_retval, st, sig;
135 size_t sz = sizeof(*SCARG(&w4, status));
135 size_t sz = sizeof(*w4.status);
136
136
137 SCARG(&w4, rusage) = NULL;
138 SCARG(&w4, options) = 0;
137 w4.rusage = NULL;
138 w4.options = 0;
139
139
140 if (SCARG(uap, status) == NULL) {
140 if (uap->status == NULL) {
141 caddr_t sg = stackgap_init();
142
141 caddr_t sg = stackgap_init();
142
143 SCARG(&w4, status) = stackgap_alloc(&sg, sz);
143 w4.status = stackgap_alloc(&sg, sz);
144 }
145 else
144 }
145 else
146 SCARG(&w4, status) = SCARG(uap, status);
146 w4.status = uap->status;
147
147
148 SCARG(&w4, pid) = WAIT_ANY;
148 w4.pid = WAIT_ANY;
149
150 if ((error = wait4(td, &w4)) != 0)
151 return error;
152
149
150 if ((error = wait4(td, &w4)) != 0)
151 return error;
152
153 if ((error = copyin(SCARG(&w4, status), &st, sizeof(st))) != 0)
153 if ((error = copyin(w4.status, &st, sizeof(st))) != 0)
154 return error;
155
156 if (WIFSIGNALED(st)) {
157 sig = WTERMSIG(st);
158 if (sig >= 0 && sig < NSIG)
159 st = (st & ~0177) | SVR4_BSD2SVR4_SIG(sig);
160 } else if (WIFSTOPPED(st)) {
161 sig = WSTOPSIG(st);
162 if (sig >= 0 && sig < NSIG)
163 st = (st & ~0xff00) | (SVR4_BSD2SVR4_SIG(sig) << 8);
164 }
165
166 /*
167 * It looks like wait(2) on svr4/solaris/2.4 returns
168 * the status in retval[1], and the pid on retval[0].
169 */
170 retval[1] = st;
171
154 return error;
155
156 if (WIFSIGNALED(st)) {
157 sig = WTERMSIG(st);
158 if (sig >= 0 && sig < NSIG)
159 st = (st & ~0177) | SVR4_BSD2SVR4_SIG(sig);
160 } else if (WIFSTOPPED(st)) {
161 sig = WSTOPSIG(st);
162 if (sig >= 0 && sig < NSIG)
163 st = (st & ~0xff00) | (SVR4_BSD2SVR4_SIG(sig) << 8);
164 }
165
166 /*
167 * It looks like wait(2) on svr4/solaris/2.4 returns
168 * the status in retval[1], and the pid on retval[0].
169 */
170 retval[1] = st;
171
172 if (SCARG(uap, status))
173 if ((error = copyout(&st, SCARG(uap, status), sizeof(st))) != 0)
172 if (uap->status)
173 if ((error = copyout(&st, uap->status, sizeof(st))) != 0)
174 return error;
175
176 return 0;
177}
178
179int
180svr4_sys_execv(td, uap)
181 struct thread *td;
182 struct svr4_sys_execv_args *uap;
183{
184 struct execve_args ap;
185 caddr_t sg;
186
187 sg = stackgap_init();
174 return error;
175
176 return 0;
177}
178
179int
180svr4_sys_execv(td, uap)
181 struct thread *td;
182 struct svr4_sys_execv_args *uap;
183{
184 struct execve_args ap;
185 caddr_t sg;
186
187 sg = stackgap_init();
188 CHECKALTEXIST(td, &sg, SCARG(uap, path));
188 CHECKALTEXIST(td, &sg, uap->path);
189
189
190 SCARG(&ap, fname) = SCARG(uap, path);
191 SCARG(&ap, argv) = SCARG(uap, argp);
192 SCARG(&ap, envv) = NULL;
190 ap.fname = uap->path;
191 ap.argv = uap->argp;
192 ap.envv = NULL;
193
194 return execve(td, &ap);
195}
196
197int
198svr4_sys_execve(td, uap)
199 struct thread *td;
200 struct svr4_sys_execve_args *uap;
201{
202 struct execve_args ap;
203 caddr_t sg;
204
205 sg = stackgap_init();
206 CHECKALTEXIST(td, &sg, uap->path);
207
193
194 return execve(td, &ap);
195}
196
197int
198svr4_sys_execve(td, uap)
199 struct thread *td;
200 struct svr4_sys_execve_args *uap;
201{
202 struct execve_args ap;
203 caddr_t sg;
204
205 sg = stackgap_init();
206 CHECKALTEXIST(td, &sg, uap->path);
207
208 SCARG(&ap, fname) = SCARG(uap, path);
209 SCARG(&ap, argv) = SCARG(uap, argp);
210 SCARG(&ap, envv) = SCARG(uap, envp);
208 ap.fname = uap->path;
209 ap.argv = uap->argp;
210 ap.envv = uap->envp;
211
212 return execve(td, &ap);
213}
214
215int
216svr4_sys_time(td, v)
217 struct thread *td;
218 struct svr4_sys_time_args *v;
219{
220 struct svr4_sys_time_args *uap = v;
221 int error = 0;
222 struct timeval tv;
223
224 microtime(&tv);
211
212 return execve(td, &ap);
213}
214
215int
216svr4_sys_time(td, v)
217 struct thread *td;
218 struct svr4_sys_time_args *v;
219{
220 struct svr4_sys_time_args *uap = v;
221 int error = 0;
222 struct timeval tv;
223
224 microtime(&tv);
225 if (SCARG(uap, t))
226 error = copyout(&tv.tv_sec, SCARG(uap, t),
227 sizeof(*(SCARG(uap, t))));
225 if (uap->t)
226 error = copyout(&tv.tv_sec, uap->t,
227 sizeof(*(uap->t)));
228 td->td_retval[0] = (int) tv.tv_sec;
229
230 return error;
231}
232
233
234/*
235 * Read SVR4-style directory entries. We suck them into kernel space so

--- 20 unchanged lines hidden (view full) ---

256 struct vattr va;
257 off_t off;
258 struct svr4_dirent64 svr4_dirent;
259 int buflen, error, eofflag, nbytes, justone;
260 u_long *cookies = NULL, *cookiep;
261 int ncookies;
262
263 DPRINTF(("svr4_sys_getdents64(%d, *, %d)\n",
228 td->td_retval[0] = (int) tv.tv_sec;
229
230 return error;
231}
232
233
234/*
235 * Read SVR4-style directory entries. We suck them into kernel space so

--- 20 unchanged lines hidden (view full) ---

256 struct vattr va;
257 off_t off;
258 struct svr4_dirent64 svr4_dirent;
259 int buflen, error, eofflag, nbytes, justone;
260 u_long *cookies = NULL, *cookiep;
261 int ncookies;
262
263 DPRINTF(("svr4_sys_getdents64(%d, *, %d)\n",
264 SCARG(uap, fd), SCARG(uap, nbytes)));
265 if ((error = getvnode(td->td_proc->p_fd, SCARG(uap, fd), &fp)) != 0) {
264 uap->fd, uap->nbytes));
265 if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)) != 0) {
266 return (error);
267 }
268
269 if ((fp->f_flag & FREAD) == 0) {
270 fdrop(fp, td);
271 return (EBADF);
272 }
273

--- 4 unchanged lines hidden (view full) ---

278 return (EINVAL);
279 }
280
281 if ((error = VOP_GETATTR(vp, &va, td->td_ucred, td))) {
282 fdrop(fp, td);
283 return error;
284 }
285
266 return (error);
267 }
268
269 if ((fp->f_flag & FREAD) == 0) {
270 fdrop(fp, td);
271 return (EBADF);
272 }
273

--- 4 unchanged lines hidden (view full) ---

278 return (EINVAL);
279 }
280
281 if ((error = VOP_GETATTR(vp, &va, td->td_ucred, td))) {
282 fdrop(fp, td);
283 return error;
284 }
285
286 nbytes = SCARG(uap, nbytes);
286 nbytes = uap->nbytes;
287 if (nbytes == 1) {
288 nbytes = sizeof (struct svr4_dirent64);
289 justone = 1;
290 }
291 else
292 justone = 0;
293
294 off = fp->f_offset;

--- 26 unchanged lines hidden (view full) ---

321
322 error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag,
323 &ncookies, &cookies);
324 if (error) {
325 goto out;
326 }
327
328 inp = buf;
287 if (nbytes == 1) {
288 nbytes = sizeof (struct svr4_dirent64);
289 justone = 1;
290 }
291 else
292 justone = 0;
293
294 off = fp->f_offset;

--- 26 unchanged lines hidden (view full) ---

321
322 error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag,
323 &ncookies, &cookies);
324 if (error) {
325 goto out;
326 }
327
328 inp = buf;
329 outp = (caddr_t) SCARG(uap, dp);
329 outp = (caddr_t) uap->dp;
330 resid = nbytes;
331 if ((len = buflen - auio.uio_resid) <= 0) {
332 goto eof;
333 }
334
335 cookiep = cookies;
336
337 if (cookies) {

--- 61 unchanged lines hidden (view full) ---

399 off += reclen;
400 outp += svr4reclen;
401 resid -= svr4reclen;
402 len -= reclen;
403 if (justone)
404 break;
405 }
406
330 resid = nbytes;
331 if ((len = buflen - auio.uio_resid) <= 0) {
332 goto eof;
333 }
334
335 cookiep = cookies;
336
337 if (cookies) {

--- 61 unchanged lines hidden (view full) ---

399 off += reclen;
400 outp += svr4reclen;
401 resid -= svr4reclen;
402 len -= reclen;
403 if (justone)
404 break;
405 }
406
407 if (outp == (caddr_t) SCARG(uap, dp))
407 if (outp == (caddr_t) uap->dp)
408 goto again;
409 fp->f_offset = off;
410
411 if (justone)
412 nbytes = resid + svr4reclen;
413
414eof:
415 td->td_retval[0] = nbytes - resid;

--- 22 unchanged lines hidden (view full) ---

438 struct uio auio;
439 struct iovec aiov;
440 struct svr4_dirent idb;
441 off_t off; /* true file offset */
442 int buflen, error, eofflag;
443 u_long *cookiebuf = NULL, *cookie;
444 int ncookies = 0, *retval = td->td_retval;
445
408 goto again;
409 fp->f_offset = off;
410
411 if (justone)
412 nbytes = resid + svr4reclen;
413
414eof:
415 td->td_retval[0] = nbytes - resid;

--- 22 unchanged lines hidden (view full) ---

438 struct uio auio;
439 struct iovec aiov;
440 struct svr4_dirent idb;
441 off_t off; /* true file offset */
442 int buflen, error, eofflag;
443 u_long *cookiebuf = NULL, *cookie;
444 int ncookies = 0, *retval = td->td_retval;
445
446 if ((error = getvnode(td->td_proc->p_fd, SCARG(uap, fd), &fp)) != 0)
446 if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)) != 0)
447 return (error);
448
449 if ((fp->f_flag & FREAD) == 0) {
450 fdrop(fp, td);
451 return (EBADF);
452 }
453
454 vp = (struct vnode *)fp->f_data;
455 if (vp->v_type != VDIR) {
456 fdrop(fp, td);
457 return (EINVAL);
458 }
459
447 return (error);
448
449 if ((fp->f_flag & FREAD) == 0) {
450 fdrop(fp, td);
451 return (EBADF);
452 }
453
454 vp = (struct vnode *)fp->f_data;
455 if (vp->v_type != VDIR) {
456 fdrop(fp, td);
457 return (EINVAL);
458 }
459
460 buflen = min(MAXBSIZE, SCARG(uap, nbytes));
460 buflen = min(MAXBSIZE, uap->nbytes);
461 buf = malloc(buflen, M_TEMP, M_WAITOK);
462 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td);
463 off = fp->f_offset;
464again:
465 aiov.iov_base = buf;
466 aiov.iov_len = buflen;
467 auio.uio_iov = &aiov;
468 auio.uio_iovcnt = 1;

--- 15 unchanged lines hidden (view full) ---

484 */
485 error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, &ncookies,
486 &cookiebuf);
487 if (error) {
488 goto out;
489 }
490
491 inp = buf;
461 buf = malloc(buflen, M_TEMP, M_WAITOK);
462 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td);
463 off = fp->f_offset;
464again:
465 aiov.iov_base = buf;
466 aiov.iov_len = buflen;
467 auio.uio_iov = &aiov;
468 auio.uio_iovcnt = 1;

--- 15 unchanged lines hidden (view full) ---

484 */
485 error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, &ncookies,
486 &cookiebuf);
487 if (error) {
488 goto out;
489 }
490
491 inp = buf;
492 outp = SCARG(uap, buf);
493 resid = SCARG(uap, nbytes);
492 outp = uap->buf;
493 resid = uap->nbytes;
494 if ((len = buflen - auio.uio_resid) == 0)
495 goto eof;
496
497 for (cookie = cookiebuf; len > 0; len -= reclen) {
498 bdp = (struct dirent *)inp;
499 reclen = bdp->d_reclen;
500 if (reclen & 3)
501 panic("svr4_sys_getdents64: bad reclen");

--- 27 unchanged lines hidden (view full) ---

529 /* advance past this real entry */
530 inp += reclen;
531 /* advance output past SVR4-shaped entry */
532 outp += svr4_reclen;
533 resid -= svr4_reclen;
534 }
535
536 /* if we squished out the whole block, try again */
494 if ((len = buflen - auio.uio_resid) == 0)
495 goto eof;
496
497 for (cookie = cookiebuf; len > 0; len -= reclen) {
498 bdp = (struct dirent *)inp;
499 reclen = bdp->d_reclen;
500 if (reclen & 3)
501 panic("svr4_sys_getdents64: bad reclen");

--- 27 unchanged lines hidden (view full) ---

529 /* advance past this real entry */
530 inp += reclen;
531 /* advance output past SVR4-shaped entry */
532 outp += svr4_reclen;
533 resid -= svr4_reclen;
534 }
535
536 /* if we squished out the whole block, try again */
537 if (outp == SCARG(uap, buf))
537 if (outp == uap->buf)
538 goto again;
539 fp->f_offset = off; /* update the vnode offset */
540
541eof:
538 goto again;
539 fp->f_offset = off; /* update the vnode offset */
540
541eof:
542 *retval = SCARG(uap, nbytes) - resid;
542 *retval = uap->nbytes - resid;
543out:
544 VOP_UNLOCK(vp, 0, td);
545 fdrop(fp, td);
546 if (cookiebuf)
547 free(cookiebuf, M_TEMP);
548 free(buf, M_TEMP);
549 return error;
550}

--- 7 unchanged lines hidden (view full) ---

558 struct mmap_args mm;
559 int *retval;
560
561 retval = td->td_retval;
562#define _MAP_NEW 0x80000000
563 /*
564 * Verify the arguments.
565 */
543out:
544 VOP_UNLOCK(vp, 0, td);
545 fdrop(fp, td);
546 if (cookiebuf)
547 free(cookiebuf, M_TEMP);
548 free(buf, M_TEMP);
549 return error;
550}

--- 7 unchanged lines hidden (view full) ---

558 struct mmap_args mm;
559 int *retval;
560
561 retval = td->td_retval;
562#define _MAP_NEW 0x80000000
563 /*
564 * Verify the arguments.
565 */
566 if (SCARG(uap, prot) & ~(PROT_READ | PROT_WRITE | PROT_EXEC))
566 if (uap->prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC))
567 return EINVAL; /* XXX still needed? */
568
567 return EINVAL; /* XXX still needed? */
568
569 if (SCARG(uap, len) == 0)
569 if (uap->len == 0)
570 return EINVAL;
571
570 return EINVAL;
571
572 SCARG(&mm, prot) = SCARG(uap, prot);
573 SCARG(&mm, len) = SCARG(uap, len);
574 SCARG(&mm, flags) = SCARG(uap, flags) & ~_MAP_NEW;
575 SCARG(&mm, fd) = SCARG(uap, fd);
576 SCARG(&mm, addr) = SCARG(uap, addr);
577 SCARG(&mm, pos) = SCARG(uap, pos);
572 mm.prot = uap->prot;
573 mm.len = uap->len;
574 mm.flags = uap->flags & ~_MAP_NEW;
575 mm.fd = uap->fd;
576 mm.addr = uap->addr;
577 mm.pos = uap->pos;
578
579 return mmap(td, &mm);
580}
581
582int
583svr4_sys_mmap64(td, uap)
584 struct thread *td;
585 struct svr4_sys_mmap64_args *uap;
586{
587 struct mmap_args mm;
588 void *rp;
589
590#define _MAP_NEW 0x80000000
591 /*
592 * Verify the arguments.
593 */
578
579 return mmap(td, &mm);
580}
581
582int
583svr4_sys_mmap64(td, uap)
584 struct thread *td;
585 struct svr4_sys_mmap64_args *uap;
586{
587 struct mmap_args mm;
588 void *rp;
589
590#define _MAP_NEW 0x80000000
591 /*
592 * Verify the arguments.
593 */
594 if (SCARG(uap, prot) & ~(PROT_READ | PROT_WRITE | PROT_EXEC))
594 if (uap->prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC))
595 return EINVAL; /* XXX still needed? */
596
595 return EINVAL; /* XXX still needed? */
596
597 if (SCARG(uap, len) == 0)
597 if (uap->len == 0)
598 return EINVAL;
599
598 return EINVAL;
599
600 SCARG(&mm, prot) = SCARG(uap, prot);
601 SCARG(&mm, len) = SCARG(uap, len);
602 SCARG(&mm, flags) = SCARG(uap, flags) & ~_MAP_NEW;
603 SCARG(&mm, fd) = SCARG(uap, fd);
604 SCARG(&mm, addr) = SCARG(uap, addr);
605 SCARG(&mm, pos) = SCARG(uap, pos);
600 mm.prot = uap->prot;
601 mm.len = uap->len;
602 mm.flags = uap->flags & ~_MAP_NEW;
603 mm.fd = uap->fd;
604 mm.addr = uap->addr;
605 mm.pos = uap->pos;
606
607 rp = (void *) round_page((vm_offset_t)(td->td_proc->p_vmspace->vm_daddr + maxdsiz));
606
607 rp = (void *) round_page((vm_offset_t)(td->td_proc->p_vmspace->vm_daddr + maxdsiz));
608 if ((SCARG(&mm, flags) & MAP_FIXED) == 0 &&
609 SCARG(&mm, addr) != 0 && (void *)SCARG(&mm, addr) < rp)
610 SCARG(&mm, addr) = rp;
608 if ((mm.flags & MAP_FIXED) == 0 &&
609 mm.addr != 0 && (void *)mm.addr < rp)
610 mm.addr = rp;
611
612 return mmap(td, &mm);
613}
614
615
616int
617svr4_sys_fchroot(td, uap)
618 struct thread *td;
619 struct svr4_sys_fchroot_args *uap;
620{
621 struct filedesc *fdp = td->td_proc->p_fd;
622 struct vnode *vp, *vpold;
623 struct file *fp;
624 int error;
625
626 if ((error = suser(td)) != 0)
627 return error;
611
612 return mmap(td, &mm);
613}
614
615
616int
617svr4_sys_fchroot(td, uap)
618 struct thread *td;
619 struct svr4_sys_fchroot_args *uap;
620{
621 struct filedesc *fdp = td->td_proc->p_fd;
622 struct vnode *vp, *vpold;
623 struct file *fp;
624 int error;
625
626 if ((error = suser(td)) != 0)
627 return error;
628 if ((error = getvnode(fdp, SCARG(uap, fd), &fp)) != 0)
628 if ((error = getvnode(fdp, uap->fd, &fp)) != 0)
629 return error;
630 vp = (struct vnode *) fp->f_data;
631 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td);
632 if (vp->v_type != VDIR)
633 error = ENOTDIR;
634 else
635 error = VOP_ACCESS(vp, VEXEC, td->td_ucred, td);
636 VOP_UNLOCK(vp, 0, td);

--- 22 unchanged lines hidden (view full) ---

659 svr4_dev_t dev;
660{
661 caddr_t sg = stackgap_init();
662
663 CHECKALTEXIST(td, &sg, path);
664
665 if (S_ISFIFO(mode)) {
666 struct mkfifo_args ap;
629 return error;
630 vp = (struct vnode *) fp->f_data;
631 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td);
632 if (vp->v_type != VDIR)
633 error = ENOTDIR;
634 else
635 error = VOP_ACCESS(vp, VEXEC, td->td_ucred, td);
636 VOP_UNLOCK(vp, 0, td);

--- 22 unchanged lines hidden (view full) ---

659 svr4_dev_t dev;
660{
661 caddr_t sg = stackgap_init();
662
663 CHECKALTEXIST(td, &sg, path);
664
665 if (S_ISFIFO(mode)) {
666 struct mkfifo_args ap;
667 SCARG(&ap, path) = path;
668 SCARG(&ap, mode) = mode;
667 ap.path = path;
668 ap.mode = mode;
669 return mkfifo(td, &ap);
670 } else {
671 struct mknod_args ap;
669 return mkfifo(td, &ap);
670 } else {
671 struct mknod_args ap;
672 SCARG(&ap, path) = path;
673 SCARG(&ap, mode) = mode;
674 SCARG(&ap, dev) = dev;
672 ap.path = path;
673 ap.mode = mode;
674 ap.dev = dev;
675 return mknod(td, &ap);
676 }
677}
678
679
680int
681svr4_sys_mknod(td, uap)
682 register struct thread *td;
683 struct svr4_sys_mknod_args *uap;
684{
685 int *retval = td->td_retval;
686 return svr4_mknod(td, retval,
675 return mknod(td, &ap);
676 }
677}
678
679
680int
681svr4_sys_mknod(td, uap)
682 register struct thread *td;
683 struct svr4_sys_mknod_args *uap;
684{
685 int *retval = td->td_retval;
686 return svr4_mknod(td, retval,
687 SCARG(uap, path), SCARG(uap, mode),
688 (svr4_dev_t)svr4_to_bsd_odev_t(SCARG(uap, dev)));
687 uap->path, uap->mode,
688 (svr4_dev_t)svr4_to_bsd_odev_t(uap->dev));
689}
690
691
692int
693svr4_sys_xmknod(td, uap)
694 struct thread *td;
695 struct svr4_sys_xmknod_args *uap;
696{
697 int *retval = td->td_retval;
698 return svr4_mknod(td, retval,
689}
690
691
692int
693svr4_sys_xmknod(td, uap)
694 struct thread *td;
695 struct svr4_sys_xmknod_args *uap;
696{
697 int *retval = td->td_retval;
698 return svr4_mknod(td, retval,
699 SCARG(uap, path), SCARG(uap, mode),
700 (svr4_dev_t)svr4_to_bsd_dev_t(SCARG(uap, dev)));
699 uap->path, uap->mode,
700 (svr4_dev_t)svr4_to_bsd_dev_t(uap->dev));
701}
702
703
704int
705svr4_sys_vhangup(td, uap)
706 struct thread *td;
707 struct svr4_sys_vhangup_args *uap;
708{

--- 5 unchanged lines hidden (view full) ---

714svr4_sys_sysconfig(td, uap)
715 struct thread *td;
716 struct svr4_sys_sysconfig_args *uap;
717{
718 int *retval;
719
720 retval = &(td->td_retval[0]);
721
701}
702
703
704int
705svr4_sys_vhangup(td, uap)
706 struct thread *td;
707 struct svr4_sys_vhangup_args *uap;
708{

--- 5 unchanged lines hidden (view full) ---

714svr4_sys_sysconfig(td, uap)
715 struct thread *td;
716 struct svr4_sys_sysconfig_args *uap;
717{
718 int *retval;
719
720 retval = &(td->td_retval[0]);
721
722 switch (SCARG(uap, name)) {
722 switch (uap->name) {
723 case SVR4_CONFIG_UNUSED:
724 *retval = 0;
725 break;
726 case SVR4_CONFIG_NGROUPS:
727 *retval = NGROUPS_MAX;
728 break;
729 case SVR4_CONFIG_CHILD_MAX:
730 *retval = maxproc;

--- 87 unchanged lines hidden (view full) ---

818 struct svr4_sys_break_args *uap;
819{
820 struct proc *p = td->td_proc;
821 struct vmspace *vm = p->p_vmspace;
822 vm_offset_t new, old, base, ns;
823 int rv;
824
825 base = round_page((vm_offset_t) vm->vm_daddr);
723 case SVR4_CONFIG_UNUSED:
724 *retval = 0;
725 break;
726 case SVR4_CONFIG_NGROUPS:
727 *retval = NGROUPS_MAX;
728 break;
729 case SVR4_CONFIG_CHILD_MAX:
730 *retval = maxproc;

--- 87 unchanged lines hidden (view full) ---

818 struct svr4_sys_break_args *uap;
819{
820 struct proc *p = td->td_proc;
821 struct vmspace *vm = p->p_vmspace;
822 vm_offset_t new, old, base, ns;
823 int rv;
824
825 base = round_page((vm_offset_t) vm->vm_daddr);
826 ns = (vm_offset_t)SCARG(uap, nsize);
826 ns = (vm_offset_t)uap->nsize;
827 new = round_page(ns);
828 /* For p_rlimit. */
829 mtx_assert(&Giant, MA_OWNED);
830 if (new > base) {
831 if ((new - base) > (unsigned) td->td_proc->p_rlimit[RLIMIT_DATA].rlim_cur) {
832 return ENOMEM;
833 }
834 if (new >= VM_MAXUSER_ADDRESS) {

--- 50 unchanged lines hidden (view full) ---

885 struct timeval t;
886 struct rusage *ru;
887 struct rusage r;
888 struct getrusage_args ga;
889
890 caddr_t sg = stackgap_init();
891 ru = stackgap_alloc(&sg, sizeof(struct rusage));
892
827 new = round_page(ns);
828 /* For p_rlimit. */
829 mtx_assert(&Giant, MA_OWNED);
830 if (new > base) {
831 if ((new - base) > (unsigned) td->td_proc->p_rlimit[RLIMIT_DATA].rlim_cur) {
832 return ENOMEM;
833 }
834 if (new >= VM_MAXUSER_ADDRESS) {

--- 50 unchanged lines hidden (view full) ---

885 struct timeval t;
886 struct rusage *ru;
887 struct rusage r;
888 struct getrusage_args ga;
889
890 caddr_t sg = stackgap_init();
891 ru = stackgap_alloc(&sg, sizeof(struct rusage));
892
893 SCARG(&ga, who) = RUSAGE_SELF;
894 SCARG(&ga, rusage) = ru;
893 ga.who = RUSAGE_SELF;
894 ga.rusage = ru;
895
896 error = getrusage(td, &ga);
897 if (error)
898 return error;
899
900 if ((error = copyin(ru, &r, sizeof r)) != 0)
901 return error;
902
903 tms.tms_utime = timeval_to_clock_t(&r.ru_utime);
904 tms.tms_stime = timeval_to_clock_t(&r.ru_stime);
905
895
896 error = getrusage(td, &ga);
897 if (error)
898 return error;
899
900 if ((error = copyin(ru, &r, sizeof r)) != 0)
901 return error;
902
903 tms.tms_utime = timeval_to_clock_t(&r.ru_utime);
904 tms.tms_stime = timeval_to_clock_t(&r.ru_stime);
905
906 SCARG(&ga, who) = RUSAGE_CHILDREN;
906 ga.who = RUSAGE_CHILDREN;
907 error = getrusage(td, &ga);
908 if (error)
909 return error;
910
911 if ((error = copyin(ru, &r, sizeof r)) != 0)
912 return error;
913
914 tms.tms_cutime = timeval_to_clock_t(&r.ru_utime);
915 tms.tms_cstime = timeval_to_clock_t(&r.ru_stime);
916
917 microtime(&t);
918 *retval = timeval_to_clock_t(&t);
919
907 error = getrusage(td, &ga);
908 if (error)
909 return error;
910
911 if ((error = copyin(ru, &r, sizeof r)) != 0)
912 return error;
913
914 tms.tms_cutime = timeval_to_clock_t(&r.ru_utime);
915 tms.tms_cstime = timeval_to_clock_t(&r.ru_stime);
916
917 microtime(&t);
918 *retval = timeval_to_clock_t(&t);
919
920 return copyout(&tms, SCARG(uap, tp), sizeof(tms));
920 return copyout(&tms, uap->tp, sizeof(tms));
921}
922
923
924int
925svr4_sys_ulimit(td, uap)
926 struct thread *td;
927 struct svr4_sys_ulimit_args *uap;
928{
929 int *retval = td->td_retval;
930
921}
922
923
924int
925svr4_sys_ulimit(td, uap)
926 struct thread *td;
927 struct svr4_sys_ulimit_args *uap;
928{
929 int *retval = td->td_retval;
930
931 switch (SCARG(uap, cmd)) {
931 switch (uap->cmd) {
932 case SVR4_GFILLIM:
933 /* For p_rlimit below. */
934 mtx_assert(&Giant, MA_OWNED);
935 *retval = td->td_proc->p_rlimit[RLIMIT_FSIZE].rlim_cur / 512;
936 if (*retval == -1)
937 *retval = 0x7fffffff;
938 return 0;
939
940 case SVR4_SFILLIM:
941 {
942 int error;
943 struct __setrlimit_args srl;
944 struct rlimit krl;
945 caddr_t sg = stackgap_init();
946 struct rlimit *url = (struct rlimit *)
947 stackgap_alloc(&sg, sizeof *url);
948
932 case SVR4_GFILLIM:
933 /* For p_rlimit below. */
934 mtx_assert(&Giant, MA_OWNED);
935 *retval = td->td_proc->p_rlimit[RLIMIT_FSIZE].rlim_cur / 512;
936 if (*retval == -1)
937 *retval = 0x7fffffff;
938 return 0;
939
940 case SVR4_SFILLIM:
941 {
942 int error;
943 struct __setrlimit_args srl;
944 struct rlimit krl;
945 caddr_t sg = stackgap_init();
946 struct rlimit *url = (struct rlimit *)
947 stackgap_alloc(&sg, sizeof *url);
948
949 krl.rlim_cur = SCARG(uap, newlimit) * 512;
949 krl.rlim_cur = uap->newlimit * 512;
950 mtx_assert(&Giant, MA_OWNED);
951 krl.rlim_max = td->td_proc->p_rlimit[RLIMIT_FSIZE].rlim_max;
952
953 error = copyout(&krl, url, sizeof(*url));
954 if (error)
955 return error;
956
950 mtx_assert(&Giant, MA_OWNED);
951 krl.rlim_max = td->td_proc->p_rlimit[RLIMIT_FSIZE].rlim_max;
952
953 error = copyout(&krl, url, sizeof(*url));
954 if (error)
955 return error;
956
957 SCARG(&srl, which) = RLIMIT_FSIZE;
958 SCARG(&srl, rlp) = url;
957 srl.which = RLIMIT_FSIZE;
958 srl.rlp = url;
959
960 error = setrlimit(td, &srl);
961 if (error)
962 return error;
963
964 mtx_assert(&Giant, MA_OWNED);
965 *retval = td->td_proc->p_rlimit[RLIMIT_FSIZE].rlim_cur;
966 if (*retval == -1)

--- 48 unchanged lines hidden (view full) ---

1015int
1016svr4_sys_pgrpsys(td, uap)
1017 struct thread *td;
1018 struct svr4_sys_pgrpsys_args *uap;
1019{
1020 int *retval = td->td_retval;
1021 struct proc *p = td->td_proc;
1022
959
960 error = setrlimit(td, &srl);
961 if (error)
962 return error;
963
964 mtx_assert(&Giant, MA_OWNED);
965 *retval = td->td_proc->p_rlimit[RLIMIT_FSIZE].rlim_cur;
966 if (*retval == -1)

--- 48 unchanged lines hidden (view full) ---

1015int
1016svr4_sys_pgrpsys(td, uap)
1017 struct thread *td;
1018 struct svr4_sys_pgrpsys_args *uap;
1019{
1020 int *retval = td->td_retval;
1021 struct proc *p = td->td_proc;
1022
1023 switch (SCARG(uap, cmd)) {
1023 switch (uap->cmd) {
1024 case 1: /* setpgrp() */
1025 /*
1026 * SVR4 setpgrp() (which takes no arguments) has the
1027 * semantics that the session ID is also created anew, so
1028 * in almost every sense, setpgrp() is identical to
1029 * setsid() for SVR4. (Under BSD, the difference is that
1030 * a setpgid(0,0) will not create a new session.)
1031 */
1032 setsid(td, NULL);
1033 /*FALLTHROUGH*/
1034
1035 case 0: /* getpgrp() */
1036 PROC_LOCK(p);
1037 *retval = p->p_pgrp->pg_id;
1038 PROC_UNLOCK(p);
1039 return 0;
1040
1041 case 2: /* getsid(pid) */
1024 case 1: /* setpgrp() */
1025 /*
1026 * SVR4 setpgrp() (which takes no arguments) has the
1027 * semantics that the session ID is also created anew, so
1028 * in almost every sense, setpgrp() is identical to
1029 * setsid() for SVR4. (Under BSD, the difference is that
1030 * a setpgid(0,0) will not create a new session.)
1031 */
1032 setsid(td, NULL);
1033 /*FALLTHROUGH*/
1034
1035 case 0: /* getpgrp() */
1036 PROC_LOCK(p);
1037 *retval = p->p_pgrp->pg_id;
1038 PROC_UNLOCK(p);
1039 return 0;
1040
1041 case 2: /* getsid(pid) */
1042 if (SCARG(uap, pid) == 0)
1042 if (uap->pid == 0)
1043 PROC_LOCK(p);
1043 PROC_LOCK(p);
1044 else if ((p = svr4_pfind(SCARG(uap, pid))) == NULL)
1044 else if ((p = svr4_pfind(uap->pid)) == NULL)
1045 return ESRCH;
1046 /*
1047 * This has already been initialized to the pid of
1048 * the session leader.
1049 */
1050 *retval = (register_t) p->p_session->s_sid;
1051 PROC_UNLOCK(p);
1052 return 0;
1053
1054 case 3: /* setsid() */
1055 return setsid(td, NULL);
1056
1057 case 4: /* getpgid(pid) */
1058
1045 return ESRCH;
1046 /*
1047 * This has already been initialized to the pid of
1048 * the session leader.
1049 */
1050 *retval = (register_t) p->p_session->s_sid;
1051 PROC_UNLOCK(p);
1052 return 0;
1053
1054 case 3: /* setsid() */
1055 return setsid(td, NULL);
1056
1057 case 4: /* getpgid(pid) */
1058
1059 if (SCARG(uap, pid) == 0)
1059 if (uap->pid == 0)
1060 PROC_LOCK(p);
1060 PROC_LOCK(p);
1061 else if ((p = svr4_pfind(SCARG(uap, pid))) == NULL)
1061 else if ((p = svr4_pfind(uap->pid)) == NULL)
1062 return ESRCH;
1063
1064 *retval = (int) p->p_pgrp->pg_id;
1065 PROC_UNLOCK(p);
1066 return 0;
1067
1068 case 5: /* setpgid(pid, pgid); */
1069 {
1070 struct setpgid_args sa;
1071
1062 return ESRCH;
1063
1064 *retval = (int) p->p_pgrp->pg_id;
1065 PROC_UNLOCK(p);
1066 return 0;
1067
1068 case 5: /* setpgid(pid, pgid); */
1069 {
1070 struct setpgid_args sa;
1071
1072 SCARG(&sa, pid) = SCARG(uap, pid);
1073 SCARG(&sa, pgid) = SCARG(uap, pgid);
1072 sa.pid = uap->pid;
1073 sa.pgid = uap->pgid;
1074 return setpgid(td, &sa);
1075 }
1076
1077 default:
1078 return EINVAL;
1079 }
1080}
1081

--- 9 unchanged lines hidden (view full) ---

1091
1092
1093static int
1094svr4_hrtcntl(td, uap, retval)
1095 struct thread *td;
1096 struct svr4_hrtcntl_args *uap;
1097 register_t *retval;
1098{
1074 return setpgid(td, &sa);
1075 }
1076
1077 default:
1078 return EINVAL;
1079 }
1080}
1081

--- 9 unchanged lines hidden (view full) ---

1091
1092
1093static int
1094svr4_hrtcntl(td, uap, retval)
1095 struct thread *td;
1096 struct svr4_hrtcntl_args *uap;
1097 register_t *retval;
1098{
1099 switch (SCARG(uap, fun)) {
1099 switch (uap->fun) {
1100 case SVR4_HRT_CNTL_RES:
1101 DPRINTF(("htrcntl(RES)\n"));
1102 *retval = SVR4_HRT_USEC;
1103 return 0;
1104
1105 case SVR4_HRT_CNTL_TOFD:
1106 DPRINTF(("htrcntl(TOFD)\n"));
1107 {
1108 struct timeval tv;
1109 svr4_hrt_time_t t;
1100 case SVR4_HRT_CNTL_RES:
1101 DPRINTF(("htrcntl(RES)\n"));
1102 *retval = SVR4_HRT_USEC;
1103 return 0;
1104
1105 case SVR4_HRT_CNTL_TOFD:
1106 DPRINTF(("htrcntl(TOFD)\n"));
1107 {
1108 struct timeval tv;
1109 svr4_hrt_time_t t;
1110 if (SCARG(uap, clk) != SVR4_HRT_CLK_STD) {
1111 DPRINTF(("clk == %d\n", SCARG(uap, clk)));
1110 if (uap->clk != SVR4_HRT_CLK_STD) {
1111 DPRINTF(("clk == %d\n", uap->clk));
1112 return EINVAL;
1113 }
1112 return EINVAL;
1113 }
1114 if (SCARG(uap, ti) == NULL) {
1114 if (uap->ti == NULL) {
1115 DPRINTF(("ti NULL\n"));
1116 return EINVAL;
1117 }
1118 microtime(&tv);
1119 t.h_sec = tv.tv_sec;
1120 t.h_rem = tv.tv_usec;
1121 t.h_res = SVR4_HRT_USEC;
1115 DPRINTF(("ti NULL\n"));
1116 return EINVAL;
1117 }
1118 microtime(&tv);
1119 t.h_sec = tv.tv_sec;
1120 t.h_rem = tv.tv_usec;
1121 t.h_res = SVR4_HRT_USEC;
1122 return copyout(&t, SCARG(uap, ti), sizeof(t));
1122 return copyout(&t, uap->ti, sizeof(t));
1123 }
1124
1125 case SVR4_HRT_CNTL_START:
1126 DPRINTF(("htrcntl(START)\n"));
1127 return ENOSYS;
1128
1129 case SVR4_HRT_CNTL_GET:
1130 DPRINTF(("htrcntl(GET)\n"));
1131 return ENOSYS;
1132 default:
1123 }
1124
1125 case SVR4_HRT_CNTL_START:
1126 DPRINTF(("htrcntl(START)\n"));
1127 return ENOSYS;
1128
1129 case SVR4_HRT_CNTL_GET:
1130 DPRINTF(("htrcntl(GET)\n"));
1131 return ENOSYS;
1132 default:
1133 DPRINTF(("Bad htrcntl command %d\n", SCARG(uap, fun)));
1133 DPRINTF(("Bad htrcntl command %d\n", uap->fun));
1134 return ENOSYS;
1135 }
1136}
1137
1138
1139int
1140svr4_sys_hrtsys(td, uap)
1141 struct thread *td;
1142 struct svr4_sys_hrtsys_args *uap;
1143{
1144 int *retval = td->td_retval;
1145
1134 return ENOSYS;
1135 }
1136}
1137
1138
1139int
1140svr4_sys_hrtsys(td, uap)
1141 struct thread *td;
1142 struct svr4_sys_hrtsys_args *uap;
1143{
1144 int *retval = td->td_retval;
1145
1146 switch (SCARG(uap, cmd)) {
1146 switch (uap->cmd) {
1147 case SVR4_HRT_CNTL:
1148 return svr4_hrtcntl(td, (struct svr4_hrtcntl_args *) uap,
1149 retval);
1150
1151 case SVR4_HRT_ALRM:
1152 DPRINTF(("hrtalarm\n"));
1153 return ENOSYS;
1154
1155 case SVR4_HRT_SLP:
1156 DPRINTF(("hrtsleep\n"));
1157 return ENOSYS;
1158
1159 case SVR4_HRT_CAN:
1160 DPRINTF(("hrtcancel\n"));
1161 return ENOSYS;
1162
1163 default:
1147 case SVR4_HRT_CNTL:
1148 return svr4_hrtcntl(td, (struct svr4_hrtcntl_args *) uap,
1149 retval);
1150
1151 case SVR4_HRT_ALRM:
1152 DPRINTF(("hrtalarm\n"));
1153 return ENOSYS;
1154
1155 case SVR4_HRT_SLP:
1156 DPRINTF(("hrtsleep\n"));
1157 return ENOSYS;
1158
1159 case SVR4_HRT_CAN:
1160 DPRINTF(("hrtcancel\n"));
1161 return ENOSYS;
1162
1163 default:
1164 DPRINTF(("Bad hrtsys command %d\n", SCARG(uap, cmd)));
1164 DPRINTF(("Bad hrtsys command %d\n", uap->cmd));
1165 return EINVAL;
1166 }
1167}
1168
1169
1170static int
1171svr4_setinfo(p, st, s)
1172 struct proc *p;

--- 57 unchanged lines hidden (view full) ---

1230 struct thread *td;
1231 struct svr4_sys_waitsys_args *uap;
1232{
1233 int nfound;
1234 int error, *retval = td->td_retval;
1235 struct proc *q, *t;
1236
1237
1165 return EINVAL;
1166 }
1167}
1168
1169
1170static int
1171svr4_setinfo(p, st, s)
1172 struct proc *p;

--- 57 unchanged lines hidden (view full) ---

1230 struct thread *td;
1231 struct svr4_sys_waitsys_args *uap;
1232{
1233 int nfound;
1234 int error, *retval = td->td_retval;
1235 struct proc *q, *t;
1236
1237
1238 switch (SCARG(uap, grp)) {
1238 switch (uap->grp) {
1239 case SVR4_P_PID:
1240 break;
1241
1242 case SVR4_P_PGID:
1243 PROC_LOCK(td->td_proc);
1239 case SVR4_P_PID:
1240 break;
1241
1242 case SVR4_P_PGID:
1243 PROC_LOCK(td->td_proc);
1244 SCARG(uap, id) = -td->td_proc->p_pgid;
1244 uap->id = -td->td_proc->p_pgid;
1245 PROC_UNLOCK(td->td_proc);
1246 break;
1247
1248 case SVR4_P_ALL:
1245 PROC_UNLOCK(td->td_proc);
1246 break;
1247
1248 case SVR4_P_ALL:
1249 SCARG(uap, id) = WAIT_ANY;
1249 uap->id = WAIT_ANY;
1250 break;
1251
1252 default:
1253 return EINVAL;
1254 }
1255
1256 DPRINTF(("waitsys(%d, %d, %p, %x)\n",
1250 break;
1251
1252 default:
1253 return EINVAL;
1254 }
1255
1256 DPRINTF(("waitsys(%d, %d, %p, %x)\n",
1257 SCARG(uap, grp), SCARG(uap, id),
1258 SCARG(uap, info), SCARG(uap, options)));
1257 uap->grp, uap->id,
1258 uap->info, uap->options));
1259
1260loop:
1261 nfound = 0;
1262 sx_slock(&proctree_lock);
1263 LIST_FOREACH(q, &td->td_proc->p_children, p_sibling) {
1264 PROC_LOCK(q);
1259
1260loop:
1261 nfound = 0;
1262 sx_slock(&proctree_lock);
1263 LIST_FOREACH(q, &td->td_proc->p_children, p_sibling) {
1264 PROC_LOCK(q);
1265 if (SCARG(uap, id) != WAIT_ANY &&
1266 q->p_pid != SCARG(uap, id) &&
1267 q->p_pgid != -SCARG(uap, id)) {
1265 if (uap->id != WAIT_ANY &&
1266 q->p_pid != uap->id &&
1267 q->p_pgid != -uap->id) {
1268 PROC_UNLOCK(q);
1269 DPRINTF(("pid %d pgid %d != %d\n", q->p_pid,
1268 PROC_UNLOCK(q);
1269 DPRINTF(("pid %d pgid %d != %d\n", q->p_pid,
1270 q->p_pgid, SCARG(uap, id)));
1270 q->p_pgid, uap->id));
1271 continue;
1272 }
1273 nfound++;
1274 mtx_lock_spin(&sched_lock);
1275 if ((q->p_state == PRS_ZOMBIE) &&
1271 continue;
1272 }
1273 nfound++;
1274 mtx_lock_spin(&sched_lock);
1275 if ((q->p_state == PRS_ZOMBIE) &&
1276 ((SCARG(uap, options) & (SVR4_WEXITED|SVR4_WTRAPPED)))) {
1276 ((uap->options & (SVR4_WEXITED|SVR4_WTRAPPED)))) {
1277 mtx_unlock_spin(&sched_lock);
1278 PROC_UNLOCK(q);
1279 sx_sunlock(&proctree_lock);
1280 *retval = 0;
1281 DPRINTF(("found %d\n", q->p_pid));
1277 mtx_unlock_spin(&sched_lock);
1278 PROC_UNLOCK(q);
1279 sx_sunlock(&proctree_lock);
1280 *retval = 0;
1281 DPRINTF(("found %d\n", q->p_pid));
1282 error = svr4_setinfo(q, q->p_xstat, SCARG(uap, info));
1282 error = svr4_setinfo(q, q->p_xstat, uap->info);
1283 if (error != 0)
1284 return error;
1285
1286
1283 if (error != 0)
1284 return error;
1285
1286
1287 if ((SCARG(uap, options) & SVR4_WNOWAIT)) {
1287 if ((uap->options & SVR4_WNOWAIT)) {
1288 DPRINTF(("Don't wait\n"));
1289 return 0;
1290 }
1291
1292 /*
1293 * If we got the child via ptrace(2) or procfs, and
1294 * the parent is different (meaning the process was
1295 * attached, rather than run as a child), then we need

--- 90 unchanged lines hidden (view full) ---

1386 uma_zfree(proc_zone, q);
1387#endif
1388 nprocs--;
1389 return 0;
1390 }
1391 /* XXXKSE this needs clarification */
1392 if (P_SHOULDSTOP(q) && ((q->p_flag & P_WAITED) == 0) &&
1393 (q->p_flag & P_TRACED ||
1288 DPRINTF(("Don't wait\n"));
1289 return 0;
1290 }
1291
1292 /*
1293 * If we got the child via ptrace(2) or procfs, and
1294 * the parent is different (meaning the process was
1295 * attached, rather than run as a child), then we need

--- 90 unchanged lines hidden (view full) ---

1386 uma_zfree(proc_zone, q);
1387#endif
1388 nprocs--;
1389 return 0;
1390 }
1391 /* XXXKSE this needs clarification */
1392 if (P_SHOULDSTOP(q) && ((q->p_flag & P_WAITED) == 0) &&
1393 (q->p_flag & P_TRACED ||
1394 (SCARG(uap, options) & (SVR4_WSTOPPED|SVR4_WCONTINUED)))) {
1394 (uap->options & (SVR4_WSTOPPED|SVR4_WCONTINUED)))) {
1395 mtx_unlock_spin(&sched_lock);
1396 DPRINTF(("jobcontrol %d\n", q->p_pid));
1395 mtx_unlock_spin(&sched_lock);
1396 DPRINTF(("jobcontrol %d\n", q->p_pid));
1397 if (((SCARG(uap, options) & SVR4_WNOWAIT)) == 0)
1397 if (((uap->options & SVR4_WNOWAIT)) == 0)
1398 q->p_flag |= P_WAITED;
1399 PROC_UNLOCK(q);
1400 *retval = 0;
1401 return svr4_setinfo(q, W_STOPCODE(q->p_xstat),
1398 q->p_flag |= P_WAITED;
1399 PROC_UNLOCK(q);
1400 *retval = 0;
1401 return svr4_setinfo(q, W_STOPCODE(q->p_xstat),
1402 SCARG(uap, info));
1402 uap->info);
1403 }
1404 mtx_unlock_spin(&sched_lock);
1405 PROC_UNLOCK(q);
1406 }
1407
1408 if (nfound == 0)
1409 return ECHILD;
1410
1403 }
1404 mtx_unlock_spin(&sched_lock);
1405 PROC_UNLOCK(q);
1406 }
1407
1408 if (nfound == 0)
1409 return ECHILD;
1410
1411 if (SCARG(uap, options) & SVR4_WNOHANG) {
1411 if (uap->options & SVR4_WNOHANG) {
1412 *retval = 0;
1412 *retval = 0;
1413 if ((error = svr4_setinfo(NULL, 0, SCARG(uap, info))) != 0)
1413 if ((error = svr4_setinfo(NULL, 0, uap->info)) != 0)
1414 return error;
1415 return 0;
1416 }
1417
1418 if ((error = tsleep((caddr_t)td->td_proc, PWAIT | PCATCH, "svr4_wait", 0)) != 0)
1419 return error;
1420 goto loop;
1421}

--- 58 unchanged lines hidden (view full) ---

1480{
1481 struct statfs_args fs_args;
1482 caddr_t sg = stackgap_init();
1483 struct statfs *fs = stackgap_alloc(&sg, sizeof(struct statfs));
1484 struct statfs bfs;
1485 struct svr4_statvfs sfs;
1486 int error;
1487
1414 return error;
1415 return 0;
1416 }
1417
1418 if ((error = tsleep((caddr_t)td->td_proc, PWAIT | PCATCH, "svr4_wait", 0)) != 0)
1419 return error;
1420 goto loop;
1421}

--- 58 unchanged lines hidden (view full) ---

1480{
1481 struct statfs_args fs_args;
1482 caddr_t sg = stackgap_init();
1483 struct statfs *fs = stackgap_alloc(&sg, sizeof(struct statfs));
1484 struct statfs bfs;
1485 struct svr4_statvfs sfs;
1486 int error;
1487
1488 CHECKALTEXIST(td, &sg, SCARG(uap, path));
1489 SCARG(&fs_args, path) = SCARG(uap, path);
1490 SCARG(&fs_args, buf) = fs;
1488 CHECKALTEXIST(td, &sg, uap->path);
1489 fs_args.path = uap->path;
1490 fs_args.buf = fs;
1491
1492 if ((error = statfs(td, &fs_args)) != 0)
1493 return error;
1494
1495 if ((error = copyin(fs, &bfs, sizeof(bfs))) != 0)
1496 return error;
1497
1498 bsd_statfs_to_svr4_statvfs(&bfs, &sfs);
1499
1491
1492 if ((error = statfs(td, &fs_args)) != 0)
1493 return error;
1494
1495 if ((error = copyin(fs, &bfs, sizeof(bfs))) != 0)
1496 return error;
1497
1498 bsd_statfs_to_svr4_statvfs(&bfs, &sfs);
1499
1500 return copyout(&sfs, SCARG(uap, fs), sizeof(sfs));
1500 return copyout(&sfs, uap->fs, sizeof(sfs));
1501}
1502
1503
1504int
1505svr4_sys_fstatvfs(td, uap)
1506 struct thread *td;
1507 struct svr4_sys_fstatvfs_args *uap;
1508{
1509 struct fstatfs_args fs_args;
1510 caddr_t sg = stackgap_init();
1511 struct statfs *fs = stackgap_alloc(&sg, sizeof(struct statfs));
1512 struct statfs bfs;
1513 struct svr4_statvfs sfs;
1514 int error;
1515
1501}
1502
1503
1504int
1505svr4_sys_fstatvfs(td, uap)
1506 struct thread *td;
1507 struct svr4_sys_fstatvfs_args *uap;
1508{
1509 struct fstatfs_args fs_args;
1510 caddr_t sg = stackgap_init();
1511 struct statfs *fs = stackgap_alloc(&sg, sizeof(struct statfs));
1512 struct statfs bfs;
1513 struct svr4_statvfs sfs;
1514 int error;
1515
1516 SCARG(&fs_args, fd) = SCARG(uap, fd);
1517 SCARG(&fs_args, buf) = fs;
1516 fs_args.fd = uap->fd;
1517 fs_args.buf = fs;
1518
1519 if ((error = fstatfs(td, &fs_args)) != 0)
1520 return error;
1521
1522 if ((error = copyin(fs, &bfs, sizeof(bfs))) != 0)
1523 return error;
1524
1525 bsd_statfs_to_svr4_statvfs(&bfs, &sfs);
1526
1518
1519 if ((error = fstatfs(td, &fs_args)) != 0)
1520 return error;
1521
1522 if ((error = copyin(fs, &bfs, sizeof(bfs))) != 0)
1523 return error;
1524
1525 bsd_statfs_to_svr4_statvfs(&bfs, &sfs);
1526
1527 return copyout(&sfs, SCARG(uap, fs), sizeof(sfs));
1527 return copyout(&sfs, uap->fs, sizeof(sfs));
1528}
1529
1530
1531int
1532svr4_sys_statvfs64(td, uap)
1533 struct thread *td;
1534 struct svr4_sys_statvfs64_args *uap;
1535{
1536 struct statfs_args fs_args;
1537 caddr_t sg = stackgap_init();
1538 struct statfs *fs = stackgap_alloc(&sg, sizeof(struct statfs));
1539 struct statfs bfs;
1540 struct svr4_statvfs64 sfs;
1541 int error;
1542
1528}
1529
1530
1531int
1532svr4_sys_statvfs64(td, uap)
1533 struct thread *td;
1534 struct svr4_sys_statvfs64_args *uap;
1535{
1536 struct statfs_args fs_args;
1537 caddr_t sg = stackgap_init();
1538 struct statfs *fs = stackgap_alloc(&sg, sizeof(struct statfs));
1539 struct statfs bfs;
1540 struct svr4_statvfs64 sfs;
1541 int error;
1542
1543 CHECKALTEXIST(td, &sg, SCARG(uap, path));
1544 SCARG(&fs_args, path) = SCARG(uap, path);
1545 SCARG(&fs_args, buf) = fs;
1543 CHECKALTEXIST(td, &sg, uap->path);
1544 fs_args.path = uap->path;
1545 fs_args.buf = fs;
1546
1547 if ((error = statfs(td, &fs_args)) != 0)
1548 return error;
1549
1550 if ((error = copyin(fs, &bfs, sizeof(bfs))) != 0)
1551 return error;
1552
1553 bsd_statfs_to_svr4_statvfs64(&bfs, &sfs);
1554
1546
1547 if ((error = statfs(td, &fs_args)) != 0)
1548 return error;
1549
1550 if ((error = copyin(fs, &bfs, sizeof(bfs))) != 0)
1551 return error;
1552
1553 bsd_statfs_to_svr4_statvfs64(&bfs, &sfs);
1554
1555 return copyout(&sfs, SCARG(uap, fs), sizeof(sfs));
1555 return copyout(&sfs, uap->fs, sizeof(sfs));
1556}
1557
1558
1559int
1560svr4_sys_fstatvfs64(td, uap)
1561 struct thread *td;
1562 struct svr4_sys_fstatvfs64_args *uap;
1563{
1564 struct fstatfs_args fs_args;
1565 caddr_t sg = stackgap_init();
1566 struct statfs *fs = stackgap_alloc(&sg, sizeof(struct statfs));
1567 struct statfs bfs;
1568 struct svr4_statvfs64 sfs;
1569 int error;
1570
1556}
1557
1558
1559int
1560svr4_sys_fstatvfs64(td, uap)
1561 struct thread *td;
1562 struct svr4_sys_fstatvfs64_args *uap;
1563{
1564 struct fstatfs_args fs_args;
1565 caddr_t sg = stackgap_init();
1566 struct statfs *fs = stackgap_alloc(&sg, sizeof(struct statfs));
1567 struct statfs bfs;
1568 struct svr4_statvfs64 sfs;
1569 int error;
1570
1571 SCARG(&fs_args, fd) = SCARG(uap, fd);
1572 SCARG(&fs_args, buf) = fs;
1571 fs_args.fd = uap->fd;
1572 fs_args.buf = fs;
1573
1574 if ((error = fstatfs(td, &fs_args)) != 0)
1575 return error;
1576
1577 if ((error = copyin(fs, &bfs, sizeof(bfs))) != 0)
1578 return error;
1579
1580 bsd_statfs_to_svr4_statvfs64(&bfs, &sfs);
1581
1573
1574 if ((error = fstatfs(td, &fs_args)) != 0)
1575 return error;
1576
1577 if ((error = copyin(fs, &bfs, sizeof(bfs))) != 0)
1578 return error;
1579
1580 bsd_statfs_to_svr4_statvfs64(&bfs, &sfs);
1581
1582 return copyout(&sfs, SCARG(uap, fs), sizeof(sfs));
1582 return copyout(&sfs, uap->fs, sizeof(sfs));
1583}
1584
1585int
1586svr4_sys_alarm(td, uap)
1587 struct thread *td;
1588 struct svr4_sys_alarm_args *uap;
1589{
1590 int error;
1591 struct itimerval *itp, *oitp;
1592 struct setitimer_args sa;
1593 caddr_t sg = stackgap_init();
1594
1595 itp = stackgap_alloc(&sg, sizeof(*itp));
1596 oitp = stackgap_alloc(&sg, sizeof(*oitp));
1597 timevalclear(&itp->it_interval);
1583}
1584
1585int
1586svr4_sys_alarm(td, uap)
1587 struct thread *td;
1588 struct svr4_sys_alarm_args *uap;
1589{
1590 int error;
1591 struct itimerval *itp, *oitp;
1592 struct setitimer_args sa;
1593 caddr_t sg = stackgap_init();
1594
1595 itp = stackgap_alloc(&sg, sizeof(*itp));
1596 oitp = stackgap_alloc(&sg, sizeof(*oitp));
1597 timevalclear(&itp->it_interval);
1598 itp->it_value.tv_sec = SCARG(uap, sec);
1598 itp->it_value.tv_sec = uap->sec;
1599 itp->it_value.tv_usec = 0;
1600
1599 itp->it_value.tv_usec = 0;
1600
1601 SCARG(&sa, which) = ITIMER_REAL;
1602 SCARG(&sa, itv) = itp;
1603 SCARG(&sa, oitv) = oitp;
1601 sa.which = ITIMER_REAL;
1602 sa.itv = itp;
1603 sa.oitv = oitp;
1604 error = setitimer(td, &sa);
1605 if (error)
1606 return error;
1607 if (oitp->it_value.tv_usec)
1608 oitp->it_value.tv_sec++;
1609 td->td_retval[0] = oitp->it_value.tv_sec;
1610 return 0;
1611
1612}
1613
1614int
1615svr4_sys_gettimeofday(td, uap)
1616 struct thread *td;
1617 struct svr4_sys_gettimeofday_args *uap;
1618{
1604 error = setitimer(td, &sa);
1605 if (error)
1606 return error;
1607 if (oitp->it_value.tv_usec)
1608 oitp->it_value.tv_sec++;
1609 td->td_retval[0] = oitp->it_value.tv_sec;
1610 return 0;
1611
1612}
1613
1614int
1615svr4_sys_gettimeofday(td, uap)
1616 struct thread *td;
1617 struct svr4_sys_gettimeofday_args *uap;
1618{
1619 if (SCARG(uap, tp)) {
1619 if (uap->tp) {
1620 struct timeval atv;
1621
1622 microtime(&atv);
1620 struct timeval atv;
1621
1622 microtime(&atv);
1623 return copyout(&atv, SCARG(uap, tp), sizeof (atv));
1623 return copyout(&atv, uap->tp, sizeof (atv));
1624 }
1625
1626 return 0;
1627}
1628
1629int
1630svr4_sys_facl(td, uap)
1631 struct thread *td;
1632 struct svr4_sys_facl_args *uap;
1633{
1634 int *retval;
1635
1636 retval = td->td_retval;
1637 *retval = 0;
1638
1624 }
1625
1626 return 0;
1627}
1628
1629int
1630svr4_sys_facl(td, uap)
1631 struct thread *td;
1632 struct svr4_sys_facl_args *uap;
1633{
1634 int *retval;
1635
1636 retval = td->td_retval;
1637 *retval = 0;
1638
1639 switch (SCARG(uap, cmd)) {
1639 switch (uap->cmd) {
1640 case SVR4_SYS_SETACL:
1641 /* We don't support acls on any filesystem */
1642 return ENOSYS;
1643
1644 case SVR4_SYS_GETACL:
1640 case SVR4_SYS_SETACL:
1641 /* We don't support acls on any filesystem */
1642 return ENOSYS;
1643
1644 case SVR4_SYS_GETACL:
1645 return copyout(retval, &SCARG(uap, num),
1646 sizeof(SCARG(uap, num)));
1645 return copyout(retval, &uap->num,
1646 sizeof(uap->num));
1647
1648 case SVR4_SYS_GETACLCNT:
1649 return 0;
1650
1651 default:
1652 return EINVAL;
1653 }
1654}

--- 19 unchanged lines hidden (view full) ---

1674 return 0;
1675}
1676
1677int
1678svr4_sys_memcntl(td, uap)
1679 struct thread *td;
1680 struct svr4_sys_memcntl_args *uap;
1681{
1647
1648 case SVR4_SYS_GETACLCNT:
1649 return 0;
1650
1651 default:
1652 return EINVAL;
1653 }
1654}

--- 19 unchanged lines hidden (view full) ---

1674 return 0;
1675}
1676
1677int
1678svr4_sys_memcntl(td, uap)
1679 struct thread *td;
1680 struct svr4_sys_memcntl_args *uap;
1681{
1682 switch (SCARG(uap, cmd)) {
1682 switch (uap->cmd) {
1683 case SVR4_MC_SYNC:
1684 {
1685 struct msync_args msa;
1686
1683 case SVR4_MC_SYNC:
1684 {
1685 struct msync_args msa;
1686
1687 SCARG(&msa, addr) = SCARG(uap, addr);
1688 SCARG(&msa, len) = SCARG(uap, len);
1689 SCARG(&msa, flags) = (int)SCARG(uap, arg);
1687 msa.addr = uap->addr;
1688 msa.len = uap->len;
1689 msa.flags = (int)uap->arg;
1690
1691 return msync(td, &msa);
1692 }
1693 case SVR4_MC_ADVISE:
1694 {
1695 struct madvise_args maa;
1696
1690
1691 return msync(td, &msa);
1692 }
1693 case SVR4_MC_ADVISE:
1694 {
1695 struct madvise_args maa;
1696
1697 SCARG(&maa, addr) = SCARG(uap, addr);
1698 SCARG(&maa, len) = SCARG(uap, len);
1699 SCARG(&maa, behav) = (int)SCARG(uap, arg);
1697 maa.addr = uap->addr;
1698 maa.len = uap->len;
1699 maa.behav = (int)uap->arg;
1700
1701 return madvise(td, &maa);
1702 }
1703 case SVR4_MC_LOCK:
1704 case SVR4_MC_UNLOCK:
1705 case SVR4_MC_LOCKAS:
1706 case SVR4_MC_UNLOCKAS:
1707 return EOPNOTSUPP;

--- 6 unchanged lines hidden (view full) ---

1714int
1715svr4_sys_nice(td, uap)
1716 struct thread *td;
1717 struct svr4_sys_nice_args *uap;
1718{
1719 struct setpriority_args ap;
1720 int error;
1721
1700
1701 return madvise(td, &maa);
1702 }
1703 case SVR4_MC_LOCK:
1704 case SVR4_MC_UNLOCK:
1705 case SVR4_MC_LOCKAS:
1706 case SVR4_MC_UNLOCKAS:
1707 return EOPNOTSUPP;

--- 6 unchanged lines hidden (view full) ---

1714int
1715svr4_sys_nice(td, uap)
1716 struct thread *td;
1717 struct svr4_sys_nice_args *uap;
1718{
1719 struct setpriority_args ap;
1720 int error;
1721
1722 SCARG(&ap, which) = PRIO_PROCESS;
1723 SCARG(&ap, who) = 0;
1724 SCARG(&ap, prio) = SCARG(uap, prio);
1722 ap.which = PRIO_PROCESS;
1723 ap.who = 0;
1724 ap.prio = uap->prio;
1725
1726 if ((error = setpriority(td, &ap)) != 0)
1727 return error;
1728
1729 /* the cast is stupid, but the structures are the same */
1730 if ((error = getpriority(td, (struct getpriority_args *)&ap)) != 0)
1731 return error;
1732

--- 4 unchanged lines hidden (view full) ---

1737svr4_sys_resolvepath(td, uap)
1738 struct thread *td;
1739 struct svr4_sys_resolvepath_args *uap;
1740{
1741 struct nameidata nd;
1742 int error, *retval = td->td_retval;
1743
1744 NDINIT(&nd, LOOKUP, NOFOLLOW | SAVENAME, UIO_USERSPACE,
1725
1726 if ((error = setpriority(td, &ap)) != 0)
1727 return error;
1728
1729 /* the cast is stupid, but the structures are the same */
1730 if ((error = getpriority(td, (struct getpriority_args *)&ap)) != 0)
1731 return error;
1732

--- 4 unchanged lines hidden (view full) ---

1737svr4_sys_resolvepath(td, uap)
1738 struct thread *td;
1739 struct svr4_sys_resolvepath_args *uap;
1740{
1741 struct nameidata nd;
1742 int error, *retval = td->td_retval;
1743
1744 NDINIT(&nd, LOOKUP, NOFOLLOW | SAVENAME, UIO_USERSPACE,
1745 SCARG(uap, path), td);
1745 uap->path, td);
1746
1747 if ((error = namei(&nd)) != 0)
1748 return error;
1749
1746
1747 if ((error = namei(&nd)) != 0)
1748 return error;
1749
1750 if ((error = copyout(nd.ni_cnd.cn_pnbuf, SCARG(uap, buf),
1751 SCARG(uap, bufsiz))) != 0)
1750 if ((error = copyout(nd.ni_cnd.cn_pnbuf, uap->buf,
1751 uap->bufsiz)) != 0)
1752 goto bad;
1753
1752 goto bad;
1753
1754 *retval = strlen(nd.ni_cnd.cn_pnbuf) < SCARG(uap, bufsiz) ?
1755 strlen(nd.ni_cnd.cn_pnbuf) + 1 : SCARG(uap, bufsiz);
1754 *retval = strlen(nd.ni_cnd.cn_pnbuf) < uap->bufsiz ?
1755 strlen(nd.ni_cnd.cn_pnbuf) + 1 : uap->bufsiz;
1756bad:
1757 NDFREE(&nd, NDF_ONLY_PNBUF);
1758 vput(nd.ni_vp);
1759 return error;
1760}
1756bad:
1757 NDFREE(&nd, NDF_ONLY_PNBUF);
1758 vput(nd.ni_vp);
1759 return error;
1760}