Source-Changes-HG archive

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

[src/pgoyette-compat]: src/sys Convert the openat_10 hook to use the MP-safe ...



details:   https://anonhg.NetBSD.org/src/rev/0f9be7c34be2
branches:  pgoyette-compat
changeset: 445149:0f9be7c34be2
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Mon Oct 15 10:44:27 2018 +0000

description:
Convert the openat_10 hook to use the MP-safe mechanism

XXX Still to do: compat70_unp_addsockcred and sysvipc50_sysctl

diffstat:

 sys/compat/common/vfs_syscalls_10.c |  15 ++++++++-------
 sys/kern/compat_stub.c              |   7 ++++++-
 sys/kern/vfs_syscalls.c             |  16 ++++++++--------
 sys/sys/compat_stub.h               |   8 +++++++-
 sys/sys/vfs_syscalls.h              |   4 +---
 5 files changed, 30 insertions(+), 20 deletions(-)

diffs (164 lines):

diff -r 8ce716e99be8 -r 0f9be7c34be2 sys/compat/common/vfs_syscalls_10.c
--- a/sys/compat/common/vfs_syscalls_10.c       Mon Oct 15 09:51:33 2018 +0000
+++ b/sys/compat/common/vfs_syscalls_10.c       Mon Oct 15 10:44:27 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_syscalls_10.c,v 1.1.2.3 2018/09/22 04:56:28 pgoyette Exp $     */
+/* $NetBSD: vfs_syscalls_10.c,v 1.1.2.4 2018/10/15 10:44:27 pgoyette Exp $     */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_10.c,v 1.1.2.3 2018/09/22 04:56:28 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_10.c,v 1.1.2.4 2018/10/15 10:44:27 pgoyette Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -40,11 +40,10 @@
 #include <sys/systm.h>
 #include <sys/namei.h>
 #include <sys/vfs_syscalls.h>
+#include <sys/compat_stub.h>
 
 #include <compat/common/compat_mod.h>
 
-static int (*orig_sys_openat_10)(struct pathbuf **);
-
 static int
 real_sys_openat_10(struct pathbuf **pb)
 {
@@ -53,15 +52,17 @@
        return (*pb == NULL ? ENOMEM : 0);
 }
 
+MODULE_SET_HOOK(compat_10_openat_hook, "openat_10", real_sys_openat_10);
+MODULE_UNSET_HOOK(compat_10_openat_hook);
+
 void vfs_syscalls_10_init(void)
 {
 
-       orig_sys_openat_10 = vec_sys_openat_10;
-       vec_sys_openat_10 = real_sys_openat_10;
+       compat_10_openat_hook_set();
 }
 
 void vfs_syscalls_10_fini(void)
 {
 
-       vec_sys_openat_10 = orig_sys_openat_10;
+       compat_10_openat_hook_unset();
 }
diff -r 8ce716e99be8 -r 0f9be7c34be2 sys/kern/compat_stub.c
--- a/sys/kern/compat_stub.c    Mon Oct 15 09:51:33 2018 +0000
+++ b/sys/kern/compat_stub.c    Mon Oct 15 10:44:27 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_stub.c,v 1.1.2.29 2018/10/15 09:51:33 pgoyette Exp $        */
+/* $NetBSD: compat_stub.c,v 1.1.2.30 2018/10/15 10:44:27 pgoyette Exp $        */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -193,3 +193,8 @@
  */
 struct compat_60_ioctl_hook_t compat_60_ioctl_hook;
 
