[Libguestfs] [PATCH nbdkit 2/2] file: Allow a file descriptor to be passed to the plugin

Richard W.M. Jones rjones at redhat.com
Wed Aug 17 21:56:58 UTC 2022


On Wed, Aug 17, 2022 at 10:37:00PM +0100, Richard W.M. Jones wrote:
> Is that actually possible?  “fcntl (fd, F_GETFL) & O_WRONLY”
> should do it?

So the answer is no as it's a kind of tri-state.

I think this should work (untested)?

  r = fcntl (fd, F_GETFL);
  if (r == -1) ...
  r &= O_ACCMODE;
  if (r == O_RDONLY)
    h->can_write = false;

There's also the case where r == O_WRONLY which the plugin (and NBD)
cannot deal with.  Not sure what to do about that - error?

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
libguestfs lets you edit virtual machines.  Supports shell scripting,
bindings from many languages.  http://libguestfs.org


More information about the Libguestfs mailing list