# HG changeset patch # User Pascal Bellard # Date 1211800979 0 # Node ID 3a838d100a4e7165577f509f4bd70f0ea5bb8176 # Parent 6b8edbd9af7e637d2ace1351b08fa3978dde4337 busybox: add stat -m diff -r 6b8edbd9af7e -r 3a838d100a4e busybox/receipt --- a/busybox/receipt Sat May 24 12:45:54 2008 +0000 +++ b/busybox/receipt Mon May 26 11:22:59 2008 +0000 @@ -30,6 +30,7 @@ $PACKAGE-$VERSION-script.u $PACKAGE-$VERSION-header_tar.u $PACKAGE-$VERSION-fixes-$VERSION.u +$PACKAGE-$VERSION-stat.u EOT cp ../stuff/$PACKAGE-$VERSION.config .config make oldconfig diff -r 6b8edbd9af7e -r 3a838d100a4e busybox/stuff/busybox-1.10.1-stat.u --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/busybox/stuff/busybox-1.10.1-stat.u Mon May 26 11:22:59 2008 +0000 @@ -0,0 +1,73 @@ +--- busybox-1.10.1/coreutils/stat.c ++++ busybox-1.10.1/coreutils/stat.c +@@ -14,12 +14,14 @@ + */ + + #include "libbb.h" ++#include + + /* vars to control behavior */ + #define OPT_FILESYS (1 << 0) + #define OPT_TERSE (1 << 1) + #define OPT_DEREFERENCE (1 << 2) +-#define OPT_SELINUX (1 << 3) ++#define OPT_MAP (1 << 3) ++#define OPT_SELINUX (1 << 4) + + #if ENABLE_FEATURE_STAT_FORMAT + typedef bool (*statfunc_ptr)(const char *, const char *); +@@ -345,6 +347,26 @@ + + /* Stat the file system and print what we find. */ + #if !ENABLE_FEATURE_STAT_FORMAT ++#define do_mapfile(filename, format) do_mapfile(filename) ++#endif ++static bool do_mapfile(const char *filename, const char *format) ++{ ++ int i = 0; ++ int fd = xopen(filename, O_RDONLY); ++ ++#if ENABLE_FEATURE_STAT_FORMAT ++ (void) format; ++#endif ++ while (1) { ++ int blk = i++; ++ if (ioctl(fd,FIBMAP,&blk) < 0 || blk == 0) break; ++ printf("%u\n",blk); ++ } ++ return 1; ++} ++ ++/* Stat the file system and print what we find. */ ++#if !ENABLE_FEATURE_STAT_FORMAT + #define do_statfs(filename, format) do_statfs(filename) + #endif + static bool do_statfs(const char *filename, const char *format) +@@ -632,13 +654,15 @@ + int ok = 1; + statfunc_ptr statfunc = do_stat; + +- getopt32(argv, "ftL" ++ getopt32(argv, "ftLm" + USE_SELINUX("Z") + USE_FEATURE_STAT_FORMAT("c:", &format) + ); + + if (option_mask32 & OPT_FILESYS) /* -f */ + statfunc = do_statfs; ++ if (option_mask32 & OPT_MAP) /* -m */ ++ statfunc = do_mapfile; + if (argc == optind) /* files */ + bb_show_usage(); + + +--- busybox-1.10.1/include/usage.h ++++ busybox-1.10.1/include/usage.h +@@ -3585,6 +3585,7 @@ + ) \ + "\n -f Display filesystem status" \ + "\n -L Dereference links" \ ++ "\n -m Display block list" \ + "\n -t Display info in terse form" \ + USE_SELINUX( \ + "\n -Z Print security context" \