nbd: Return correct error for write to read-only export
authorEric Blake <eblake@redhat.com>
Wed, 6 Apr 2016 03:35:02 +0000 (21:35 -0600)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 7 Apr 2016 22:07:43 +0000 (00:07 +0200)
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

index b95571bdf5259688b99ad6540e5bd7681f2a00b2..98e39576053c22fe9d47af4c08ccf600251bc357 100644 (file)
@@ -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;