diff options
-rw-r--r-- | configs/mingw32_defconfig | 8 | ||||
-rw-r--r-- | coreutils/Config.src | 10 | ||||
-rw-r--r-- | coreutils/stat.c | 23 |
3 files changed, 36 insertions, 5 deletions
diff --git a/configs/mingw32_defconfig b/configs/mingw32_defconfig index 28c8a0f65..af4b667e2 100644 --- a/configs/mingw32_defconfig +++ b/configs/mingw32_defconfig | |||
@@ -1,7 +1,7 @@ | |||
1 | # | 1 | # |
2 | # Automatically generated make config: don't edit | 2 | # Automatically generated make config: don't edit |
3 | # Busybox version: 1.21.0.git | 3 | # Busybox version: 1.21.0.git |
4 | # Tue Jun 26 13:14:48 2012 | 4 | # Tue Oct 9 15:33:27 2012 |
5 | # | 5 | # |
6 | CONFIG_HAVE_DOT_CONFIG=y | 6 | CONFIG_HAVE_DOT_CONFIG=y |
7 | # CONFIG_PLATFORM_POSIX is not set | 7 | # CONFIG_PLATFORM_POSIX is not set |
@@ -273,8 +273,9 @@ CONFIG_SORT=y | |||
273 | CONFIG_FEATURE_SORT_BIG=y | 273 | CONFIG_FEATURE_SORT_BIG=y |
274 | CONFIG_SPLIT=y | 274 | CONFIG_SPLIT=y |
275 | CONFIG_FEATURE_SPLIT_FANCY=y | 275 | CONFIG_FEATURE_SPLIT_FANCY=y |
276 | # CONFIG_STAT is not set | 276 | CONFIG_STAT=y |
277 | # CONFIG_FEATURE_STAT_FORMAT is not set | 277 | CONFIG_FEATURE_STAT_FORMAT=y |
278 | # CONFIG_FEATURE_STAT_FILESYSTEM is not set | ||
278 | # CONFIG_STTY is not set | 279 | # CONFIG_STTY is not set |
279 | CONFIG_SUM=y | 280 | CONFIG_SUM=y |
280 | # CONFIG_SYNC is not set | 281 | # CONFIG_SYNC is not set |
@@ -609,6 +610,7 @@ CONFIG_HD=y | |||
609 | # CONFIG_FEATURE_VOLUMEID_HFS is not set | 610 | # CONFIG_FEATURE_VOLUMEID_HFS is not set |
610 | # CONFIG_FEATURE_VOLUMEID_JFS is not set | 611 | # CONFIG_FEATURE_VOLUMEID_JFS is not set |
611 | # CONFIG_FEATURE_VOLUMEID_XFS is not set | 612 | # CONFIG_FEATURE_VOLUMEID_XFS is not set |
613 | # CONFIG_FEATURE_VOLUMEID_NILFS is not set | ||
612 | # CONFIG_FEATURE_VOLUMEID_NTFS is not set | 614 | # CONFIG_FEATURE_VOLUMEID_NTFS is not set |
613 | # CONFIG_FEATURE_VOLUMEID_ISO9660 is not set | 615 | # CONFIG_FEATURE_VOLUMEID_ISO9660 is not set |
614 | # CONFIG_FEATURE_VOLUMEID_UDF is not set | 616 | # CONFIG_FEATURE_VOLUMEID_UDF is not set |
diff --git a/coreutils/Config.src b/coreutils/Config.src index 81be71993..2ca71521f 100644 --- a/coreutils/Config.src +++ b/coreutils/Config.src | |||
@@ -581,7 +581,6 @@ config FEATURE_SPLIT_FANCY | |||
581 | config STAT | 581 | config STAT |
582 | bool "stat" | 582 | bool "stat" |
583 | default y | 583 | default y |
584 | select PLATFORM_LINUX # statfs() | ||
585 | help | 584 | help |
586 | display file or filesystem status. | 585 | display file or filesystem status. |
587 | 586 | ||
@@ -594,6 +593,15 @@ config FEATURE_STAT_FORMAT | |||
594 | users can pass a custom format string for output. This adds about | 593 | users can pass a custom format string for output. This adds about |
595 | 7k to a nonstatic build on amd64. | 594 | 7k to a nonstatic build on amd64. |
596 | 595 | ||
596 | config FEATURE_STAT_FILESYSTEM | ||
597 | bool "Enable display of filesystem status (-f)" | ||
598 | default y | ||
599 | depends on STAT | ||
600 | select PLATFORM_LINUX # statfs() | ||
601 | help | ||
602 | Without this, stat will not support the '-f' option to display | ||
603 | information about filesystem status. | ||
604 | |||
597 | config STTY | 605 | config STTY |
598 | bool "stty" | 606 | bool "stty" |
599 | default y | 607 | default y |
diff --git a/coreutils/stat.c b/coreutils/stat.c index 3fb212f0f..5af365a7e 100644 --- a/coreutils/stat.c +++ b/coreutils/stat.c | |||
@@ -20,7 +20,9 @@ | |||
20 | //usage: IF_FEATURE_STAT_FORMAT( | 20 | //usage: IF_FEATURE_STAT_FORMAT( |
21 | //usage: "\n -c fmt Use the specified format" | 21 | //usage: "\n -c fmt Use the specified format" |
22 | //usage: ) | 22 | //usage: ) |
23 | //usage: IF_FEATURE_STAT_FILESYSTEM( | ||
23 | //usage: "\n -f Display filesystem status" | 24 | //usage: "\n -f Display filesystem status" |
25 | //usage: ) | ||
24 | //usage: "\n -L Follow links" | 26 | //usage: "\n -L Follow links" |
25 | //usage: "\n -t Display info in terse form" | 27 | //usage: "\n -t Display info in terse form" |
26 | //usage: IF_SELINUX( | 28 | //usage: IF_SELINUX( |
@@ -54,6 +56,7 @@ | |||
54 | //usage: " %Y Time of last modification as seconds since Epoch\n" | 56 | //usage: " %Y Time of last modification as seconds since Epoch\n" |
55 | //usage: " %z Time of last change\n" | 57 | //usage: " %z Time of last change\n" |
56 | //usage: " %Z Time of last change as seconds since Epoch\n" | 58 | //usage: " %Z Time of last change as seconds since Epoch\n" |
59 | //usage: IF_FEATURE_STAT_FILESYSTEM( | ||
57 | //usage: "\nValid format sequences for file systems:\n" | 60 | //usage: "\nValid format sequences for file systems:\n" |
58 | //usage: " %a Free blocks available to non-superuser\n" | 61 | //usage: " %a Free blocks available to non-superuser\n" |
59 | //usage: " %b Total data blocks in file system\n" | 62 | //usage: " %b Total data blocks in file system\n" |
@@ -71,6 +74,7 @@ | |||
71 | //usage: " %t Type in hex\n" | 74 | //usage: " %t Type in hex\n" |
72 | //usage: " %T Type in human readable form" | 75 | //usage: " %T Type in human readable form" |
73 | //usage: ) | 76 | //usage: ) |
77 | //usage: ) | ||
74 | 78 | ||
75 | #include "libbb.h" | 79 | #include "libbb.h" |
76 | 80 | ||
@@ -132,6 +136,7 @@ static const char *human_time(time_t t) | |||
132 | #undef buf | 136 | #undef buf |
133 | } | 137 | } |
134 | 138 | ||
139 | #if ENABLE_FEATURE_STAT_FILESYSTEM | ||
135 | /* Return the type of the specified file system. | 140 | /* Return the type of the specified file system. |
136 | * Some systems have statfvs.f_basetype[FSTYPSZ]. (AIX, HP-UX, and Solaris) | 141 | * Some systems have statfvs.f_basetype[FSTYPSZ]. (AIX, HP-UX, and Solaris) |
137 | * Others have statfs.f_fstypename[MFSNAMELEN]. (NetBSD 1.5.2) | 142 | * Others have statfs.f_fstypename[MFSNAMELEN]. (NetBSD 1.5.2) |
@@ -202,6 +207,7 @@ static unsigned long long get_f_fsid(const struct statfs *statfsbuf) | |||
202 | while (--sz > 0); | 207 | while (--sz > 0); |
203 | return r; | 208 | return r; |
204 | } | 209 | } |
210 | #endif /* FEATURE_STAT_FILESYSTEM */ | ||
205 | 211 | ||
206 | #if ENABLE_FEATURE_STAT_FORMAT | 212 | #if ENABLE_FEATURE_STAT_FORMAT |
207 | static void strcatc(char *str, char c) | 213 | static void strcatc(char *str, char c) |
@@ -217,6 +223,7 @@ static void printfs(char *pformat, const char *msg) | |||
217 | printf(pformat, msg); | 223 | printf(pformat, msg); |
218 | } | 224 | } |
219 | 225 | ||
226 | #if ENABLE_FEATURE_STAT_FILESYSTEM | ||
220 | /* print statfs info */ | 227 | /* print statfs info */ |
221 | static void FAST_FUNC print_statfs(char *pformat, const char m, | 228 | static void FAST_FUNC print_statfs(char *pformat, const char m, |
222 | const char *const filename, const void *data | 229 | const char *const filename, const void *data |
@@ -263,6 +270,7 @@ static void FAST_FUNC print_statfs(char *pformat, const char m, | |||
263 | printf(pformat, m); | 270 | printf(pformat, m); |
264 | } | 271 | } |
265 | } | 272 | } |
273 | #endif | ||
266 | 274 | ||
267 | /* print stat info */ | 275 | /* print stat info */ |
268 | static void FAST_FUNC print_stat(char *pformat, const char m, | 276 | static void FAST_FUNC print_stat(char *pformat, const char m, |
@@ -335,10 +343,18 @@ static void FAST_FUNC print_stat(char *pformat, const char m, | |||
335 | printf(pformat, (unsigned long) 512); //ST_NBLOCKSIZE | 343 | printf(pformat, (unsigned long) 512); //ST_NBLOCKSIZE |
336 | } else if (m == 'b') { | 344 | } else if (m == 'b') { |
337 | strcat(pformat, "llu"); | 345 | strcat(pformat, "llu"); |
346 | #if !ENABLE_PLATFORM_MINGW32 | ||
338 | printf(pformat, (unsigned long long) statbuf->st_blocks); | 347 | printf(pformat, (unsigned long long) statbuf->st_blocks); |
348 | #else | ||
349 | printf(pformat, (unsigned long long) ((statbuf->st_size+511)/512)); | ||
350 | #endif | ||
339 | } else if (m == 'o') { | 351 | } else if (m == 'o') { |
340 | strcat(pformat, "lu"); | 352 | strcat(pformat, "lu"); |
353 | #if !ENABLE_PLATFORM_MINGW32 | ||
341 | printf(pformat, (unsigned long) statbuf->st_blksize); | 354 | printf(pformat, (unsigned long) statbuf->st_blksize); |
355 | #else | ||
356 | printf(pformat, (unsigned long) 4096); | ||
357 | #endif | ||
342 | } else if (m == 'x') { | 358 | } else if (m == 'x') { |
343 | printfs(pformat, human_time(statbuf->st_atime)); | 359 | printfs(pformat, human_time(statbuf->st_atime)); |
344 | } else if (m == 'X') { | 360 | } else if (m == 'X') { |
@@ -423,6 +439,7 @@ static void print_it(const char *masterformat, | |||
423 | } | 439 | } |
424 | #endif /* FEATURE_STAT_FORMAT */ | 440 | #endif /* FEATURE_STAT_FORMAT */ |
425 | 441 | ||
442 | #if ENABLE_FEATURE_STAT_FILESYSTEM | ||
426 | /* Stat the file system and print what we find. */ | 443 | /* Stat the file system and print what we find. */ |
427 | #if !ENABLE_FEATURE_STAT_FORMAT | 444 | #if !ENABLE_FEATURE_STAT_FORMAT |
428 | #define do_statfs(filename, format) do_statfs(filename) | 445 | #define do_statfs(filename, format) do_statfs(filename) |
@@ -538,6 +555,7 @@ static bool do_statfs(const char *filename, const char *format) | |||
538 | #endif /* FEATURE_STAT_FORMAT */ | 555 | #endif /* FEATURE_STAT_FORMAT */ |
539 | return 1; | 556 | return 1; |
540 | } | 557 | } |
558 | #endif /* FEATURE_STAT_FILESYSTEM */ | ||
541 | 559 | ||
542 | /* stat the file and print what we find */ | 560 | /* stat the file and print what we find */ |
543 | #if !ENABLE_FEATURE_STAT_FORMAT | 561 | #if !ENABLE_FEATURE_STAT_FORMAT |
@@ -714,12 +732,15 @@ int stat_main(int argc UNUSED_PARAM, char **argv) | |||
714 | statfunc_ptr statfunc = do_stat; | 732 | statfunc_ptr statfunc = do_stat; |
715 | 733 | ||
716 | opt_complementary = "-1"; /* min one arg */ | 734 | opt_complementary = "-1"; /* min one arg */ |
717 | opts = getopt32(argv, "ftL" | 735 | opts = getopt32(argv, "tL" |
736 | IF_FEATURE_STAT_FILESYSTEM("f") | ||
718 | IF_SELINUX("Z") | 737 | IF_SELINUX("Z") |
719 | IF_FEATURE_STAT_FORMAT("c:", &format) | 738 | IF_FEATURE_STAT_FORMAT("c:", &format) |
720 | ); | 739 | ); |
740 | #if ENABLE_FEATURE_STAT_FILESYSTEM | ||
721 | if (opts & OPT_FILESYS) /* -f */ | 741 | if (opts & OPT_FILESYS) /* -f */ |
722 | statfunc = do_statfs; | 742 | statfunc = do_statfs; |
743 | #endif | ||
723 | #if ENABLE_SELINUX | 744 | #if ENABLE_SELINUX |
724 | if (opts & OPT_SELINUX) { | 745 | if (opts & OPT_SELINUX) { |
725 | selinux_or_die(); | 746 | selinux_or_die(); |