wok-4.x diff busybox/stuff/busybox-1.18-stat.u @ rev 9667

openerp-web: fix depends
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon May 02 15:56:46 2011 +0200 (2011-05-02)
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/busybox/stuff/busybox-1.18-stat.u	Mon May 02 15:56:46 2011 +0200
     1.3 @@ -0,0 +1,77 @@
     1.4 +Add non standard stat -m support to display file block list
     1.5 +Useful to patch read-only filesystems such as ISO9660, for defragmentation
     1.6 +tools or boot loaders
     1.7 +--- busybox-1.18.0/include/usage.src.h
     1.8 ++++ busybox-1.18.0/include/usage.src.h
     1.9 +@@ -3654,6 +3654,7 @@
    1.10 +      "\n	-f	Display filesystem status" \
    1.11 +      "\n	-L	Follow links" \
    1.12 +      "\n	-t	Display info in terse form" \
    1.13 ++     "\n	-m	Display block list" \
    1.14 + 	IF_SELINUX( \
    1.15 +      "\n	-Z	Print security context" \
    1.16 + 	) \
    1.17 +
    1.18 +--- busybox-1.17.1/coreutils/stat.c
    1.19 ++++ busybox-1.17.1/coreutils/stat.c
    1.20 +@@ -13,11 +13,13 @@
    1.21 +  * Licensed under GPLv2 or later, see file LICENSE in this source tree.
    1.22 +  */
    1.23 + #include "libbb.h"
    1.24 ++#include <linux/fs.h>
    1.25 + 
    1.26 + #define OPT_FILESYS     (1 << 0)
    1.27 + #define OPT_TERSE       (1 << 1)
    1.28 + #define OPT_DEREFERENCE (1 << 2)
    1.29 +-#define OPT_SELINUX     (1 << 3)
    1.30 ++#define OPT_MAP         (1 << 3)
    1.31 ++#define OPT_SELINUX     (1 << 4)
    1.32 + 
    1.33 + #if ENABLE_FEATURE_STAT_FORMAT
    1.34 + typedef bool (*statfunc_ptr)(const char *, const char *);
    1.35 +@@ -359,6 +361,26 @@
    1.36 + 
    1.37 + /* Stat the file system and print what we find.  */
    1.38 + #if !ENABLE_FEATURE_STAT_FORMAT
    1.39 ++#define do_mapfile(filename, format) do_mapfile(filename)
    1.40 ++#endif
    1.41 ++static bool do_mapfile(const char *filename, const char *format)
    1.42 ++{
    1.43 ++	int i = 0;
    1.44 ++	int fd = xopen(filename, O_RDONLY);
    1.45 ++
    1.46 ++#if ENABLE_FEATURE_STAT_FORMAT
    1.47 ++	(void) format;
    1.48 ++#endif
    1.49 ++	while (1) {
    1.50 ++		int blk = i++;
    1.51 ++		if (ioctl(fd,FIBMAP,&blk) < 0 || blk == 0) break;
    1.52 ++		printf("%u\n",blk);
    1.53 ++	}	
    1.54 ++	return 1;
    1.55 ++}
    1.56 ++
    1.57 ++/* Stat the file system and print what we find.  */
    1.58 ++#if !ENABLE_FEATURE_STAT_FORMAT
    1.59 + #define do_statfs(filename, format) do_statfs(filename)
    1.60 + #endif
    1.61 + static bool do_statfs(const char *filename, const char *format)
    1.62 +@@ -648,7 +670,7 @@
    1.63 + 	statfunc_ptr statfunc = do_stat;
    1.64 + 
    1.65 + 	opt_complementary = "-1"; /* min one arg */
    1.66 +-	opts = getopt32(argv, "ftL"
    1.67 ++	opts = getopt32(argv, "ftLm"
    1.68 + 		IF_SELINUX("Z")
    1.69 + 		IF_FEATURE_STAT_FORMAT("c:", &format)
    1.70 + 	);
    1.71 +@@ -659,6 +681,9 @@
    1.72 + 		selinux_or_die();
    1.73 + 	}
    1.74 + #endif
    1.75 ++ 	if (opts & OPT_MAP) { /* -m */
    1.76 ++ 		statfunc = do_mapfile;
    1.77 ++	}
    1.78 + 	ok = 1;
    1.79 + 	argv += optind;
    1.80 + 	for (i = 0; argv[i]; ++i)