Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/rump_allserver * make it possible to specify an offs...
details: https://anonhg.NetBSD.org/src/rev/ef3f9806b5b6
branches: trunk
changeset: 761629:ef3f9806b5b6
user: pooka <pooka%NetBSD.org@localhost>
date: Thu Feb 03 11:21:16 2011 +0000
description:
* make it possible to specify an offset in -d
* truncate -d hostpath only if it's a regular file and smaller
than offset+size
diffstat:
usr.bin/rump_allserver/rump_allserver.1 | 21 ++++++++++++++++-
usr.bin/rump_allserver/rump_allserver.c | 40 +++++++++++++++++++++++++-------
2 files changed, 51 insertions(+), 10 deletions(-)
diffs (138 lines):
diff -r a8cbdae7129d -r ef3f9806b5b6 usr.bin/rump_allserver/rump_allserver.1
--- a/usr.bin/rump_allserver/rump_allserver.1 Thu Feb 03 11:01:51 2011 +0000
+++ b/usr.bin/rump_allserver/rump_allserver.1 Thu Feb 03 11:21:16 2011 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: rump_allserver.1,v 1.8 2011/01/08 09:36:26 pooka Exp $
+.\" $NetBSD: rump_allserver.1,v 1.9 2011/02/03 11:21:16 pooka Exp $
.\"
.\" Copyright (c) 2010 Antti Kantee. All rights reserved.
.\"
@@ -91,6 +91,25 @@
.Xr dd 1 ,
this argument accepts a suffix as the multiplier for the number.
.El
+.Pp
+The following specifier is optional:
+.Bl -tag -width hostpath1234
+.It Ar offset
+Offset of the mapping.
+The window into
+.Ar hostpath
+therefore is
+.Fa [ offset , offset+size ] .
+In case this parameter is not given, the default value 0 is used.
+.El
+.Pp
+In case
+.Ar hostpath
+does not exist, it will be created as a regular file.
+In case
+.Ar hostpath
+is a regular file and is not large enough to accommodate the
+specified size, it will be extended to the specified size.
.It Fl l Ar library
Call
.Fn dlopen
diff -r a8cbdae7129d -r ef3f9806b5b6 usr.bin/rump_allserver/rump_allserver.c
--- a/usr.bin/rump_allserver/rump_allserver.c Thu Feb 03 11:01:51 2011 +0000
+++ b/usr.bin/rump_allserver/rump_allserver.c Thu Feb 03 11:21:16 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rump_allserver.c,v 1.13 2011/01/03 12:18:25 wiz Exp $ */
+/* $NetBSD: rump_allserver.c,v 1.14 2011/02/03 11:21:16 pooka Exp $ */
/*-
* Copyright (c) 2010 Antti Kantee. All Rights Reserved.
@@ -27,7 +27,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: rump_allserver.c,v 1.13 2011/01/03 12:18:25 wiz Exp $");
+__RCSID("$NetBSD: rump_allserver.c,v 1.14 2011/02/03 11:21:16 pooka Exp $");
#endif /* !lint */
#include <sys/types.h>
@@ -81,6 +81,8 @@
"hostpath",
#define DSIZE 2
"size",
+#define DOFFSET 3
+ "offset",
NULL
};
@@ -88,6 +90,7 @@
const char *key;
const char *hostpath;
off_t flen;
+ off_t foffset;
enum rump_etfs_type type;
};
@@ -119,9 +122,9 @@
case 'd': {
char *options, *value;
char *key, *hostpath;
- long long flen;
+ long long flen, foffset;
- flen = 0;
+ flen = foffset = 0;
key = hostpath = NULL;
options = optarg;
while (*options) {
@@ -153,6 +156,16 @@
flen = strsuftoll("-d size", value,
0, LLONG_MAX);
break;
+ case DOFFSET:
+ if (foffset != 0) {
+ fprintf(stderr,
+ "offset already given\n");
+ usage();
+ }
+ /* XXX: off_t max? */
+ foffset = strsuftoll("-d offset", value,
+ 0, LLONG_MAX);
+ break;
default:
fprintf(stderr, "invalid dtoken\n");
usage();
@@ -175,6 +188,7 @@
etfs[curetfs].key = key;
etfs[curetfs].hostpath = hostpath;
etfs[curetfs].flen = flen;
+ etfs[curetfs].foffset = foffset;
etfs[curetfs].type = RUMP_ETFS_BLK;
curetfs++;
@@ -247,17 +261,25 @@
/* register host drives */
for (i = 0; i < curetfs; i++) {
+ struct stat sb;
+ off_t fsize;
int fd;
+ fsize = etfs[i].foffset + etfs[i].flen;
fd = open(etfs[i].hostpath, O_RDWR | O_CREAT, 0755);
if (fd == -1)
- die(sflag, error, "etfs hostpath create");
- if (ftruncate(fd, etfs[i].flen) == -1)
- die(sflag, error, "truncate");
+ die(sflag, errno, "etfs hostpath create");
+ if (fstat(fd, &sb) == -1)
+ die(sflag, errno, "fstat etfs hostpath");
+ if (S_ISREG(sb.st_mode) && sb.st_size < fsize) {
+ if (ftruncate(fd, fsize) == -1)
+ die(sflag, errno, "truncate");
+ }
close(fd);
- if ((error = rump_pub_etfs_register(etfs[i].key,
- etfs[i].hostpath, etfs[i].type)) != 0)
+ if ((error = rump_pub_etfs_register_withsize(etfs[i].key,
+ etfs[i].hostpath, etfs[i].type,
+ etfs[i].foffset, etfs[i].flen)) != 0)
die(sflag, error, "etfs register");
}
Home |
Main Index |
Thread Index |
Old Index