[BusyBox] [patch] new applet mountpoint

Bernhard Fischer rep.nop at aon.at
Fri Aug 19 16:59:25 UTC 2005


On Fri, Aug 19, 2005 at 11:58:50AM -0400, Mike Frysinger wrote:
>On Thursday 18 August 2005 03:16 pm, Bernhard Fischer wrote:
>> +               if (!(opt & OPT_q))
>> +                        bb_fprintf(stderr, "mountpoint: %s: %s\n", arg,
>> strerror(errno));
>
>shouldnt you just use
>bb_perror_msg(arg);
>-mike

yes and one should also use bb_error_msg.

against the patch i initially sent.
-------------- next part --------------
diff -X excl -rup busybox.sent/miscutils/mountpoint.c busybox/miscutils/mountpoint.c
--- busybox.sent/miscutils/mountpoint.c	2005-08-19 18:51:48.303133395 +0200
+++ busybox/miscutils/mountpoint.c	2005-08-19 18:48:31.123760068 +0200
@@ -40,7 +40,7 @@ int mountpoint_main(int argc, char **arg
 		char *arg = argv[optind];
 		struct stat st;
 
-		if ( (opt & OPT_x && stat(arg, &st) == 0) || (lstat(arg, &st) == 0)) {
+		if ( (opt & OPT_x && stat(arg, &st) == 0) || (lstat(arg, &st) == 0) ) {
 			if (opt & OPT_x) {
 #ifdef __linux__
 				if (S_ISBLK(st.st_mode))
@@ -48,18 +48,16 @@ int mountpoint_main(int argc, char **arg
 				if (S_ISBLK(st.st_mode) && !S_ISCHR(st.st_mode))
 #endif
 				{
-						bb_printf("%u:%u\n", major(st.st_rdev),
-									minor(st.st_rdev));
-						return EXIT_SUCCESS;
+					bb_printf("%u:%u\n", major(st.st_rdev),
+								minor(st.st_rdev));
+					return EXIT_SUCCESS;
 				} else {
 					if (opt & OPT_q)
-						bb_printf("\n");
+						putchar('\n');
 					else
-						bb_fprintf(stderr, "mountpoint: %s: not a block device\n",
-							arg);
+						bb_error_msg("%s: not a block device", arg);
 				}
 				return EXIT_FAILURE;
-
 			} else
 			if (S_ISDIR(st.st_mode)) {
 				dev_t st_dev = st.st_dev;
@@ -77,13 +75,12 @@ int mountpoint_main(int argc, char **arg
 				}
 			} else {
 				if (!(opt & OPT_q))
-					bb_fprintf(stderr, "mountpoint: %s: not a directory\n",
-							arg);
+					bb_error_msg("%s: not a directory", arg);
 				return EXIT_FAILURE;
 			}
 		}
 		if (!(opt & OPT_q))
-			 bb_fprintf(stderr, "mountpoint: %s: %s\n", arg, strerror(errno));
+			bb_perror_msg(arg);
 		return EXIT_FAILURE;
 	}
 }



More information about the busybox mailing list