poke-devel
[Top][All Lists]
Advanced

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

[PATCH 3/3] ios: Add Size to '.info ios'.


From: Eric Blake
Subject: [PATCH 3/3] ios: Add Size to '.info ios'.
Date: Mon, 2 Mar 2020 13:39:48 -0600

Commit d4703c9b dropped Position from '.info ios' (especially since
the recent change to pread means that a 'current position' really
isn't needed), but it turns out that knowing the size of an ios is
still useful.  The information is already available for programmatic
use from 'iosize(number)', but seeing everything at once during .info
is nice.

* src/pk-ios.c (pk_cmd_info_ios, print_info_ios): Add Size
column.
* doc/poke.texi (info command): Document the addition.
* testsuite/poke.cmd/file-mode.pk: Adjust expected output.
* testsuite/poke.cmd/file-relative.pk: Likewise.
---
 ChangeLog                           |  9 +++++++++
 doc/poke.texi                       | 12 ++++++------
 src/pk-ios.c                        | 22 +++++++++++++++++++++-
 testsuite/poke.cmd/file-mode.pk     |  6 +++---
 testsuite/poke.cmd/file-relative.pk |  4 ++--
 5 files changed, 41 insertions(+), 12 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index dd104091..83f3ba8f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2020-03-02  Eric Blake  <address@hidden>
+
+       ios: Add Size to '.info ios'.
+       * src/pk-ios.c (pk_cmd_info_ios, print_info_ios): Add Size
+       column.
+       * doc/poke.texi (info command): Document the addition.
+       * testsuite/poke.cmd/file-mode.pk: Adjust expected output.
+       * testsuite/poke.cmd/file-relative.pk: Likewise.
+
 2020-03-02  Eric Blake  <address@hidden>

        * src/pk-ios.c (print_info_ios): Correct hyperlink.
diff --git a/doc/poke.texi b/doc/poke.texi
index 03b8321d..71836bea 100644
--- a/doc/poke.texi
+++ b/doc/poke.texi
@@ -665,9 +665,9 @@ info command

 @example
 (poke) .info ios
-  Id   Mode    Name
-* #0   rw      foo.bson
-  #1   r       foo.o
+Id     Mode    Size    Name
+* #0   rw      22#B    foo.bson
+#1     r       55288#B foo.o
 @end example

 @cindex IO space
@@ -681,9 +681,9 @@ info command
 (poke) .ios #1
 The current file is now `foo.o'.
 (poke) .info ios
-  Id   Mode    Filename
-  #0   rw      foo.bson
-* #1   r       foo.o
+  Id   Mode    Size    Filename
+  #0   rw      22#B    foo.bson
+* #1   r       55288#B foo.o
 @end example

 @item .info variable
diff --git a/src/pk-ios.c b/src/pk-ios.c
index 268ce373..3e142eb0 100644
--- a/src/pk-ios.c
+++ b/src/pk-ios.c
@@ -194,6 +194,26 @@ print_info_ios (ios io, void *data)
              ios_get_id (io),
             mode);

+#if HAVE_HSERVER
+  {
+    char *cmd;
+    char *hyperlink;
+
+    asprintf (&cmd, "0x%08jx#B", ios_size (io) / 8);
+    hyperlink = pk_hserver_make_hyperlink ('i', cmd);
+    free (cmd);
+
+    pk_term_hyperlink (hyperlink, NULL);
+    pk_printf ("0x%08jx#B", ios_size (io) / 8);
+    pk_term_end_hyperlink ();
+
+    free (hyperlink);
+  }
+#else
+  pk_printf ("0x%08jx#B", ios_size (io) / 8);
+#endif
+  pk_puts ("\t");
+
 #if HAVE_HSERVER
   {
     char *cmd;
@@ -221,7 +241,7 @@ pk_cmd_info_ios (int argc, struct pk_cmd_arg argv[], 
uint64_t uflags)
 {
   assert (argc == 0);

-  pk_printf (_("  Id\tMode\tName\n"));
+  pk_printf (_("  Id\tMode\tSize\t\tName\n"));
   ios_map (print_info_ios, NULL);

   return 1;
diff --git a/testsuite/poke.cmd/file-mode.pk b/testsuite/poke.cmd/file-mode.pk
index a2d81822..dfe44632 100644
--- a/testsuite/poke.cmd/file-mode.pk
+++ b/testsuite/poke.cmd/file-mode.pk
@@ -3,6 +3,6 @@
 /* { dg-command { .file /etc/passwd } } */
 /* { dg-command { .file /dev/null } } */
 /* { dg-command { .info ios } } */
-/* { dg-output "  Id\tMode\tName" } */
-/* { dg-output {\n. #1\trw\t/dev/null} } */
-/* { dg-output {\n  #0\tr[w ]\t/etc/passwd} } */
+/* { dg-output "  Id\tMode\tSize\t\tName" } */
+/* { dg-output {\n. #1\trw\t0x00000000#B\t/dev/null} } */
+/* { dg-output {\n  #0\tr[w ]\t0x[0-9a-f]*#B\t/etc/passwd} } */
diff --git a/testsuite/poke.cmd/file-relative.pk 
b/testsuite/poke.cmd/file-relative.pk
index 060ffd81..ca816d9e 100644
--- a/testsuite/poke.cmd/file-relative.pk
+++ b/testsuite/poke.cmd/file-relative.pk
@@ -3,5 +3,5 @@

 /* { dg-command { .file "a#b" } } */
 /* { dg-command { .info ios } } */
-/* { dg-output "  Id\tMode\tName" } */
-/* { dg-output "\n\\* #0\trw\t./a#b" } */
+/* { dg-output "  Id\tMode\tSize\t\tName" } */
+/* { dg-output "\n\\* #0\trw\t0x00000008#B\t./a#b" } */
-- 
2.25.1




reply via email to

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