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