* [PATCH] format_proc_swaps: ensure space between fields for clarity
@ 2021-04-30 13:19 Brian Inglis
2021-04-30 19:06 ` Corinna Vinschen
0 siblings, 1 reply; 3+ messages in thread
From: Brian Inglis @ 2021-04-30 13:19 UTC (permalink / raw)
To: cygwin-patches
page/swap space name >= 40 or size/used >= 8 leaves no space between fields;
ensure a space after name and add extra tabs after size and used fields;
output appears like Linux 5.8 after changes to mm/swapfile(swap_show);
proc-swaps-space-before.log:
==> /proc/swaps <==
Filename Type Size Used Priority
/mnt/c/pagefile.sys file 11567748292920 0
/mnt/d/pagefile.sys file 12582912205960 0
proc-swaps-space-after.log:
==> /proc/swaps <==
Filename Type Size Used Priority
/mnt/c/pagefile.sys file 11567748 241024 0
/mnt/d/pagefile.sys file 12582912 182928 0
---
winsup/cygwin/fhandler_proc.cc | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/winsup/cygwin/fhandler_proc.cc b/winsup/cygwin/fhandler_proc.cc
index 7cd0b3af02..eb4efb07d4 100644
--- a/winsup/cygwin/fhandler_proc.cc
+++ b/winsup/cygwin/fhandler_proc.cc
@@ -1920,7 +1920,7 @@ format_proc_swaps (void *, char *&destbuf)
}
bufptr += __small_sprintf (bufptr,
- "Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
+ "Filename\t\t\t\tType\t\tSize\t\tUsed\t\tPriority\n");
if (spi && NT_SUCCESS (status))
{
@@ -1932,8 +1932,17 @@ format_proc_swaps (void *, char *&destbuf)
used = (unsigned long long) spp->TotalUsed * wincap.page_size ();
cygwin_conv_path (CCP_WIN_W_TO_POSIX, spp->FileName.Buffer,
filename, NT_MAX_PATH);
- bufptr += sprintf (bufptr, "%-40s%-16s%-8llu%-8llu%-8d\n",
- filename, "file", total >> 10, used >> 10, 0);
+ /* ensure space between fields for clarity */
+ size_t tabo = strlen (filename) / 8; /* offset tabs to space name */
+ bufptr += sprintf (bufptr, "%s%s%s\t\t%llu%s\t%llu%s\t%d\n",
+ filename,
+ tabo < 5 ? "\t\t\t\t\t" + tabo : " ",
+ "file",
+ total >> 10,
+ total < 10000000000 ? "\t" : "",
+ used >> 10,
+ used < 10000000000 ? "\t" : "",
+ 0);
}
while (spp->NextEntryOffset
&& (spp = (PSYSTEM_PAGEFILE_INFORMATION)
--
2.31.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] format_proc_swaps: ensure space between fields for clarity
2021-04-30 13:19 [PATCH] format_proc_swaps: ensure space between fields for clarity Brian Inglis
@ 2021-04-30 19:06 ` Corinna Vinschen
2021-05-01 0:37 ` Brian Inglis
0 siblings, 1 reply; 3+ messages in thread
From: Corinna Vinschen @ 2021-04-30 19:06 UTC (permalink / raw)
To: cygwin-patches
On Apr 30 07:19, Brian Inglis wrote:
> page/swap space name >= 40 or size/used >= 8 leaves no space between fields;
> ensure a space after name and add extra tabs after size and used fields;
> output appears like Linux 5.8 after changes to mm/swapfile(swap_show);
>
> proc-swaps-space-before.log:
> ==> /proc/swaps <==
> Filename Type Size Used Priority
> /mnt/c/pagefile.sys file 11567748292920 0
> /mnt/d/pagefile.sys file 12582912205960 0
>
> proc-swaps-space-after.log:
> ==> /proc/swaps <==
> Filename Type Size Used Priority
> /mnt/c/pagefile.sys file 11567748 241024 0
> /mnt/d/pagefile.sys file 12582912 182928 0
> ---
> winsup/cygwin/fhandler_proc.cc | 15 ++++++++++++---
> 1 file changed, 12 insertions(+), 3 deletions(-)
Pushed.
Thanks,
Corinna
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] format_proc_swaps: ensure space between fields for clarity
2021-04-30 19:06 ` Corinna Vinschen
@ 2021-05-01 0:37 ` Brian Inglis
0 siblings, 0 replies; 3+ messages in thread
From: Brian Inglis @ 2021-05-01 0:37 UTC (permalink / raw)
To: cygwin-patches
On 2021-04-30 13:06, Corinna Vinschen wrote:
> On Apr 30 07:19, Brian Inglis wrote:
>> page/swap space name >= 40 or size/used >= 8 leaves no space between fields;
>> ensure a space after name and add extra tabs after size and used fields;
>> output appears like Linux 5.8 after changes to mm/swapfile(swap_show);
>>
>> proc-swaps-space-before.log:
>> ==> /proc/swaps <==
>> Filename Type Size Used Priority
>> /mnt/c/pagefile.sys file 11567748292920 0
>> /mnt/d/pagefile.sys file 12582912205960 0
>>
>> proc-swaps-space-after.log:
>> ==> /proc/swaps <==
>> Filename Type Size Used Priority
>> /mnt/c/pagefile.sys file 11567748 241024 0
>> /mnt/d/pagefile.sys file 12582912 182928 0
>> ---
>> winsup/cygwin/fhandler_proc.cc | 15 ++++++++++++---
>> 1 file changed, 12 insertions(+), 3 deletions(-)
>
> Pushed.
Cheers!
Don't know how those numbers got bumped - perhaps during Windows 20H2 update?
Must have been original 8GB when updating proc(5) in docs, or I'd have noticed.
--
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.
[Data in binary units and prefixes, physical quantities in SI.]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-05-01 0:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-30 13:19 [PATCH] format_proc_swaps: ensure space between fields for clarity Brian Inglis
2021-04-30 19:06 ` Corinna Vinschen
2021-05-01 0:37 ` Brian Inglis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).