summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/paths.h3
-rw-r--r--sbin/fsck/fsck.c35
-rw-r--r--sbin/fsck/pathnames.h35
-rw-r--r--sbin/mount/mount.c29
-rw-r--r--sbin/mount/pathnames.h3
5 files changed, 16 insertions, 89 deletions
diff --git a/include/paths.h b/include/paths.h
index c9c1563..33d47ed 100644
--- a/include/paths.h
+++ b/include/paths.h
@@ -44,6 +44,9 @@
/* All standard utilities path. */
#define _PATH_STDPATH \
"/usr/bin:/bin:/usr/sbin:/sbin:"
+/* Locate system binaries */
+#define _PATH_SYSPATH \
+ "/sbin:/usr/sbin"
#define _PATH_AUTHCONF "/etc/auth.conf"
#define _PATH_BSHELL "/bin/sh"
diff --git a/sbin/fsck/fsck.c b/sbin/fsck/fsck.c
index 35a4b91..f11ee89 100644
--- a/sbin/fsck/fsck.c
+++ b/sbin/fsck/fsck.c
@@ -62,7 +62,6 @@ __FBSDID("$FreeBSD$");
#include <string.h>
#include <unistd.h>
-#include "pathnames.h"
#include "fsutil.h"
static enum { IN_LIST, NOT_IN_LIST } which = NOT_IN_LIST;
@@ -281,16 +280,10 @@ static int
checkfs(const char *pvfstype, const char *spec, const char *mntpt,
char *auxopt, pid_t *pidp)
{
- /* List of directories containing fsck_xxx subcommands. */
- static const char *edirs[] = {
- _PATH_SBIN,
- _PATH_USRSBIN,
- NULL
- };
- const char **argv, **edir;
+ const char **argv;
pid_t pid;
int argc, i, status, maxargc;
- char *optbuf, execname[MAXPATHLEN + 1], execbase[MAXPATHLEN];
+ char *optbuf, execbase[MAXPATHLEN];
char *vfstype = NULL;
const char *extra = NULL;
@@ -361,25 +354,11 @@ checkfs(const char *pvfstype, const char *spec, const char *mntpt,
_exit(0);
/* Go find an executable. */
- edir = edirs;
- do {
- (void)snprintf(execname,
- sizeof(execname), "%s/%s", *edir, execbase);
- execv(execname, (char * const *)argv);
- if (errno != ENOENT) {
- if (spec)
- warn("exec %s for %s", execname, spec);
- else
- warn("exec %s", execname);
- }
- } while (*++edir != NULL);
-
- if (errno == ENOENT) {
- if (spec)
- warn("exec %s for %s", execname, spec);
- else
- warn("exec %s", execname);
- }
+ execvP(execbase, _PATH_SYSPATH, (char * const *)argv);
+ if (spec)
+ warn("exec %s for %s in %s", execbase, spec, _PATH_SYSPATH);
+ else
+ warn("exec %s in %s", execbase, _PATH_SYSPATH);
_exit(1);
/* NOTREACHED */
diff --git a/sbin/fsck/pathnames.h b/sbin/fsck/pathnames.h
deleted file mode 100644
index 5f3166e..0000000
--- a/sbin/fsck/pathnames.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* $NetBSD: pathnames.h,v 1.1 1996/09/11 20:27:15 christos Exp $ */
-
-/*
- * Copyright (c) 1996 Christos Zoulas. All rights reserved.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Christos Zoulas.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#define _PATH_SBIN "/sbin"
-#define _PATH_USRSBIN "/usr/sbin"
diff --git a/sbin/mount/mount.c b/sbin/mount/mount.c
index 4fccd91..bb4579d 100644
--- a/sbin/mount/mount.c
+++ b/sbin/mount/mount.c
@@ -54,6 +54,7 @@ static const char rcsid[] =
#include <err.h>
#include <errno.h>
#include <fstab.h>
+#include <paths.h>
#include <pwd.h>
#include <signal.h>
#include <stdio.h>
@@ -392,13 +393,8 @@ mountfs(vfstype, spec, name, flags, options, mntopts)
const char *vfstype, *spec, *name, *options, *mntopts;
int flags;
{
- /* List of directories containing mount_xxx subcommands. */
- static const char *edirs[] = {
- _PATH_SBIN,
- _PATH_USRSBIN,
- NULL
- };
const char *argv[100], **edir;
+ char *path, *cur;
struct statfs sf;
pid_t pid;
int argc, i, status;
@@ -469,25 +465,10 @@ mountfs(vfstype, spec, name, flags, options, mntopts)
exit(mount_ufs(argc, (char * const *) argv));
/* Go find an executable. */
- for (edir = edirs; *edir; edir++) {
- (void)snprintf(execname,
- sizeof(execname), "%s/mount_%s", *edir, vfstype);
- execv(execname, (char * const *)argv);
- }
+ (void)snprintf(execname, sizeof(execname), "mount_%s", vfstype);
+ execvP(execname, _PATH_SYSPATH, (char * const *)argv);
if (errno == ENOENT) {
- int len = 0;
- char *cp;
- for (edir = edirs; *edir; edir++)
- len += strlen(*edir) + 2; /* ", " */
- if ((cp = malloc(len)) == NULL)
- errx(1, "malloc failed");
- cp[0] = '\0';
- for (edir = edirs; *edir; edir++) {
- strcat(cp, *edir);
- if (edir[1] != NULL)
- strcat(cp, ", ");
- }
- warn("exec mount_%s not found in %s", vfstype, cp);
+ warn("exec mount_%s not found in %s", vfstype, path);
}
exit(1);
/* NOTREACHED */
diff --git a/sbin/mount/pathnames.h b/sbin/mount/pathnames.h
index 45a4a01..5209f04 100644
--- a/sbin/mount/pathnames.h
+++ b/sbin/mount/pathnames.h
@@ -31,8 +31,7 @@
* SUCH DAMAGE.
*
* @(#)pathnames.h 8.2 (Berkeley) 3/27/94
+ * $FreeBSD$
*/
-#define _PATH_SBIN "/sbin"
-#define _PATH_USRSBIN "/usr/sbin"
#define _PATH_MOUNTDPID "/var/run/mountd.pid"
OpenPOWER on IntegriCloud