Mapping of EOVERFLOW was missed in commit 6f8c8084. Mapping of EOPNOTSUPP is essential for .zero to trigger a fallback to .pwrite, missed in commit 6c0e00e9 (not to mention that it becomes a valid protocol failure once fast zero support is added). There is no Unix.ENOTSUP, or that would get the same treatment per commit abb2b47c. Preserving EROFS and EFBIG is useful because protocol.c special-cases those (by merging them into EPERM and ENOSPC over the wire). There is no Unix.EDQUOT, or that would get the same treatment. Signed-off-by: Eric Blake <eblake@redhat.com> --- plugins/ocaml/ocaml.c | 7 +++++++ plugins/ocaml/NBDKit.ml | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/plugins/ocaml/ocaml.c b/plugins/ocaml/ocaml.c index 064cdedb..5161775f 100644 --- a/plugins/ocaml/ocaml.c +++ b/plugins/ocaml/ocaml.c @@ -849,12 +849,19 @@ ocaml_nbdkit_set_error (value nv) int err; switch (Int_val (nv)) { + /* On-the-wire values */ case 1: err = EPERM; break; case 2: err = EIO; break; case 3: err = ENOMEM; break; case 4: err = EINVAL; break; case 5: err = ENOSPC; break; case 6: err = ESHUTDOWN; break; + case 7: err = EOVERFLOW; break; + /* Necessary for .zero support */ + case 8: err = ENOTSUP; break; + /* Other errno that server/protocol.c treats specially */ + case 9: err = EROFS; break; + case 10: err = EFBIG; break; default: abort (); } diff --git a/plugins/ocaml/NBDKit.ml b/plugins/ocaml/NBDKit.ml index 68d15836..e54a7705 100644 --- a/plugins/ocaml/NBDKit.ml +++ b/plugins/ocaml/NBDKit.ml @@ -267,6 +267,10 @@ let set_error unix_error | Unix.EINVAL -> 4 | Unix.ENOSPC -> 5 | Unix.ESHUTDOWN -> 6 + | Unix.EOVERFLOW -> 7 + | Unix.EOPNOTSUPP -> 8 + | Unix.EROFS -> 9 + | Unix.EFBIG -> 10 | _ -> 4 (* EINVAL *) in _set_error nbd_error -- 2.20.1
Richard W.M. Jones
2019-Aug-16 17:24 UTC
Re: [Libguestfs] [nbdkit PATCH] ocaml: Map more errno values
On Fri, Aug 16, 2019 at 08:29:28AM -0500, Eric Blake wrote:> --- a/plugins/ocaml/ocaml.c > +++ b/plugins/ocaml/ocaml.c > @@ -849,12 +849,19 @@ ocaml_nbdkit_set_error (value nv) > int err; > > switch (Int_val (nv)) { > + /* On-the-wire values */Not sure about this comment. The values on the left match the values in NBDKit.ml's ‘set_error’ function, and are basically internal to the OCaml bindings. The values on the right are from <errno.h> and AIUI they might be unrelated to what is sent on the wire (especially on non-Linux). Nevertheless the implementation is still correct, so ACK. Rich.> case 1: err = EPERM; break; > case 2: err = EIO; break; > case 3: err = ENOMEM; break; > case 4: err = EINVAL; break; > case 5: err = ENOSPC; break; > case 6: err = ESHUTDOWN; break; > + case 7: err = EOVERFLOW; break; > + /* Necessary for .zero support */ > + case 8: err = ENOTSUP; break; > + /* Other errno that server/protocol.c treats specially */ > + case 9: err = EROFS; break; > + case 10: err = EFBIG; break; > default: abort (); > } > > diff --git a/plugins/ocaml/NBDKit.ml b/plugins/ocaml/NBDKit.ml > index 68d15836..e54a7705 100644 > --- a/plugins/ocaml/NBDKit.ml > +++ b/plugins/ocaml/NBDKit.ml > @@ -267,6 +267,10 @@ let set_error unix_error > | Unix.EINVAL -> 4 > | Unix.ENOSPC -> 5 > | Unix.ESHUTDOWN -> 6 > + | Unix.EOVERFLOW -> 7 > + | Unix.EOPNOTSUPP -> 8 > + | Unix.EROFS -> 9 > + | Unix.EFBIG -> 10 > | _ -> 4 (* EINVAL *) in > > _set_error nbd_error > -- > 2.20.1 > > _______________________________________________ > Libguestfs mailing list > Libguestfs@redhat.com > https://www.redhat.com/mailman/listinfo/libguestfs-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW
Seemingly Similar Threads
- [PATCH nbdkit] common/include: Add locale-safe ascii_strcasecmp and ascii_strncasecmp.
- [nbdkit PATCH] sh: Parse a larger number of error messages
- [nbdkit PATCH 1/3] server: Add internal support for NBDKIT_FLAG_FAST_ZERO
- [nbdkit PATCH v2 3/6] protocol: Support ESHUTDOWN error
- Re: [nbdkit PATCH 3/7] RFC: protocol: Only send EOVERFLOW when valid