wok view busybox/stuff/busybox-1.16.1-stat.u @ rev 5684

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