+/*
+ * Hook for compat_10 openat
+ */
+struct compat_10_openat_hook_t compat_10_openat_hook;
+
diff -r 8ce716e99be8 -r 0f9be7c34be2 sys/kern/vfs_syscalls.c
--- a/sys/kern/vfs_syscalls.c   Mon Oct 15 09:51:33 2018 +0000
+++ b/sys/kern/vfs_syscalls.c   Mon Oct 15 10:44:27 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_syscalls.c,v 1.518.2.1 2018/03/14 02:24:56 pgoyette Exp $  */
+/*     $NetBSD: vfs_syscalls.c,v 1.518.2.2 2018/10/15 10:44:27 pgoyette Exp $  */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.518.2.1 2018/03/14 02:24:56 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.518.2.2 2018/10/15 10:44:27 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_fileassoc.h"
@@ -108,6 +108,7 @@
 #include <sys/module.h>
 #include <sys/buf.h>
 #include <sys/event.h>
+#include <sys/compat_stub.h>
 
 #include <miscfs/genfs/genfs.h>
 #include <miscfs/specfs/specdev.h>
@@ -141,11 +142,6 @@
 static int fd_nameiat_simple_user(struct lwp *, int, const char *,
     namei_simple_flags_t, struct vnode **);
 
-/* Routine for COMPAT_10 handling of NULL pathbuf passed to do_sys_openat */
-
-static int stub_sys_openat_10(struct pathbuf **);
-int (*vec_sys_openat_10)(struct pathbuf **) = stub_sys_openat_10;
-
 /*
  * This table is used to maintain compatibility with 4.3BSD
  * and NetBSD 0.9 mount syscalls - and possibly other systems.
@@ -1639,6 +1635,10 @@
        return 0;
 }
 
+MODULE_CALL_HOOK_DECL(compat_10_openat_hook, f, (struct pathbuf **));
+MODULE_CALL_HOOK(compat_10_openat_hook, f, (struct pathbuf **pb), (pb),
+    stub_sys_openat_10(pb));
+
 static int
 do_sys_openat(lwp_t *l, int fdat, const char *path, int flags,
     int mode, int *fd)
@@ -1649,7 +1649,7 @@
        int error;
 
        if (path == NULL) {
-               error = (*vec_sys_openat_10)(&pb);
+               error = compat_10_openat_hook_f_call(&pb);
                if (error)
                        return error;
        } else {
diff -r 8ce716e99be8 -r 0f9be7c34be2 sys/sys/compat_stub.h
--- a/sys/sys/compat_stub.h     Mon Oct 15 09:51:33 2018 +0000
+++ b/sys/sys/compat_stub.h     Mon Oct 15 10:44:27 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_stub.h,v 1.1.2.41 2018/10/15 09:51:34 pgoyette Exp $        */
+/* $NetBSD: compat_stub.h,v 1.1.2.42 2018/10/15 10:44:28 pgoyette Exp $        */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -245,4 +245,10 @@
 MODULE_HOOK2(compat_60_ioctl_hook, (dev_t, u_long, void *, int, struct lwp *),
     (dev_t, u_long, void *, int, struct lwp *));
 
+/*
+ * Hook for compat_10 openat
+ */
+struct pathbuf;
+MODULE_HOOK(compat_10_openat_hook, (struct pathbuf **));
+
 #endif /* _SYS_COMPAT_STUB_H */
diff -r 8ce716e99be8 -r 0f9be7c34be2 sys/sys/vfs_syscalls.h
--- a/sys/sys/vfs_syscalls.h    Mon Oct 15 09:51:33 2018 +0000
+++ b/sys/sys/vfs_syscalls.h    Mon Oct 15 10:44:27 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_syscalls.h,v 1.23.2.2 2018/04/17 00:02:58 pgoyette Exp $        */
+/*     $NetBSD: vfs_syscalls.h,v 1.23.2.3 2018/10/15 10:44:28 pgoyette Exp $        */
 
 /*
  * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -86,6 +86,4 @@
 extern const char *const mountcompatnames[];
 extern const int nmountcompatnames;
 
-extern int (*vec_sys_openat_10)(struct pathbuf **);
-
 #endif /* _SYS_VFS_SYSCALLS_H_ */



Home | Main Index | Thread Index | Old Index