Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/compat/linux/common/linux_file.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/compat/linux/common/linux_file.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.37 retrieving revision 1.37.2.13 diff -u -p -r1.37 -r1.37.2.13 --- src/sys/compat/linux/common/linux_file.c 2001/01/22 21:31:37 1.37 +++ src/sys/compat/linux/common/linux_file.c 2002/12/19 00:42:53 1.37.2.13 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_file.c,v 1.37 2001/01/22 21:31:37 jdolecek Exp $ */ +/* $NetBSD: linux_file.c,v 1.37.2.13 2002/12/19 00:42:53 thorpej Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -41,6 +41,9 @@ * linux_sys_llseek : linux_llseek.c */ +#include +__KERNEL_RCSID(0, "$NetBSD: linux_file.c,v 1.37.2.13 2002/12/19 00:42:53 thorpej Exp $"); + #include #include #include @@ -54,8 +57,11 @@ #include #include #include +#include #include +#include +#include #include #include @@ -71,7 +77,7 @@ static int bsd_to_linux_ioflags __P((int static void bsd_to_linux_flock __P((struct flock *, struct linux_flock *)); static void linux_to_bsd_flock __P((struct linux_flock *, struct flock *)); static void bsd_to_linux_stat __P((struct stat *, struct linux_stat *)); -static int linux_stat1 __P((struct proc *, void *, register_t *, int)); +static int linux_stat1 __P((struct lwp *, void *, register_t *, int)); /* * Some file-related calls are handled here. The usual flag conversion @@ -134,8 +140,8 @@ bsd_to_linux_ioflags(bflags) * Just call open(2) with the TRUNC, CREAT and WRONLY flags. */ int -linux_sys_creat(p, v, retval) - struct proc *p; +linux_sys_creat(l, v, retval) + struct lwp *l; void *v; register_t *retval; { @@ -143,17 +149,18 @@ linux_sys_creat(p, v, retval) syscallarg(const char *) path; syscallarg(int) mode; } */ *uap = v; + struct proc *p = l->l_proc; struct sys_open_args oa; caddr_t sg; - sg = stackgap_init(p->p_emul); + sg = stackgap_init(p, 0); CHECK_ALT_CREAT(p, &sg, SCARG(uap, path)); SCARG(&oa, path) = SCARG(uap, path); SCARG(&oa, flags) = O_CREAT | O_TRUNC | O_WRONLY; SCARG(&oa, mode) = SCARG(uap, mode); - return sys_open(p, &oa, retval); + return sys_open(l, &oa, retval); } /* @@ -163,8 +170,8 @@ linux_sys_creat(p, v, retval) * (XXX is this necessary?) */ int -linux_sys_open(p, v, retval) - struct proc *p; +linux_sys_open(l, v, retval) + struct lwp *l; void *v; register_t *retval; { @@ -173,11 +180,12 @@ linux_sys_open(p, v, retval) syscallarg(int) flags; syscallarg(int) mode; } */ *uap = v; + struct proc *p = l->l_proc; int error, fl; struct sys_open_args boa; caddr_t sg; - sg = stackgap_init(p->p_emul); + sg = stackgap_init(p, 0); fl = linux_to_bsd_ioflags(SCARG(uap, flags)); @@ -190,7 +198,7 @@ linux_sys_open(p, v, retval) SCARG(&boa, flags) = fl; SCARG(&boa, mode) = SCARG(uap, mode); - if ((error = sys_open(p, &boa, retval))) + if ((error = sys_open(l, &boa, retval))) return error; /* @@ -201,10 +209,12 @@ linux_sys_open(p, v, retval) */ if (!(fl & O_NOCTTY) && SESS_LEADER(p) && !(p->p_flag & P_CONTROLT)) { struct filedesc *fdp = p->p_fd; - struct file *fp = fdp->fd_ofiles[*retval]; + struct file *fp; + + fp = fd_getfile(fdp, *retval); /* ignore any error, just give it a try */ - if (fp->f_type == DTYPE_VNODE) + if (fp != NULL && fp->f_type == DTYPE_VNODE) (fp->f_ops->fo_ioctl) (fp, TIOCSCTTY, (caddr_t) 0, p); } return 0; @@ -269,8 +279,8 @@ linux_to_bsd_flock(lfp, bfp) * because the flag values and lock structure are different. */ int -linux_sys_fcntl(p, v, retval) - struct proc *p; +linux_sys_fcntl(l, v, retval) + struct lwp *l; void *v; register_t *retval; { @@ -279,6 +289,7 @@ linux_sys_fcntl(p, v, retval) syscallarg(int) cmd; syscallarg(void *) arg; } */ *uap = v; + struct proc *p = l->l_proc; int fd, cmd, error; u_long val; caddr_t arg, sg; @@ -289,6 +300,7 @@ linux_sys_fcntl(p, v, retval) struct file *fp; struct vnode *vp; struct vattr va; + const struct cdevsw *cdev; long pgid; struct pgrp *pgrp; struct tty *tp, *(*d_tty) __P((dev_t)); @@ -311,19 +323,65 @@ linux_sys_fcntl(p, v, retval) SCARG(&fca, fd) = fd; SCARG(&fca, cmd) = F_GETFL; SCARG(&fca, arg) = arg; - if ((error = sys_fcntl(p, &fca, retval))) + if ((error = sys_fcntl(l, &fca, retval))) return error; retval[0] = bsd_to_linux_ioflags(retval[0]); return 0; - case LINUX_F_SETFL: + case LINUX_F_SETFL: { + struct file *fp = NULL; + val = linux_to_bsd_ioflags((unsigned long)SCARG(uap, arg)); + /* + * Linux seems to have same semantics for sending SIGIO to the + * read side of socket, but slighly different semantics + * for SIGIO to the write side. Rather than sending the SIGIO + * every time it's possible to write (directly) more data, it + * only sends SIGIO if last write(2) failed due to insufficient + * memory to hold the data. This is compatible enough + * with NetBSD semantics to not do anything about the + * difference. + * + * Linux does NOT send SIGIO for pipes. Deal with socketpair + * ones and DTYPE_PIPE ones. For these, we don't set + * the underlying flags (we don't pass O_ASYNC flag down + * to sys_fcntl()), but set the FASYNC flag for file descriptor, + * so that F_GETFL would report the ASYNC i/o is on. + */ + if (val & O_ASYNC) { + if (((fp = fd_getfile(p->p_fd, fd)) == NULL)) + return (EBADF); + + FILE_USE(fp); + + if (((fp->f_type == DTYPE_SOCKET) && fp->f_data + && ((struct socket *)fp->f_data)->so_state & SS_ISAPIPE) + || (fp->f_type == DTYPE_PIPE)) + val &= ~O_ASYNC; + else { + /* not a pipe, do not modify anything */ + FILE_UNUSE(fp, p); + fp = NULL; + } + } + SCARG(&fca, fd) = fd; SCARG(&fca, cmd) = F_SETFL; SCARG(&fca, arg) = (caddr_t) val; - return sys_fcntl(p, &fca, retval); + + error = sys_fcntl(l, &fca, retval); + + /* Now set the FASYNC flag for pipes */ + if (fp) { + if (!error) + fp->f_flag |= FASYNC; + FILE_UNUSE(fp, p); + } + + return (error); + } case LINUX_F_GETLK: - sg = stackgap_init(p->p_emul); - bfp = (struct flock *) stackgap_alloc(&sg, sizeof *bfp); + sg = stackgap_init(p, 0); + bfp = (struct flock *) stackgap_alloc(p, &sg, sizeof *bfp); if ((error = copyin(arg, &lfl, sizeof lfl))) return error; linux_to_bsd_flock(&lfl, &bfl); @@ -332,52 +390,59 @@ linux_sys_fcntl(p, v, retval) SCARG(&fca, fd) = fd; SCARG(&fca, cmd) = F_GETLK; SCARG(&fca, arg) = bfp; - if ((error = sys_fcntl(p, &fca, retval))) + if ((error = sys_fcntl(l, &fca, retval))) return error; if ((error = copyin(bfp, &bfl, sizeof bfl))) return error; bsd_to_linux_flock(&bfl, &lfl); return copyout(&lfl, arg, sizeof lfl); - break; + case LINUX_F_SETLK: case LINUX_F_SETLKW: cmd = (cmd == LINUX_F_SETLK ? F_SETLK : F_SETLKW); if ((error = copyin(arg, &lfl, sizeof lfl))) return error; linux_to_bsd_flock(&lfl, &bfl); - sg = stackgap_init(p->p_emul); - bfp = (struct flock *) stackgap_alloc(&sg, sizeof *bfp); + sg = stackgap_init(p, 0); + bfp = (struct flock *) stackgap_alloc(p, &sg, sizeof *bfp); if ((error = copyout(&bfl, bfp, sizeof bfl))) return error; - SCARG(&fca, fd) = fd; - SCARG(&fca, cmd) = cmd; - SCARG(&fca, arg) = bfp; - return sys_fcntl(p, &fca, retval); + arg = (caddr_t)bfp; break; + case LINUX_F_SETOWN: case LINUX_F_GETOWN: /* - * We need to route around the normal fcntl() for these calls, - * since it uses TIOC{G,S}PGRP, which is too restrictive for - * Linux F_{G,S}ETOWN semantics. For sockets, this problem - * does not exist. + * We need to route fcntl() for tty descriptors around normal + * fcntl(), since NetBSD tty TIOC{G,S}PGRP semantics is too + * restrictive for Linux F_{G,S}ETOWN. For non-tty descriptors, + * this is not a problem. */ fdp = p->p_fd; - if ((u_int)fd >= fdp->fd_nfiles || - (fp = fdp->fd_ofiles[fd]) == NULL) + if ((fp = fd_getfile(fdp, fd)) == NULL) return EBADF; - if (fp->f_type == DTYPE_SOCKET) { + /* FILE_USE() not needed here */ + if (fp->f_type != DTYPE_VNODE) { + not_tty: + /* Not a tty, proceed with common fcntl() */ cmd = cmd == LINUX_F_SETOWN ? F_SETOWN : F_GETOWN; break; } + + /* check that the vnode is a tty */ vp = (struct vnode *)fp->f_data; if (vp->v_type != VCHR) - return EINVAL; + goto not_tty; if ((error = VOP_GETATTR(vp, &va, p->p_ucred, p))) return error; - d_tty = cdevsw[major(va.va_rdev)].d_tty; + cdev = cdevsw_lookup(va.va_rdev); + if (cdev == NULL) + return (ENXIO); + d_tty = cdev->d_tty; if (!d_tty || (!(tp = (*d_tty)(va.va_rdev)))) - return EINVAL; + goto not_tty; + + /* set tty pg_id appropriately */ if (cmd == LINUX_F_GETOWN) { retval[0] = tp->t_pgrp ? tp->t_pgrp->pg_id : NO_PID; return 0; @@ -386,7 +451,7 @@ linux_sys_fcntl(p, v, retval) pgid = -(long)arg; } else { struct proc *p1 = pfind((long)arg); - if (p1 == 0) + if (p1 == NULL) return (ESRCH); pgid = (long)p1->p_pgrp->pg_id; } @@ -395,6 +460,7 @@ linux_sys_fcntl(p, v, retval) return EPERM; tp->t_pgrp = pgrp; return 0; + default: return EOPNOTSUPP; } @@ -403,7 +469,7 @@ linux_sys_fcntl(p, v, retval) SCARG(&fca, cmd) = cmd; SCARG(&fca, arg) = arg; - return sys_fcntl(p, &fca, retval); + return sys_fcntl(l, &fca, retval); } /* @@ -420,7 +486,7 @@ bsd_to_linux_stat(bsp, lsp) struct linux_stat *lsp; { - lsp->lst_dev = bsp->st_dev; + lsp->lst_dev = linux_fakedev(bsp->st_dev, 0); lsp->lst_ino = bsp->st_ino; lsp->lst_mode = (linux_mode_t)bsp->st_mode; if (bsp->st_nlink >= (1 << 15)) @@ -429,7 +495,7 @@ bsd_to_linux_stat(bsp, lsp) lsp->lst_nlink = (linux_nlink_t)bsp->st_nlink; lsp->lst_uid = bsp->st_uid; lsp->lst_gid = bsp->st_gid; - lsp->lst_rdev = linux_fakedev(bsp->st_rdev); + lsp->lst_rdev = linux_fakedev(bsp->st_rdev, 1); lsp->lst_size = bsp->st_size; lsp->lst_blksize = bsp->st_blksize; lsp->lst_blocks = bsp->st_blocks; @@ -443,8 +509,8 @@ bsd_to_linux_stat(bsp, lsp) * by one function to avoid code duplication. */ int -linux_sys_fstat(p, v, retval) - struct proc *p; +linux_sys_fstat(l, v, retval) + struct lwp *l; void *v; register_t *retval; { @@ -452,20 +518,21 @@ linux_sys_fstat(p, v, retval) syscallarg(int) fd; syscallarg(linux_stat *) sp; } */ *uap = v; + struct proc *p = l->l_proc; struct sys___fstat13_args fsa; struct linux_stat tmplst; struct stat *st,tmpst; caddr_t sg; int error; - sg = stackgap_init(p->p_emul); + sg = stackgap_init(p, 0); - st = stackgap_alloc(&sg, sizeof (struct stat)); + st = stackgap_alloc(p, &sg, sizeof (struct stat)); SCARG(&fsa, fd) = SCARG(uap, fd); SCARG(&fsa, sb) = st; - if ((error = sys___fstat13(p, &fsa, retval))) + if ((error = sys___fstat13(l, &fsa, retval))) return error; if ((error = copyin(st, &tmpst, sizeof tmpst))) @@ -480,8 +547,8 @@ linux_sys_fstat(p, v, retval) } static int -linux_stat1(p, v, retval, dolstat) - struct proc *p; +linux_stat1(l, v, retval, dolstat) + struct lwp *l; void *v; register_t *retval; int dolstat; @@ -489,12 +556,13 @@ linux_stat1(p, v, retval, dolstat) struct sys___stat13_args sa; struct linux_stat tmplst; struct stat *st, tmpst; + struct proc *p = l->l_proc; caddr_t sg; int error; struct linux_sys_stat_args *uap = v; - sg = stackgap_init(p->p_emul); - st = stackgap_alloc(&sg, sizeof (struct stat)); + sg = stackgap_init(p, 0); + st = stackgap_alloc(p, &sg, sizeof (struct stat)); if (dolstat) CHECK_ALT_SYMLINK(p, &sg, SCARG(uap, path)); else @@ -503,8 +571,8 @@ linux_stat1(p, v, retval, dolstat) SCARG(&sa, ub) = st; SCARG(&sa, path) = SCARG(uap, path); - if ((error = (dolstat ? sys___lstat13(p, &sa, retval) : - sys___stat13(p, &sa, retval)))) + if ((error = (dolstat ? sys___lstat13(l, &sa, retval) : + sys___stat13(l, &sa, retval)))) return error; if ((error = copyin(st, &tmpst, sizeof tmpst))) @@ -519,8 +587,8 @@ linux_stat1(p, v, retval, dolstat) } int -linux_sys_stat(p, v, retval) - struct proc *p; +linux_sys_stat(l, v, retval) + struct lwp *l; void *v; register_t *retval; { @@ -529,14 +597,14 @@ linux_sys_stat(p, v, retval) syscallarg(struct linux_stat *) sp; } */ *uap = v; - return linux_stat1(p, uap, retval, 0); + return linux_stat1(l, uap, retval, 0); } /* Note: this is "newlstat" in the Linux sources */ /* (we don't bother with the old lstat currently) */ int -linux_sys_lstat(p, v, retval) - struct proc *p; +linux_sys_lstat(l, v, retval) + struct lwp *l; void *v; register_t *retval; { @@ -545,15 +613,15 @@ linux_sys_lstat(p, v, retval) syscallarg(struct linux_stat *) sp; } */ *uap = v; - return linux_stat1(p, uap, retval, 1); + return linux_stat1(l, uap, retval, 1); } /* * The following syscalls are mostly here because of the alternate path check. */ int -linux_sys_access(p, v, retval) - struct proc *p; +linux_sys_access(l, v, retval) + struct lwp *l; void *v; register_t *retval; { @@ -561,16 +629,17 @@ linux_sys_access(p, v, retval) syscallarg(const char *) path; syscallarg(int) flags; } */ *uap = v; - caddr_t sg = stackgap_init(p->p_emul); + struct proc *p = l->l_proc; + caddr_t sg = stackgap_init(p, 0); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_access(p, uap, retval); + return sys_access(l, uap, retval); } int -linux_sys_unlink(p, v, retval) - struct proc *p; +linux_sys_unlink(l, v, retval) + struct lwp *l; void *v; register_t *retval; @@ -578,32 +647,34 @@ linux_sys_unlink(p, v, retval) struct linux_sys_unlink_args /* { syscallarg(const char *) path; } */ *uap = v; - caddr_t sg = stackgap_init(p->p_emul); + struct proc *p = l->l_proc; + caddr_t sg = stackgap_init(p, 0); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_unlink(p, uap, retval); + return sys_unlink(l, uap, retval); } int -linux_sys_chdir(p, v, retval) - struct proc *p; +linux_sys_chdir(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_chdir_args /* { syscallarg(const char *) path; } */ *uap = v; - caddr_t sg = stackgap_init(p->p_emul); + struct proc *p = l->l_proc; + caddr_t sg = stackgap_init(p, 0); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_chdir(p, uap, retval); + return sys_chdir(l, uap, retval); } int -linux_sys_mknod(p, v, retval) - struct proc *p; +linux_sys_mknod(l, v, retval) + struct lwp *l; void *v; register_t *retval; { @@ -612,25 +683,39 @@ linux_sys_mknod(p, v, retval) syscallarg(int) mode; syscallarg(int) dev; } */ *uap = v; - caddr_t sg = stackgap_init(p->p_emul); - struct sys_mkfifo_args bma; + struct proc *p = l->l_proc; + caddr_t sg = stackgap_init(p, 0); CHECK_ALT_CREAT(p, &sg, SCARG(uap, path)); /* - * BSD handles FIFOs seperately + * BSD handles FIFOs separately */ if (SCARG(uap, mode) & S_IFIFO) { + struct sys_mkfifo_args bma; + SCARG(&bma, path) = SCARG(uap, path); SCARG(&bma, mode) = SCARG(uap, mode); - return sys_mkfifo(p, uap, retval); - } else - return sys_mknod(p, uap, retval); + return sys_mkfifo(p, &bma, retval); + } else { + struct sys_mknod_args bma; + + SCARG(&bma, path) = SCARG(uap, path); + SCARG(&bma, mode) = SCARG(uap, mode); + /* + * Linux device numbers uses 8 bits for minor and 8 bits + * for major. Due to how we map our major and minor, + * this just fints into our dev_t. Just mask off the + * upper 16bit to remove any random junk. + */ + SCARG(&bma, dev) = SCARG(uap, dev) & 0xffff; + return sys_mknod(l, &bma, retval); + } } int -linux_sys_chmod(p, v, retval) - struct proc *p; +linux_sys_chmod(l, v, retval) + struct lwp *l; void *v; register_t *retval; { @@ -638,17 +723,18 @@ linux_sys_chmod(p, v, retval) syscallarg(const char *) path; syscallarg(int) mode; } */ *uap = v; - caddr_t sg = stackgap_init(p->p_emul); + struct proc *p = l->l_proc; + caddr_t sg = stackgap_init(p, 0); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_chmod(p, uap, retval); + return sys_chmod(l, uap, retval); } -#if defined(__i386__) || defined(__m68k__) +#if defined(__i386__) || defined(__m68k__) || defined(__arm__) int -linux_sys_chown16(p, v, retval) - struct proc *p; +linux_sys_chown16(l, v, retval) + struct lwp *l; void *v; register_t *retval; { @@ -657,8 +743,9 @@ linux_sys_chown16(p, v, retval) syscallarg(int) uid; syscallarg(int) gid; } */ *uap = v; + struct proc *p = l->l_proc; struct sys___posix_chown_args bca; - caddr_t sg = stackgap_init(p->p_emul); + caddr_t sg = stackgap_init(p, 0); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); @@ -668,12 +755,12 @@ linux_sys_chown16(p, v, retval) SCARG(&bca, gid) = ((linux_gid_t)SCARG(uap, gid) == (linux_gid_t)-1) ? (gid_t)-1 : SCARG(uap, gid); - return sys___posix_chown(p, &bca, retval); + return sys___posix_chown(l, &bca, retval); } int -linux_sys_fchown16(p, v, retval) - struct proc *p; +linux_sys_fchown16(l, v, retval) + struct lwp *l; void *v; register_t *retval; { @@ -690,12 +777,12 @@ linux_sys_fchown16(p, v, retval) SCARG(&bfa, gid) = ((linux_gid_t)SCARG(uap, gid) == (linux_gid_t)-1) ? (gid_t)-1 : SCARG(uap, gid); - return sys___posix_fchown(p, &bfa, retval); + return sys___posix_fchown(l, &bfa, retval); } int -linux_sys_lchown16(p, v, retval) - struct proc *p; +linux_sys_lchown16(l, v, retval) + struct lwp *l; void *v; register_t *retval; { @@ -704,8 +791,9 @@ linux_sys_lchown16(p, v, retval) syscallarg(int) uid; syscallarg(int) gid; } */ *uap = v; + struct proc *p = l->l_proc; struct sys___posix_lchown_args bla; - caddr_t sg = stackgap_init(p->p_emul); + caddr_t sg = stackgap_init(p, 0); CHECK_ALT_SYMLINK(p, &sg, SCARG(uap, path)); @@ -715,13 +803,14 @@ linux_sys_lchown16(p, v, retval) SCARG(&bla, gid) = ((linux_gid_t)SCARG(uap, gid) == (linux_gid_t)-1) ? (gid_t)-1 : SCARG(uap, gid); - return sys___posix_lchown(p, &bla, retval); + return sys___posix_lchown(l, &bla, retval); } -#endif /* __i386__ || __m68k__ */ -#if defined (__i386__) || defined (__m68k__) || defined (__powerpc__) +#endif /* __i386__ || __m68k__ || __arm__ */ +#if defined (__i386__) || defined (__m68k__) || \ + defined (__powerpc__) || defined (__mips__) || defined(__arm__) int -linux_sys_chown(p, v, retval) - struct proc *p; +linux_sys_chown(l, v, retval) + struct lwp *l; void *v; register_t *retval; { @@ -730,16 +819,17 @@ linux_sys_chown(p, v, retval) syscallarg(int) uid; syscallarg(int) gid; } */ *uap = v; - caddr_t sg = stackgap_init(p->p_emul); + struct proc *p = l->l_proc; + caddr_t sg = stackgap_init(p, 0); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys___posix_chown(p, uap, retval); + return sys___posix_chown(l, uap, retval); } int -linux_sys_lchown(p, v, retval) - struct proc *p; +linux_sys_lchown(l, v, retval) + struct lwp *l; void *v; register_t *retval; { @@ -748,17 +838,18 @@ linux_sys_lchown(p, v, retval) syscallarg(int) uid; syscallarg(int) gid; } */ *uap = v; - caddr_t sg = stackgap_init(p->p_emul); + struct proc *p = l->l_proc; + caddr_t sg = stackgap_init(p, 0); CHECK_ALT_SYMLINK(p, &sg, SCARG(uap, path)); - return sys___posix_lchown(p, uap, retval); + return sys___posix_lchown(l, uap, retval); } -#endif /* __i386__ || __m68k__ || __powerpc__ */ +#endif /* __i386__ || __m68k__ || __powerpc__ || __mips__ || __arm__ */ int -linux_sys_rename(p, v, retval) - struct proc *p; +linux_sys_rename(l, v, retval) + struct lwp *l; void *v; register_t *retval; { @@ -766,17 +857,18 @@ linux_sys_rename(p, v, retval) syscallarg(const char *) from; syscallarg(const char *) to; } */ *uap = v; - caddr_t sg = stackgap_init(p->p_emul); + struct proc *p = l->l_proc; + caddr_t sg = stackgap_init(p, 0); CHECK_ALT_EXIST(p, &sg, SCARG(uap, from)); CHECK_ALT_CREAT(p, &sg, SCARG(uap, to)); - return sys___posix_rename(p, uap, retval); + return sys___posix_rename(l, uap, retval); } int -linux_sys_mkdir(p, v, retval) - struct proc *p; +linux_sys_mkdir(l, v, retval) + struct lwp *l; void *v; register_t *retval; { @@ -784,32 +876,34 @@ linux_sys_mkdir(p, v, retval) syscallarg(const char *) path; syscallarg(int) mode; } */ *uap = v; - caddr_t sg = stackgap_init(p->p_emul); + struct proc *p = l->l_proc; + caddr_t sg = stackgap_init(p, 0); CHECK_ALT_CREAT(p, &sg, SCARG(uap, path)); - return sys_mkdir(p, uap, retval); + return sys_mkdir(l, uap, retval); } int -linux_sys_rmdir(p, v, retval) - struct proc *p; +linux_sys_rmdir(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_rmdir_args /* { syscallarg(const char *) path; } */ *uap = v; - caddr_t sg = stackgap_init(p->p_emul); + struct proc *p = l->l_proc; + caddr_t sg = stackgap_init(p, 0); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_rmdir(p, uap, retval); + return sys_rmdir(l, uap, retval); } int -linux_sys_symlink(p, v, retval) - struct proc *p; +linux_sys_symlink(l, v, retval) + struct lwp *l; void *v; register_t *retval; { @@ -817,17 +911,18 @@ linux_sys_symlink(p, v, retval) syscallarg(const char *) path; syscallarg(const char *) to; } */ *uap = v; - caddr_t sg = stackgap_init(p->p_emul); + struct proc *p = l->l_proc; + caddr_t sg = stackgap_init(p, 0); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); CHECK_ALT_CREAT(p, &sg, SCARG(uap, to)); - return sys_symlink(p, uap, retval); + return sys_symlink(l, uap, retval); } int -linux_sys_link(p, v, retval) - struct proc *p; +linux_sys_link(l, v, retval) + struct lwp *l; void *v; register_t *retval; { @@ -835,17 +930,18 @@ linux_sys_link(p, v, retval) syscallarg(const char *) path; syscallarg(const char *) link; } */ *uap = v; - caddr_t sg = stackgap_init(p->p_emul); + struct proc *p = l->l_proc; + caddr_t sg = stackgap_init(p, 0); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); CHECK_ALT_CREAT(p, &sg, SCARG(uap, link)); - return sys_link(p, uap, retval); + return sys_link(l, uap, retval); } int -linux_sys_readlink(p, v, retval) - struct proc *p; +linux_sys_readlink(l, v, retval) + struct lwp *l; void *v; register_t *retval; { @@ -854,16 +950,17 @@ linux_sys_readlink(p, v, retval) syscallarg(char *) buf; syscallarg(int) count; } */ *uap = v; - caddr_t sg = stackgap_init(p->p_emul); + struct proc *p = l->l_proc; + caddr_t sg = stackgap_init(p, 0); CHECK_ALT_SYMLINK(p, &sg, SCARG(uap, name)); - return sys_readlink(p, uap, retval); + return sys_readlink(l, uap, retval); } int -linux_sys_truncate(p, v, retval) - struct proc *p; +linux_sys_truncate(l, v, retval) + struct lwp *l; void *v; register_t *retval; { @@ -871,11 +968,12 @@ linux_sys_truncate(p, v, retval) syscallarg(const char *) path; syscallarg(long) length; } */ *uap = v; - caddr_t sg = stackgap_init(p->p_emul); + struct proc *p = l->l_proc; + caddr_t sg = stackgap_init(p, 0); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return compat_43_sys_truncate(p, uap, retval); + return compat_43_sys_truncate(l, uap, retval); } /* @@ -885,8 +983,8 @@ linux_sys_truncate(p, v, retval) * (syscall #148 on the arm) */ int -linux_sys_fdatasync(p, v, retval) - struct proc *p; +linux_sys_fdatasync(l, v, retval) + struct lwp *l; void *v; register_t *retval; { @@ -895,15 +993,15 @@ linux_sys_fdatasync(p, v, retval) syscallarg(int) fd; } */ *uap = v; #endif - return sys_fsync(p, v, retval); + return sys_fsync(l, v, retval); } /* * pread(2). */ int -linux_sys_pread(p, v, retval) - struct proc *p; +linux_sys_pread(l, v, retval) + struct lwp *l; void *v; register_t *retval; { @@ -920,15 +1018,15 @@ linux_sys_pread(p, v, retval) SCARG(&pra, nbyte) = SCARG(uap, nbyte); SCARG(&pra, offset) = SCARG(uap, offset); - return sys_read(p, &pra, retval); + return sys_read(l, &pra, retval); } /* * pwrite(2). */ int -linux_sys_pwrite(p, v, retval) - struct proc *p; +linux_sys_pwrite(l, v, retval) + struct lwp *l; void *v; register_t *retval; { @@ -945,5 +1043,5 @@ linux_sys_pwrite(p, v, retval) SCARG(&pra, nbyte) = SCARG(uap, nbyte); SCARG(&pra, offset) = SCARG(uap, offset); - return sys_write(p, &pra, retval); + return sys_write(l, &pra, retval); }