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 > > > > > > > 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? > > > > Or allow it, but with the caveat that every NBD_CMD_READ will fail. > > The only reason to special case h->can_write=false for O_RDONLY is > > because then we don't advertise it to the client; to save them from > > getting failures on NBD_CMD_WRITE - but that's because it is an easy > > thing to advertise. Advertising that NBD_CMD_READ will fail is not > > easy (and less likely to happen in practice), so failing to serve the > > file is just as viable as serving it and letting every NBD_CMD_READ > > fail. > > That's basically what I did, plus a debug message :-)
What you have committed looks okay to me for handling the common case of O_RDONLY without worrying about the other cases. And if someone tries to play with passing in an fd opened under O_EXEC, they deserve whatever behavior happens naturally from that explicitly unusual corner-case. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org _______________________________________________ Libguestfs mailing list [email protected] https://listman.redhat.com/mailman/listinfo/libguestfs
