summaryrefslogtreecommitdiffstats
path: root/sbin/mount
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/mount
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/mount')
-rw-r--r--sbin/mount/mount.c29
-rw-r--r--sbin/mount/pathnames.h3
2 files changed, 6 insertions, 26 deletions
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