diff options
author | Joel Sing <jsing@cvs.openbsd.org> | 2008-08-14 17:10:30 +0000 |
---|---|---|
committer | Joel Sing <jsing@cvs.openbsd.org> | 2008-08-14 17:10:30 +0000 |
commit | 3ae163dbd6453b43a968daba4c367b8cb1e70100 (patch) | |
tree | 9e8c6e3cd03ea998fa6bed516003ae0063e92236 /sbin | |
parent | 93820f4b0b65e48a8c5fe415afa684e8fcdb1feb (diff) |
Allow the sector size to be specified by the user when configuring a
vnd(4) device, via a new -s option to vnconfig/mount_vnd. This allows us
to create disklabels and file systems that are suitable for use on
devices that have a non-512 byte sector size (eg. CDROMs).
With help from krw@ and feedback from pedro@.
ok krw@, pedro@
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/mount_vnd/mount_vnd.8 | 12 | ||||
-rw-r--r-- | sbin/mount_vnd/mount_vnd.c | 23 |
2 files changed, 26 insertions, 9 deletions
diff --git a/sbin/mount_vnd/mount_vnd.8 b/sbin/mount_vnd/mount_vnd.8 index fe3a8636085..a44c76af947 100644 --- a/sbin/mount_vnd/mount_vnd.8 +++ b/sbin/mount_vnd/mount_vnd.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: mount_vnd.8,v 1.13 2008/05/26 21:14:46 jmc Exp $ +.\" $OpenBSD: mount_vnd.8,v 1.14 2008/08/14 17:10:29 jsing Exp $ .\" .\" Copyright (c) 1993 University of Utah. .\" Copyright (c) 1980, 1989, 1991, 1993 @@ -49,7 +49,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: May 26 2008 $ +.Dd $Mdocdate: August 14 2008 $ .Dt MOUNT_VND 8 .Os .Sh NAME @@ -63,6 +63,7 @@ .Op Fl K Ar rounds .Op Fl o Ar options .Op Fl S Ar saltfile +.Op Fl s Ar secsize .Ar image .Ar vnd_dev .Ek @@ -71,6 +72,7 @@ .Op Fl ckluv .Op Fl K Ar rounds .Op Fl S Ar saltfile +.Op Fl s Ar secsize .Ar vnd_dev .Ar image .Ek @@ -208,6 +210,12 @@ If the salt filename is not specified using .Fl S , it defaults to .Ar image Ns .slt . +.It Fl s Ar secsize +Specify the sector size, in bytes, to be used by the device. +The default sector size is 512 bytes. +If specified +.Ar secsize +must be a multiple of 512 bytes and cannot exceed 65536 bytes. .It Fl u .Nm vnconfig only. diff --git a/sbin/mount_vnd/mount_vnd.c b/sbin/mount_vnd/mount_vnd.c index 50fe6555525..70441e42b51 100644 --- a/sbin/mount_vnd/mount_vnd.c +++ b/sbin/mount_vnd/mount_vnd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mount_vnd.c,v 1.5 2008/06/14 01:47:27 grunk Exp $ */ +/* $OpenBSD: mount_vnd.c,v 1.6 2008/08/14 17:10:29 jsing Exp $ */ /* * Copyright (c) 1993 University of Utah. * Copyright (c) 1990, 1993 @@ -67,7 +67,7 @@ int verbose = 0; int run_mount_vnd = 0; __dead void usage(void); -int config(char *, char *, int, char *, size_t); +int config(char *, char *, int, size_t, char *, size_t); int getinfo(const char *); char *get_pkcs_key(char *, char *); @@ -76,7 +76,8 @@ main(int argc, char **argv) { int ch, rv, action, opt_c, opt_k, opt_K, opt_l, opt_u; char *key, *mntopts, *rounds, *saltopt; - size_t keylen = 0; + size_t keylen = 0, secsize = 0; + const char *errstr; extern char *__progname; if (strcasecmp(__progname, "mount_vnd") == 0) @@ -86,7 +87,7 @@ main(int argc, char **argv) key = mntopts = rounds = saltopt = NULL; action = VND_CONFIG; - while ((ch = getopt(argc, argv, "ckK:lo:S:uv")) != -1) { + while ((ch = getopt(argc, argv, "ckK:lo:s:S:uv")) != -1) { switch (ch) { case 'c': opt_c = 1; @@ -107,6 +108,11 @@ main(int argc, char **argv) case 'S': saltopt = optarg; break; + case 's': + secsize = strtonum(optarg, 512, 65536, &errstr); + if (errstr || (secsize & 0x1ff) != 0) + errx(1, "invalid sector size: %s", optarg); + break; case 'u': opt_u = 1; break; @@ -156,9 +162,10 @@ main(int argc, char **argv) ind_raw = 0; ind_reg = 1; } - rv = config(argv[ind_raw], argv[ind_reg], action, key, keylen); + rv = config(argv[ind_raw], argv[ind_reg], action, secsize, key, + keylen); } else if (action == VND_UNCONFIG && argc == 1) - rv = config(argv[0], NULL, action, NULL, 0); + rv = config(argv[0], NULL, action, 0, NULL, 0); else if (action == VND_GET) rv = getinfo(argc ? argv[0] : NULL); else @@ -274,7 +281,8 @@ query: } int -config(char *dev, char *file, int action, char *key, size_t keylen) +config(char *dev, char *file, int action, size_t secsize, char *key, + size_t keylen) { struct vnd_ioctl vndio; FILE *f; @@ -289,6 +297,7 @@ config(char *dev, char *file, int action, char *key, size_t keylen) goto out; } vndio.vnd_file = file; + vndio.vnd_secsize = secsize; vndio.vnd_key = (u_char *)key; vndio.vnd_keylen = keylen; |