wok-4.x view busybox/stuff/busybox-1.17.1-stat.u @ rev 6319
Added libproxy and libproxy-dev to build_depends. libproxy is also need to run subversion so its in depends too.
author | Christopher Rogers <slaxemulator@gmail.com> |
---|---|
date | Fri Sep 17 04:44:53 2010 +0000 (2010-09-17) |
parents | b5f4ef5d86ec |
children |
line source
1 Add non standard stat -m support to display file block list
2 Useful to patch read-only filesystems such as ISO9660 or fragmentation checking
3 --- busybox-1.17.1/include/usage.src.h
4 +++ busybox-1.17.1/include/usage.src.h
5 @@ -3979,6 +3979,7 @@
6 "\n -f Display filesystem status" \
7 "\n -L Follow links" \
8 "\n -t Display info in terse form" \
9 + "\n -m Display block list" \
10 IF_SELINUX( \
11 "\n -Z Print security context" \
12 ) \
14 --- busybox-1.17.1/coreutils/stat.c
15 +++ busybox-1.17.1/coreutils/stat.c
16 @@ -13,11 +13,13 @@
17 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
18 */
19 #include "libbb.h"
20 +#include <linux/fs.h>
22 #define OPT_FILESYS (1 << 0)
23 #define OPT_TERSE (1 << 1)
24 #define OPT_DEREFERENCE (1 << 2)
25 -#define OPT_SELINUX (1 << 3)
26 +#define OPT_MAP (1 << 3)
27 +#define OPT_SELINUX (1 << 4)
29 #if ENABLE_FEATURE_STAT_FORMAT
30 typedef bool (*statfunc_ptr)(const char *, const char *);
31 @@ -361,6 +363,26 @@
33 /* Stat the file system and print what we find. */
34 #if !ENABLE_FEATURE_STAT_FORMAT
35 +#define do_mapfile(filename, format) do_mapfile(filename)
36 +#endif
37 +static bool do_mapfile(const char *filename, const char *format)
38 +{
39 + int i = 0;
40 + int fd = xopen(filename, O_RDONLY);
41 +
42 +#if ENABLE_FEATURE_STAT_FORMAT
43 + (void) format;
44 +#endif
45 + while (1) {
46 + int blk = i++;
47 + if (ioctl(fd,FIBMAP,&blk) < 0 || blk == 0) break;
48 + printf("%u\n",blk);
49 + }
50 + return 1;
51 +}
52 +
53 +/* Stat the file system and print what we find. */
54 +#if !ENABLE_FEATURE_STAT_FORMAT
55 #define do_statfs(filename, format) do_statfs(filename)
56 #endif
57 static bool do_statfs(const char *filename, const char *format)
58 @@ -651,7 +673,7 @@
59 statfunc_ptr statfunc = do_stat;
61 opt_complementary = "-1"; /* min one arg */
62 - opts = getopt32(argv, "ftL"
63 + opts = getopt32(argv, "ftLm"
64 IF_SELINUX("Z")
65 IF_FEATURE_STAT_FORMAT("c:", &format)
66 );
67 @@ -662,6 +684,9 @@
68 selinux_or_die();
69 }
70 #endif
71 + if (opts & OPT_MAP) { /* -m */
72 + statfunc = do_mapfile;
73 + }
74 ok = 1;
75 argv += optind;
76 for (i = 0; argv[i]; ++i)