Module Name: src Committed By: pooka Date: Thu Feb 17 16:03:05 UTC 2011
Modified Files: src/usr.bin/rump_allserver: rump_allserver.1 rump_allserver.c Log Message: Make it possible to specify the type of file (blk/chr/reg) that a mapped file (-d) is exposed as within the rump kernel. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/usr.bin/rump_allserver/rump_allserver.1 cvs rdiff -u -r1.16 -r1.17 src/usr.bin/rump_allserver/rump_allserver.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/rump_allserver/rump_allserver.1 diff -u src/usr.bin/rump_allserver/rump_allserver.1:1.12 src/usr.bin/rump_allserver/rump_allserver.1:1.13 --- src/usr.bin/rump_allserver/rump_allserver.1:1.12 Fri Feb 4 20:06:23 2011 +++ src/usr.bin/rump_allserver/rump_allserver.1 Thu Feb 17 16:03:05 2011 @@ -1,4 +1,4 @@ -.\" $NetBSD: rump_allserver.1,v 1.12 2011/02/04 20:06:23 pooka Exp $ +.\" $NetBSD: rump_allserver.1,v 1.13 2011/02/17 16:03:05 pooka Exp $ .\" .\" Copyright (c) 2010 Antti Kantee. All rights reserved. .\" @@ -23,7 +23,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd February 4, 2011 +.Dd February 17, 2011 .Dt RUMP_SERVER 1 .Os .Sh NAME @@ -70,7 +70,7 @@ .It Fl d Ar drivespec The argument .Ar drivespec -maps a host file a block device in the rump fs namespace. +maps a host file in the rump fs namespace. The string .Ar drivespec must be of comma-separated @@ -98,8 +98,7 @@ must contain an existing and valid disklabel within the first 64k. .El .Pp -The following specifier is optional and used only if disklabel is -not specified: +The following are optional: .Bl -tag -width hostpath1234 .It Ar offset Offset of the mapping. @@ -108,6 +107,17 @@ therefore is .Fa [ offset , offset+size ] . In case this parameter is not given, the default value 0 is used. +.It Ar type +The type of file that +.Ar key +is exposed as within the rump kernel. +The possibilities are +.Dq blk , +.Dq chr , +and +.Dq reg +for block device, character device and regular file, respectively. +The default is a block device. .El .Pp In case Index: src/usr.bin/rump_allserver/rump_allserver.c diff -u src/usr.bin/rump_allserver/rump_allserver.c:1.16 src/usr.bin/rump_allserver/rump_allserver.c:1.17 --- src/usr.bin/rump_allserver/rump_allserver.c:1.16 Fri Feb 4 20:06:23 2011 +++ src/usr.bin/rump_allserver/rump_allserver.c Thu Feb 17 16:03:05 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: rump_allserver.c,v 1.16 2011/02/04 20:06:23 pooka Exp $ */ +/* $NetBSD: rump_allserver.c,v 1.17 2011/02/17 16:03:05 pooka Exp $ */ /*- * Copyright (c) 2010, 2011 Antti Kantee. All Rights Reserved. @@ -27,7 +27,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: rump_allserver.c,v 1.16 2011/02/04 20:06:23 pooka Exp $"); +__RCSID("$NetBSD: rump_allserver.c,v 1.17 2011/02/17 16:03:05 pooka Exp $"); #endif /* !lint */ #include <sys/types.h> @@ -87,6 +87,8 @@ "offset", #define DLABEL 4 "disklabel", +#define DTYPE 5 + "type", NULL }; @@ -99,6 +101,15 @@ enum rump_etfs_type type; }; +struct etfstype { + const char *name; + enum rump_etfs_type type; +} etfstypes[] = { + { "blk", RUMP_ETFS_BLK }, + { "chr", RUMP_ETFS_CHR }, + { "reg", RUMP_ETFS_REG }, +}; + int main(int argc, char *argv[]) { @@ -129,10 +140,12 @@ char *key, *hostpath; long long flen, foffset; char partition; + int ftype; flen = foffset = 0; partition = 0; key = hostpath = NULL; + ftype = -1; options = optarg; while (*options) { switch (getsubopt(&options, @@ -192,6 +205,28 @@ partition = *value; break; + case DTYPE: + if (ftype != -1) { + fprintf(stderr, + "type already specified\n"); + usage(); + } + + for (i = 0; + i < __arraycount(etfstypes); + i++) { + if (strcmp(etfstypes[i].name, + value) == 0) + break; + } + if (i == __arraycount(etfstypes)) { + fprintf(stderr, + "invalid type %s\n", value); + usage(); + } + ftype = etfstypes[i].type; + break; + default: fprintf(stderr, "invalid dtoken\n"); usage(); @@ -204,6 +239,8 @@ fprintf(stderr, "incomplete drivespec\n"); usage(); } + if (ftype == -1) + ftype = RUMP_ETFS_BLK; if (netfs - curetfs == 0) { etfs = realloc(etfs, (netfs+16)*sizeof(*etfs)); @@ -217,7 +254,7 @@ etfs[curetfs].flen = flen; etfs[curetfs].foffset = foffset; etfs[curetfs].partition = partition; - etfs[curetfs].type = RUMP_ETFS_BLK; + etfs[curetfs].type = ftype; curetfs++; break;