/proc/partitions: add some space to avoid ragged output format

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

/proc/partitions: add some space to avoid ragged output format

Thomas Wolff


0001-avoid-ragged-output-of-proc-partitions.patch (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: /proc/partitions: add some space to avoid ragged output format

Brian Inglis
Hi Thomas,

In this industry, you plan ahead a bit further and longer: you need to go for at
least a three digit increase (below) or more; legacy 8TB HDDs are cheap and
common, 20TB are available, 100TB SSDs are available now (#blocks 97656250000 -
11 digits), capacity is expanding *faster* than HDDs:

https://www.tomshardware.com/news/100tb-ssd-nimbus-sata-flash,36687.html

and speeds now exceed 6GB/s and 1M IO/s.

We're also at 64C/128T 6GHz (overclocked) chips with 256MB L3 and L4 caches,
256GB memory, and over the next decade, feature sizes dropping by an order of
magnitude from 14nm to 1.4nm, with corresponding increases, so maintainers
should consider capacity increases when they look at code.

To make this easier next time ;^> I'd define a couple of formats:

#define PROC_PARTITION_HDR "%5s %5s %12s %s\n\n"
#define PROC_PARTITION_FMT "%5d %5d %12U %s\n"

or simplify the code further with:

#define PROC_PARTITION_HDR "%5s %5s %12s %-6s %-s\n\n"
#define PROC_PARTITION_FMT "%5d %5d %12U %-6s %-s\n"

and sprintf the header into the buffer:

-  print ("major minor  #blocks  name   win-mounts\n\n");
+  bufptr += __small_sprintf (bufptr, PROC_PARTITION_HDR,
+    "major", "minor", "#blocks",
+    "name   win-mounts\n\n");

*or*

-  print ("major minor  #blocks  name   win-mounts\n\n");
+  bufptr += __small_sprintf (bufptr, PROC_PARTITION_HDR,
+    "major", "minor", "#blocks",
+    "name", "win-mounts\n\n");


On 2020-03-02 14:39, Thomas Wolff wrote:

---
 winsup/cygwin/fhandler_proc.cc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/winsup/cygwin/fhandler_proc.cc b/winsup/cygwin/fhandler_proc.cc
index 605a8443f..3373f3ef5 100644
--- a/winsup/cygwin/fhandler_proc.cc
+++ b/winsup/cygwin/fhandler_proc.cc
@@ -1491,7 +1491,7 @@ format_proc_partitions (void *, char *&destbuf)
  }
       if (!got_one)
  {
-  print ("major minor  #blocks  name   win-mounts\n\n");
+  print ("major minor    #blocks   name   win-mounts\n\n");
   got_one = true;
  }
       /* Fetch partition info for the entire disk to get its size. */
@@ -1514,7 +1514,7 @@ format_proc_partitions (void *, char *&destbuf)
   size = 0;
  }
       device dev (drive_num, 0);
