Source-Changes-HG archive

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

[src/pgoyette-compat]: src/sys Move necessary routines out of compat_util.c a...



details:   https://anonhg.NetBSD.org/src/rev/53e7ab58b2d8
branches:  pgoyette-compat
changeset: 320957:53e7ab58b2d8
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Tue Mar 06 10:37:41 2018 +0000

description:
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

diffstat:

 sys/compat/common/compat_util.c |  78 +---------------------------------------
 sys/compat/common/files.common  |   3 +-
 sys/kern/exec_elf.c             |  78 +++++++++++++++++++++++++++++++++++++++-
 sys/kern/files.kern             |   3 +-
 4 files changed, 81 insertions(+), 81 deletions(-)

diffs (227 lines):

diff -r e3110a62fd40 -r 53e7ab58b2d8 sys/compat/common/compat_util.c
--- a/sys/compat/common/compat_util.c   Tue Mar 06 10:07:35 2018 +0000
+++ b/sys/compat/common/compat_util.c   Tue Mar 06 10:37:41 2018 +0000
@@ -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 @@
 
 #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
diff -r e3110a62fd40 -r 53e7ab58b2d8 sys/compat/common/files.common
--- a/sys/compat/common/files.common    Tue Mar 06 10:07:35 2018 +0000
+++ b/sys/compat/common/files.common    Tue Mar 06 10:37:41 2018 +0000
@@ -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.
diff -r e3110a62fd40 -r 53e7ab58b2d8 sys/kern/exec_elf.c
--- a/sys/kern/exec_elf.c       Tue Mar 06 10:07:35 2018 +0000
+++ b/sys/kern/exec_elf.c       Tue Mar 06 10:37:41 2018 +0000
@@ -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 @@
        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;
+}
diff -r e3110a62fd40 -r 53e7ab58b2d8 sys/kern/files.kern
--- a/sys/kern/files.kern       Tue Mar 06 10:07:35 2018 +0000
+++ b/sys/kern/files.kern       Tue Mar 06 10:37:41 2018 +0000
@@ -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



Home | Main Index | Thread Index | Old Index