Module Name:    src
Committed By:   mrg
Date:           Sun Oct 11 23:58:16 UTC 2015

Modified Files:
        src/sbin/swapctl: swapctl.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 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.39 src/sbin/swapctl/swapctl.c:1.40
--- src/sbin/swapctl/swapctl.c:1.39	Tue Jan  1 19:01:10 2013
+++ src/sbin/swapctl/swapctl.c	Sun Oct 11 23:58:16 2015
@@ -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 int	pri;		/* uses 0 as default pr
 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 @@ add_swap(char *path, int priority)
 
 	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 @@ delete_swap(char *path)
 	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 @@ set_dumpdev1(char *spec)
 	}
 
 	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 @@ set_dumpdev(char *path)
 		err(1, "%s", path);
 	spec = buf;
 
-	return set_dumpdev1(spec);
+	if (! set_dumpdev1(spec))
+		exit(1);
 }
 
 static int

Reply via email to