Richard W.M. Jones
2022-Aug-18 09:53 UTC
[Libguestfs] [PATCH nbdkit 1/2] file: Add an internal "mode"
This is upstream in 5 commits 5764fa6f4..dd28b0054: gitlab.com/nbdkit/nbdkit/-/commit/2620d95a4585204f0db0d55c0d41276d11970436 gitlab.com/nbdkit/nbdkit/-/commit/185e7d4010b353f36b5ca5d47467a770c530e58c gitlab.com/nbdkit/nbdkit/-/commit/17655b1ca67caa454e7a4ac83bc8c052b79a692d gitlab.com/nbdkit/nbdkit/-/commit/e7fdffde8142fb083625678b7a55455751185502 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 :-( Rich. -- Richard Jones, Virtualization Group, Red Hat people.redhat.com/~rjones Read my programming and virtualization blog: rwmj.wordpress.com virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. people.redhat.com/~rjones/virt-top
Laszlo Ersek
2022-Aug-18 10:30 UTC
[Libguestfs] [PATCH nbdkit 1/2] file: Add an internal "mode"
On 08/18/22 11:53, Richard W.M. Jones wrote:> > This is upstream in 5 commits 5764fa6f4..dd28b0054: > > gitlab.com/nbdkit/nbdkit/-/commit/2620d95a4585204f0db0d55c0d41276d11970436 > gitlab.com/nbdkit/nbdkit/-/commit/185e7d4010b353f36b5ca5d47467a770c530e58c > gitlab.com/nbdkit/nbdkit/-/commit/17655b1ca67caa454e7a4ac83bc8c052b79a692d > gitlab.com/nbdkit/nbdkit/-/commit/e7fdffde8142fb083625678b7a55455751185502 > 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 The latter is actually expected; it comes from open(). See EISDIR at <pubs.opengroup.org/onlinepubs/9699919799/functions/open.html>. Commit dd28b005430d also adds dfd = open (tmpdir, O_RDONLY | O_DIRECTORY); where I think O_DIRECTORY is not strictly necessary (per spec, because O_CREAT is absent, O_DIRECTORY only helps us refuse a non-directory -- but we do not expect such "attacks" here). So my take is that O_DIRECTORY could be dropped from the C code, at which point a bash redirection (read-only) should work just the same. Laszlo