bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] doc: du - clarify default blocksize in usage/manpage


From: Pádraig Brady
Subject: Re: [PATCH] doc: du - clarify default blocksize in usage/manpage
Date: Wed, 09 Sep 2009 16:57:40 +0100
User-agent: Thunderbird 2.0.0.6 (X11/20071008)

Eric Blake wrote:
> According to OndYej Vaaík on 9/9/2009 2:19 AM:
>> Hello,
>> as requested via https://bugzilla.redhat.com/show_bug.cgi?id=511188 , it
>> would be nice to clarify default blocksize used by du in manpage/--help
>> output. Although I closed that bugzilla as notabug, further
>> communication via private emails convinced me to propose that change to
>> upstream.
>> As it breaks translation strings, I guess it would be better to postpone
>> commit after 7.6 (if accepted).
> 
> The default block size depends on POSIXLY_CORRECT (which requires 512, not
> 1024) and on BLOCK_SIZE (which the user can set to a different size).
> Maybe a better thing to do would be adding a blurb about environment
> variables that affect block size.
> 
> Also, df and ls need the same treatment, whatever we decide to do.

Sorry if you get this thrice, resending using a another smtp server...

Good point about df. I've updated the attached patch accordingly.
ls doesn't need to mention it I think since it defaults to 1.
There is a section in the info docs explaining the various ways
of specifying block size for these programs.

cheers,
Pádraig.


diff --git a/src/df.c b/src/df.c
index 86fd0e3..a14a671 100644
--- a/src/df.c
+++ b/src/df.c
@@ -810,13 +810,13 @@ or all file systems by default.\n\
       fputs (_("\
 Mandatory arguments to long options are mandatory for short options too.\n\
 "), stdout);
-      fputs (_("\
+      printf (_("\
   -a, --all             include dummy file systems\n\
-  -B, --block-size=SIZE  use SIZE-byte blocks\n\
+  -B, --block-size=SIZE use SIZE-byte blocks instead of %"PRIuMAX"\n\
       --total           produce a grand total\n\
   -h, --human-readable  print sizes in human readable format (e.g., 1K 234M 
2G)\n\
   -H, --si              likewise, but use powers of 1000 not 1024\n\
-"), stdout);
+"), output_block_size);
       fputs (_("\
   -i, --inodes          list inode information instead of block usage\n\
   -k                    like --block-size=1K\n\
@@ -860,7 +860,6 @@ main (int argc, char **argv)
   inode_format = false;
   show_all_fs = false;
   show_listed_fs = false;
-  human_output_opts = -1;
   print_type = false;
   file_systems_processed = false;
   posix_format = false;
@@ -868,6 +867,10 @@ main (int argc, char **argv)
   print_grand_total = false;
   grand_fsu.fsu_blocksize = 1;
 
+  bool specified_block_size = false;
+  human_options (getenv ("DF_BLOCK_SIZE"),
+                 &human_output_opts, &output_block_size);
+
   for (;;)
     {
       int oi = -1;
@@ -888,6 +891,7 @@ main (int argc, char **argv)
             if (e != LONGINT_OK)
               xstrtol_fatal (e, oi, c, long_options, optarg);
           }
+          specified_block_size = true;
           break;
         case 'i':
           inode_format = true;
@@ -895,14 +899,17 @@ main (int argc, char **argv)
         case 'h':
           human_output_opts = human_autoscale | human_SI | human_base_1024;
           output_block_size = 1;
+          specified_block_size = true;
           break;
         case 'H':
           human_output_opts = human_autoscale | human_SI;
           output_block_size = 1;
+          specified_block_size = true;
           break;
         case 'k':
           human_output_opts = 0;
           output_block_size = 1024;
+          specified_block_size = true;
           break;
         case 'l':
           show_local_fs = true;
@@ -910,12 +917,16 @@ main (int argc, char **argv)
         case 'm': /* obsolescent */
           human_output_opts = 0;
           output_block_size = 1024 * 1024;
+          specified_block_size = true;
           break;
         case 'T':
           print_type = true;
           break;
         case 'P':
           posix_format = true;
+          human_output_opts = 0;
+          if (!specified_block_size)
+            output_block_size = (getenv ("POSIXLY_CORRECT") ? 512 : 1024);
           break;
         case SYNC_OPTION:
           require_sync = true;
@@ -949,18 +960,6 @@ main (int argc, char **argv)
         }
     }
 
-  if (human_output_opts == -1)
-    {
-      if (posix_format)
-        {
-          human_output_opts = 0;
-          output_block_size = (getenv ("POSIXLY_CORRECT") ? 512 : 1024);
-        }
-      else
-        human_options (getenv ("DF_BLOCK_SIZE"),
-                       &human_output_opts, &output_block_size);
-    }
-
   /* Fail if the same file system type was both selected and excluded.  */
   {
     bool match = false;
diff --git a/src/du.c b/src/du.c
index 9da901a..503b58d 100644
--- a/src/du.c
+++ b/src/du.c
@@ -283,13 +283,13 @@ Mandatory arguments to long options are mandatory for 
short options too.\n\
                           larger due to holes in (`sparse') files, internal\n\
                           fragmentation, indirect blocks, and the like\n\
 "), stdout);
-      fputs (_("\
-  -B, --block-size=SIZE  use SIZE-byte blocks\n\
+      printf (_("\
+  -B, --block-size=SIZE use SIZE-byte blocks instead of %"PRIuMAX"\n\
   -b, --bytes           equivalent to `--apparent-size --block-size=1'\n\
   -c, --total           produce a grand total\n\
   -D, --dereference-args  dereference only symlinks that are listed on the\n\
                           command line\n\
-"), stdout);
+"), output_block_size);
       fputs (_("\
       --files0-from=F   summarize disk usage of the NUL-terminated file\n\
                           names specified in file F;\n\



reply via email to

[Prev in Thread] Current Thread [Next in Thread]