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

2022-08-18 Thread Eric Blake
On Thu, Aug 18, 2022 at 04:36:13PM +0100, Richard W.M. Jones wrote: > This is what I pushed - how does it look? I ignored the cases we > cannot deal with, except O_WRONLY where I emit a debug message but > continue: > > https://gitlab.com/nbdkit/nbdkit/-/blob/master/plugins/file/file.c#L572 > >

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

2022-08-18 Thread Richard W.M. Jones
On Thu, Aug 18, 2022 at 10:28:17AM -0500, Eric Blake wrote: > On Wed, Aug 17, 2022 at 10:56:58PM +0100, Richard W.M. Jones wrote: > > 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? > > > >

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

2022-08-18 Thread Eric Blake
On Wed, Aug 17, 2022 at 10:56:58PM +0100, Richard W.M. Jones wrote: > 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. More like 5-state (by

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

2022-08-18 Thread Laszlo Ersek
On 08/17/22 23:56, Richard W.M. Jones wrote: > 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)? > >

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

2022-08-17 Thread Richard W.M. Jones
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 &=

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

2022-08-17 Thread Richard W.M. Jones
On Wed, Aug 17, 2022 at 03:57:24PM -0500, Eric Blake wrote: > On Wed, Aug 17, 2022 at 04:38:11PM +0100, Richard W.M. Jones wrote: > > This allows you to pass in a file descriptor to the plugin, eg: > > > > $ exec 6<>/var/tmp/fedora-36.img > > $ ./nbdkit file fd=6 --run 'nbdinfo $uri' > > > >

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

2022-08-17 Thread Eric Blake
On Wed, Aug 17, 2022 at 04:38:11PM +0100, Richard W.M. Jones wrote: > This allows you to pass in a file descriptor to the plugin, eg: > > $ exec 6<>/var/tmp/fedora-36.img > $ ./nbdkit file fd=6 --run 'nbdinfo $uri' > > Note this was previously possible on most platforms using /dev/fd/, > but

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

2022-08-17 Thread Richard W.M. Jones
This allows you to pass in a file descriptor to the plugin, eg: $ exec 6<>/var/tmp/fedora-36.img $ ./nbdkit file fd=6 --run 'nbdinfo $uri' Note this was previously possible on most platforms using /dev/fd/, but not all platforms that have file descriptors support this (although it is POSIX)