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))
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 \
+ ""
+#define rdev_full_usage "\n\n" \
+ "Display to standard output the device node associated with the file\n"
\
+ "system mounted at '/'"
+#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 '/'.
+
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
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.
+ */
+
+#include <stdlib.h>
+
+#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);
+}
--
1.5.6.3
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox