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

[Libguestfs] [nbdkit PATCH 1/2] nbd: Don't advertise writes if nbdkit is readonly



Although nbdkit connections.c currently calls but ignores the
value of nbd_can_write() if the user requested -r, it is still
better to update our internal flags so that nbd_can_write()
gives an answer consistent with how nbd_open() was called.

Signed-off-by: Eric Blake <eblake redhat com>
---
 plugins/nbd/nbd.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/plugins/nbd/nbd.c b/plugins/nbd/nbd.c
index df49a1d..b844bf5 100644
--- a/plugins/nbd/nbd.c
+++ b/plugins/nbd/nbd.c
@@ -504,6 +504,8 @@ nbd_open (int readonly)
     nbdkit_error ("unexpected version %#" PRIx64, version);
     goto err;
   }
+  if (readonly)
+    h->flags |= NBD_FLAG_READ_ONLY;

   /* Spawn a dedicated reader thread */
   if ((errno = pthread_mutex_init (&h->write_lock, NULL))) {
-- 
2.13.6


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