Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/pgoyette-compat]: src/sys Make do_openat()'s handling of path=NULL modular
details: https://anonhg.NetBSD.org/src/rev/f60e78748496
branches: pgoyette-compat
changeset: 321022:f60e78748496
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Wed Mar 14 02:24:56 2018 +0000
description:
Make do_openat()'s handling of path=NULL modular
diffstat:
sys/compat/common/Makefile.sysio | 5 ++-
sys/compat/common/compat_mod.c | 11 +++++-
sys/compat/common/files.common | 5 ++-
sys/compat/common/vfs_syscalls_10.c | 61 +++++++++++++++++++++++++++++++++++++
sys/kern/vfs_syscalls.c | 26 ++++++++++-----
sys/sys/vfs_syscalls.h | 6 +++-
6 files changed, 100 insertions(+), 14 deletions(-)
diffs (226 lines):
diff -r a27053dd3010 -r f60e78748496 sys/compat/common/Makefile.sysio
--- a/sys/compat/common/Makefile.sysio Tue Mar 13 21:59:51 2018 +0000
+++ b/sys/compat/common/Makefile.sysio Wed Mar 14 02:24:56 2018 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.sysio,v 1.7.18.1 2018/03/13 09:10:31 pgoyette Exp $
+# $NetBSD: Makefile.sysio,v 1.7.18.2 2018/03/14 02:24:56 pgoyette Exp $
# Sources for syscall and ioctl compatibility across the versions.
@@ -9,6 +9,9 @@
# Compatibility code for NetBSD 0.9
SRCS+= kern_info_09.c
+# Compatability code for NetBSD 1.0
+SRCS+= vfs_syscalls_10.c
+
# Compatibility code for NetBSD 1.2
SRCS+= kern_xxx_12.c vfs_syscalls_12.c vm_12.c
diff -r a27053dd3010 -r f60e78748496 sys/compat/common/compat_mod.c
--- a/sys/compat/common/compat_mod.c Tue Mar 13 21:59:51 2018 +0000
+++ b/sys/compat/common/compat_mod.c Wed Mar 14 02:24:56 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_mod.c,v 1.24.14.5 2018/03/13 09:10:31 pgoyette Exp $ */
+/* $NetBSD: compat_mod.c,v 1.24.14.6 2018/03/14 02:24:56 pgoyette Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: compat_mod.c,v 1.24.14.5 2018/03/13 09:10:31 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_mod.c,v 1.24.14.6 2018/03/14 02:24:56 pgoyette Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -53,6 +53,7 @@
#include <sys/syscallargs.h>
#include <sys/syscallvar.h>
#include <sys/sysctl.h>
+#include <sys/vfs_syscalls.h>
#include <net/if.h>
@@ -275,10 +276,16 @@
sendsig_sigcontext_vec = sendsig_sigcontext;
#endif
#endif
+#ifdef COMPAT_10
+ vfs_syscalls_10_init();
+#endif
compat_sysctl_init();
return 0;
case MODULE_CMD_FINI:
+#ifdef COMPAT_10
+ vfs_syscalls_10_fini();
+#endif
#ifdef COMPAT_16
/*
* Ensure sendsig_sigcontext() is not being used.
diff -r a27053dd3010 -r f60e78748496 sys/compat/common/files.common
--- a/sys/compat/common/files.common Tue Mar 13 21:59:51 2018 +0000
+++ b/sys/compat/common/files.common Wed Mar 14 02:24:56 2018 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.common,v 1.1.2.7 2018/03/13 09:10:31 pgoyette Exp $
+# $NetBSD: files.common,v 1.1.2.8 2018/03/14 02:24:56 pgoyette Exp $
#
# Generic files, used by all compat options.
@@ -25,6 +25,9 @@
# Compatibility code for NetBSD 0.9
file compat/common/kern_info_09.c compat_netbsd
+# Compatability code for NetBSD 1.0
+file compat/common/vfs_syscalls_10.c compat_netbsd
+
# Compatibility code for NetBSD 1.2
file compat/common/kern_xxx_12.c compat_netbsd
file compat/common/vfs_syscalls_12.c compat_netbsd
diff -r a27053dd3010 -r f60e78748496 sys/compat/common/vfs_syscalls_10.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/common/vfs_syscalls_10.c Wed Mar 14 02:24:56 2018 +0000
@@ -0,0 +1,61 @@
+/* $NetBSD: vfs_syscalls_10.c,v 1.1.2.1 2018/03/14 02:24:56 pgoyette Exp $ */
+
+/*-
+ * Copyright (c) 2018 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Paul Goyette
+ *
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_10.c,v 1.1.2.1 2018/03/14 02:24:56 pgoyette Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/namei.h>
+#include <sys/vfs_syscalls.h>
+
+static int (*orig_sys_openat_10)(struct pathbuf **);
+
+static int
+real_sys_openat_10(struct pathbuf **pb)
+{
+
+ *pb = pathbuf_create(".");
+ return (*pb == NULL ? ENOMEM : 0);
+}
+
+void vfs_syscalls_10_init(void)
+{
+
+ orig_sys_openat_10 = vec_sys_openat_10;
+ vec_sys_openat_10 = real_sys_openat_10;
+}
+
+void vfs_syscalls_10_fini(void)
+{
+
+ vec_sys_openat_10 = orig_sys_openat_10;
+}
diff -r a27053dd3010 -r f60e78748496 sys/kern/vfs_syscalls.c
--- a/sys/kern/vfs_syscalls.c Tue Mar 13 21:59:51 2018 +0000
+++ b/sys/kern/vfs_syscalls.c Wed Mar 14 02:24:56 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_syscalls.c,v 1.518 2018/01/09 03:31:13 christos Exp $ */
+/* $NetBSD: vfs_syscalls.c,v 1.518.2.1 2018/03/14 02:24:56 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 2018/01/09 03:31:13 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.518.2.1 2018/03/14 02:24:56 pgoyette Exp $");
#ifdef _KERNEL_OPT
#include "opt_fileassoc.h"
@@ -141,6 +141,10 @@
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
@@ -1629,6 +1633,13 @@
* and call the device open routine if any.
*/
static int
+stub_sys_openat_10(struct pathbuf **pb)
+{
+
+ return 0;
+}
+
+static int
do_sys_openat(lwp_t *l, int fdat, const char *path, int flags,
int mode, int *fd)
{
@@ -1637,14 +1648,11 @@
struct pathbuf *pb;
int error;
-#ifdef COMPAT_10 /* XXX: and perhaps later */
if (path == NULL) {
- pb = pathbuf_create(".");
- if (pb == NULL)
- return ENOMEM;
- } else
-#endif
- {
+ error = (*vec_sys_openat_10)(&pb);
+ if (error)
+ return error;
+ } else {
error = pathbuf_copyin(path, &pb);
if (error)
return error;
diff -r a27053dd3010 -r f60e78748496 sys/sys/vfs_syscalls.h
--- a/sys/sys/vfs_syscalls.h Tue Mar 13 21:59:51 2018 +0000
+++ b/sys/sys/vfs_syscalls.h Wed Mar 14 02:24:56 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_syscalls.h,v 1.23 2017/07/29 04:02:49 riastradh Exp $ */
+/* $NetBSD: vfs_syscalls.h,v 1.23.2.1 2018/03/14 02:24:56 pgoyette Exp $ */
/*
* Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -86,4 +86,8 @@
extern const char *const mountcompatnames[];
extern const int nmountcompatnames;
+extern int (*vec_sys_openat_10)(struct pathbuf **);
+void vfs_syscalls_10_init(void);
+void vfs_syscalls_10_fini(void);
+
#endif /* _SYS_VFS_SYSCALLS_H_ */
Home |
Main Index |
Thread Index |
Old Index