aboutsummaryrefslogtreecommitdiff
path: root/nbd
diff options
context:
space:
mode:
Diffstat (limited to 'nbd')
-rw-r--r--nbd/common.c27
-rw-r--r--nbd/nbd-internal.h2
-rw-r--r--nbd/server.c2
3 files changed, 30 insertions, 1 deletions
diff --git a/nbd/common.c b/nbd/common.c
index 593904f..6047d71 100644
--- a/nbd/common.c
+++ b/nbd/common.c
@@ -151,6 +151,28 @@ const char *nbd_cmd_lookup(uint16_t cmd)
}
+const char *nbd_reply_type_lookup(uint16_t type)
+{
+ switch (type) {
+ case NBD_REPLY_TYPE_NONE:
+ return "none";
+ case NBD_REPLY_TYPE_OFFSET_DATA:
+ return "data";
+ case NBD_REPLY_TYPE_OFFSET_HOLE:
+ return "hole";
+ case NBD_REPLY_TYPE_ERROR:
+ return "generic error";
+ case NBD_REPLY_TYPE_ERROR_OFFSET:
+ return "error at offset";
+ default:
+ if (type & (1 << 15)) {
+ return "<unknown error>";
+ }
+ return "<unknown>";
+ }
+}
+
+
const char *nbd_err_lookup(int err)
{
switch (err) {
@@ -166,6 +188,8 @@ const char *nbd_err_lookup(int err)
return "EINVAL";
case NBD_ENOSPC:
return "ENOSPC";
+ case NBD_EOVERFLOW:
+ return "EOVERFLOW";
case NBD_ESHUTDOWN:
return "ESHUTDOWN";
default:
@@ -193,6 +217,9 @@ int nbd_errno_to_system_errno(int err)
case NBD_ENOSPC:
ret = ENOSPC;
break;
+ case NBD_EOVERFLOW:
+ ret = EOVERFLOW;
+ break;
case NBD_ESHUTDOWN:
ret = ESHUTDOWN;
break;
diff --git a/nbd/nbd-internal.h b/nbd/nbd-internal.h
index df6c8b2..4f24d6e 100644
--- a/nbd/nbd-internal.h
+++ b/nbd/nbd-internal.h
@@ -47,7 +47,6 @@
#define NBD_OLDSTYLE_NEGOTIATE_SIZE (8 + 8 + 8 + 4 + 124)
#define NBD_REQUEST_MAGIC 0x25609513
-#define NBD_SIMPLE_REPLY_MAGIC 0x67446698
#define NBD_OPTS_MAGIC 0x49484156454F5054LL
#define NBD_CLIENT_MAGIC 0x0000420281861253LL
#define NBD_REP_MAGIC 0x0003e889045565a9LL
@@ -114,6 +113,7 @@ const char *nbd_opt_lookup(uint32_t opt);
const char *nbd_rep_lookup(uint32_t rep);
const char *nbd_info_lookup(uint16_t info);
const char *nbd_cmd_lookup(uint16_t info);
+const char *nbd_reply_type_lookup(uint16_t type);
const char *nbd_err_lookup(int err);
int nbd_drop(QIOChannel *ioc, size_t size, Error **errp);
diff --git a/nbd/server.c b/nbd/server.c
index 459e00c..efb6003 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -40,6 +40,8 @@ static int system_errno_to_nbd_errno(int err)
case EFBIG:
case ENOSPC:
return NBD_ENOSPC;
+ case EOVERFLOW:
+ return NBD_EOVERFLOW;
case ESHUTDOWN:
return NBD_ESHUTDOWN;
case EINVAL: