summaryrefslogtreecommitdiffstats
path: root/sbin/fsck
diff options
context:
space:
mode:
authorgordon <gordon@FreeBSD.org>2003-06-29 17:53:48 +0000
committergordon <gordon@FreeBSD.org>2003-06-29 17:53:48 +0000
commit5114761edeb50c00a21a84e861ac273231f47b34 (patch)
treeee59a96fbce376aed725c236e135967facd297a2 /sbin/fsck
parent4ad1bccf132b3c564df8fe00da9bd5e9124ef9a5 (diff)
downloadFreeBSD-src-5114761edeb50c00a21a84e861ac273231f47b34.zip
FreeBSD-src-5114761edeb50c00a21a84e861ac273231f47b34.tar.gz
Convert fsck and mount to using execvP to find fsck_foo and mount_foo.
This simplifies the code path and makes the default path easy to override in the /rescue case. Submitted by: Tim Kientzle <kientzle@acm.org>
Diffstat (limited to 'sbin/fsck')
-rw-r--r--sbin/fsck/fsck.c35
-rw-r--r--sbin/fsck/pathnames.h35
2 files changed, 7 insertions, 63 deletions
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"
OpenPOWER on IntegriCloud