wok diff busybox/stuff/busybox-1.32-stat.u @ rev 25002
updated nrg2iso (0.4 -> 0.4.1)
author | Hans-G?nter Theisgen |
---|---|
date | Mon May 16 14:45:30 2022 +0100 (2022-05-16) |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/busybox/stuff/busybox-1.32-stat.u Mon May 16 14:45:30 2022 +0100 1.3 @@ -0,0 +1,78 @@ 1.4 +Add non standard stat -m support to display file block list 1.5 +Useful to patch read-only filesystems such as ISO9660, for defragmentation 1.6 +tools or boot loaders 1.7 +--- busybox-1.32/coreutils/stat.c 1.8 ++++ busybox-1.32/coreutils/stat.c 1.9 +@@ -54,6 +54,7 @@ 1.10 + //usage: ) 1.11 + //usage: "\n -L Follow links" 1.12 + //usage: "\n -t Terse display" 1.13 ++//usage: "\n -m Display block list" 1.14 + //usage: IF_SELINUX( 1.15 + //usage: "\n -Z Print security context" 1.16 + //usage: ) 1.17 +@@ -106,13 +107,15 @@ 1.18 + //usage: ) 1.19 + 1.20 + #include "libbb.h" 1.21 ++#include <linux/fs.h> 1.22 + #include "common_bufsiz.h" 1.23 + 1.24 + enum { 1.25 + OPT_TERSE = (1 << 0), 1.26 + OPT_DEREFERENCE = (1 << 1), 1.27 +- OPT_FILESYS = (1 << 2) * ENABLE_FEATURE_STAT_FILESYSTEM, 1.28 +- OPT_SELINUX = (1 << (2+ENABLE_FEATURE_STAT_FILESYSTEM)) * ENABLE_SELINUX, 1.29 ++ OPT_MAP = (1 << 2), 1.30 ++ OPT_FILESYS = (1 << 3) * ENABLE_FEATURE_STAT_FILESYSTEM, 1.31 ++ OPT_SELINUX = (1 << (3+ENABLE_FEATURE_STAT_FILESYSTEM)) * ENABLE_SELINUX, 1.32 + }; 1.33 + 1.34 + #if ENABLE_FEATURE_STAT_FORMAT 1.35 +@@ -463,6 +466,25 @@ 1.36 + } 1.37 + #endif /* FEATURE_STAT_FORMAT */ 1.38 + 1.39 ++#if !ENABLE_FEATURE_STAT_FORMAT 1.40 ++#define do_mapfile(filename, format) do_mapfile(filename) 1.41 ++#endif 1.42 ++static bool do_mapfile(const char *filename, const char *format) 1.43 ++{ 1.44 ++ int i = 0; 1.45 ++ int fd = xopen(filename, O_RDONLY); 1.46 ++ 1.47 ++#if ENABLE_FEATURE_STAT_FORMAT 1.48 ++ (void) format; 1.49 ++#endif 1.50 ++ while (1) { 1.51 ++ int blk = i++; 1.52 ++ if (ioctl(fd,FIBMAP,&blk) < 0 || blk == 0) break; 1.53 ++ printf("%u\n",blk); 1.54 ++ } 1.55 ++ return 1; 1.56 ++} 1.57 ++ 1.58 + #if ENABLE_FEATURE_STAT_FILESYSTEM 1.59 + /* Stat the file system and print what we find. */ 1.60 + #if !ENABLE_FEATURE_STAT_FORMAT 1.61 +@@ -767,7 +789,7 @@ 1.62 + opts = 1.63 + #endif 1.64 + getopt32(argv, "^" 1.65 +- "tL" 1.66 ++ "tLm" 1.67 + IF_FEATURE_STAT_FILESYSTEM("f") 1.68 + IF_SELINUX("Z") 1.69 + IF_FEATURE_STAT_FORMAT("c:") 1.70 +@@ -783,6 +805,11 @@ 1.71 + selinux_or_die(); 1.72 + } 1.73 + #endif 1.74 ++#if ENABLE_FEATURE_STAT_FILESYSTEM 1.75 ++ if (opts & OPT_MAP) { /* -m */ 1.76 ++ statfunc = do_mapfile; 1.77 ++ } 1.78 ++#endif 1.79 + ok = 1; 1.80 + argv += optind; 1.81 + for (i = 0; argv[i]; ++i)