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