wok-next annotate busybox/stuff/busybox-1.12.0-stat.u @ rev 4953

UP ntfs-3g and ntfs-3g-dev
author Rohit Joshi <jozee@slitaz.org>
date Wed Feb 17 09:45:16 2010 +0000 (2010-02-17)
parents
children
rev   line source
pascal@1299 1 Add stat -m
pascal@1299 2 --- busybox-1.12.0/coreutils/stat.c
pascal@1299 3 +++ busybox-1.12.0/coreutils/stat.c
pascal@1299 4 @@ -14,12 +14,14 @@
pascal@1299 5 */
pascal@1299 6
pascal@1299 7 #include "libbb.h"
pascal@1299 8 +#include <linux/fs.h>
pascal@1299 9
pascal@1299 10 /* vars to control behavior */
pascal@1299 11 #define OPT_FILESYS (1 << 0)
pascal@1299 12 #define OPT_TERSE (1 << 1)
pascal@1299 13 #define OPT_DEREFERENCE (1 << 2)
pascal@1299 14 -#define OPT_SELINUX (1 << 3)
pascal@1299 15 +#define OPT_MAP (1 << 3)
pascal@1299 16 +#define OPT_SELINUX (1 << 4)
pascal@1299 17
pascal@1299 18 #if ENABLE_FEATURE_STAT_FORMAT
pascal@1299 19 typedef bool (*statfunc_ptr)(const char *, const char *);
pascal@1299 20 @@ -345,6 +347,26 @@ static void print_it(const char *masterf
pascal@1299 21
pascal@1299 22 /* Stat the file system and print what we find. */
pascal@1299 23 #if !ENABLE_FEATURE_STAT_FORMAT
pascal@1299 24 +#define do_mapfile(filename, format) do_mapfile(filename)
pascal@1299 25 +#endif
pascal@1299 26 +static bool do_mapfile(const char *filename, const char *format)
pascal@1299 27 +{
pascal@1299 28 + int i = 0;
pascal@1299 29 + int fd = xopen(filename, O_RDONLY);
pascal@1299 30 +
pascal@1299 31 +#if ENABLE_FEATURE_STAT_FORMAT
pascal@1299 32 + (void) format;
pascal@1299 33 +#endif
pascal@1299 34 + while (1) {
pascal@1299 35 + int blk = i++;
pascal@1299 36 + if (ioctl(fd,FIBMAP,&blk) < 0 || blk == 0) break;
pascal@1299 37 + printf("%u\n",blk);
pascal@1299 38 + }
pascal@1299 39 + return 1;
pascal@1299 40 +}
pascal@1299 41 +
pascal@1299 42 +/* Stat the file system and print what we find. */
pascal@1299 43 +#if !ENABLE_FEATURE_STAT_FORMAT
pascal@1299 44 #define do_statfs(filename, format) do_statfs(filename)
pascal@1299 45 #endif
pascal@1299 46 static bool do_statfs(const char *filename, const char *format)
pascal@1299 47 @@ -632,13 +654,15 @@ int stat_main(int argc, char **argv)
pascal@1299 48 int ok = 1;
pascal@1299 49 statfunc_ptr statfunc = do_stat;
pascal@1299 50
pascal@1299 51 - getopt32(argv, "ftL"
pascal@1299 52 + getopt32(argv, "ftLm"
pascal@1299 53 USE_SELINUX("Z")
pascal@1299 54 USE_FEATURE_STAT_FORMAT("c:", &format)
pascal@1299 55 );
pascal@1299 56
pascal@1299 57 if (option_mask32 & OPT_FILESYS) /* -f */
pascal@1299 58 statfunc = do_statfs;
pascal@1299 59 + if (option_mask32 & OPT_MAP) /* -m */
pascal@1299 60 + statfunc = do_mapfile;
pascal@1299 61 if (argc == optind) /* files */
pascal@1299 62 bb_show_usage();
pascal@1299 63
pascal@1299 64
pascal@1299 65 --- busybox-1.12.0/include/usage.h
pascal@1299 66 +++ busybox-1.12.0/include/usage.h
pascal@1299 67 @@ -3746,6 +3746,7 @@
pascal@1299 68 ) \
pascal@1299 69 "\n -f Display filesystem status" \
pascal@1299 70 "\n -L Dereference links" \
pascal@1299 71 + "\n -m Display block list" \
pascal@1299 72 "\n -t Display info in terse form" \
pascal@1299 73 USE_SELINUX( \
pascal@1299 74 "\n -Z Print security context" \