Source-Changes-HG archive

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

[src/trunk]: src/sbin/swapctl When processing swapon -a (or swapctl -A, or sw...



details:   https://anonhg.NetBSD.org/src/rev/14e281b4ab13
branches:  trunk
changeset: 373800:14e281b4ab13
user:      kre <kre%NetBSD.org@localhost>
date:      Wed Mar 01 15:15:56 2023 +0000

description:
When processing swapon -a (or swapctl -A, or swapctl -U) ignore lines in
fstab that have nothing to do with swapping (fs_type is neither "sw" nor "dp")
before running getfsspecname() on the fs_spec field of the line.

This avoids entries like this:

NAME=OFTEN_UNCONNECTED   /local/archived ffs     rw,log,noauto    0 0

in fstab from generating spurious error messages when the wedge named
is not currently connected to the system - that is the drive on which the
wedge exists is not connected, or not powered on.   "noauto" handles that
for some other uses, the "0"s in fs_freq and fs_passno work for other uses,
but swap{on,ctl} never look at those fields (not for this purpose).

Non "sw"/"dp" lines were being ignored anyway, but not until (a little) later.

diffstat:

 sbin/swapctl/swapctl.c |  14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diffs (42 lines):

diff -r af0a58c790b8 -r 14e281b4ab13 sbin/swapctl/swapctl.c
--- a/sbin/swapctl/swapctl.c    Wed Mar 01 15:11:28 2023 +0000
+++ b/sbin/swapctl/swapctl.c    Wed Mar 01 15:15:56 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: swapctl.c,v 1.41 2022/04/04 19:33:44 andvar Exp $      */
+/*     $NetBSD: swapctl.c,v 1.42 2023/03/01 15:15:56 kre Exp $ */
 
 /*
  * Copyright (c) 1996, 1997, 1999, 2015 Matthew R. Green
@@ -64,7 +64,7 @@
 #include <sys/cdefs.h>
 
 #ifndef lint
-__RCSID("$NetBSD: swapctl.c,v 1.41 2022/04/04 19:33:44 andvar Exp $");
+__RCSID("$NetBSD: swapctl.c,v 1.42 2023/03/01 15:15:56 kre Exp $");
 #endif
 
 
@@ -733,6 +733,13 @@
                char buf[MAXPATHLEN];
                char *spec, *fsspec;
 
+               /*
+                * Ignore any ewtries which are not related to swapping
+                */
+               if (strcmp(fp->fs_type, "sw") != 0 &&
+                   strcmp(fp->fs_type, "dp") != 0)
+                       continue;
+
                if (getfsspecname(buf, sizeof(buf), fp->fs_spec) == NULL) {
                        warn("%s", buf);
                        continue;
@@ -745,9 +752,6 @@
                        continue;
                }
 
-               if (strcmp(fp->fs_type, "sw") != 0)
-                       continue;
-
                /* handle dp as mnt option */
                if (strstr(fp->fs_mntops, "dp") && add)
                        set_dumpdev1(spec);



Home | Main Index | Thread Index | Old Index