This makes it consistent with other nbd_is_* and nbd_can_* APIs. Suggested by Thomas Haller. --- docs/libnbd.pod | 2 +- examples/batched-read-write.c | 2 +- examples/simple-reads-and-writes.c | 2 +- examples/threaded-reads-and-writes.c | 2 +- generator/generator | 2 +- lib/flags.c | 2 +- lib/rw.c | 6 +++--- tests/aio-parallel-load.c | 2 +- tests/aio-parallel.c | 2 +- tests/read-only-flag.c | 4 ++-- tests/read-write-flag.c | 4 ++-- tests/synch-parallel.c | 2 +- 12 files changed, 16 insertions(+), 16 deletions(-) diff --git a/docs/libnbd.pod b/docs/libnbd.pod index 74227fd..6a329d6 100644 --- a/docs/libnbd.pod +++ b/docs/libnbd.pod @@ -383,7 +383,7 @@ the export, such as whether it is writable and if it can support flush to permanent storage. These flags can be accessed from libnbd using APIs such as: - int is_read_only = nbd_read_only (nbd); + int is_read_only = nbd_is_read_only (nbd); int can_flush = nbd_can_flush (nbd); (and several more, see L<libnbd-api(3)>). diff --git a/examples/batched-read-write.c b/examples/batched-read-write.c index 9d2c02b..d39a1e5 100644 --- a/examples/batched-read-write.c +++ b/examples/batched-read-write.c @@ -160,7 +160,7 @@ main (int argc, char *argv[]) } } - if (nbd_read_only (nbd) == 1) { + if (nbd_is_read_only (nbd) == 1) { fprintf (stderr, "%s: error: this NBD export is read-only\n", argv[0]); exit (EXIT_FAILURE); } diff --git a/examples/simple-reads-and-writes.c b/examples/simple-reads-and-writes.c index 0c80e6d..b429d2f 100644 --- a/examples/simple-reads-and-writes.c +++ b/examples/simple-reads-and-writes.c @@ -47,7 +47,7 @@ main (int argc, char *argv[]) } assert (exportsize >= sizeof buf); - if (nbd_read_only (nbd) == 1) { + if (nbd_is_read_only (nbd) == 1) { fprintf (stderr, "%s: error: this NBD export is read-only\n", argv[0]); exit (EXIT_FAILURE); } diff --git a/examples/threaded-reads-and-writes.c b/examples/threaded-reads-and-writes.c index 5fff50c..85d6e42 100644 --- a/examples/threaded-reads-and-writes.c +++ b/examples/threaded-reads-and-writes.c @@ -116,7 +116,7 @@ main (int argc, char *argv[]) exit (EXIT_FAILURE); } - if (nbd_read_only (nbd) == 1) { + if (nbd_is_read_only (nbd) == 1) { fprintf (stderr, "%s: error: this NBD export is read-only\n", argv[0]); exit (EXIT_FAILURE); } diff --git a/generator/generator b/generator/generator index 7328438..132d6cb 100755 --- a/generator/generator +++ b/generator/generator @@ -1231,7 +1231,7 @@ behave like inetd clients, such as C<nbdkit --single>. See also C<nbd_kill_command>."; }; - "read_only", { + "is_read_only", { default_call with args = []; ret = RBool; permitted_states = [ Connected; Closed ]; diff --git a/lib/flags.c b/lib/flags.c index cdbc28f..2bcacb8 100644 --- a/lib/flags.c +++ b/lib/flags.c @@ -65,7 +65,7 @@ get_flag (struct nbd_handle *h, uint16_t flag) } int -nbd_unlocked_read_only (struct nbd_handle *h) +nbd_unlocked_is_read_only (struct nbd_handle *h) { return get_flag (h, NBD_FLAG_READ_ONLY); } diff --git a/lib/rw.c b/lib/rw.c index bba62be..50ba23d 100644 --- a/lib/rw.c +++ b/lib/rw.c @@ -341,7 +341,7 @@ nbd_unlocked_aio_pwrite_callback (struct nbd_handle *h, const void *buf, { struct command_cb cb = { .completion = completion, .user_data = user_data, }; - if (nbd_unlocked_read_only (h) == 1) { + if (nbd_unlocked_is_read_only (h) == 1) { set_error (EINVAL, "server does not support write operations"); return -1; } @@ -406,7 +406,7 @@ nbd_unlocked_aio_trim_callback (struct nbd_handle *h, { struct command_cb cb = { .completion = completion, .user_data = user_data, }; - if (nbd_unlocked_read_only (h) == 1) { + if (nbd_unlocked_is_read_only (h) == 1) { set_error (EINVAL, "server does not support write operations"); return -1; } @@ -482,7 +482,7 @@ nbd_unlocked_aio_zero_callback (struct nbd_handle *h, { struct command_cb cb = { .completion = completion, .user_data = user_data, }; - if (nbd_unlocked_read_only (h) == 1) { + if (nbd_unlocked_is_read_only (h) == 1) { set_error (EINVAL, "server does not support write operations"); return -1; } diff --git a/tests/aio-parallel-load.c b/tests/aio-parallel-load.c index ce39140..f4ba635 100644 --- a/tests/aio-parallel-load.c +++ b/tests/aio-parallel-load.c @@ -231,7 +231,7 @@ start_thread (void *arg) assert (nbd_get_size (nbd) == EXPORTSIZE); assert (nbd_can_multi_conn (nbd) > 0); - assert (nbd_read_only (nbd) == 0); + assert (nbd_is_read_only (nbd) == 0); /* Issue commands. */ assert (nbd_aio_in_flight (nbd) == 0); diff --git a/tests/aio-parallel.c b/tests/aio-parallel.c index 166b560..f8d4891 100644 --- a/tests/aio-parallel.c +++ b/tests/aio-parallel.c @@ -239,7 +239,7 @@ start_thread (void *arg) assert (nbd_get_size (nbd) == EXPORTSIZE); assert (nbd_can_multi_conn (nbd) > 0); - assert (nbd_read_only (nbd) == 0); + assert (nbd_is_read_only (nbd) == 0); /* Issue commands. */ assert (nbd_aio_in_flight (nbd) == 0); diff --git a/tests/read-only-flag.c b/tests/read-only-flag.c index da55bf8..7f51f74 100644 --- a/tests/read-only-flag.c +++ b/tests/read-only-flag.c @@ -16,7 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -/* Simple end-to-end test of nbdkit -r / nbd_read_only. */ +/* Simple end-to-end test of nbdkit -r / nbd_is_read_only. */ #include <config.h> @@ -43,7 +43,7 @@ main (int argc, char *argv[]) exit (EXIT_FAILURE); } - if ((r = nbd_read_only (nbd)) == -1) { + if ((r = nbd_is_read_only (nbd)) == -1) { fprintf (stderr, "%s\n", nbd_get_error ()); exit (EXIT_FAILURE); } diff --git a/tests/read-write-flag.c b/tests/read-write-flag.c index 3e33473..ad14a46 100644 --- a/tests/read-write-flag.c +++ b/tests/read-write-flag.c @@ -16,7 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -/* Simple end-to-end test of nbdkit without -r / nbd_read_only. */ +/* Simple end-to-end test of nbdkit without -r / nbd_is_read_only. */ #include <config.h> @@ -42,7 +42,7 @@ main (int argc, char *argv[]) exit (EXIT_FAILURE); } - if ((r = nbd_read_only (nbd)) == -1) { + if ((r = nbd_is_read_only (nbd)) == -1) { fprintf (stderr, "%s\n", nbd_get_error ()); exit (EXIT_FAILURE); } diff --git a/tests/synch-parallel.c b/tests/synch-parallel.c index 136bc60..40df85d 100644 --- a/tests/synch-parallel.c +++ b/tests/synch-parallel.c @@ -207,7 +207,7 @@ start_thread (void *arg) assert (nbd_get_size (nbd) == EXPORTSIZE); assert (nbd_can_multi_conn (nbd) > 0); - assert (nbd_read_only (nbd) == 0); + assert (nbd_is_read_only (nbd) == 0); /* Issue commands. */ while (1) { -- 2.22.0