Source-Changes-HG archive

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

[src/trunk]: src/sbin/swapctl don't stop processing /etc/fstab when one entry...



details:   https://anonhg.NetBSD.org/src/rev/98799c9bc645
branches:  trunk
changeset: 811081:98799c9bc645
user:      mrg <mrg%NetBSD.org@localhost>
date:      Sun Oct 11 23:58:16 2015 +0000

description:
don't stop processing /etc/fstab when one entry fails, both for
add and remove loops.  now when you add a new swap file and run
"swapctl -A" it won't give up after the existing one gives EBUSY
and move on to the rest.

diffstat:

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

diffs (97 lines):

diff -r 1b2d05cc56bc -r 98799c9bc645 sbin/swapctl/swapctl.c
--- a/sbin/swapctl/swapctl.c    Sun Oct 11 22:08:46 2015 +0000
+++ b/sbin/swapctl/swapctl.c    Sun Oct 11 23:58:16 2015 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: swapctl.c,v 1.39 2013/01/01 19:01:10 dsl Exp $ */
+/*     $NetBSD: swapctl.c,v 1.40 2015/10/11 23:58:16 mrg Exp $ */
 
 /*
- * Copyright (c) 1996, 1997, 1999 Matthew R. Green
+ * Copyright (c) 1996, 1997, 1999, 2015 Matthew R. Green
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -64,7 +64,7 @@
 #include <sys/cdefs.h>
 
 #ifndef lint
-__RCSID("$NetBSD: swapctl.c,v 1.39 2013/01/01 19:01:10 dsl Exp $");
+__RCSID("$NetBSD: swapctl.c,v 1.40 2015/10/11 23:58:16 mrg Exp $");
 #endif
 
 
@@ -151,7 +151,7 @@
 static void change_priority(char *);
 static int  add_swap(char *, int);
 static int  delete_swap(char *);
-static void set_dumpdev1(char *);
+static int set_dumpdev1(char *);
 static void set_dumpdev(char *);
 static int get_dumpdev(void);
 __dead static  void do_fstab(int);
@@ -475,9 +475,10 @@
 
        if (swapctl(SWAP_ON, spec, priority) < 0) {
 oops:
-               err(1, "%s", path);
+               warn("%s", path);
+               return 0;
        }
-       return (1);
+       return 1;
 }
 
 /*
@@ -489,19 +490,23 @@
        char buf[MAXPATHLEN];
        char *spec;
 
-       if (getfsspecname(buf, sizeof(buf), path) == NULL)
-               err(1, "%s", path);
+       if (getfsspecname(buf, sizeof(buf), path) == NULL) {
+               warn("%s", path);
+               return 0;
+       }
        spec = buf;
 
        if (nflag)
                return 1;
 
-       if (swapctl(SWAP_OFF, spec, pri) < 0) 
-               err(1, "%s", path);
-       return (1);
+       if (swapctl(SWAP_OFF, spec, pri) < 0) {
+               warn("%s", path);
+               return 0;
+       }
+       return 1;
 }
 
-static void
+static int
 set_dumpdev1(char *spec)
 {
        int rv = 0;
@@ -514,9 +519,11 @@
        }
 
        if (rv == -1)
-               err(1, "could not set dump device to %s", spec);
+               warn("could not set dump device to %s", spec);
        else
                printf("%s: setting dump device to %s\n", getprogname(), spec);
+
+       return rv == -1 ? 0 : 1;
 }
 
 static void
@@ -529,7 +536,8 @@
                err(1, "%s", path);
        spec = buf;
 
-       return set_dumpdev1(spec);
+       if (! set_dumpdev1(spec))
+               exit(1);
 }
 
 static int



Home | Main Index | Thread Index | Old Index