poke-devel
[Top][All Lists]
Advanced

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

[PATCH 1/7] ios: Drop Position column from .info ios


From: Eric Blake
Subject: [PATCH 1/7] ios: Drop Position column from .info ios
Date: Sat, 29 Feb 2020 05:12:19 -0600

Currently, there is only one client of ios_tell() - namely, '.info
ios'.  But in Poke, all actions relating to an ios are given an
explicit offset (even interfaces like dump that don't take an offset
from the user still end up computing a series of offsets before
interacting with the ios).  We don't really have or need a notion of
back-to-back actions where the second can omit the offset and
magically happen at the next bit after the first.  What's more, the
output we were giving was rounded to a byte boundary, and required
extra bookkeeping in the .mem driver to maintain it (the upcoming .nbd
driver would be another driver that has to artificially track current
offset).  While at it, fix some typos.

* src/pk-ios.c (pk_cmd_info_ios, print_info_ios): Simplify.
* src/ios.c (ios_tell): Delete.
* src/ios.h (ios_tell): Likewise.
* doc/poke.texi (info command): Update output.
* testsuite/poke.cmd/file-mode.pk: Likewise.
* testsuite/poke.cmd/file-relative.pk: Likewise.
---
 ChangeLog                           | 10 ++++++++++
 doc/poke.texi                       | 12 ++++++------
 src/ios.h                           |  6 ------
 src/ios.c                           | 15 ++++-----------
 src/pk-ios.c                        | 22 +---------------------
 testsuite/poke.cmd/file-mode.pk     |  6 +++---
 testsuite/poke.cmd/file-relative.pk |  4 ++--
 7 files changed, 26 insertions(+), 49 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ad0e4d0f..832d6124 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2020-02-27  Eric Blake  <address@hidden>
+
+       ios: Drop Position column from .info ios
+       * src/pk-ios.c (pk_cmd_info_ios, print_info_ios): Simplify.
+       * src/ios.c (ios_tell): Delete.
+       * src/ios.h (ios_tell): Likewise.
+       * doc/poke.texi (info command): Update output.
+       * testsuite/poke.cmd/file-mode.pk: Likewise.
+       * testsuite/poke.cmd/file-relative.pk: Likewise.
+
 2020-02-23  John Darrington <address@hidden>

        * src/pk-cmd.c (pk_cmd_exec_1)[case 'f']: Remove a lot
diff --git a/doc/poke.texi b/doc/poke.texi
index 6951db15..58ca9f9d 100644
--- a/doc/poke.texi
+++ b/doc/poke.texi
@@ -607,9 +607,9 @@ info command

 @example
 (poke) .info ios
-  Id   Mode    Position        Name
-* #0   rw      0x00000000#b    foo.bson
-  #1   r       0x00000000#b    foo.o
+  Id   Mode    Name
+* #0   rw      foo.bson
+  #1   r       foo.o
 @end example

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

 @item .info variable
diff --git a/src/ios.h b/src/ios.h
index cbe613f9..54eac388 100644
--- a/src/ios.h
+++ b/src/ios.h
@@ -157,12 +157,6 @@ void ios_close (ios io);

 uint64_t ios_flags (ios io);

-/* Many IO devices are able to maintain a current read/write pointer.
-   The function below can be used to retrieve it, as an IOS
-   offset.  */
-
-ios_off ios_tell (ios io);
-
 /* The following function returns the handler operated by the given IO
    space.  */

diff --git a/src/ios.c b/src/ios.c
index bb760161..9e31ac48 100644
--- a/src/ios.c
+++ b/src/ios.c
@@ -252,13 +252,6 @@ ios_flags (ios io)
   return io->dev_if->get_flags (io->dev);
 }

-ios_off
-ios_tell (ios io)
-{
-  ios_dev_off dev_off = io->dev_if->tell (io->dev);
-  return dev_off * 8;
-}
-
 const char *
 ios_handler (ios io)
 {
@@ -813,7 +806,7 @@ ios_read_int (ios io, ios_off offset, int flags,
       }
     }

-  /* Fall into the case for the unaligned and the sizes other than 8k.  */
+  /* Fall into the case for the unaligned and the sizes other than 8x.  */
   int ret_val = ios_read_int_common(io, offset, flags, bits, endian,
                                    (uint64_t *) value);
   if (ret_val == IOS_OK)
@@ -916,7 +909,7 @@ ios_read_uint (ios io, ios_off offset, int flags,
       }
     }

-  /* Fall into the case for the unaligned and the sizes other than 8k.  */
+  /* Fall into the case for the unaligned and the sizes other than 8x.  */
   return ios_read_int_common (io, offset, flags, bits, endian, value);
 }

@@ -1536,7 +1529,7 @@ ios_write_int (ios io, ios_off offset, int flags,
   int unused_bits = 64 - bits;
   uint64_t uvalue = ((uint64_t) (value << unused_bits)) >> unused_bits;

-  /* Fall into the case for the unaligned and the sizes other than 8k.  */
+  /* Fall into the case for the unaligned and the sizes other than 8x.  */
   return ios_write_int_common (io, offset, flags, bits, endian, uvalue);
 }

@@ -1557,7 +1550,7 @@ ios_write_uint (ios io, ios_off offset, int flags,
   if (offset % 8 == 0 && bits % 8 == 0)
     return ios_write_int_fast (io, flags, bits, endian, value);

-  /* Fall into the case for the unaligned and the sizes other than 8k.  */
+  /* Fall into the case for the unaligned and the sizes other than 8x.  */
   return ios_write_int_common (io, offset, flags, bits, endian, value);
 }

diff --git a/src/pk-ios.c b/src/pk-ios.c
index 08ca89f8..01896d87 100644
--- a/src/pk-ios.c
+++ b/src/pk-ios.c
@@ -194,26 +194,6 @@ 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_tell (io));
-    hyperlink = pk_hserver_make_hyperlink ('i', cmd);
-    free (cmd);
-
-    pk_term_hyperlink (hyperlink, NULL);
-    pk_printf ("0x%08jx#b", ios_tell (io));
-    pk_term_end_hyperlink ();
-
-    free (hyperlink);
-  }
-#else
-  pk_printf ("0x%08jx#b", ios_tell (io));
-#endif
-  pk_puts ("\t");
-
 #if HAVE_HSERVER
   {
     char *cmd;
@@ -241,7 +221,7 @@ pk_cmd_info_ios (int argc, struct pk_cmd_arg argv[], 
uint64_t uflags)
 {
   assert (argc == 0);

-  pk_printf (_("  Id\tMode\tPosition\tName\n"));
+  pk_printf (_("  Id\tMode\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 7341458a..a2d81822 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\tPosition\tName" } */
-/* { dg-output {\n. #1\trw\t0x00000000#b\t/dev/null} } */
-/* { dg-output {\n  #0\tr[w ]\t0x00000000#b\t/etc/passwd} } */
+/* { dg-output "  Id\tMode\tName" } */
+/* { dg-output {\n. #1\trw\t/dev/null} } */
+/* { dg-output {\n  #0\tr[w ]\t/etc/passwd} } */
diff --git a/testsuite/poke.cmd/file-relative.pk 
b/testsuite/poke.cmd/file-relative.pk
index 82b3f2aa..060ffd81 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\tPosition\tName" } */
-/* { dg-output "\n\\* #0\trw\t0x00000000#b\t./a#b" } */
+/* { dg-output "  Id\tMode\tName" } */
+/* { dg-output "\n\\* #0\trw\t./a#b" } */
-- 
2.25.1




reply via email to

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