On Wed, Aug 12, 2009 at 6:00 PM, Denys Vlasenko<[email protected]> wrote:
> On Wed, Aug 12, 2009 at 8:33 PM, Matthew Stoltenberg<[email protected]> wrote:
>> +int volname_main(int argc, char *argv[])
>> +{
>> +       int fd;
>> +       int status;
>> +       char *device;
>> +       char buffer[33];
>> +
>> +       if (argc == 2) {
>> +               device = argv[1];
>
> cc1: warnings being treated as errors
> miscutils/volname.c:33: error: no previous prototype for 'volname_main'
> miscutils/volname.c: In function 'volname_main':
> miscutils/volname.c:39: error: assignment discards qualifiers from
> pointer target type
>
> You need to try to eliminate all warnings
> before you submit your code.
>
> I applied your code with some edits. Thanks.
> --
> vda
>

Sorry about that.  I thought I had warnings turned on (was initially
testing this in a goofy cross-compile system at work).  See attached
for updates with warning fix.

Here's successful compile: with -Wall
[ mstol...@flash-ubuntu ~/Download/busybox-1.14.3  :) ] $ gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
4.3.3-5ubuntu4'
--with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--with-gxx-include-dir=/usr/include/c++/4.3 --program-suffix=-4.3
--enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc
--enable-mpfr --enable-targets=all --with-tune=generic
--enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu
--target=i486-linux-gnu
Thread model: posix
gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4)
[ mstol...@flash-ubuntu ~/Download/busybox-1.14.3  :) ] $ rm miscutils/volname.o
[ mstol...@flash-ubuntu ~/Download/busybox-1.14.3  :) ] $ CFLAGS=-Wall make
  CC      miscutils/volname.o
  AR      miscutils/lib.a
  LINK    busybox_unstripped
Trying libraries: crypt m
 Library crypt is not needed, excluding it
 Library m is not needed, excluding it
Final link with: <none>

Also, using on my box...
[ mstol...@flash-ubuntu ~/Download/busybox-1.14.3  :) ] $ ./busybox volname
BABYLON5_SEASON4_DISC3


Lastly, the online FAQ could use an update to avoid the "no previous
prototype" warning.

Matt
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[]) MAIN_EXTERNALLY_VISIBLE;
+int volname_main(int argc, char *argv[])
+{
+	int fd;
+	const 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