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