From owner-freebsd-current@FreeBSD.ORG Sat Apr 15 01:43:54 2006 Return-Path: X-Original-To: freebsd-current@freebsd.org Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7255216A405 for ; Sat, 15 Apr 2006 01:43:54 +0000 (UTC) (envelope-from ota@j.email.ne.jp) Received: from mail.asahi-net.or.jp (mail2.asahi-net.or.jp [202.224.39.198]) by mx1.FreeBSD.org (Postfix) with ESMTP id 235AF43D45 for ; Sat, 15 Apr 2006 01:43:53 +0000 (GMT) (envelope-from ota@j.email.ne.jp) Received: from dynabook-freebsd.advok.com (cpe-24-168-145-70.nj.res.rr.com [24.168.145.70]) by mail.asahi-net.or.jp (Postfix) with ESMTP id 8C303287FE for ; Sat, 15 Apr 2006 10:43:51 +0900 (JST) Date: Fri, 14 Apr 2006 21:43:49 -0500 From: Yoshihiro Ota To: freebsd-current@freebsd.org Message-Id: <20060414214349.86db4184.ota@j.email.ne.jp> X-Mailer: Sylpheed version 2.2.3 (GTK+ 2.8.16; i386-portbld-freebsd6.1) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: [patch] mdmfs suffix support X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Apr 2006 01:43:54 -0000 This patch helps and enhances to mount md-based device such as uzip, slice/partitions, and so on. I think examples below can tell more than I can describe. If mount_md is created with this patch such that we can add md-devices to fstab, possibilities of md-device will greatly expand. Regards, Hiro # mdmfs -P -F ports-5.4.uzip -oro md.uzip /tmp/test # df /tmp/test Filesystem 1K-blocks Used Avail Capacity Mounted on /dev/md4.uzip 358126 277934 51542 84% /tmp/test # mdmfs -P -F ports-5.4.uzip -oro /dev/md8.uzip /tmp/test # df | grep test /dev/md4.uzip 358126 277934 51542 84% /tmp/test /dev/md8.uzip 358126 277934 51542 84% /tmp/test2 # mdmfs -P -F hd10meg.img mds1a /tmp/test3 # df /tmp/test3 Filesystem 1K-blocks Used Avail Capacity Mounted on /dev/md9s1a 7526 4 6920 0% /tmp/test3 # mdmfs -P -F file.md md /tmp/test4 # df /tmp/test4 Filesystem 1K-blocks Used Avail Capacity Mounted on /dev/md10 846 4 776 1% /tmp/test4 --- mdmfs.c.orig Thu Feb 16 16:28:54 2006 +++ mdmfs.c Fri Apr 14 21:27:08 2006 @@ -48,6 +48,7 @@ #include #include #include +#include #include typedef enum { false, true } bool; @@ -67,6 +68,7 @@ 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; @@ -258,13 +260,16 @@ 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; } @@ -446,8 +451,8 @@ { 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); }