summaryrefslogtreecommitdiff
path: root/sbin/mount_vnd/mount_vnd.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2019-04-25 22:39:47 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2019-04-25 22:39:47 +0000
commit6da168c9141aae0c15f9da588d567dd87a67f1c3 (patch)
treed0e35d1f14503cff11c2aa371a6cdb9e791fc3d7 /sbin/mount_vnd/mount_vnd.c
parentf8e4c18351840b7189b0181b9f578e38c1408134 (diff)
Remove vnconfig functionality, and try to adapt the manual page.
I'm considering simply deleting mount_vnd -- are there any users of this bizzare feature?
Diffstat (limited to 'sbin/mount_vnd/mount_vnd.c')
-rw-r--r--sbin/mount_vnd/mount_vnd.c191
1 files changed, 29 insertions, 162 deletions
diff --git a/sbin/mount_vnd/mount_vnd.c b/sbin/mount_vnd/mount_vnd.c
index 55f01a07598..8b04f6307e9 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.20 2016/01/24 06:32:33 mmcc Exp $ */
+/* $OpenBSD: mount_vnd.c,v 1.21 2019/04/25 22:39:46 deraadt Exp $ */
/*
* Copyright (c) 1993 University of Utah.
* Copyright (c) 1990, 1993
@@ -31,10 +31,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * from: Utah $Hdr: vnconfig.c 1.1 93/12/15$
- *
- * @(#)vnconfig.c 8.1 (Berkeley) 12/15/93
*/
#include <sys/param.h> /* DEV_BSIZE */
@@ -57,42 +53,20 @@
#include <limits.h>
#include <util.h>
-#define DEFAULT_VND "vnd0"
-
-#define VND_CONFIG 1
-#define VND_UNCONFIG 2
-#define VND_GET 3
-
-int verbose = 0;
-int run_mount_vnd = 0;
-
__dead void usage(void);
-int config(char *, char *, int, struct disklabel *, char *,
- size_t);
-int getinfo(const char *);
+int config(char *, char *, struct disklabel *, char *, size_t);
char *get_pkcs_key(char *, char *);
int
main(int argc, char **argv)
{
- int ch, rv, action, opt_c, opt_k, opt_K, opt_l, opt_u;
- char *key, *mntopts, *rounds, *saltopt;
+ int ch, rv, opt_k = 0, opt_K = 0;
+ char *key = NULL, *mntopts = NULL, *rounds = NULL, *saltopt = NULL;
size_t keylen = 0;
- extern char *__progname;
struct disklabel *dp = NULL;
- if (strcasecmp(__progname, "mount_vnd") == 0)
- run_mount_vnd = 1;
-
- opt_c = opt_k = opt_K = opt_l = opt_u = 0;
- key = mntopts = rounds = saltopt = NULL;
- action = VND_CONFIG;
-
- while ((ch = getopt(argc, argv, "ckK:lo:S:t:uv")) != -1) {
+ while ((ch = getopt(argc, argv, "kK:o:S:t:")) != -1) {
switch (ch) {
- case 'c':
- opt_c = 1;
- break;
case 'k':
opt_k = 1;
break;
@@ -100,9 +74,6 @@ main(int argc, char **argv)
opt_K = 1;
rounds = optarg;
break;
- case 'l':
- opt_l = 1;
- break;
case 'o':
mntopts = optarg;
break;
@@ -114,12 +85,6 @@ main(int argc, char **argv)
if (dp == NULL)
errx(1, "unknown disk type: %s", optarg);
break;
- case 'u':
- opt_u = 1;
- break;
- case 'v':
- verbose = 1;
- break;
default:
usage();
/* NOTREACHED */
@@ -128,54 +93,26 @@ main(int argc, char **argv)
argc -= optind;
argv += optind;
- if (opt_c + opt_l + opt_u > 1)
- errx(1, "-c, -l and -u are mutually exclusive options");
-
- if (opt_l)
- action = VND_GET;
- else if (opt_u)
- action = VND_UNCONFIG;
- else
- action = VND_CONFIG; /* default behavior */
-
- if (saltopt && (!opt_K))
+ if (saltopt && !opt_K)
errx(1, "-S only makes sense when used with -K");
- if (action == VND_CONFIG && argc == 2) {
- int ind_raw, ind_reg;
-
- if (opt_k || opt_K) {
- fprintf(stderr,
- "WARNING: Consider using softraid crypto.\n");
- }
- if (opt_k) {
- if (opt_K)
- errx(1, "-k and -K are mutually exclusive");
- key = getpass("Encryption key: ");
- if (key == NULL || (keylen = strlen(key)) == 0)
- errx(1, "Need an encryption key");
- } else if (opt_K) {
- key = get_pkcs_key(rounds, saltopt);
- keylen = BLF_MAXUTILIZED;
- }
-
- /* fix order of arguments. */
- if (run_mount_vnd) {
- ind_raw = 1;
- ind_reg = 0;
- } else {
- ind_raw = 0;
- ind_reg = 1;
- }
- rv = config(argv[ind_raw], argv[ind_reg], action, dp, key,
- keylen);
- } else if (action == VND_UNCONFIG && argc == 1)
- rv = config(argv[0], NULL, action, NULL, NULL, 0);
- else if (action == VND_GET)
- rv = getinfo(argc ? argv[0] : NULL);
- else
+ if (argc != 2)
usage();
+ if (opt_k || opt_K)
+ fprintf(stderr, "WARNING: Consider using softraid crypto.\n");
+ if (opt_k) {
+ if (opt_K)
+ errx(1, "-k and -K are mutually exclusive");
+ key = getpass("Encryption key: ");
+ if (key == NULL || (keylen = strlen(key)) == 0)
+ errx(1, "Need an encryption key");
+ } else if (opt_K) {
+ key = get_pkcs_key(rounds, saltopt);
+ keylen = BLF_MAXUTILIZED;
+ }
+ rv = config(argv[1], argv[0], dp, key, keylen);
+
exit(rv);
}
@@ -247,54 +184,7 @@ get_pkcs_key(char *arg, char *saltopt)
}
int
-getinfo(const char *vname)
-{
- int vd, print_all = 0;
- struct vnd_user vnu;
-
- if (vname == NULL) {
- vname = DEFAULT_VND;
- print_all = 1;
- }
-
- vd = opendev((char *)vname, O_RDONLY, OPENDEV_PART, NULL);
- if (vd < 0)
- err(1, "open: %s", vname);
-
- vnu.vnu_unit = -1;
-
-query:
- if (ioctl(vd, VNDIOCGET, &vnu) == -1) {
- if (print_all && errno == ENXIO && vnu.vnu_unit > 0) {
- close(vd);
- return (0);
- } else {
- err(1, "ioctl: %s", vname);
- }
- }
-
- fprintf(stdout, "vnd%d: ", vnu.vnu_unit);
-
- if (!vnu.vnu_ino)
- fprintf(stdout, "not in use\n");
- else
- fprintf(stdout, "covering %s on %s, inode %llu\n",
- vnu.vnu_file, devname(vnu.vnu_dev, S_IFBLK),
- (unsigned long long)vnu.vnu_ino);
-
- if (print_all) {
- vnu.vnu_unit++;
- goto query;
- }
-
- close(vd);
-
- return (0);
-}
-
-int
-config(char *dev, char *file, int action, struct disklabel *dp, char *key,
- size_t keylen)
+config(char *dev, char *file, struct disklabel *dp, char *key, size_t keylen)
{
struct vnd_ioctl vndio;
char *rdev;
@@ -313,26 +203,11 @@ config(char *dev, char *file, int action, struct disklabel *dp, char *key,
vndio.vnd_keylen = keylen;
/*
- * Clear (un-configure) the device
- */
- if (action == VND_UNCONFIG) {
- rv = ioctl(fd, VNDIOCCLR, &vndio);
- if (rv)
- warn("VNDIOCCLR");
- else if (verbose)
- printf("%s: cleared\n", dev);
- }
- /*
* Configure the device
*/
- if (action == VND_CONFIG) {
- rv = ioctl(fd, VNDIOCSET, &vndio);
- if (rv)
- warn("VNDIOCSET");
- else if (verbose)
- printf("%s: %llu bytes on %s\n", dev, vndio.vnd_size,
- file);
- }
+ rv = ioctl(fd, VNDIOCSET, &vndio);
+ if (rv)
+ warn("VNDIOCSET");
close(fd);
fflush(stdout);
@@ -345,17 +220,9 @@ config(char *dev, char *file, int action, struct disklabel *dp, char *key,
__dead void
usage(void)
{
- extern char *__progname;
-
- if (run_mount_vnd)
- (void)fprintf(stderr,
- "usage: mount_vnd [-k] [-K rounds] [-o options] "
- "[-S saltfile] [-t disktype]\n"
- "\t\t image vnd_dev\n");
- else
- (void)fprintf(stderr,
- "usage: %s [-ckluv] [-K rounds] [-S saltfile] "
- "[-t disktype] vnd_dev image\n", __progname);
-
+ (void)fprintf(stderr,
+ "usage: mount_vnd [-k] [-K rounds] [-o options] "
+ "[-S saltfile] [-t disktype]\n"
+ "\t\t image vnd_dev\n");
exit(1);
}