wok view busybox/stuff/busybox-1.17.0-stat.u @ rev 5773

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