Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/swapctl support new `swapctl -z' that shows the dump de...



details:   https://anonhg.NetBSD.org/src/rev/309632fc21e1
branches:  trunk
changeset: 499337:309632fc21e1
user:      mrg <mrg%NetBSD.org@localhost>
date:      Fri Nov 17 11:43:41 2000 +0000

description:
support new `swapctl -z' that shows the dump device.

diffstat:

 sbin/swapctl/swapctl.8 |   8 +++++++-
 sbin/swapctl/swapctl.c |  37 +++++++++++++++++++++++++++++++++----
 2 files changed, 40 insertions(+), 5 deletions(-)

diffs (136 lines):

diff -r 771aab110a48 -r 309632fc21e1 sbin/swapctl/swapctl.8
--- a/sbin/swapctl/swapctl.8    Fri Nov 17 11:40:05 2000 +0000
+++ b/sbin/swapctl/swapctl.8    Fri Nov 17 11:43:41 2000 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: swapctl.8,v 1.17 2000/03/05 11:35:22 lukem Exp $
+.\"    $NetBSD: swapctl.8,v 1.18 2000/11/17 11:43:41 mrg Exp $
 .\"
 .\" Copyright (c) 1997 Matthew R. Green
 .\" All rights reserved.
@@ -57,6 +57,8 @@
 .Nm ""
 .Fl l | Fl s
 .Op Fl k
+.Nm ""
+.Fl z
 .Nm swapon
 .Fl a | Ar path
 .Nm swapoff
@@ -195,6 +197,10 @@
 to be added.  This option is useful in early system startup, where swapping
 may be needed before all file systems are available, such as during
 disk checks of large file systems.
+.It Fl z
+The
+.Fl z
+option displays the current dump device.
 .El
 .Sh SWAP OPTIONS
 When parsing the
diff -r 771aab110a48 -r 309632fc21e1 sbin/swapctl/swapctl.c
--- a/sbin/swapctl/swapctl.c    Fri Nov 17 11:40:05 2000 +0000
+++ b/sbin/swapctl/swapctl.c    Fri Nov 17 11:43:41 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: swapctl.c,v 1.15 2000/07/07 12:29:10 itojun Exp $      */
+/*     $NetBSD: swapctl.c,v 1.16 2000/11/17 11:43:41 mrg Exp $ */
 
 /*
  * Copyright (c) 1996, 1997, 1999 Matthew R. Green
@@ -33,6 +33,7 @@
  *     -A              add all devices listed as `sw' in /etc/fstab (also
  *                     (sets the dump device, if listed in fstab)
  *     -D <dev>        set dumpdev to <dev>
+ *     -z              show dumpdev
  *     -U              remove all devices listed as `sw' in /etc/fstab.
  *     -t [blk|noblk]  if -A or -U , add (remove) either all block device
  *                     or all non-block devices
@@ -79,6 +80,7 @@
 #define        CMD_d           0x20    /* delete a swap file/device */
 #define        CMD_l           0x40    /* list swap files/devices */
 #define        CMD_s           0x80    /* summary of swap files/devices */
+#define        CMD_z           0x100   /* show dump device */
 
 #define        SET_COMMAND(cmd) \
 do { \
@@ -92,7 +94,7 @@
  * line, and the ones which require that none exist.
  */
 #define        REQUIRE_PATH    (CMD_D | CMD_a | CMD_c | CMD_d)
-#define        REQUIRE_NOPATH  (CMD_A | CMD_U | CMD_l | CMD_s)
+#define        REQUIRE_NOPATH  (CMD_A | CMD_U | CMD_l | CMD_s | CMD_z)
 
 /*
  * Option flags, and the commands with which they are valid.
@@ -104,7 +106,7 @@
 #define        PFLAG_CMDS      (CMD_A | CMD_a | CMD_c)
 
 char   *tflag;         /* swap device type (blk or noblk) */
-#define        TFLAG_CMDS      (CMD_A | CMD_U )
+#define        TFLAG_CMDS      (CMD_A | CMD_U)
 
 int    pri;            /* uses 0 as default pri */
 
@@ -112,6 +114,7 @@
 static int  add_swap __P((const char *, int));
 static int  delete_swap __P((const char *));
 static void set_dumpdev __P((const char *));
+static void get_dumpdev __P((void));
        int  main __P((int, char *[]));
 static void do_fstab __P((int));
 static void usage __P((void));
@@ -141,7 +144,7 @@
        }
 #endif
 
-       while ((c = getopt(argc, argv, "ADUacdlkp:st:")) != -1) {
+       while ((c = getopt(argc, argv, "ADUacdlkp:st:z")) != -1) {
                switch (c) {
                case 'A':
                        SET_COMMAND(CMD_A);
@@ -191,6 +194,10 @@
                        tflag = optarg;
                        break;
 
+               case 'z':
+                       SET_COMMAND(CMD_z);
+                       break;
+
                default:
                        usage();
                        /* NOTREACHED */
@@ -264,6 +271,10 @@
                set_dumpdev(argv[0]);
                break;
 
+       case CMD_z:
+               get_dumpdev();
+               break;
+
        case CMD_U:
                do_fstab(0);
                break;
@@ -393,6 +404,24 @@
 }
 
 static void
+get_dumpdev()
+{
+       dev_t   dev;
+       char    *name;
+
+       if (swapctl(SWAP_GETDUMPDEV, &dev, NULL) == -1)
+               warn("could not get dump device");
+       else {
+               name = devname(dev, S_IFBLK);
+               printf("dump device is ");
+               if (name)
+                       printf("%s\n", name);
+               else
+                       printf("major %d minor %d\n", major(dev), minor(dev));
+       }
+}
+
+static void
 do_fstab(add)
        int add;
 {



Home | Main Index | Thread Index | Old Index