From owner-svn-src-stable@freebsd.org Wed Mar 8 13:09:14 2017 Return-Path: Delivered-To: svn-src-stable@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 B113ACFB1D0; Wed, 8 Mar 2017 13:09:14 +0000 (UTC) (envelope-from mmokhi@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 6EEDF1A68; Wed, 8 Mar 2017 13:09:14 +0000 (UTC) (envelope-from mmokhi@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v28D9D9I051559; Wed, 8 Mar 2017 13:09:13 GMT (envelope-from mmokhi@FreeBSD.org) Received: (from mmokhi@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v28D9Cxw051553; Wed, 8 Mar 2017 13:09:12 GMT (envelope-from mmokhi@FreeBSD.org) Message-Id: <201703081309.v28D9Cxw051553@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmokhi set sender to mmokhi@FreeBSD.org using -f From: Mahdi Mokhtari Date: Wed, 8 Mar 2017 13:09:12 +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: r314909 - in stable/11/sys: amd64/linux amd64/linux32 compat/linux i386/linux X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Mar 2017 13:09:14 -0000 Author: mmokhi (ports committer) Date: Wed Mar 8 13:09:12 2017 New Revision: 314909 URL: https://svnweb.freebsd.org/changeset/base/314909 Log: MFC r314219 Add linux_preadv() and linux_pwritev() syscalls to Linuxulator. Approved by: dchagin Modified: stable/11/sys/amd64/linux/linux_dummy.c stable/11/sys/amd64/linux32/linux.h stable/11/sys/amd64/linux32/linux32_dummy.c stable/11/sys/amd64/linux32/linux32_machdep.c stable/11/sys/compat/linux/linux_file.c stable/11/sys/i386/linux/linux_dummy.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/amd64/linux/linux_dummy.c ============================================================================== --- stable/11/sys/amd64/linux/linux_dummy.c Wed Mar 8 12:18:58 2017 (r314908) +++ stable/11/sys/amd64/linux/linux_dummy.c Wed Mar 8 13:09:12 2017 (r314909) @@ -111,9 +111,6 @@ DUMMY(timerfd_gettime); /* linux 2.6.27: */ DUMMY(signalfd4); DUMMY(inotify_init1); -/* linux 2.6.30: */ -DUMMY(preadv); -DUMMY(pwritev); /* linux 2.6.31: */ DUMMY(rt_tgsigqueueinfo); DUMMY(perf_event_open); Modified: stable/11/sys/amd64/linux32/linux.h ============================================================================== --- stable/11/sys/amd64/linux32/linux.h Wed Mar 8 12:18:58 2017 (r314908) +++ stable/11/sys/amd64/linux32/linux.h Wed Mar 8 13:09:12 2017 (r314909) @@ -663,6 +663,7 @@ struct l_user_desc { (((desc)->b >> LINUX_ENTRY_B_USEABLE) & 1) struct iovec; +struct uio; struct l_iovec32 { uint32_t iov_base; @@ -671,6 +672,8 @@ struct l_iovec32 { int linux32_copyiniov(struct l_iovec32 *iovp32, l_ulong iovcnt, struct iovec **iovp, int error); +int linux32_copyinuio(struct l_iovec32 *iovp, l_ulong iovcnt, + struct uio **uiop); int linux_copyout_rusage(struct rusage *ru, void *uaddr); /* robust futexes */ Modified: stable/11/sys/amd64/linux32/linux32_dummy.c ============================================================================== --- stable/11/sys/amd64/linux32/linux32_dummy.c Wed Mar 8 12:18:58 2017 (r314908) +++ stable/11/sys/amd64/linux32/linux32_dummy.c Wed Mar 8 13:09:12 2017 (r314909) @@ -110,9 +110,6 @@ DUMMY(timerfd_gettime); /* linux 2.6.27: */ DUMMY(signalfd4); DUMMY(inotify_init1); -/* linux 2.6.30: */ -DUMMY(preadv); -DUMMY(pwritev); /* linux 2.6.31: */ DUMMY(rt_tgsigqueueinfo); DUMMY(perf_event_open); Modified: stable/11/sys/amd64/linux32/linux32_machdep.c ============================================================================== --- stable/11/sys/amd64/linux32/linux32_machdep.c Wed Mar 8 12:18:58 2017 (r314908) +++ stable/11/sys/amd64/linux32/linux32_machdep.c Wed Mar 8 13:09:12 2017 (r314909) @@ -144,7 +144,7 @@ linux_execve(struct thread *td, struct l CTASSERT(sizeof(struct l_iovec32) == 8); -static int +int linux32_copyinuio(struct l_iovec32 *iovp, l_ulong iovcnt, struct uio **uiop) { struct l_iovec32 iov32; Modified: stable/11/sys/compat/linux/linux_file.c ============================================================================== --- stable/11/sys/compat/linux/linux_file.c Wed Mar 8 12:18:58 2017 (r314908) +++ stable/11/sys/compat/linux/linux_file.c Wed Mar 8 13:09:12 2017 (r314909) @@ -1062,6 +1062,62 @@ linux_pwrite(td, uap) } int +linux_preadv(struct thread *td, struct linux_preadv_args *uap) +{ + struct uio *auio; + int error; + off_t offset; + + /* + * According http://man7.org/linux/man-pages/man2/preadv.2.html#NOTES + * pos_l and pos_h, respectively, contain the + * low order and high order 32 bits of offset. + */ + offset = (((off_t)uap->pos_h << (sizeof(offset) * 4)) << + (sizeof(offset) * 4)) | uap->pos_l; + if (offset < 0) + return (EINVAL); +#ifdef COMPAT_LINUX32 + error = linux32_copyinuio(PTRIN(uap->vec), uap->vlen, &auio); +#else + error = copyinuio(uap->vec, uap->vlen, &auio); +#endif + if (error != 0) + return (error); + error = kern_preadv(td, uap->fd, auio, offset); + free(auio, M_IOV); + return (error); +} + +int +linux_pwritev(struct thread *td, struct linux_pwritev_args *uap) +{ + struct uio *auio; + int error; + off_t offset; + + /* + * According http://man7.org/linux/man-pages/man2/pwritev.2.html#NOTES + * pos_l and pos_h, respectively, contain the + * low order and high order 32 bits of offset. + */ + offset = (((off_t)uap->pos_h << (sizeof(offset) * 4)) << + (sizeof(offset) * 4)) | uap->pos_l; + if (offset < 0) + return (EINVAL); +#ifdef COMPAT_LINUX32 + error = linux32_copyinuio(PTRIN(uap->vec), uap->vlen, &auio); +#else + error = copyinuio(uap->vec, uap->vlen, &auio); +#endif + if (error != 0) + return (error); + error = kern_pwritev(td, uap->fd, auio, offset); + free(auio, M_IOV); + return (error); +} + +int linux_mount(struct thread *td, struct linux_mount_args *args) { char fstypename[MFSNAMELEN]; Modified: stable/11/sys/i386/linux/linux_dummy.c ============================================================================== --- stable/11/sys/i386/linux/linux_dummy.c Wed Mar 8 12:18:58 2017 (r314908) +++ stable/11/sys/i386/linux/linux_dummy.c Wed Mar 8 13:09:12 2017 (r314909) @@ -106,9 +106,6 @@ DUMMY(timerfd_gettime); /* linux 2.6.27: */ DUMMY(signalfd4); DUMMY(inotify_init1); -/* linux 2.6.30: */ -DUMMY(preadv); -DUMMY(pwritev); /* linux 2.6.31: */ DUMMY(rt_tgsigqueueinfo); DUMMY(perf_event_open);