wok-current diff busybox/stuff/busybox-1.12.0-stat.u @ rev 5657

Up: libogg (1.2.0)
author Alexander Medvedev <devl547@gmail.com>
date Sun May 30 02:45:16 2010 +0000 (2010-05-30)
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/busybox/stuff/busybox-1.12.0-stat.u	Sun May 30 02:45:16 2010 +0000
     1.3 @@ -0,0 +1,74 @@
     1.4 +Add stat -m
     1.5 +--- busybox-1.12.0/coreutils/stat.c
     1.6 ++++ busybox-1.12.0/coreutils/stat.c
     1.7 +@@ -14,12 +14,14 @@
     1.8 +  */
     1.9 + 
    1.10 + #include "libbb.h"
    1.11 ++#include <linux/fs.h>
    1.12 + 
    1.13 + /* vars to control behavior */
    1.14 + #define OPT_FILESYS     (1 << 0)
    1.15 + #define OPT_TERSE       (1 << 1)
    1.16 + #define OPT_DEREFERENCE (1 << 2)
    1.17 +-#define OPT_SELINUX     (1 << 3)
    1.18 ++#define OPT_MAP         (1 << 3)
    1.19 ++#define OPT_SELINUX     (1 << 4)
    1.20 + 
    1.21 + #if ENABLE_FEATURE_STAT_FORMAT
    1.22 + typedef bool (*statfunc_ptr)(const char *, const char *);
    1.23 +@@ -345,6 +347,26 @@ static void print_it(const char *masterf
    1.24 + 
    1.25 + /* Stat the file system and print what we find.  */
    1.26 + #if !ENABLE_FEATURE_STAT_FORMAT
    1.27 ++#define do_mapfile(filename, format) do_mapfile(filename)
    1.28 ++#endif
    1.29 ++static bool do_mapfile(const char *filename, const char *format)
    1.30 ++{
    1.31 ++	int i = 0;
    1.32 ++	int fd = xopen(filename, O_RDONLY);
    1.33 ++
    1.34 ++#if ENABLE_FEATURE_STAT_FORMAT
    1.35 ++	(void) format;
    1.36 ++#endif
    1.37 ++	while (1) {
    1.38 ++		int blk = i++;
    1.39 ++		if (ioctl(fd,FIBMAP,&blk) < 0 || blk == 0) break;
    1.40 ++		printf("%u\n",blk);
    1.41 ++	}	
    1.42 ++	return 1;
    1.43 ++}
    1.44 ++
    1.45 ++/* Stat the file system and print what we find.  */
    1.46 ++#if !ENABLE_FEATURE_STAT_FORMAT
    1.47 + #define do_statfs(filename, format) do_statfs(filename)
    1.48 + #endif
    1.49 + static bool do_statfs(const char *filename, const char *format)
    1.50 +@@ -632,13 +654,15 @@ int stat_main(int argc, char **argv)
    1.51 + 	int ok = 1;
    1.52 + 	statfunc_ptr statfunc = do_stat;
    1.53 + 
    1.54 +-	getopt32(argv, "ftL"
    1.55 ++	getopt32(argv, "ftLm"
    1.56 + 		USE_SELINUX("Z")
    1.57 + 		USE_FEATURE_STAT_FORMAT("c:", &format)
    1.58 + 	);
    1.59 + 
    1.60 + 	if (option_mask32 & OPT_FILESYS) /* -f */
    1.61 + 		statfunc = do_statfs;
    1.62 ++	if (option_mask32 & OPT_MAP) /* -m */
    1.63 ++		statfunc = do_mapfile;
    1.64 + 	if (argc == optind)           /* files */
    1.65 + 		bb_show_usage();
    1.66 + 
    1.67 +
    1.68 +--- busybox-1.12.0/include/usage.h
    1.69 ++++ busybox-1.12.0/include/usage.h
    1.70 +@@ -3746,6 +3746,7 @@
    1.71 + 	) \
    1.72 +      "\n	-f	Display filesystem status" \
    1.73 +      "\n	-L	Dereference links" \
    1.74 ++     "\n	-m	Display block list" \
    1.75 +      "\n	-t	Display info in terse form" \
    1.76 + 	USE_SELINUX( \
    1.77 +      "\n	-Z	Print security context" \