Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/dkctl add a new command, "keeplabel".
details: https://anonhg.NetBSD.org/src/rev/90f355ab6ef0
branches: trunk
changeset: 533480:90f355ab6ef0
user: yamt <yamt%NetBSD.org@localhost>
date: Mon Jul 01 18:49:57 2002 +0000
description:
add a new command, "keeplabel".
diffstat:
sbin/dkctl/dkctl.8 | 13 ++++++++++++-
sbin/dkctl/dkctl.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 62 insertions(+), 2 deletions(-)
diffs (113 lines):
diff -r 33974b7c4d02 -r 90f355ab6ef0 sbin/dkctl/dkctl.8
--- a/sbin/dkctl/dkctl.8 Mon Jul 01 18:25:09 2002 +0000
+++ b/sbin/dkctl/dkctl.8 Mon Jul 01 18:49:57 2002 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: dkctl.8,v 1.2 2002/01/09 23:10:19 wiz Exp $
+.\" $NetBSD: dkctl.8,v 1.3 2002/07/01 18:49:57 yamt Exp $
.\"
.\" Copyright 2002 Wasabi Systems, Inc.
.\" All rights reserved.
@@ -88,6 +88,17 @@
is specified, the cache synchronization command will be issued even
if the kernel does not believe that there are any dirty cache blocks
in the disk's cache.
+.Pp
+.Nm keeplabel
+.Op Ar yes | no
+.Pp
+Specify to keep or drop the in-core disklabel on the last close of
+the disk device.
+(Keep if
+.Ar yes
+is specified, drop if
+.Ar no
+is specified.)
.Sh SEE ALSO
.Xr ioctl 2 ,
.Xr sd 4 ,
diff -r 33974b7c4d02 -r 90f355ab6ef0 sbin/dkctl/dkctl.c
--- a/sbin/dkctl/dkctl.c Mon Jul 01 18:25:09 2002 +0000
+++ b/sbin/dkctl/dkctl.c Mon Jul 01 18:49:57 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dkctl.c,v 1.1 2002/01/09 22:30:14 thorpej Exp $ */
+/* $NetBSD: dkctl.c,v 1.2 2002/07/01 18:49:57 yamt Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
@@ -51,6 +51,14 @@
#include <unistd.h>
#include <util.h>
+#define YES 1
+#define NO 0
+
+/* I don't think nl_langinfo is suitable in this case */
+#define YES_STR "yes"
+#define NO_STR "no"
+#define YESNO_ARG YES_STR " | " NO_STR
+
struct command {
const char *cmd_name;
const char *arg_names;
@@ -67,9 +75,12 @@
const char *cmdname; /* command user issued */
const char *argnames; /* helpstring; expected arguments */
+int yesno(const char *);
+
void disk_getcache(int, char *[]);
void disk_setcache(int, char *[]);
void disk_synccache(int, char *[]);
+void disk_keeplabel(int, char *[]);
struct command commands[] = {
{ "getcache",
@@ -87,6 +98,11 @@
disk_synccache,
O_RDWR },
+ { "keeplabel",
+ YESNO_ARG,
+ disk_keeplabel,
+ O_RDWR },
+
{ NULL,
NULL,
NULL,
@@ -225,3 +241,36 @@
if (ioctl(fd, DIOCCACHESYNC, &force) == -1)
err(1, "%s: sync cache", dvname);
}
+
+void
+disk_keeplabel(int argc, char *argv[])
+{
+ int keep;
+ int yn;
+
+ if (argc != 1)
+ usage();
+
+ yn = yesno(argv[0]);
+ if (yn < 0)
+ usage();
+
+ keep = yn == YES;
+
+ if (ioctl(fd, DIOCKLABEL, &keep) == -1)
+ err(1, "%s: keep label", dvname);
+}
+
+/*
+ * return YES, NO or -1.
+ */
+int
+yesno(const char *p)
+{
+
+ if (!strcmp(p, YES_STR))
+ return YES;
+ if (!strcmp(p, NO_STR))
+ return NO;
+ return -1;
+}
Home |
Main Index |
Thread Index |
Old Index