Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-7-0]: src/usr.sbin/vnconfig Pull up following revision(s) (reques...
details: https://anonhg.NetBSD.org/src/rev/ba89753a65c4
branches: netbsd-7-0
changeset: 801165:ba89753a65c4
user: martin <martin%NetBSD.org@localhost>
date: Sun Apr 10 09:45:09 2016 +0000
description:
Pull up following revision(s) (requested by christos in ticket #1076):
usr.sbin/vnconfig/vnconfig.8: revision 1.41
usr.sbin/vnconfig/vnconfig.c: revision 1.43-1.44
Since now the kernel returns ENXIO again for devices exceeding the
number of devices configured in the kernel, use that instead of
scanning /dev.
Cosmetic tweaks to vncfonfig -l output.
This should restore compatibility for old scripts
trying to find free vnodes in the new cloning world order.
diffstat:
usr.sbin/vnconfig/vnconfig.8 | 76 ++++++++++++++++++++++++---
usr.sbin/vnconfig/vnconfig.c | 114 ++++++++++++++++++++++++++----------------
2 files changed, 136 insertions(+), 54 deletions(-)
diffs (truncated from 355 to 300 lines):
diff -r d4c922c88e1a -r ba89753a65c4 usr.sbin/vnconfig/vnconfig.8
--- a/usr.sbin/vnconfig/vnconfig.8 Mon Apr 04 10:04:34 2016 +0000
+++ b/usr.sbin/vnconfig/vnconfig.8 Sun Apr 10 09:45:09 2016 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: vnconfig.8,v 1.39.8.1 2015/11/08 02:04:46 riz Exp $
+.\" $NetBSD: vnconfig.8,v 1.39.8.2 2016/04/10 09:45:09 martin Exp $
.\"
.\" Copyright (c) 1997 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -69,6 +69,7 @@
.Nd configure vnode disks
.Sh SYNOPSIS
.Nm
+.\" Fcf:lm:rt:uvz
.Op Fl crvz
.Op Fl f Ar disktab
.Op Fl t Ar typename
@@ -81,7 +82,8 @@
.Ar vnode_disk
.Nm
.Fl l
-.Op Ar vnode_disk
+.Op Fl m Ar min
+.Op Ar vnode_disk ...
.Sh DESCRIPTION
The
.Nm
@@ -124,7 +126,7 @@
cylinders.
.Ar secsize
is the number of bytes per sector.
-It must be an even multiple of 512.
+It must be a power of two, and at least 512.
.Ar nsectors
is the number of sectors per track.
.Ar ntracks
@@ -144,9 +146,28 @@
.Pa /etc/disktab .
.It Fl l
List the vnd devices and indicate which ones are in use.
-If a specific
-.Ar vnode_disk
-is given, then only that will be described.
+If one or more specific
+.Ar vnode_disks
+are given, then only those will be described.
+.It Fl m Ar min
+Together with
+.Fl l
+and if no specific devices are given,
+causes at least
+.Ar min
+devices to be listed.
+The default for
+.Ar min
+is 4,
+but all vnd devices up to (and sometimes just beyond)
+the highest numbered vnd device configured since
+the system last booted will be listed.
+If
+.Ar min
+is set to 0,
+then only vnd devices currently in use will be shown.
+.It Fl r
+Configure the device as read-only.
.It Fl t Ar typename
If configuring the device, look up
.Ar typename
@@ -156,8 +177,6 @@
This option and the
.Ar geomspec
argument are mutually exclusive.
-.It Fl r
-Configure the device as read-only.
.It Fl u
Unconfigures the device.
.It Fl v
@@ -172,9 +191,25 @@
manpage on how to create such an image.
.El
.Pp
-If no action option is given,
+If no action option
+.Op Fl clu
+is given,
.Fl c
is assumed.
+.Sh EXIT STATUS
+.Nm
+will exit with status 0 if the operation requested
+completed successfully,
+or 1 otherwise.
+Unsuccessful completion can be caused by unknown or
+incorrectly used options;
+attempting to configure a vnd that is already configured;
+or unconfigure one that is not, or without
+.Fl F ,
+one which is still in use;
+or if devices are specified that do not exist or are not
+.Xr vnd 4
+devices, giving an improper geometry, etc.
.Sh FILES
.Bl -tag -width /etc/disktab -compact
.It Pa /dev/rvnd??
@@ -190,6 +225,10 @@
.Pa vnd0 .
Please note that use of the second form of the command is discouraged because
it requires knowledge of the raw partition which varies between architectures.
+For the first form, be aware that there must not be a file
+.Ar vnd0
+in the current directory, or it will be assumed to be the vnd device to
+be configured (which will usually fail.)
.Pp
.Dl vndconfig vnd0 /tmp/floppy.img 512/18/2/80
.Pp
@@ -212,6 +251,22 @@
Unconfigures the
.Pa vnd0
device.
+.Pp
+To obtain status on all vnd devices listed in /dev
+(assuming a system where the
+.Sq d
+partition is the whole device (RAW_PART)), use:
+.Pp
+.Dl vndconfig -l /dev/vnd*d
+.Pp
+Using
+.Dl vndconfig -m0 -l /dev/vnd*d
+will omit those devices that are not in use, whereas
+.Dl vnconfig -l
+will list all devices known to the kernel (at least 4
+without
+.Fl m )
+regardless of what might appear in /dev (or elsewhere.)
.Sh SEE ALSO
.Xr vndcompress 1 ,
.Xr opendisk 3 ,
@@ -229,4 +284,5 @@
in
.Nx 7.0
for consistency with other similar commands.
-(The original name was also retained for backwards compatability.)
+(The original name was also retained as an alternative
+for backwards compatibility.)
diff -r d4c922c88e1a -r ba89753a65c4 usr.sbin/vnconfig/vnconfig.c
--- a/usr.sbin/vnconfig/vnconfig.c Mon Apr 04 10:04:34 2016 +0000
+++ b/usr.sbin/vnconfig/vnconfig.c Sun Apr 10 09:45:09 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vnconfig.c,v 1.42 2014/05/23 20:50:16 dholland Exp $ */
+/* $NetBSD: vnconfig.c,v 1.42.4.1 2016/04/10 09:45:09 martin Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -73,13 +73,11 @@
#include <sys/buf.h>
#include <sys/disklabel.h>
#include <sys/disk.h>
-#include <sys/bitops.h>
#include <dev/vndvar.h>
#include <disktab.h>
#include <err.h>
-#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <stddef.h>
@@ -89,28 +87,36 @@
#include <unistd.h>
#include <util.h>
#include <paths.h>
+#include <limits.h>
#define VND_CONFIG 1
#define VND_UNCONFIG 2
#define VND_GET 3
+/* with -l we always print at least this many entries */
+#define DUMMY_FREE 4
+
static int verbose = 0;
static int readonly = 0;
static int force = 0;
static int compressed = 0;
+static int minimum = DUMMY_FREE;
static char *tabname;
-static void show(int, int);
+static int show(int, int, const char * const);
static int config(char *, char *, char *, int);
static int getgeom(struct vndgeom *, char *);
__dead static void usage(void);
+static void show_unused(int);
int
main(int argc, char *argv[])
{
int ch, rv, action = VND_CONFIG;
+ char *end;
+ unsigned long cnt;
- while ((ch = getopt(argc, argv, "Fcf:lrt:uvz")) != -1) {
+ while ((ch = getopt(argc, argv, "Fcf:lm:rt:uvz")) != -1) {
switch (ch) {
case 'F':
force = 1;
@@ -125,6 +131,12 @@
case 'l':
action = VND_GET;
break;
+ case 'm':
+ cnt = strtoul(optarg, &end, 10);
+ if (cnt >= INT_MAX || end == optarg || *end != '\0')
+ usage();
+ minimum = (int)cnt;
+ break;
case 'r':
readonly = 1;
break;
@@ -161,51 +173,58 @@
usage();
rv = config(argv[0], NULL, NULL, action);
} else { /* VND_GET */
- int n, v;
+ int n, vdisk;
const char *vn;
char path[64];
- if (argc != 0 && argc != 1)
- usage();
-
- vn = argc ? argv[0] : "vnd0";
-
- v = opendisk(vn, O_RDONLY, path, sizeof(path), 0);
- if (v == -1)
- err(1, "open: %s", vn);
+ if (argc == 0) {
+ vn = "vnd0";
- if (argc)
- show(v, -1);
- else {
- DIR *dirp;
- struct dirent *dp;
- __BITMAP_TYPE(, uint32_t, 65536) bm;
-
- __BITMAP_ZERO(&bm);
-
- if ((dirp = opendir(_PATH_DEV)) == NULL)
- err(1, "opendir: %s", _PATH_DEV);
-
- while ((dp = readdir(dirp)) != NULL) {
- if (strncmp(dp->d_name, "rvnd", 4) != 0)
- continue;
- n = atoi(dp->d_name + 4);
- if (__BITMAP_ISSET(n, &bm))
- continue;
- __BITMAP_SET(n, &bm);
- show(v, n);
+ vdisk = opendisk(vn, O_RDONLY, path, sizeof(path), 0);
+ if (vdisk == -1) {
+ if (minimum == 0)
+ return 1;
+ err(1, "open: %s", vn);
}
- closedir(dirp);
+ for (n = 0; show(vdisk, n, 0); n++)
+ continue;
+ while (n < minimum)
+ show_unused(n++);
+ close(vdisk);
+ return 0;
}
- close(v);
+
rv = 0;
+ while (--argc >= 0) {
+ vn = *argv++;
+
+ vdisk = opendisk(vn, O_RDONLY, path, sizeof(path), 0);
+ if (vdisk == -1) {
+ warn("open: %s", vn);
+ rv = 1;
+ continue;
+ }
+
+ if (!show(vdisk, -1, vn))
+ rv = 1;
+ close(vdisk);
+ }
}
return rv;
}
static void
-show(int v, int n)
+show_unused(int n)
+{
Home |
Main Index |
Thread Index |
Old Index