From owner-svn-src-all@freebsd.org Sun Mar 19 14:36:20 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 99DC2D13E08; Sun, 19 Mar 2017 14:36:20 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 744CB9C9; Sun, 19 Mar 2017 14:36:20 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2JEaJNY069626; Sun, 19 Mar 2017 14:36:19 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2JEaJAQ069620; Sun, 19 Mar 2017 14:36:19 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201703191436.v2JEaJAQ069620@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Sun, 19 Mar 2017 14:36:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315550 - in stable/11/sys: compat/cloudabi compat/freebsd32 compat/linux kern X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Mar 2017 14:36:20 -0000 Author: trasz Date: Sun Mar 19 14:36:19 2017 New Revision: 315550 URL: https://svnweb.freebsd.org/changeset/base/315550 Log: MFC r312987: Add kern_lseek() and use it instead of sys_lseek() in various compats. I didn't touch svr4/, there's no point. Sponsored by: DARPA, AFRL Modified: stable/11/sys/compat/cloudabi/cloudabi_fd.c stable/11/sys/compat/freebsd32/freebsd32_misc.c stable/11/sys/compat/linux/linux_file.c stable/11/sys/kern/vfs_syscalls.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/compat/cloudabi/cloudabi_fd.c ============================================================================== --- stable/11/sys/compat/cloudabi/cloudabi_fd.c Sun Mar 19 14:25:23 2017 (r315549) +++ stable/11/sys/compat/cloudabi/cloudabi_fd.c Sun Mar 19 14:36:19 2017 (r315550) @@ -203,26 +203,23 @@ cloudabi_sys_fd_replace(struct thread *t int cloudabi_sys_fd_seek(struct thread *td, struct cloudabi_sys_fd_seek_args *uap) { - struct lseek_args lseek_args = { - .fd = uap->fd, - .offset = uap->offset - }; + int whence; switch (uap->whence) { case CLOUDABI_WHENCE_CUR: - lseek_args.whence = SEEK_CUR; + whence = SEEK_CUR; break; case CLOUDABI_WHENCE_END: - lseek_args.whence = SEEK_END; + whence = SEEK_END; break; case CLOUDABI_WHENCE_SET: - lseek_args.whence = SEEK_SET; + whence = SEEK_SET; break; default: return (EINVAL); } - return (sys_lseek(td, &lseek_args)); + return (kern_lseek(td, uap->fd, uap->offset, whence)); } /* Converts a file descriptor to a CloudABI file descriptor type. */ Modified: stable/11/sys/compat/freebsd32/freebsd32_misc.c ============================================================================== --- stable/11/sys/compat/freebsd32/freebsd32_misc.c Sun Mar 19 14:25:23 2017 (r315549) +++ stable/11/sys/compat/freebsd32/freebsd32_misc.c Sun Mar 19 14:36:19 2017 (r315550) @@ -1467,12 +1467,8 @@ freebsd32_pwrite(struct thread *td, stru int ofreebsd32_lseek(struct thread *td, struct ofreebsd32_lseek_args *uap) { - struct lseek_args nuap; - nuap.fd = uap->fd; - nuap.offset = uap->offset; - nuap.whence = uap->whence; - return (sys_lseek(td, &nuap)); + return (kern_lseek(td, uap->fd, uap->offset, uap->whence)); } #endif @@ -1480,13 +1476,10 @@ int freebsd32_lseek(struct thread *td, struct freebsd32_lseek_args *uap) { int error; - struct lseek_args ap; off_t pos; - ap.fd = uap->fd; - ap.offset = PAIR32TO64(off_t,uap->offset); - ap.whence = uap->whence; - error = sys_lseek(td, &ap); + error = kern_lseek(td, uap->fd, PAIR32TO64(off_t, uap->offset), + uap->whence); /* Expand the quad return into two parts for eax and edx */ pos = td->td_uretoff.tdu_off; td->td_retval[RETVAL_LO] = pos & 0xffffffff; /* %eax */ @@ -1583,13 +1576,10 @@ int freebsd6_freebsd32_lseek(struct thread *td, struct freebsd6_freebsd32_lseek_args *uap) { int error; - struct lseek_args ap; off_t pos; - ap.fd = uap->fd; - ap.offset = PAIR32TO64(off_t,uap->offset); - ap.whence = uap->whence; - error = sys_lseek(td, &ap); + error = kern_lseek(td, uap->fd, PAIR32TO64(off_t, uap->offset), + uap->whence); /* Expand the quad return into two parts for eax and edx */ pos = *(off_t *)(td->td_retval); td->td_retval[RETVAL_LO] = pos & 0xffffffff; /* %eax */ Modified: stable/11/sys/compat/linux/linux_file.c ============================================================================== --- stable/11/sys/compat/linux/linux_file.c Sun Mar 19 14:25:23 2017 (r315549) +++ stable/11/sys/compat/linux/linux_file.c Sun Mar 19 14:36:19 2017 (r315550) @@ -212,31 +212,19 @@ linux_open(struct thread *td, struct lin int linux_lseek(struct thread *td, struct linux_lseek_args *args) { - struct lseek_args /* { - int fd; - int pad; - off_t offset; - int whence; - } */ tmp_args; - int error; #ifdef DEBUG if (ldebug(lseek)) printf(ARGS(lseek, "%d, %ld, %d"), args->fdes, (long)args->off, args->whence); #endif - tmp_args.fd = args->fdes; - tmp_args.offset = (off_t)args->off; - tmp_args.whence = args->whence; - error = sys_lseek(td, &tmp_args); - return (error); + return (kern_lseek(td, args->fdes, args->off, args->whence)); } #if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32)) int linux_llseek(struct thread *td, struct linux_llseek_args *args) { - struct lseek_args bsd_args; int error; off_t off; @@ -247,14 +235,12 @@ linux_llseek(struct thread *td, struct l #endif off = (args->olow) | (((off_t) args->ohigh) << 32); - bsd_args.fd = args->fd; - bsd_args.offset = off; - bsd_args.whence = args->whence; - - if ((error = sys_lseek(td, &bsd_args))) + error = kern_lseek(td, args->fd, off, args->whence); + if (error != 0) return (error); - if ((error = copyout(td->td_retval, args->res, sizeof (off_t)))) + error = copyout(td->td_retval, args->res, sizeof(off_t)); + if (error != 0) return (error); td->td_retval[0] = 0; Modified: stable/11/sys/kern/vfs_syscalls.c ============================================================================== --- stable/11/sys/kern/vfs_syscalls.c Sun Mar 19 14:25:23 2017 (r315549) +++ stable/11/sys/kern/vfs_syscalls.c Sun Mar 19 14:36:19 2017 (r315550) @@ -1804,25 +1804,25 @@ struct lseek_args { }; #endif int -sys_lseek(td, uap) - struct thread *td; - register struct lseek_args /* { - int fd; - int pad; - off_t offset; - int whence; - } */ *uap; +sys_lseek(struct thread *td, struct lseek_args *uap) +{ + + return (kern_lseek(td, uap->fd, uap->offset, uap->whence)); +} + +int +kern_lseek(struct thread *td, int fd, off_t offset, int whence) { struct file *fp; cap_rights_t rights; int error; - AUDIT_ARG_FD(uap->fd); - error = fget(td, uap->fd, cap_rights_init(&rights, CAP_SEEK), &fp); + AUDIT_ARG_FD(fd); + error = fget(td, fd, cap_rights_init(&rights, CAP_SEEK), &fp); if (error != 0) return (error); error = (fp->f_ops->fo_flags & DFLAG_SEEKABLE) != 0 ? - fo_seek(fp, uap->offset, uap->whence, td) : ESPIPE; + fo_seek(fp, offset, whence, td) : ESPIPE; fdrop(fp, td); return (error); } @@ -1839,41 +1839,20 @@ struct olseek_args { }; #endif int -olseek(td, uap) - struct thread *td; - register struct olseek_args /* { - int fd; - long offset; - int whence; - } */ *uap; +olseek(struct thread *td, struct olseek_args *uap) { - struct lseek_args /* { - int fd; - int pad; - off_t offset; - int whence; - } */ nuap; - nuap.fd = uap->fd; - nuap.offset = uap->offset; - nuap.whence = uap->whence; - return (sys_lseek(td, &nuap)); + return (kern_lseek(td, uap->fd, uap->offset, uap->whence)); } #endif /* COMPAT_43 */ #if defined(COMPAT_FREEBSD6) /* Version with the 'pad' argument */ int -freebsd6_lseek(td, uap) - struct thread *td; - register struct freebsd6_lseek_args *uap; +freebsd6_lseek(struct thread *td, struct freebsd6_lseek_args *uap) { - struct lseek_args ouap; - ouap.fd = uap->fd; - ouap.offset = uap->offset; - ouap.whence = uap->whence; - return (sys_lseek(td, &ouap)); + return (kern_lseek(td, uap->fd, uap->offset, uap->whence)); } #endif