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)? > > 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?
(after a bit of reading POSIX): I think a switch statement should handle these; O_RDONLY and O_RDWR intuitively, everything else (O_EXEC, O_SEARCH, O_WRONLY) should be rejected. Laszlo _______________________________________________ Libguestfs mailing list [email protected] https://listman.redhat.com/mailman/listinfo/libguestfs
