Source-Changes-HG archive

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

[src/trunk]: src/sys/compat/common add emul_find_interp() function: the funct...



details:   https://anonhg.NetBSD.org/src/rev/cd5ff5de7a35
branches:  trunk
changeset: 539921:cd5ff5de7a35
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Fri Nov 29 17:08:06 2002 +0000

description:
add emul_find_interp() function: the function looks for interpreter
in alternative emul tree first, and updates interpreter pathname
if found there; if not found in alternative emul tree, pathname
without the emul prefix is checked, and error returned if the file
doesn't exist

diffstat:

 sys/compat/common/compat_util.c |  35 +++++++++++++++++++++++++++++++++--
 sys/compat/common/compat_util.h |   4 +++-
 2 files changed, 36 insertions(+), 3 deletions(-)

diffs (74 lines):

diff -r fc904f227cad -r cd5ff5de7a35 sys/compat/common/compat_util.c
--- a/sys/compat/common/compat_util.c   Fri Nov 29 16:32:50 2002 +0000
+++ b/sys/compat/common/compat_util.c   Fri Nov 29 17:08:06 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat_util.c,v 1.24 2002/09/23 05:57:44 simonb Exp $  */
+/*     $NetBSD: compat_util.c,v 1.25 2002/11/29 17:08:06 jdolecek Exp $        */
 
 /*-
  * Copyright (c) 1994 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: compat_util.c,v 1.24 2002/09/23 05:57:44 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_util.c,v 1.25 2002/11/29 17:08:06 jdolecek Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -216,6 +216,37 @@
 }
 
 /*
+ * 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 proc *p, const char *prefix, char *itp)
+{
+       const char *bp;
+       int error;
+
+       if (emul_find(p, NULL, prefix, itp, &bp, CHECK_ALT_FL_EXISTS) == 0) {
+               size_t len;
+
+               if ((error = copystr(bp, itp, MAXPATHLEN, &len)))
+                       return error;
+               free((void *)bp, M_TEMP);
+       } else {
+               /* check filename without the emul prefix */
+               struct nameidata nd;
+       
+               NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, itp, p);
+
+               if ((error = namei(&nd)))
+                       return error;
+
+               vrele(nd.ni_vp);
+       }
+
+       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
  * with any flags which could not be translated.
diff -r fc904f227cad -r cd5ff5de7a35 sys/compat/common/compat_util.h
--- a/sys/compat/common/compat_util.h   Fri Nov 29 16:32:50 2002 +0000
+++ b/sys/compat/common/compat_util.h   Fri Nov 29 17:08:06 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat_util.h,v 1.11 2002/11/29 16:32:50 jdolecek Exp $        */
+/*     $NetBSD: compat_util.h,v 1.12 2002/11/29 17:08:07 jdolecek Exp $        */
 
 /*-
  * Copyright (c) 1994 The NetBSD Foundation, Inc.
@@ -82,6 +82,8 @@
 int emul_find(struct proc *, caddr_t *, const char *, const char *,
                   const char **, int);
 
+int emul_find_interp(struct proc *, const char *, char *);
+
 unsigned long emul_flags_translate(const struct emul_flags_xtab *tab,
                                   unsigned long in, unsigned long *leftover);
 



Home | Main Index | Thread Index | Old Index