[BusyBox] Fix for sysctl -e documentation (patch)

Rick Richardson rickr at mn.rr.com
Thu Apr 15 23:00:17 UTC 2004


Here is a patch that corrects the documentation for the sysctl -e option.

Yes, the fix is in the code. :-)

-Rick

-- 
Rick Richardson  rickr at mn.rr.com    http://home.mn.rr.com/richardsons/
Linux tools for geocaching          http://geo.rkkda.com

"I never thought I would spend my free time driving around looking for dollar
store items hidden on top of mountains under a bunch of rocks."
    --Denny Ford of Tres Hombres 
-------------- next part --------------
--- sysctl.c.orig	Thu Apr 15 17:48:07 2004
+++ sysctl.c	Thu Apr 15 17:56:04 2004
@@ -44,6 +44,7 @@
  */
 static const char PROC_PATH[] = "/proc/sys/";
 static const char DEFAULT_PRELOAD[] = "/etc/sysctl.conf";
+static char IgnoreError = 0;
 
 /* error messages */
 static const char ERR_UNKNOWN_PARAMETER[] = "error: Unknown parameter '%s'\n";
@@ -90,6 +91,9 @@
 			case 'n':
 				output = 0;
 				break;
+			case 'e':
+				IgnoreError = 1;
+				break;
 			case 'w':
 				write_mode = 1;
 				switches_allowed = 0;
@@ -219,9 +223,13 @@
 		*cptr = '.';
 
 	if ((fd = open(tmpname, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0) {
+		retval = -1;
 		switch (errno) {
 		case ENOENT:
-			bb_error_msg(ERR_INVALID_KEY, outname);
+			if (IgnoreError)
+				retval = 0;
+			else
+				bb_error_msg(ERR_INVALID_KEY, outname);
 			break;
 		case EACCES:
 			bb_perror_msg(ERR_PERMISSION_DENIED, outname);
@@ -230,7 +238,6 @@
 			bb_error_msg(ERR_UNKNOWN_WRITING, errno, outname);
 			break;
 		}
-		retval = -1;
 	} else {
 		dwrite_str(fd, value);
 		close(fd);
@@ -273,9 +280,13 @@
 		*cptr = '.';
 
 	if ((fp = fopen(tmpname, "r")) == NULL) {
+		retval = -1;
 		switch (errno) {
 		case ENOENT:
-			bb_error_msg(ERR_INVALID_KEY, outname);
+			if (IgnoreError)
+				retval = 0;
+			else
+				bb_error_msg(ERR_INVALID_KEY, outname);
 			break;
 		case EACCES:
 			bb_error_msg(ERR_PERMISSION_DENIED, outname);
@@ -284,7 +295,6 @@
 			bb_error_msg(ERR_UNKNOWN_READING, errno, outname);
 			break;
 		}
-		retval = -1;
 	} else {
 		while (fgets(inbuf, sizeof(inbuf) - 1, fp)) {
 			if (output) {


More information about the busybox mailing list