Module Name: src Committed By: kre Date: Wed Mar 1 15:15:56 UTC 2023
Modified Files: src/sbin/swapctl: swapctl.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sbin/swapctl/swapctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sbin/swapctl/swapctl.c diff -u src/sbin/swapctl/swapctl.c:1.41 src/sbin/swapctl/swapctl.c:1.42 --- src/sbin/swapctl/swapctl.c:1.41 Mon Apr 4 19:33:44 2022 +++ src/sbin/swapctl/swapctl.c Wed Mar 1 15:15:56 2023 @@ -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 @@ do_fstab(int add) 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 @@ do_fstab(int add) continue; } - if (strcmp(fp->fs_type, "sw") != 0) - continue; - /* handle dp as mnt option */ if (strstr(fp->fs_mntops, "dp") && add) set_dumpdev1(spec);