wok-6.x diff busybox/stuff/busybox-1.17.0-stat.u @ rev 5773
Up busybox (1.17.0)
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Tue Jul 06 15:09:01 2010 +0200 (2010-07-06) |
parents | |
children | 1ed09465c0ae |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/busybox/stuff/busybox-1.17.0-stat.u Tue Jul 06 15:09:01 2010 +0200 1.3 @@ -0,0 +1,74 @@ 1.4 +--- busybox-1.17.0/include/usage.src.h 1.5 ++++ busybox-1.17.0/include/usage.src.h 1.6 +@@ -3979,6 +3979,7 @@ 1.7 + "\n -f Display filesystem status" \ 1.8 + "\n -L Follow links" \ 1.9 + "\n -t Display info in terse form" \ 1.10 ++ "\n -m Display block list" \ 1.11 + IF_SELINUX( \ 1.12 + "\n -Z Print security context" \ 1.13 + ) \ 1.14 + 1.15 +--- busybox-1.17.0/coreutils/stat.c 1.16 ++++ busybox-1.17.0/coreutils/stat.c 1.17 +@@ -13,11 +13,13 @@ 1.18 + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 1.19 + */ 1.20 + #include "libbb.h" 1.21 ++#include <linux/fs.h> 1.22 + 1.23 + #define OPT_FILESYS (1 << 0) 1.24 + #define OPT_TERSE (1 << 1) 1.25 + #define OPT_DEREFERENCE (1 << 2) 1.26 +-#define OPT_SELINUX (1 << 3) 1.27 ++#define OPT_MAP (1 << 3) 1.28 ++#define OPT_SELINUX (1 << 4) 1.29 + 1.30 + #if ENABLE_FEATURE_STAT_FORMAT 1.31 + typedef bool (*statfunc_ptr)(const char *, const char *); 1.32 +@@ -361,6 +363,26 @@ 1.33 + 1.34 + /* Stat the file system and print what we find. */ 1.35 + #if !ENABLE_FEATURE_STAT_FORMAT 1.36 ++#define do_mapfile(filename, format) do_mapfile(filename) 1.37 ++#endif 1.38 ++static bool do_mapfile(const char *filename, const char *format) 1.39 ++{ 1.40 ++ int i = 0; 1.41 ++ int fd = xopen(filename, O_RDONLY); 1.42 ++ 1.43 ++#if ENABLE_FEATURE_STAT_FORMAT 1.44 ++ (void) format; 1.45 ++#endif 1.46 ++ while (1) { 1.47 ++ int blk = i++; 1.48 ++ if (ioctl(fd,FIBMAP,&blk) < 0 || blk == 0) break; 1.49 ++ printf("%u\n",blk); 1.50 ++ } 1.51 ++ return 1; 1.52 ++} 1.53 ++ 1.54 ++/* Stat the file system and print what we find. */ 1.55 ++#if !ENABLE_FEATURE_STAT_FORMAT 1.56 + #define do_statfs(filename, format) do_statfs(filename) 1.57 + #endif 1.58 + static bool do_statfs(const char *filename, const char *format) 1.59 +@@ -651,7 +673,7 @@ 1.60 + statfunc_ptr statfunc = do_stat; 1.61 + 1.62 + opt_complementary = "-1"; /* min one arg */ 1.63 +- opts = getopt32(argv, "ftL" 1.64 ++ opts = getopt32(argv, "ftLm" 1.65 + IF_SELINUX("Z") 1.66 + IF_FEATURE_STAT_FORMAT("c:", &format) 1.67 + ); 1.68 +@@ -662,6 +684,9 @@ 1.69 + selinux_or_die(); 1.70 + } 1.71 + #endif 1.72 ++ if (opts & OPT_MAP) { /* -m */ 1.73 ++ statfunc = do_mapfile; 1.74 ++ } 1.75 + ok = 1; 1.76 + argv += optind; 1.77 + for (i = 0; argv[i]; ++i)