[Libguestfs] [PATCH nbdkit 1/2] file: Add an internal "mode"
Eric Blake
eblake at redhat.com
Thu Aug 18 15:31:13 UTC 2022
On Thu, Aug 18, 2022 at 12:30:21PM +0200, Laszlo Ersek wrote:
> On 08/18/22 11:53, Richard W.M. Jones wrote:
> >
> > This is upstream in 5 commits 5764fa6f4..dd28b0054:
> >
> > https://gitlab.com/nbdkit/nbdkit/-/commit/2620d95a4585204f0db0d55c0d41276d11970436
> > https://gitlab.com/nbdkit/nbdkit/-/commit/185e7d4010b353f36b5ca5d47467a770c530e58c
> > https://gitlab.com/nbdkit/nbdkit/-/commit/17655b1ca67caa454e7a4ac83bc8c052b79a692d
> > https://gitlab.com/nbdkit/nbdkit/-/commit/e7fdffde8142fb083625678b7a55455751185502
> > https://gitlab.com/nbdkit/nbdkit/-/commit/dd28b005430d020ccd1825437937c317332d3007
> >
> > This also includes dirfd functionality and a rather complicated test
> > for that. Turns out that bash refuses to open a directory as a file
> > descriptor :-(
>
> This doesn't match my experience; for me, bash opens e.g. /tmp just fine
> on both RHEL7 and Fedora35 -- but it must be a read-only open.
>
> $ exec 9</tmp
> [ok]
>
> $ exec 9<>/tmp
> bash: /tmp: Is a directory
Yep, POSIX forbids opening a directory with O_RDWR or O_WRONLY. But
just because a directory fd is read-only (we could also permit a
directory that was opened with O_SEARCH instead of O_RDONLY - except
that Linux O_SEARCH/O_EXEC support isn't quite yet in line with POSIX)
doesn't mean h->read_only should be set, because the read-only status
of the directory does not necessarily apply to files within the
directory.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
More information about the Libguestfs
mailing list