aboutsummaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authorMatteo Riondato <matteo@FreeBSD.org>2007-02-15 13:49:44 +0000
committerMatteo Riondato <matteo@FreeBSD.org>2007-02-15 13:49:44 +0000
commit8c6a98de69db047cdc1bc72e476b5f38aa1ef53d (patch)
tree543947c7ee1eea2115d392eac1a1db064c7d4d5a /sbin
parent780a98ad1fad6be38ca5322b7d79d94b982b8061 (diff)
downloadsrc-8c6a98de69db047cdc1bc72e476b5f38aa1ef53d.tar.gz
src-8c6a98de69db047cdc1bc72e476b5f38aa1ef53d.zip
Enhances mdmfs(8) to mount md-based device such as uzip.
Examples of use can be found in the PR text. PR: 103501 MFC after: 1 week
Notes
Notes: svn path=/head/; revision=166749
Diffstat (limited to 'sbin')
-rw-r--r--sbin/mdmfs/mdmfs.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/sbin/mdmfs/mdmfs.c b/sbin/mdmfs/mdmfs.c
index c07be219979b..5b895d5ddbf7 100644
--- a/sbin/mdmfs/mdmfs.c
+++ b/sbin/mdmfs/mdmfs.c
@@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$");
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <ctype.h>
#include <unistd.h>
typedef enum { false, true } bool;
@@ -66,6 +67,7 @@ static bool loudsubs; /* Suppress output from helper programs? */
static bool norun; /* Actually run the helper programs? */
static int unit; /* The unit we're working with. */
static const char *mdname; /* Name of memory disk device (e.g., "md"). */
+static const char *mdsuffix; /* Suffix of memory disk device (e.g., ".uzip"). */
static size_t mdnamelen; /* Length of mdname. */
static const char *path_mdconfig =_PATH_MDCONFIG;
@@ -236,13 +238,16 @@ main(int argc, char **argv)
unitstr += 5;
if (strncmp(unitstr, mdname, mdnamelen) == 0)
unitstr += mdnamelen;
- if (*unitstr == '\0') {
+ if (!isdigit(*unitstr)) {
autounit = true;
unit = -1;
+ mdsuffix = unitstr;
} else {
ul = strtoul(unitstr, &p, 10);
- if (ul == ULONG_MAX || *p != '\0')
+ if (ul == ULONG_MAX)
errx(1, "bad device unit: %s", unitstr);
+ if (*p != '\0')
+ mdsuffix = p;
unit = ul;
}
@@ -424,8 +429,8 @@ do_mount(const char *args, const char *mtpoint)
{
int rv;
- rv = run(NULL, "%s%s /dev/%s%d %s", _PATH_MOUNT, args,
- mdname, unit, mtpoint);
+ rv = run(NULL, "%s%s /dev/%s%d%s %s", _PATH_MOUNT, args,
+ mdname, unit, mdsuffix, mtpoint);
if (rv)
errx(1, "mount exited with error code %d", rv);
}