diff mbox

[PULL,04/15] nbd: Return correct error for write to read-only export

Message ID 1460047845-14488-5-git-send-email-pbonzini@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Paolo Bonzini April 7, 2016, 4:50 p.m. UTC
From: Eric Blake <eblake@redhat.com>

The NBD Protocol requires that servers should send EPERM for
attempts to write (or trim) a read-only export.  We were
correct for TRIM (blk_co_discard() gave EPERM); but were
manually setting EROFS which then got mapped to EINVAL over
the wire on writes.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1459913704-19949-2-git-send-email-eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 nbd/server.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox

Patch

diff --git a/nbd/server.c b/nbd/server.c
index b95571b..98e3957 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -26,6 +26,7 @@  static int system_errno_to_nbd_errno(int err)
     case 0:
         return NBD_SUCCESS;
     case EPERM:
+    case EROFS:
         return NBD_EPERM;
     case EIO:
         return NBD_EIO;