1 1.35 ryo /* $NetBSD: linux_llseek.c,v 1.35 2021/09/23 06:56:27 ryo Exp $ */ 2 1.23 erh 3 1.23 erh /*- 4 1.25 fvdl * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. 5 1.23 erh * All rights reserved. 6 1.23 erh * 7 1.23 erh * This code is derived from software contributed to The NetBSD Foundation 8 1.25 fvdl * by Frank van der Linden and Eric Haszlakiewicz. 9 1.23 erh * 10 1.23 erh * Redistribution and use in source and binary forms, with or without 11 1.23 erh * modification, are permitted provided that the following conditions 12 1.23 erh * are met: 13 1.23 erh * 1. Redistributions of source code must retain the above copyright 14 1.23 erh * notice, this list of conditions and the following disclaimer. 15 1.23 erh * 2. Redistributions in binary form must reproduce the above copyright 16 1.23 erh * notice, this list of conditions and the following disclaimer in the 17 1.23 erh * documentation and/or other materials provided with the distribution. 18 1.23 erh * 19 1.23 erh * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 1.23 erh * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 1.23 erh * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 1.23 erh * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 1.23 erh * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 1.23 erh * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 1.23 erh * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 1.23 erh * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 1.23 erh * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 1.23 erh * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 1.23 erh * POSSIBILITY OF SUCH DAMAGE. 30 1.1 fvdl */ 31 1.26 lukem 32 1.26 lukem #include <sys/cdefs.h> 33 1.35 ryo __KERNEL_RCSID(0, "$NetBSD: linux_llseek.c,v 1.35 2021/09/23 06:56:27 ryo Exp $"); 34 1.1 fvdl 35 1.1 fvdl #include <sys/param.h> 36 1.1 fvdl #include <sys/systm.h> 37 1.1 fvdl #include <sys/kernel.h> 38 1.1 fvdl #include <sys/mount.h> 39 1.13 fvdl #include <sys/conf.h> 40 1.1 fvdl 41 1.33 tsutsui #include <sys/sched.h> 42 1.1 fvdl #include <sys/syscallargs.h> 43 1.1 fvdl 44 1.24 christos #include <compat/linux/common/linux_types.h> 45 1.24 christos #include <compat/linux/common/linux_signal.h> 46 1.24 christos #include <compat/linux/common/linux_fcntl.h> 47 1.24 christos #include <compat/linux/common/linux_util.h> 48 1.24 christos 49 1.1 fvdl #include <compat/linux/linux_syscallargs.h> 50 1.1 fvdl 51 1.23 erh /* Used on: arm, i386, m68k, mips, ppc, sparc */ 52 1.35 ryo /* Not used on: aarch64, alpha, sparc64 */ 53 1.1 fvdl 54 1.1 fvdl /* 55 1.2 fvdl * This appears to be part of a Linux attempt to switch to 64 bits file sizes. 56 1.2 fvdl */ 57 1.2 fvdl int 58 1.31 dsl linux_sys_llseek(struct lwp *l, const struct linux_sys_llseek_args *uap, register_t *retval) 59 1.11 thorpej { 60 1.31 dsl /* { 61 1.2 fvdl syscallarg(int) fd; 62 1.2 fvdl syscallarg(uint32_t) ohigh; 63 1.2 fvdl syscallarg(uint32_t) olow; 64 1.29 christos syscallarg(void *) res; 65 1.2 fvdl syscallarg(int) whence; 66 1.31 dsl } */ 67 1.12 mycroft struct sys_lseek_args bla; 68 1.2 fvdl int error; 69 1.2 fvdl off_t off; 70 1.2 fvdl 71 1.2 fvdl off = SCARG(uap, olow) | (((off_t) SCARG(uap, ohigh)) << 32); 72 1.2 fvdl 73 1.2 fvdl SCARG(&bla, fd) = SCARG(uap, fd); 74 1.2 fvdl SCARG(&bla, offset) = off; 75 1.2 fvdl SCARG(&bla, whence) = SCARG(uap, whence); 76 1.2 fvdl 77 1.27 thorpej if ((error = sys_lseek(l, &bla, retval))) 78 1.2 fvdl return error; 79 1.2 fvdl 80 1.2 fvdl if ((error = copyout(retval, SCARG(uap, res), sizeof (off_t)))) 81 1.2 fvdl return error; 82 1.2 fvdl 83 1.2 fvdl retval[0] = 0; 84 1.2 fvdl return 0; 85 1.1 fvdl } 86