Module Name:    src
Committed By:   pgoyette
Date:           Wed Mar 14 02:24:56 UTC 2018

Modified Files:
        src/sys/compat/common [pgoyette-compat]: Makefile.sysio compat_mod.c
            files.common
        src/sys/kern [pgoyette-compat]: vfs_syscalls.c
        src/sys/sys [pgoyette-compat]: vfs_syscalls.h
Added Files:
        src/sys/compat/common [pgoyette-compat]: vfs_syscalls_10.c

Log Message:
Make do_openat()'s handling of path=NULL modular


To generate a diff of this commit:
cvs rdiff -u -r1.7.18.1 -r1.7.18.2 src/sys/compat/common/Makefile.sysio
cvs rdiff -u -r1.24.14.5 -r1.24.14.6 src/sys/compat/common/compat_mod.c
cvs rdiff -u -r1.1.2.7 -r1.1.2.8 src/sys/compat/common/files.common
cvs rdiff -u -r0 -r1.1.2.1 src/sys/compat/common/vfs_syscalls_10.c
cvs rdiff -u -r1.518 -r1.518.2.1 src/sys/kern/vfs_syscalls.c
cvs rdiff -u -r1.23 -r1.23.2.1 src/sys/sys/vfs_syscalls.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/common/Makefile.sysio
diff -u src/sys/compat/common/Makefile.sysio:1.7.18.1 src/sys/compat/common/Makefile.sysio:1.7.18.2
--- src/sys/compat/common/Makefile.sysio:1.7.18.1	Tue Mar 13 09:10:31 2018
+++ src/sys/compat/common/Makefile.sysio	Wed Mar 14 02:24:56 2018
@@ -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 @@ SRCS+=	kern_exit_43.c kern_info_43.c ker
 # 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
 

Index: src/sys/compat/common/compat_mod.c
diff -u src/sys/compat/common/compat_mod.c:1.24.14.5 src/sys/compat/common/compat_mod.c:1.24.14.6
--- src/sys/compat/common/compat_mod.c:1.24.14.5	Tue Mar 13 09:10:31 2018
+++ src/sys/compat/common/compat_mod.c	Wed Mar 14 02:24:56 2018
@@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: compat_mod.c
 #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 @@ compat_modcmd(modcmd_t cmd, void *arg)
 		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.

Index: src/sys/compat/common/files.common
diff -u src/sys/compat/common/files.common:1.1.2.7 src/sys/compat/common/files.common:1.1.2.8
--- src/sys/compat/common/files.common:1.1.2.7	Tue Mar 13 09:10:31 2018
+++ src/sys/compat/common/files.common	Wed Mar 14 02:24:56 2018
@@ -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 @@ file	compat/common/if_43.c			compat_netb
 # 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

Index: src/sys/kern/vfs_syscalls.c
diff -u src/sys/kern/vfs_syscalls.c:1.518 src/sys/kern/vfs_syscalls.c:1.518.2.1
--- src/sys/kern/vfs_syscalls.c:1.518	Tue Jan  9 03:31:13 2018
+++ src/sys/kern/vfs_syscalls.c	Wed Mar 14 02:24:56 2018
@@ -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(struct lwp *, int,
 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 @@ fd_open(const char *path, int open_flags
  * 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 @@ do_sys_openat(lwp_t *l, int fdat, const 
 	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;

Index: src/sys/sys/vfs_syscalls.h
diff -u src/sys/sys/vfs_syscalls.h:1.23 src/sys/sys/vfs_syscalls.h:1.23.2.1
--- src/sys/sys/vfs_syscalls.h:1.23	Sat Jul 29 04:02:49 2017
+++ src/sys/sys/vfs_syscalls.h	Wed Mar 14 02:24:56 2018
@@ -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 @@ void	change_root(struct cwdinfo *, struc
 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_ */

Added files:

Index: src/sys/compat/common/vfs_syscalls_10.c
diff -u /dev/null src/sys/compat/common/vfs_syscalls_10.c:1.1.2.1
--- /dev/null	Wed Mar 14 02:24:56 2018
+++ src/sys/compat/common/vfs_syscalls_10.c	Wed Mar 14 02:24:56 2018
@@ -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;
+}

Reply via email to