On Wed, Aug 12, 2009 at 3:01 PM, Tito<[email protected]> wrote:
> Hi,
> i would suggest to make use of libbb functions to reduce size
> and to send the patch as attachment.

Cool!  This is my first applet so I didn't know those existed :)  I
can definitely see how that reduces code space usage.

See patch file (I tested the functionality on several x86 machines).

Matt
diff -ruN -x CVS -x '.config*' -x busybox.spec busybox-1.14.3/docs/sigint.htm busybox/docs/sigint.htm
--- busybox-1.14.3/docs/sigint.htm	2009-07-28 18:33:00.000000000 -0500
+++ busybox/docs/sigint.htm	2009-08-12 13:51:40.000000000 -0500
@@ -2,7 +2,7 @@
 <HEAD>
 <link rel="SHORTCUT ICON" href="http://www.cons.org/favicon.ico";>
 <TITLE>Proper handling of SIGINT/SIGQUIT [http://www.cons.org/cracauer/sigint.html]</TITLE>
-<!-- Created by: GNU m4 using $Revision: 1.20 $ of crawww.m4lib on 11-Feb-2005 -->
+<!-- Created by: GNU m4 using $Revision: 1.2.8.1 $ of crawww.m4lib on 11-Feb-2005 -->
 <BODY BGCOLOR="#fff8e1">
 <CENTER><H2>Proper handling of SIGINT/SIGQUIT</H2></CENTER>
 <img src=linie.png width="100%" alt=" ">
@@ -623,5 +623,5 @@
 <P><img src=linie.png width="100%" alt=" ">
 <BR>&copy;2005 Martin Cracauer &lt;cracauer @ cons.org&gt;
 <A HREF="http://www.cons.org/cracauer/";>http://www.cons.org/cracauer/</A>
-<BR>Last changed: $Date: 2005/02/11 21:44:43 $
+<BR>Last changed: $Date: 2009/08/12 18:51:40 $
 </BODY></HTML>
diff -ruN -x CVS -x '.config*' -x busybox.spec busybox-1.14.3/include/applets.h busybox/include/applets.h
--- busybox-1.14.3/include/applets.h	2009-08-02 13:17:33.000000000 -0500
+++ busybox/include/applets.h	2009-08-12 12:49:38.000000000 -0500
@@ -408,6 +408,7 @@
 USE_VCONFIG(APPLET(vconfig, _BB_DIR_SBIN, _BB_SUID_NEVER))
 USE_VI(APPLET(vi, _BB_DIR_BIN, _BB_SUID_NEVER))
 USE_VLOCK(APPLET(vlock, _BB_DIR_USR_BIN, _BB_SUID_ALWAYS))
+USE_VOLNAME(APPLET(volname, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
 USE_WATCH(APPLET(watch, _BB_DIR_BIN, _BB_SUID_NEVER))
 USE_WATCHDOG(APPLET(watchdog, _BB_DIR_SBIN, _BB_SUID_NEVER))
 USE_WC(APPLET(wc, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
diff -ruN -x CVS -x '.config*' -x busybox.spec busybox-1.14.3/include/usage.h busybox/include/usage.h
--- busybox-1.14.3/include/usage.h	2009-08-02 13:16:36.000000000 -0500
+++ busybox/include/usage.h	2009-08-12 12:51:16.000000000 -0500
@@ -4804,6 +4804,11 @@
      "\nOptions:" \
      "\n	-a	Lock all VTs" \
 
+#define volname_trivial_usage \
+       "[DEVICE]"
+#define volname_full_usage "\n\n" \
+       "Show volume name for specified DEVICE (or default /dev/cdrom)\n"
+
 #define watch_trivial_usage \
        "[-n seconds] [-t] COMMAND..."
 #define watch_full_usage "\n\n" \
diff -ruN -x CVS -x '.config*' -x busybox.spec busybox-1.14.3/miscutils/Config.in busybox/miscutils/Config.in
--- busybox-1.14.3/miscutils/Config.in	2009-08-02 13:16:36.000000000 -0500
+++ busybox/miscutils/Config.in	2009-08-12 12:48:40.000000000 -0500
@@ -570,6 +570,12 @@
 	  error, but returns default 80x24.
 	  Usage in shell scripts: width=`ttysize w`.
 
+config VOLNAME
+	bool "volname"
+	default n
+	help
+	  Used to find volume name of cdroms. (defaults to /dev/cdrom)
+
 config WATCHDOG
 	bool "watchdog"
 	default n
diff -ruN -x CVS -x '.config*' -x busybox.spec busybox-1.14.3/miscutils/Kbuild busybox/miscutils/Kbuild
--- busybox-1.14.3/miscutils/Kbuild	2009-08-02 13:16:36.000000000 -0500
+++ busybox/miscutils/Kbuild	2009-08-12 12:48:37.000000000 -0500
@@ -38,4 +38,5 @@
 lib-$(CONFIG_TIME)        += time.o
 lib-$(CONFIG_TIMEOUT)     += timeout.o
 lib-$(CONFIG_TTYSIZE)     += ttysize.o
+lib-$(CONFIG_VOLNAME)     += volname.o
 lib-$(CONFIG_WATCHDOG)    += watchdog.o
diff -ruN -x CVS -x '.config*' -x busybox.spec busybox-1.14.3/miscutils/volname.c busybox/miscutils/volname.c
--- busybox-1.14.3/miscutils/volname.c	1969-12-31 18:00:00.000000000 -0600
+++ busybox/miscutils/volname.c	2009-08-12 17:02:55.000000000 -0500
@@ -0,0 +1,39 @@
+/* vi: set sw=4 ts=4: */
+/******************************************************************************
+ * 'volname' utility Reads and displays CD-ROM volume name
+ *
+ * Licensed under GPL version 2 (or later), see file LICENSE in this tarball for details.
+ *
+ * usage: volname [<device-file>]
+ *
+ * Original Copyright (C) 2000-2001 Jeff Tranter <[email protected]>
+ * Modified for busybox by Matthew Stoltenbegr <[email protected]>
+ *
+ *
+ *****************************************************************************/
+
+#include "libbb.h"
+
+int volname_main(int argc, char *argv[])
+{
+	int fd;
+	int status;
+	char *device = "/dev/cdrom";
+	char buffer[33];
+
+	if (argc == 2) {
+		device = argv[1];
+	} else if (argc > 2) {
+		bb_show_usage();
+	}
+
+	fd = xopen(device, O_RDONLY);
+	xlseek(fd, 32808, SEEK_SET);
+	xread(fd, buffer, 32);
+
+	printf("%32.32s\n", buffer);
+	if (ENABLE_FEATURE_CLEAN_UP) {
+		close(fd);
+	}
+	return 0;
+}
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to