wok-current rev 857
busybox: add stat -m
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Mon May 26 11:22:59 2008 +0000 (2008-05-26) |
parents | 6b8edbd9af7e |
children | 4b14537dc5b5 |
files | busybox/receipt busybox/stuff/busybox-1.10.1-stat.u |
line diff
1.1 --- a/busybox/receipt Sat May 24 12:45:54 2008 +0000 1.2 +++ b/busybox/receipt Mon May 26 11:22:59 2008 +0000 1.3 @@ -30,6 +30,7 @@ 1.4 $PACKAGE-$VERSION-script.u 1.5 $PACKAGE-$VERSION-header_tar.u 1.6 $PACKAGE-$VERSION-fixes-$VERSION.u 1.7 +$PACKAGE-$VERSION-stat.u 1.8 EOT 1.9 cp ../stuff/$PACKAGE-$VERSION.config .config 1.10 make oldconfig
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/busybox/stuff/busybox-1.10.1-stat.u Mon May 26 11:22:59 2008 +0000 2.3 @@ -0,0 +1,73 @@ 2.4 +--- busybox-1.10.1/coreutils/stat.c 2.5 ++++ busybox-1.10.1/coreutils/stat.c 2.6 +@@ -14,12 +14,14 @@ 2.7 + */ 2.8 + 2.9 + #include "libbb.h" 2.10 ++#include <linux/fs.h> 2.11 + 2.12 + /* vars to control behavior */ 2.13 + #define OPT_FILESYS (1 << 0) 2.14 + #define OPT_TERSE (1 << 1) 2.15 + #define OPT_DEREFERENCE (1 << 2) 2.16 +-#define OPT_SELINUX (1 << 3) 2.17 ++#define OPT_MAP (1 << 3) 2.18 ++#define OPT_SELINUX (1 << 4) 2.19 + 2.20 + #if ENABLE_FEATURE_STAT_FORMAT 2.21 + typedef bool (*statfunc_ptr)(const char *, const char *); 2.22 +@@ -345,6 +347,26 @@ 2.23 + 2.24 + /* Stat the file system and print what we find. */ 2.25 + #if !ENABLE_FEATURE_STAT_FORMAT 2.26 ++#define do_mapfile(filename, format) do_mapfile(filename) 2.27 ++#endif 2.28 ++static bool do_mapfile(const char *filename, const char *format) 2.29 ++{ 2.30 ++ int i = 0; 2.31 ++ int fd = xopen(filename, O_RDONLY); 2.32 ++ 2.33 ++#if ENABLE_FEATURE_STAT_FORMAT 2.34 ++ (void) format; 2.35 ++#endif 2.36 ++ while (1) { 2.37 ++ int blk = i++; 2.38 ++ if (ioctl(fd,FIBMAP,&blk) < 0 || blk == 0) break; 2.39 ++ printf("%u\n",blk); 2.40 ++ } 2.41 ++ return 1; 2.42 ++} 2.43 ++ 2.44 ++/* Stat the file system and print what we find. */ 2.45 ++#if !ENABLE_FEATURE_STAT_FORMAT 2.46 + #define do_statfs(filename, format) do_statfs(filename) 2.47 + #endif 2.48 + static bool do_statfs(const char *filename, const char *format) 2.49 +@@ -632,13 +654,15 @@ 2.50 + int ok = 1; 2.51 + statfunc_ptr statfunc = do_stat; 2.52 + 2.53 +- getopt32(argv, "ftL" 2.54 ++ getopt32(argv, "ftLm" 2.55 + USE_SELINUX("Z") 2.56 + USE_FEATURE_STAT_FORMAT("c:", &format) 2.57 + ); 2.58 + 2.59 + if (option_mask32 & OPT_FILESYS) /* -f */ 2.60 + statfunc = do_statfs; 2.61 ++ if (option_mask32 & OPT_MAP) /* -m */ 2.62 ++ statfunc = do_mapfile; 2.63 + if (argc == optind) /* files */ 2.64 + bb_show_usage(); 2.65 + 2.66 + 2.67 +--- busybox-1.10.1/include/usage.h 2.68 ++++ busybox-1.10.1/include/usage.h 2.69 +@@ -3585,6 +3585,7 @@ 2.70 + ) \ 2.71 + "\n -f Display filesystem status" \ 2.72 + "\n -L Dereference links" \ 2.73 ++ "\n -m Display block list" \ 2.74 + "\n -t Display info in terse form" \ 2.75 + USE_SELINUX( \ 2.76 + "\n -Z Print security context" \