On Fri, Aug 15, 2008 at 01:42:52PM -0700, [EMAIL PROTECTED] wrote:
>From: Grant Erickson <[EMAIL PROTECTED]>
>
>This patch adds a highly simplified version of the 'rdev' utility. The
>applet simply displays to standard output the device node associated
>with the file systme mounted at '/':
>
>       % ./busybox rdev
>       /dev/sda1 /
>
>Signed-off-by: Grant Erickson <[EMAIL PROTECTED]>
>---
>diff -aruN busybox-1.11.1/include/applets.h busybox-1.11.1.N/include/applets.h
>--- busybox-1.11.1/include/applets.h   2008-06-25 05:51:29.000000000 -0700
>+++ busybox-1.11.1.N/include/applets.h 2008-08-15 13:08:30.000000000 -0700
>@@ -236,6 +236,7 @@
> USE_MAN(APPLET(man, _BB_DIR_SBIN, _BB_SUID_NEVER))
> USE_MATCHPATHCON(APPLET(matchpathcon, _BB_DIR_USR_SBIN, _BB_SUID_NEVER))
> USE_MD5SUM(APPLET_ODDNAME(md5sum, md5_sha1_sum, _BB_DIR_USR_BIN, 
> _BB_SUID_NEVER, md5sum))
>+USE_RDEV(APPLET(rdev, _BB_DIR_BIN, _BB_SUID_NEVER))

That broke every applet after this line, see top of this file.
Also, my rdev resides in /usr/sbin.

> USE_MDEV(APPLET(mdev, _BB_DIR_SBIN, _BB_SUID_NEVER))
> USE_MESG(APPLET(mesg, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
> USE_MICROCOM(APPLET(microcom, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
>diff -aruN busybox-1.11.1/include/usage.h busybox-1.11.1.N/include/usage.h
>--- busybox-1.11.1/include/usage.h     2008-07-11 13:22:20.000000000 -0700
>+++ busybox-1.11.1.N/include/usage.h   2008-08-15 13:13:33.000000000 -0700
>@@ -2390,6 +2390,15 @@
>        "busybox: OK\n" \
>        "^D\n"
> 
>+#define rdev_trivial_usage \
>+       ""

The usage should be kept in alphabetical order.

>+#define rdev_full_usage "\n\n" \
>+       "Display to standard output the device node associated with the 
>file\n" \
>+       "system mounted at '/'"

A bit too verbose for my taste :)

>+#define rdev_example_usage \
>+       "$ rdev\n" \
>+       "/dev/mtdblock9 /\n"
>+
> #define mdev_trivial_usage \
>        "[-s]"
> #define mdev_full_usage "\n\n" \
>diff -aruN busybox-1.11.1/util-linux/Config.in 
>busybox-1.11.1.N/util-linux/Config.in
>--- busybox-1.11.1/util-linux/Config.in        2008-06-25 05:51:32.000000000 
>-0700
>+++ busybox-1.11.1.N/util-linux/Config.in      2008-08-15 12:57:38.000000000 
>-0700
>@@ -293,6 +293,13 @@
>         file or block device, and to query the status of a loop device.  This
>         version does not currently support enabling data encryption.
> 
>+config RDEV
>+       bool "rdev"
>+       default y
>+       help
>+        rdev is used to display to standard output a line containing the
>+        device node associated with the file system mounted at '/'.

Ditto. Should be kept in alphabetical order for clarity.

>+
> config MDEV
>       bool "mdev"
>       default n
>diff -aruN busybox-1.11.1/util-linux/Kbuild busybox-1.11.1.N/util-linux/Kbuild
>--- busybox-1.11.1/util-linux/Kbuild   2008-06-25 05:51:32.000000000 -0700
>+++ busybox-1.11.1.N/util-linux/Kbuild 2008-08-15 13:14:58.000000000 -0700
>@@ -19,6 +19,7 @@
> lib-$(CONFIG_IPCRM)             += ipcrm.o
> lib-$(CONFIG_IPCS)              += ipcs.o
> lib-$(CONFIG_LOSETUP)           += losetup.o
>+lib-$(CONFIG_RDEV)              += rdev.o

ditto.

> lib-$(CONFIG_MDEV)              += mdev.o
> lib-$(CONFIG_MKFS_MINIX)        += mkfs_minix.o
> lib-$(CONFIG_MKSWAP)            += mkswap.o
>diff -aruN busybox-1.11.1/util-linux/rdev.c busybox-1.11.1.N/util-linux/rdev.c
>--- busybox-1.11.1/util-linux/rdev.c   1969-12-31 16:00:00.000000000 -0800
>+++ busybox-1.11.1.N/util-linux/rdev.c 2008-08-15 13:06:29.000000000 -0700
>@@ -0,0 +1,28 @@
>+/*
>+ *    Copyright (c) 2008 Nuovation System Designs, LLC
>+ *      Grant Erickson <[EMAIL PROTECTED]>
>+ *
>+ *    Licensed under GPLv2 or later, see LICENSE file for details.
>+ *
>+ *    Description:
>+ *      This file implements a light, minimally featured version of
>+ *      'rdev' which reports the device node associated with the
>+ *      currently-mounted root file system.
>+ */

The whole comment above is in non-standard format.

>+
>+#include <stdlib.h>

1) superfluous include.
>+
>+#include "libbb.h"
>+
>+int rdev_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
>+int rdev_main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
>+{
>+      char const * const root_path = "/";
>+      char const * const root_device = find_block_device(root_path);
>+
>+      if (root_device != NULL) {
>+              printf("%s %s\n", root_device, root_path);
>+      }
>+
>+      return (root_device ? EXIT_SUCCESS : EXIT_FAILURE);

2) see how it is bloated to generate 2 conditional branches (-2 bytes)
3) Since root_path cannot change, it's bloated to pass it to printf (-7
   bytes)
4) ATTRIBUTE_UNUSED was (oddly, IMO) renamed to UNUSED_PARAM. You should
   have diffed the new applet against trunk.


I have fixed the abovementioned errors and applied it:
$ size util-linux/rdev.o*
   text    data     bss     dec     hex filename
     54       0       0      54      36 util-linux/rdev.o.yours
     45       0       0      45      2d util-linux/rdev.o

Let's see if somebody needs this to display or change vmlinuz' rootdev.

Thanks and cheers,
Bernhard
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to