[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[COMMITTED] poke, ios: dump should not print anything if the IOS is not
From: |
Jose E. Marchesi |
Subject: |
[COMMITTED] poke, ios: dump should not print anything if the IOS is not readable |
Date: |
Sat, 27 Mar 2021 14:02:15 +0100 |
This patch makes dump to check that the given IOS exists and is
readable before trying to emit any output (like ruler and/or ASCII).
Note the XXX note:
/* First of all, we require a readable IO space. */
if (! (ioflags (ios) & IOS_F_READ))
/* XXX change to E_perm when it becomes available. */
raise E_no_ios;
This will be changed as soon as we have support for E_perm, which has
been sent to poke-devel for review.
Note also that this patch makes the memory IOD to ignore user-provided
flags and set them to read/write.
2021-03-27 Jose E. Marchesi <jemarch@gnu.org>
* libpoke/ios-dev-mem.c (ios_dev_mem_open): Memory IOS are always
read/write.
* poke/pk-dump.pk (Arguments): Raise E_perm if the specified IOS
is not readable.
* testsuite/poke.cmd/dump-10.pk: New test.
* testsuite/poke.cmd/dump-11.pk: Likewise.
* testsuite/Makefile.am (EXTRA_DIST): Add new test.
---
ChangeLog | 10 ++++++++++
libpoke/ios-dev-mem.c | 2 +-
poke/pk-dump.pk | 5 +++++
testsuite/Makefile.am | 2 ++
testsuite/poke.cmd/dump-10.pk | 7 +++++++
testsuite/poke.cmd/dump-11.pk | 4 ++++
6 files changed, 29 insertions(+), 1 deletion(-)
create mode 100644 testsuite/poke.cmd/dump-10.pk
create mode 100644 testsuite/poke.cmd/dump-11.pk
diff --git a/ChangeLog b/ChangeLog
index c9a6a721..d18e7e29 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2021-03-27 Jose E. Marchesi <jemarch@gnu.org>
+
+ * libpoke/ios-dev-mem.c (ios_dev_mem_open): Memory IOS are always
+ read/write.
+ * poke/pk-dump.pk (Arguments): Raise E_perm if the specified IOS
+ is not readable.
+ * testsuite/poke.cmd/dump-10.pk: New test.
+ * testsuite/poke.cmd/dump-11.pk: Likewise.
+ * testsuite/Makefile.am (EXTRA_DIST): Add new test.
+
2021-03-27 Jose E. Marchesi <jemarch@gnu.org>
* libpoke/pkl-tab.y (builtin): Rule for BUILTIN_IOFLAGS.
diff --git a/libpoke/ios-dev-mem.c b/libpoke/ios-dev-mem.c
index 8b8c9006..d49d8b52 100644
--- a/libpoke/ios-dev-mem.c
+++ b/libpoke/ios-dev-mem.c
@@ -75,7 +75,7 @@ ios_dev_mem_open (const char *handler, uint64_t flags, int
*error)
}
mio->size = MEM_STEP;
- mio->flags = flags;
+ mio->flags = IOS_F_READ | IOS_F_WRITE;
if (error)
*error = IOD_OK;
diff --git a/poke/pk-dump.pk b/poke/pk-dump.pk
index e6d99c77..38ef5677 100644
--- a/poke/pk-dump.pk
+++ b/poke/pk-dump.pk
@@ -187,6 +187,11 @@ fun dump = (int<32> ios = get_ios,
}
}
+ /* First of all, we require a readable IO space. */
+ if (! (ioflags (ios) & IOS_F_READ))
+ /* XXX change to E_perm when it becomes available. */
+ raise E_no_ios;
+
/* The `dump' command is byte-oriented.
The base offset is truncated to bytes.
The offset is rounded up to the next byte. */
diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am
index 29440fae..980fb9eb 100644
--- a/testsuite/Makefile.am
+++ b/testsuite/Makefile.am
@@ -69,6 +69,8 @@ EXTRA_DIST = \
poke.cmd/dump-7.pk \
poke.cmd/dump-8.pk \
poke.cmd/dump-9.pk \
+ poke.cmd/dump-10.pk \
+ poke.cmd/dump-11.pk \
poke.cmd/extract-1.pk \
poke.cmd/file-mode.pk \
poke.cmd/file-relative.pk \
diff --git a/testsuite/poke.cmd/dump-10.pk b/testsuite/poke.cmd/dump-10.pk
new file mode 100644
index 00000000..80ef97cf
--- /dev/null
+++ b/testsuite/poke.cmd/dump-10.pk
@@ -0,0 +1,7 @@
+/* { dg-do run } */
+/* { dg-data {c*} {0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80} foo } */
+
+/* { dg-command { var input = open ("foo", IOS_M_WRONLY) } } */
+/* XXX change to E_perm when it becomes available */
+/* { dg-command { try dump :ios input; catch if E_no_ios { print "caught\n"; }
} } */
+/* { dg-output "caught" } */
diff --git a/testsuite/poke.cmd/dump-11.pk b/testsuite/poke.cmd/dump-11.pk
new file mode 100644
index 00000000..d13f9134
--- /dev/null
+++ b/testsuite/poke.cmd/dump-11.pk
@@ -0,0 +1,4 @@
+/* { dg-do run } */
+
+/* { dg-command { try dump; catch if E_no_ios { print "caught\n"; } } } */
+/* { dg-output "caught" } */
--
2.25.0.2.g232378479e
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [COMMITTED] poke, ios: dump should not print anything if the IOS is not readable,
Jose E. Marchesi <=