Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/compat/linux32/common - Use LINUX32_F_xxx instead of LIN...



details:   https://anonhg.NetBSD.org/src/rev/1ab8449bf0ae
branches:  trunk
changeset: 1026435:1ab8449bf0ae
user:      ryo <ryo%NetBSD.org@localhost>
date:      Thu Nov 25 02:35:00 2021 +0000

description:
- Use LINUX32_F_xxx instead of LINUX_F_xxx for compat_linux32.
  aarch64 and arm have different values.
- Compile linux32_sys_fadvise64() only if the syscall is required.

diffstat:

 sys/compat/linux32/arch/amd64/linux32_fcntl.h |  42 ++++++++++++++++++++++++++
 sys/compat/linux32/common/linux32_fcntl.c     |  20 +++++++-----
 sys/compat/linux32/common/linux32_fcntl.h     |  43 +++++++++++++++++++++++++++
 3 files changed, 97 insertions(+), 8 deletions(-)

diffs (163 lines):

diff -r 30ff6bf116d3 -r 1ab8449bf0ae sys/compat/linux32/arch/amd64/linux32_fcntl.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/linux32/arch/amd64/linux32_fcntl.h     Thu Nov 25 02:35:00 2021 +0000
@@ -0,0 +1,42 @@
+/*-
+ * Copyright (c) 2021 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Ryo Shimizu.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _AMD64_LINUX32_FCNTL_H_
+#define _AMD64_LINUX32_FCNTL_H_
+
+#include <compat/linux/common/linux_fcntl.h>
+
+#define LINUX32_F_GETLK                LINUX_F_GETLK
+#define LINUX32_F_SETLK                LINUX_F_SETLK
+#define LINUX32_F_SETLKW       LINUX_F_SETLKW
+#define LINUX32_F_GETLK64      LINUX_F_GETLK64
+#define LINUX32_F_SETLK64      LINUX_F_SETLK64
+#define LINUX32_F_SETLKW64     LINUX_F_SETLKW64
+
+#endif /* _AMD64_LINUX32_FCNTL_H_ */
diff -r 30ff6bf116d3 -r 1ab8449bf0ae sys/compat/linux32/common/linux32_fcntl.c
--- a/sys/compat/linux32/common/linux32_fcntl.c Thu Nov 25 02:32:24 2021 +0000
+++ b/sys/compat/linux32/common/linux32_fcntl.c Thu Nov 25 02:35:00 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux32_fcntl.c,v 1.10 2014/05/17 09:30:07 njoly Exp $ */
+/*     $NetBSD: linux32_fcntl.c,v 1.11 2021/11/25 02:35:00 ryo Exp $ */
 
 /*-
  * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
@@ -33,7 +33,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(0, "$NetBSD: linux32_fcntl.c,v 1.10 2014/05/17 09:30:07 njoly Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux32_fcntl.c,v 1.11 2021/11/25 02:35:00 ryo Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -57,8 +57,10 @@
 #include <compat/linux/linux_syscallargs.h>
 
 #include <compat/linux32/common/linux32_types.h>
+#include <compat/linux32/common/linux32_fcntl.h>
 #include <compat/linux32/common/linux32_signal.h>
 #include <compat/linux32/common/linux32_machdep.h>
+#include <compat/linux32/linux32_syscall.h>
 #include <compat/linux32/linux32_syscallargs.h>
 
 struct linux32_flock {
@@ -120,18 +122,18 @@
        int cmd =  SCARG(uap, cmd);
 
        switch (cmd) {
-       case LINUX_F_GETLK64:
+       case LINUX32_F_GETLK64:
                do_linux_getlk(SCARG(uap, fd), cmd, SCARG_P32(uap, arg),
                    linux32, flock64);
-       case LINUX_F_SETLK64:
-       case LINUX_F_SETLKW64:
+       case LINUX32_F_SETLK64:
+       case LINUX32_F_SETLKW64:
                do_linux_setlk(SCARG(uap, fd), cmd, SCARG_P32(uap, arg),
                    linux32, flock64, LINUX_F_SETLK64);
-       case LINUX_F_GETLK:
+       case LINUX32_F_GETLK:
                do_linux_getlk(SCARG(uap, fd), cmd, SCARG_P32(uap, arg),
                    linux32, flock);
-       case LINUX_F_SETLK:
-       case LINUX_F_SETLKW:
+       case LINUX32_F_SETLK:
+       case LINUX32_F_SETLKW:
                do_linux_setlk(SCARG(uap, fd), cmd, SCARG_P32(uap, arg),
                    linux32, flock, LINUX_F_SETLK);
        default:
@@ -145,6 +147,7 @@
        return linux_sys_fcntl(l, &ua, retval);
 }
 
+#ifdef LINUX32_SYS_fadvise64
 int
 linux32_sys_fadvise64(struct lwp *l,
     const struct linux32_sys_fadvise64_args *uap, register_t *retval)
@@ -161,6 +164,7 @@
        return do_posix_fadvise(SCARG(uap, fd), off,
            SCARG(uap, len), linux_to_bsd_posix_fadv(SCARG(uap, advice)));
 }
+#endif
 
 int
 linux32_sys_fadvise64_64(struct lwp *l,
diff -r 30ff6bf116d3 -r 1ab8449bf0ae sys/compat/linux32/common/linux32_fcntl.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/linux32/common/linux32_fcntl.h Thu Nov 25 02:35:00 2021 +0000
@@ -0,0 +1,43 @@
+/*     $NetBSD: linux32_fcntl.h,v 1.1 2021/11/25 02:35:00 ryo Exp $    */
+
+/*-
+ * Copyright (c) 2021 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Ryo Shimizu.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _LINUX32_FCNTL_H_
+#define _LINUX32_FCNTL_H_
+
+#if defined(__aarch64__)
+#include <compat/linux32/arch/aarch64/linux32_fcntl.h>
+#elif defined(__amd64__)
+#include <compat/linux32/arch/amd64/linux32_fcntl.h>
+#else
+#error Undefined linux32_fcntl.h machine type.
+#endif
+
+#endif /* _LINUX32_FCNTL_H_ */



Home | Main Index | Thread Index | Old Index