linux_file.c (315550) | linux_file.c (315553) |
---|---|
1/*- 2 * Copyright (c) 1994-1995 S��ren Schmidt 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 13 unchanged lines hidden (view full) --- 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 29#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1994-1995 S��ren Schmidt 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 13 unchanged lines hidden (view full) --- 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 29#include <sys/cdefs.h> |
30__FBSDID("$FreeBSD: stable/11/sys/compat/linux/linux_file.c 315550 2017-03-19 14:36:19Z trasz $"); | 30__FBSDID("$FreeBSD: stable/11/sys/compat/linux/linux_file.c 315553 2017-03-19 14:46:40Z trasz $"); |
31 32#include "opt_compat.h" 33 34#include <sys/param.h> 35#include <sys/systm.h> 36#include <sys/capsicum.h> 37#include <sys/conf.h> 38#include <sys/dirent.h> --- 954 unchanged lines hidden (view full) --- 993 struct thread *td; 994 struct linux_fdatasync_args *uap; 995{ 996 997 return (kern_fsync(td, uap->fd, false)); 998} 999 1000int | 31 32#include "opt_compat.h" 33 34#include <sys/param.h> 35#include <sys/systm.h> 36#include <sys/capsicum.h> 37#include <sys/conf.h> 38#include <sys/dirent.h> --- 954 unchanged lines hidden (view full) --- 993 struct thread *td; 994 struct linux_fdatasync_args *uap; 995{ 996 997 return (kern_fsync(td, uap->fd, false)); 998} 999 1000int |
1001linux_pread(td, uap) 1002 struct thread *td; 1003 struct linux_pread_args *uap; | 1001linux_pread(struct thread *td, struct linux_pread_args *uap) |
1004{ | 1002{ |
1005 struct pread_args bsd; | |
1006 cap_rights_t rights; 1007 struct vnode *vp; 1008 int error; 1009 | 1003 cap_rights_t rights; 1004 struct vnode *vp; 1005 int error; 1006 |
1010 bsd.fd = uap->fd; 1011 bsd.buf = uap->buf; 1012 bsd.nbyte = uap->nbyte; 1013 bsd.offset = uap->offset; 1014 error = sys_pread(td, &bsd); | 1007 error = kern_pread(td, uap->fd, uap->buf, uap->nbyte, uap->offset); |
1015 if (error == 0) { 1016 /* This seems to violate POSIX but linux does it */ 1017 error = fgetvp(td, uap->fd, 1018 cap_rights_init(&rights, CAP_PREAD), &vp); 1019 if (error != 0) 1020 return (error); 1021 if (vp->v_type == VDIR) { 1022 vrele(vp); 1023 return (EISDIR); 1024 } 1025 vrele(vp); 1026 } 1027 return (error); 1028} 1029 1030int | 1008 if (error == 0) { 1009 /* This seems to violate POSIX but linux does it */ 1010 error = fgetvp(td, uap->fd, 1011 cap_rights_init(&rights, CAP_PREAD), &vp); 1012 if (error != 0) 1013 return (error); 1014 if (vp->v_type == VDIR) { 1015 vrele(vp); 1016 return (EISDIR); 1017 } 1018 vrele(vp); 1019 } 1020 return (error); 1021} 1022 1023int |
1031linux_pwrite(td, uap) 1032 struct thread *td; 1033 struct linux_pwrite_args *uap; | 1024linux_pwrite(struct thread *td, struct linux_pwrite_args *uap) |
1034{ | 1025{ |
1035 struct pwrite_args bsd; | |
1036 | 1026 |
1037 bsd.fd = uap->fd; 1038 bsd.buf = uap->buf; 1039 bsd.nbyte = uap->nbyte; 1040 bsd.offset = uap->offset; 1041 return (sys_pwrite(td, &bsd)); | 1027 return (kern_pwrite(td, uap->fd, uap->buf, uap->nbyte, uap->offset)); |
1042} 1043 1044int 1045linux_preadv(struct thread *td, struct linux_preadv_args *uap) 1046{ 1047 struct uio *auio; 1048 int error; 1049 off_t offset; --- 638 unchanged lines hidden --- | 1028} 1029 1030int 1031linux_preadv(struct thread *td, struct linux_preadv_args *uap) 1032{ 1033 struct uio *auio; 1034 int error; 1035 off_t offset; --- 638 unchanged lines hidden --- |