wok-6.x annotate busybox/stuff/busybox-1.30-stat.u @ rev 23353

updated perl-io-socket-ssl (2.060 -> 2.068)
author Hans-G?nter Theisgen
date Tue Mar 31 09:53:02 2020 +0100 (2020-03-31)
parents
children
rev   line source
pascal@20652 1 Add non standard stat -m support to display file block list
pascal@20652 2 Useful to patch read-only filesystems such as ISO9660, for defragmentation
pascal@20652 3 tools or boot loaders
pascal@20652 4 --- busybox-1.30/coreutils/stat.c
pascal@20652 5 +++ busybox-1.30/coreutils/stat.c
pascal@20652 6 @@ -54,6 +54,7 @@
pascal@20652 7 //usage: )
pascal@20652 8 //usage: "\n -L Follow links"
pascal@20652 9 //usage: "\n -t Terse display"
pascal@20652 10 +//usage: "\n -m Display block list"
pascal@20652 11 //usage: IF_SELINUX(
pascal@20652 12 //usage: "\n -Z Print security context"
pascal@20652 13 //usage: )
pascal@20652 14 @@ -106,13 +107,15 @@
pascal@20652 15 //usage: )
pascal@20652 16
pascal@20652 17 #include "libbb.h"
pascal@20652 18 +#include <linux/fs.h>
pascal@20652 19 #include "common_bufsiz.h"
pascal@20652 20
pascal@20652 21 enum {
pascal@20652 22 OPT_TERSE = (1 << 0),
pascal@20652 23 OPT_DEREFERENCE = (1 << 1),
pascal@20652 24 - OPT_FILESYS = (1 << 2) * ENABLE_FEATURE_STAT_FILESYSTEM,
pascal@20652 25 - OPT_SELINUX = (1 << (2+ENABLE_FEATURE_STAT_FILESYSTEM)) * ENABLE_SELINUX,
pascal@20652 26 + OPT_MAP = (1 << 2),
pascal@20652 27 + OPT_FILESYS = (1 << 3) * ENABLE_FEATURE_STAT_FILESYSTEM,
pascal@20652 28 + OPT_SELINUX = (1 << (3+ENABLE_FEATURE_STAT_FILESYSTEM)) * ENABLE_SELINUX,
pascal@20652 29 };
pascal@20652 30
pascal@20652 31 #if ENABLE_FEATURE_STAT_FORMAT
pascal@20652 32 @@ -463,6 +466,25 @@
pascal@20652 33 }
pascal@20652 34 #endif /* FEATURE_STAT_FORMAT */
pascal@20652 35
pascal@20652 36 +#if !ENABLE_FEATURE_STAT_FORMAT
pascal@20652 37 +#define do_mapfile(filename, format) do_mapfile(filename)
pascal@20652 38 +#endif
pascal@20652 39 +static bool do_mapfile(const char *filename, const char *format)
pascal@20652 40 +{
pascal@20652 41 + int i = 0;
pascal@20652 42 + int fd = xopen(filename, O_RDONLY);
pascal@20652 43 +
pascal@20652 44 +#if ENABLE_FEATURE_STAT_FORMAT
pascal@20652 45 + (void) format;
pascal@20652 46 +#endif
pascal@20652 47 + while (1) {
pascal@20652 48 + int blk = i++;
pascal@20652 49 + if (ioctl(fd,FIBMAP,&blk) < 0 || blk == 0) break;
pascal@20652 50 + printf("%u\n",blk);
pascal@20652 51 + }
pascal@20652 52 + return 1;
pascal@20652 53 +}
pascal@20652 54 +
pascal@20652 55 #if ENABLE_FEATURE_STAT_FILESYSTEM
pascal@20652 56 /* Stat the file system and print what we find. */
pascal@20652 57 #if !ENABLE_FEATURE_STAT_FORMAT
pascal@20652 58 @@ -766,7 +788,7 @@
pascal@20652 59 opts =
pascal@20652 60 #endif
pascal@20652 61 getopt32(argv, "^"
pascal@20652 62 - "tL"
pascal@20652 63 + "tLm"
pascal@20652 64 IF_FEATURE_STAT_FILESYSTEM("f")
pascal@20652 65 IF_SELINUX("Z")
pascal@20652 66 IF_FEATURE_STAT_FORMAT("c:")
pascal@20652 67 @@ -782,6 +804,11 @@
pascal@20652 68 selinux_or_die();
pascal@20652 69 }
pascal@20652 70 #endif
pascal@20652 71 +#if ENABLE_FEATURE_STAT_FILESYSTEM
pascal@20652 72 + if (opts & OPT_MAP) { /* -m */
pascal@20652 73 + statfunc = do_mapfile;
pascal@20652 74 + }
pascal@20652 75 +#endif
pascal@20652 76 ok = 1;
pascal@20652 77 argv += optind;
pascal@20652 78 for (i = 0; argv[i]; ++i)