-      bufptr += __small_sprintf (bufptr, "%5d %5d %9U %s\n",
+      bufptr += __small_sprintf (bufptr, "%5d %5d %12U %s\n",
  dev.get_major (), dev.get_minor (),
  size >> 10, dev.name () + 5);
       /* Fetch drive layout info to get size of all partitions on the disk. */
@@ -1561,7 +1561,7 @@ format_proc_partitions (void *, char *&destbuf)
       continue;
     device dev (drive_num, part_num);

-    bufptr += __small_sprintf (bufptr, "%5d %5d %9U %s",
+    bufptr += __small_sprintf (bufptr, "%5d %5d %12U %s",
        dev.get_major (), dev.get_minor (),
        size >> 10, dev.name () + 5);
     /* Check if the partition is mounted in Windows and, if so,

--
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.
Reply | Threaded
Open this post in threaded view
|

Re: /proc/partitions: add some space to avoid ragged output format

Thomas Wolff
Am 03.03.2020 um 00:26 schrieb Brian Inglis:

> Hi Thomas,
>
> In this industry, you plan ahead a bit further and longer: you need to go for at
> least a three digit increase (below) or more; legacy 8TB HDDs are cheap and
> common, 20TB are available, 100TB SSDs are available now (#blocks 97656250000 -
> 11 digits), capacity is expanding *faster* than HDDs:
>
> https://www.tomshardware.com/news/100tb-ssd-nimbus-sata-flash,36687.html
>
> and speeds now exceed 6GB/s and 1M IO/s.
>
> We're also at 64C/128T 6GHz (overclocked) chips with 256MB L3 and L4 caches,
> 256GB memory, and over the next decade, feature sizes dropping by an order of
> magnitude from 14nm to 1.4nm, with corresponding increases, so maintainers
> should consider capacity increases when they look at code.
>
> To make this easier next time ;^> I'd define a couple of formats:
>
> #define PROC_PARTITION_HDR "%5s %5s %12s %s\n\n"
> #define PROC_PARTITION_FMT "%5d %5d %12U %s\n"
>
> or simplify the code further with:
>
> #define PROC_PARTITION_HDR "%5s %5s %12s %-6s %-s\n\n"
> #define PROC_PARTITION_FMT "%5d %5d %12U %-6s %-s\n"
>
> and sprintf the header into the buffer:
>
> -  print ("major minor  #blocks  name   win-mounts\n\n");
> +  bufptr += __small_sprintf (bufptr, PROC_PARTITION_HDR,
> +    "major", "minor", "#blocks",
> +    "name   win-mounts\n\n");
>
> *or*
>
> -  print ("major minor  #blocks  name   win-mounts\n\n");
> +  bufptr += __small_sprintf (bufptr, PROC_PARTITION_HDR,
> +    "major", "minor", "#blocks",
> +    "name", "win-mounts\n\n");
>
Hi Brian,
yes, I thought about factoring out the format as well, but then only
submitted a quick-and-dirty patch.
If you're suggesting a more solid solution, would you submit your patch?
Thomas


> On 2020-03-02 14:39, Thomas Wolff wrote:
>
> ---
>   winsup/cygwin/fhandler_proc.cc | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/winsup/cygwin/fhandler_proc.cc b/winsup/cygwin/fhandler_proc.cc
> index 605a8443f..3373f3ef5 100644
> --- a/winsup/cygwin/fhandler_proc.cc
> +++ b/winsup/cygwin/fhandler_proc.cc
> @@ -1491,7 +1491,7 @@ format_proc_partitions (void *, char *&destbuf)
>   }
>         if (!got_one)
>   {
> -  print ("major minor  #blocks  name   win-mounts\n\n");
> +  print ("major minor    #blocks   name   win-mounts\n\n");
>    got_one = true;
>   }
>         /* Fetch partition info for the entire disk to get its size. */
> @@ -1514,7 +1514,7 @@ format_proc_partitions (void *, char *&destbuf)
>    size = 0;
>   }
>         device dev (drive_num, 0);
> -      bufptr += __small_sprintf (bufptr, "%5d %5d %9U %s\n",
> +      bufptr += __small_sprintf (bufptr, "%5d %5d %12U %s\n",
>   dev.get_major (), dev.get_minor (),
>   size >> 10, dev.name () + 5);
>         /* Fetch drive layout info to get size of all partitions on the disk. */
> @@ -1561,7 +1561,7 @@ format_proc_partitions (void *, char *&destbuf)
>        continue;
>      device dev (drive_num, part_num);
>
> -    bufptr += __small_sprintf (bufptr, "%5d %5d %9U %s",
> +    bufptr += __small_sprintf (bufptr, "%5d %5d %12U %s",
>         dev.get_major (), dev.get_minor (),
>         size >> 10, dev.name () + 5);
>      /* Check if the partition is mounted in Windows and, if so,
>