[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: [PATCH] applet volname
From:       Matthew Stoltenberg <d3matt () gmail ! com>
Date:       2009-08-12 23:52:15
Message-ID: 3c1bc2140908121652h4ff3570cq171b78a93f56c39 () mail ! gmail ! com
[Download RAW message or body]

On Wed, Aug 12, 2009 at 6:00 PM, Denys Vlasenko<vda.linux@googlemail.com> wrote:
> On Wed, Aug 12, 2009 at 8:33 PM, Matthew Stoltenberg<d3matt@gmail.com> 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
[ mstolten@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)
[ mstolten@flash-ubuntu ~/Download/busybox-1.14.3  :) ] $ rm miscutils/volname.o
[ mstolten@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...
[ mstolten@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

["volname_patch2-1.14.3.patch" (text/x-patch)]

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 <tranter@pobox.com>
+ * Modified for busybox by Matthew Stoltenbegr <d3matt@gmail.c>
+ *
+ *
+ *****************************************************************************/
+
+#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
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic