i was poking around the raid stuff and thought that the form:
        if (ioctl(...) != 0)
                bb_perror_msg_and_die("ioctl");
seemed pretty common ... and indeed it is:
console-tools/deallocvt.c
console-tools/loadfont.c
console-tools/setconsole.c
console-tools/setkeycodes.c
console-tools/setlogcons.c
loginutils/getty.c
loginutils/vlock.c
miscutils/devfsd.c
miscutils/eject.c
miscutils/mt.c
miscutils/raidautorun.c
networking/arp.c
networking/arping.c
networking/ether-wake.c
networking/ifconfig.c
networking/interface.c
networking/nameif.c
networking/route.c
networking/slattach.c
networking/traceroute.c
networking/vconfig.c
networking/zcip.c
util-linux/fbset.c
util-linux/fdformat.c
util-linux/fdisk.c
util-linux/hwclock.c

these are the much more common ioctl() form which takes three parameters: the 
fd, the command, and an argument (pointer, whatever)

there is some information lost here in terms of the error message, but i 
honestly dont think it's a big deal plus we'll save on string space ;)

a quick sample here (i thought there was a `make` command to do this 
automatically ...):

before:
   4030       0      12    4042     fca libbb/xfuncs.o
    115       0       0     115      73 miscutils/raidautorun.o
    145       0       0     145      91 console-tools/deallocvt.o

after:
   4097       0      12    4109    100d libbb/xfuncs.o
     91       0       0      91      5b miscutils/raidautorun.o
    113       0       0     113      71 console-tools/deallocvt.o
-mike

Attachment: signature.asc
Description: This is a digitally signed message part.

Index: console-tools/deallocvt.c
===================================================================
--- console-tools/deallocvt.c	(revision 18902)
+++ console-tools/deallocvt.c	(working copy)
@@ -31,8 +31,7 @@ int deallocvt_main(int argc, char **argv
 		bb_show_usage();
 	}
 
-	if (-1 == ioctl(get_console_fd(), VT_DISALLOCATE, num)) {
-		bb_perror_msg_and_die("VT_DISALLOCATE");
-	}
+	xioctl(get_console_fd(), VT_DISALLOCATE, num);
+
 	return EXIT_SUCCESS;
 }
Index: libbb/xfuncs.c
===================================================================
--- libbb/xfuncs.c	(revision 18902)
+++ libbb/xfuncs.c	(working copy)
@@ -639,3 +639,13 @@ int get_terminal_width_height(const int 
 
 	return ret;
 }
+
+/* Die if the ioctl() call failed.  Only support the 3 arg form. */
+#undef xioctl
+int xioctl(int fd, int request, unsigned long arg)
+{
+	int ret = ioctl(fd, request, arg);
+	if (ret != 0)
+		bb_perror_msg_and_die("ioctl");
+	return ret;
+}
Index: miscutils/raidautorun.c
===================================================================
--- miscutils/raidautorun.c	(revision 18902)
+++ miscutils/raidautorun.c	(working copy)
@@ -19,9 +19,7 @@ int raidautorun_main(int argc, char **ar
 	if (argc != 2)
 		bb_show_usage();
 
-	if (ioctl(xopen(argv[1], O_RDONLY), RAID_AUTORUN, NULL) != 0) {
-		bb_perror_msg_and_die("ioctl");
-	}
+	xioctl(xopen(argv[1], O_RDONLY), RAID_AUTORUN, NULL);
 
 	return EXIT_SUCCESS;
 }
Index: include/libbb.h
===================================================================
--- include/libbb.h	(revision 18902)
+++ include/libbb.h	(working copy)
@@ -249,7 +249,8 @@ DIR *warn_opendir(const char *path);
 char *xrealloc_getcwd_or_warn(char *cwd);
 char *xmalloc_readlink_or_warn(const char *path);
 char *xmalloc_realpath(const char *path);
-
+int xioctl(int fd, int request, unsigned long arg);
+#define xioctl(fd,request,arg) xioctl(fd,request,(unsigned long)arg)
 
 //TODO: signal(sid, f) is the same? then why?
 extern void sig_catch(int,void (*)(int));
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to