diff options
Diffstat (limited to 'coreutils/du.c')
-rw-r--r-- | coreutils/du.c | 66 |
1 files changed, 31 insertions, 35 deletions
diff --git a/coreutils/du.c b/coreutils/du.c index a547b1e14..a1ca5b59b 100644 --- a/coreutils/du.c +++ b/coreutils/du.c @@ -25,26 +25,22 @@ #include "busybox.h" -#ifdef CONFIG_FEATURE_HUMAN_READABLE -# ifdef CONFIG_FEATURE_DU_DEFAULT_BLOCKSIZE_1K +#if ENABLE_FEATURE_HUMAN_READABLE +# if ENABLE_FEATURE_DU_DEFAULT_BLOCKSIZE_1K static unsigned long disp_hr = 1024; # else static unsigned long disp_hr = 512; # endif -#elif defined CONFIG_FEATURE_DU_DEFAULT_BLOCKSIZE_1K -static unsigned int disp_k = 1; +#elif ENABLE_FEATURE_DU_DEFAULT_BLOCKSIZE_1K +static unsigned disp_k = 1; #else -static unsigned int disp_k; /* bss inits to 0 */ +static unsigned disp_k; /* bss inits to 0 */ #endif static int max_print_depth = INT_MAX; static nlink_t count_hardlinks = 1; -static int status -#if EXIT_SUCCESS == 0 - = EXIT_SUCCESS -#endif - ; +static int status; static int print_files; static int slink_depth; static int du_depth; @@ -55,9 +51,9 @@ static dev_t dir_dev; static void print(long size, const char * const filename) { /* TODO - May not want to defer error checking here. */ -#ifdef CONFIG_FEATURE_HUMAN_READABLE +#if ENABLE_FEATURE_HUMAN_READABLE printf("%s\t%s\n", make_human_readable_str(size, 512, disp_hr), - filename); + filename); #else if (disp_k) { size++; @@ -73,7 +69,7 @@ static long du(const char * const filename) struct stat statbuf; long sum; - if ((lstat(filename, &statbuf)) != 0) { + if (lstat(filename, &statbuf) != 0) { bb_perror_msg("%s", filename); status = EXIT_FAILURE; return 0; @@ -91,7 +87,7 @@ static long du(const char * const filename) if (S_ISLNK(statbuf.st_mode)) { if (slink_depth > du_depth) { /* -H or -L */ - if ((stat(filename, &statbuf)) != 0) { + if (stat(filename, &statbuf) != 0) { bb_perror_msg("%s", filename); status = EXIT_FAILURE; return 0; @@ -130,7 +126,7 @@ static long du(const char * const filename) char *name = entry->d_name; newfile = concat_subpath_file(filename, name); - if(newfile == NULL) + if (newfile == NULL) continue; ++du_depth; sum += du(newfile); @@ -155,9 +151,9 @@ int du_main(int argc, char **argv) char *smax_print_depth; unsigned opt; -#ifdef CONFIG_FEATURE_DU_DEFUALT_BLOCKSIZE_1K +#if ENABLE_FEATURE_DU_DEFAULT_BLOCKSIZE_1K if (getenv("POSIXLY_CORRECT")) { /* TODO - a new libbb function? */ -#ifdef CONFIG_FEATURE_HUMAN_READABLE +#if ENABLE_FEATURE_HUMAN_READABLE disp_hr = 512; #else disp_k = 0; @@ -171,55 +167,55 @@ int du_main(int argc, char **argv) * gnu du exits with an error code in this case. We choose to simply * ignore -a. This is consistent with -s being equivalent to -d 0. */ -#ifdef CONFIG_FEATURE_HUMAN_READABLE +#if ENABLE_FEATURE_HUMAN_READABLE opt_complementary = "h-km:k-hm:m-hk:H-L:L-H:s-d:d-s"; opt = getopt32(argc, argv, "aHkLsx" "d:" "lc" "hm", &smax_print_depth); - if((opt & (1 << 9))) { + if (opt & (1 << 9)) { /* -h opt */ disp_hr = 0; } - if((opt & (1 << 10))) { + if (opt & (1 << 10)) { /* -m opt */ disp_hr = 1024*1024; } - if((opt & (1 << 2))) { + if (opt & (1 << 2)) { /* -k opt */ disp_hr = 1024; } #else opt_complementary = "H-L:L-H:s-d:d-s"; opt = getopt32(argc, argv, "aHkLsx" "d:" "lc", &smax_print_depth); -#if !defined CONFIG_FEATURE_DU_DEFAULT_BLOCKSIZE_1K - if((opt & (1 << 2))) { +#if !ENABLE_FEATURE_DU_DEFAULT_BLOCKSIZE_1K + if (opt & (1 << 2)) { /* -k opt */ - disp_k = 1; + disp_k = 1; } #endif #endif - if((opt & (1 << 0))) { + if (opt & (1 << 0)) { /* -a opt */ print_files = INT_MAX; } - if((opt & (1 << 1))) { + if (opt & (1 << 1)) { /* -H opt */ slink_depth = 1; } - if((opt & (1 << 3))) { + if (opt & (1 << 3)) { /* -L opt */ - slink_depth = INT_MAX; + slink_depth = INT_MAX; } - if((opt & (1 << 4))) { + if (opt & (1 << 4)) { /* -s opt */ - max_print_depth = 0; - } + max_print_depth = 0; + } one_file_system = opt & (1 << 5); /* -x opt */ - if((opt & (1 << 6))) { + if (opt & (1 << 6)) { /* -d opt */ max_print_depth = xatoi_u(smax_print_depth); } - if((opt & (1 << 7))) { + if (opt & (1 << 7)) { /* -l opt */ - count_hardlinks = INT_MAX; + count_hardlinks = MAXINT(nlink_t); } print_final_total = opt & (1 << 8); /* -c opt */ @@ -238,7 +234,7 @@ int du_main(int argc, char **argv) total += du(*argv); slink_depth = slink_depth_save; } while (*++argv); -#ifdef CONFIG_FEATURE_CLEAN_UP +#if ENABLE_FEATURE_CLEAN_UP reset_ino_dev_hashtable(); #endif |