Module Name: src
Committed By: pgoyette
Date: Tue Mar 6 10:37:42 UTC 2018
Modified Files:
src/sys/compat/common [pgoyette-compat]: compat_util.c files.common
src/sys/kern [pgoyette-compat]: exec_elf.c files.kern
Log Message:
Move necessary routines out of compat_util.c and into exec_elf.c
Once again, compat_util.c is only for modules, so move it back into
compat/common/files.common and out of kern/files.kern
To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.46.18.1 src/sys/compat/common/compat_util.c
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 src/sys/compat/common/files.common
cvs rdiff -u -r1.93 -r1.93.2.1 src/sys/kern/exec_elf.c
cvs rdiff -u -r1.16.2.2 -r1.16.2.3 src/sys/kern/files.kern
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/compat_util.c
diff -u src/sys/compat/common/compat_util.c:1.46 src/sys/compat/common/compat_util.c:1.46.18.1
--- src/sys/compat/common/compat_util.c:1.46 Sun Nov 9 17:48:07 2014
+++ src/sys/compat/common/compat_util.c Tue Mar 6 10:37:41 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_util.c,v 1.46 2014/11/09 17:48:07 maxv Exp $ */
+/* $NetBSD: compat_util.c,v 1.46.18.1 2018/03/06 10:37:41 pgoyette Exp $ */
/*-
* Copyright (c) 1994 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: compat_util.c,v 1.46 2014/11/09 17:48:07 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_util.c,v 1.46.18.1 2018/03/06 10:37:41 pgoyette Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -76,80 +76,6 @@ __KERNEL_RCSID(0, "$NetBSD: compat_util.
#include <compat/common/compat_util.h>
-void
-emul_find_root(struct lwp *l, struct exec_package *epp)
-{
- struct vnode *vp;
- const char *emul_path;
-
- if (epp->ep_emul_root != NULL)
- /* We've already found it */
- return;
-
- emul_path = epp->ep_esch->es_emul->e_path;
- if (emul_path == NULL)
- /* Emulation doesn't have a root */
- return;
-
- if (namei_simple_kernel(emul_path, NSM_FOLLOW_NOEMULROOT, &vp) != 0)
- /* emulation root doesn't exist */
- return;
-
- epp->ep_emul_root = vp;
-}
-
-/*
- * Search the alternate path for dynamic binary interpreter. If not found
- * there, check if the interpreter exists in within 'proper' tree.
- */
-int
-emul_find_interp(struct lwp *l, struct exec_package *epp, const char *itp)
-{
- int error;
- struct pathbuf *pb;
- struct nameidata nd;
- unsigned int flags;
-
- pb = pathbuf_create(itp);
- if (pb == NULL) {
- return ENOMEM;
- }
-
- /* If we haven't found the emulation root already, do so now */
- /* Maybe we should remember failures somehow ? */
- if (epp->ep_esch->es_emul->e_path != 0 && epp->ep_emul_root == NULL)
- emul_find_root(l, epp);
-
- if (epp->ep_interp != NULL)
- vrele(epp->ep_interp);
-
- /* We need to use the emulation root for the new program,
- * not the one for the current process. */
- if (epp->ep_emul_root == NULL)
- flags = FOLLOW;
- else {
- nd.ni_erootdir = epp->ep_emul_root;
- /* hack: Pass in the emulation path for ktrace calls */
- nd.ni_next = epp->ep_esch->es_emul->e_path;
- flags = FOLLOW | TRYEMULROOT | EMULROOTSET;
- }
-
- NDINIT(&nd, LOOKUP, flags, pb);
- error = namei(&nd);
- if (error != 0) {
- epp->ep_interp = NULL;
- pathbuf_destroy(pb);
- return error;
- }
-
- /* Save interpreter in case we actually need to load it */
- epp->ep_interp = nd.ni_vp;
-
- pathbuf_destroy(pb);
-
- return 0;
-}
-
/*
* Translate one set of flags to another, based on the entries in
* the given table. If 'leftover' is specified, it is filled in
Index: src/sys/compat/common/files.common
diff -u src/sys/compat/common/files.common:1.1.2.2 src/sys/compat/common/files.common:1.1.2.3
--- src/sys/compat/common/files.common:1.1.2.2 Tue Mar 6 10:00:10 2018
+++ src/sys/compat/common/files.common Tue Mar 6 10:37:41 2018
@@ -1,10 +1,11 @@
-# $NetBSD: files.common,v 1.1.2.2 2018/03/06 10:00:10 pgoyette Exp $
+# $NetBSD: files.common,v 1.1.2.3 2018/03/06 10:37:41 pgoyette Exp $
#
# Generic files, used by all compat options.
#
file compat/common/compat_mod.c compat_netbsd
file compat/common/compat_exec.c compat_netbsd
+file compat/common/compat_util.c compat_netbsd
#
# Sources for syscall and ioctl compatibility across the versions.
Index: src/sys/kern/exec_elf.c
diff -u src/sys/kern/exec_elf.c:1.93 src/sys/kern/exec_elf.c:1.93.2.1
--- src/sys/kern/exec_elf.c:1.93 Tue Nov 7 19:44:04 2017
+++ src/sys/kern/exec_elf.c Tue Mar 6 10:37:41 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: exec_elf.c,v 1.93 2017/11/07 19:44:04 christos Exp $ */
+/* $NetBSD: exec_elf.c,v 1.93.2.1 2018/03/06 10:37:41 pgoyette Exp $ */
/*-
* Copyright (c) 1994, 2000, 2005, 2015 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: exec_elf.c,v 1.93 2017/11/07 19:44:04 christos Exp $");
+__KERNEL_RCSID(1, "$NetBSD: exec_elf.c,v 1.93.2.1 2018/03/06 10:37:41 pgoyette Exp $");
#ifdef _KERNEL_OPT
#include "opt_pax.h"
@@ -1084,3 +1084,77 @@ elf_free_emul_arg(void *arg)
KASSERT(ap != NULL);
kmem_free(ap, sizeof(*ap));
}
+
+void
+emul_find_root(struct lwp *l, struct exec_package *epp)
+{
+ struct vnode *vp;
+ const char *emul_path;
+
+ if (epp->ep_emul_root != NULL)
+ /* We've already found it */
+ return;
+
+ emul_path = epp->ep_esch->es_emul->e_path;
+ if (emul_path == NULL)
+ /* Emulation doesn't have a root */
+ return;
+
+ if (namei_simple_kernel(emul_path, NSM_FOLLOW_NOEMULROOT, &vp) != 0)
+ /* emulation root doesn't exist */
+ return;
+
+ epp->ep_emul_root = vp;
+}
+
+/*
+ * Search the alternate path for dynamic binary interpreter. If not found
+ * there, check if the interpreter exists in within 'proper' tree.
+ */
+int
+emul_find_interp(struct lwp *l, struct exec_package *epp, const char *itp)
+{
+ int error;
+ struct pathbuf *pb;
+ struct nameidata nd;
+ unsigned int flags;
+
+ pb = pathbuf_create(itp);
+ if (pb == NULL) {
+ return ENOMEM;
+ }
+
+ /* If we haven't found the emulation root already, do so now */
+ /* Maybe we should remember failures somehow ? */
+ if (epp->ep_esch->es_emul->e_path != 0 && epp->ep_emul_root == NULL)
+ emul_find_root(l, epp);
+
+ if (epp->ep_interp != NULL)
+ vrele(epp->ep_interp);
+
+ /* We need to use the emulation root for the new program,
+ * not the one for the current process. */
+ if (epp->ep_emul_root == NULL)
+ flags = FOLLOW;
+ else {
+ nd.ni_erootdir = epp->ep_emul_root;
+ /* hack: Pass in the emulation path for ktrace calls */
+ nd.ni_next = epp->ep_esch->es_emul->e_path;
+ flags = FOLLOW | TRYEMULROOT | EMULROOTSET;
+ }
+
+ NDINIT(&nd, LOOKUP, flags, pb);
+ error = namei(&nd);
+ if (error != 0) {
+ epp->ep_interp = NULL;
+ pathbuf_destroy(pb);
+ return error;
+ }
+
+ /* Save interpreter in case we actually need to load it */
+ epp->ep_interp = nd.ni_vp;
+
+ pathbuf_destroy(pb);
+
+ return 0;
+}
Index: src/sys/kern/files.kern
diff -u src/sys/kern/files.kern:1.16.2.2 src/sys/kern/files.kern:1.16.2.3
--- src/sys/kern/files.kern:1.16.2.2 Tue Mar 6 09:43:06 2018
+++ src/sys/kern/files.kern Tue Mar 6 10:37:41 2018
@@ -1,11 +1,10 @@
-# $NetBSD: files.kern,v 1.16.2.2 2018/03/06 09:43:06 pgoyette Exp $
+# $NetBSD: files.kern,v 1.16.2.3 2018/03/06 10:37:41 pgoyette Exp $
#
# kernel sources
#
define kern: machdep, uvm
defflag opt_kern.h KERN
-file compat/common/compat_util.c kern
file conf/debugsyms.c kern
file conf/param.c kern
file kern/bufq_disksort.c bufq_disksort