Hi, is it possible to implement something like losetup --find with NBD? i.e. is there a safe method to grab the next free /dev/nbdX without disturbing anything. (in your own program that makes use of NBD)
The nbd-client leaves it to the user to provide a free /dev/nbdX on the command line. If the user gets it wrong, and tries to start two clients on the same device, both clients fail and any further requests to that device result in I/O errors. My attempt was to call NBD_SET_SOCK ioctl first, which only succeeds when the device was free. However doing so, subsequent ioctl (like BLKROSET) seem to fail, and in nbd-client itself, the SET_SOCK is the last ioctl before DO_IT, rather than the first, so I guess it's not supposed to be used this way? Checking /sys/block/nbd*/pid does not seem to be entirely reliable either, as it seems to be only set on the DO_IT, so if two programs search for a free device at the same time, they might race. Is there something I'm missing? Are there any NBD programs that do not ask the user for the /dev/nbdX so I might have a look at what they've done about it? Regards Andreas Klauer ------------------------------------------------------------------------------ Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce. With Perforce, you get hassle-free workflows. Merge that actually works. Faster operations. Version large binaries. Built-in WAN optimization and the freedom to use Git, Perforce or both. Make the move to Perforce. http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk _______________________________________________ Nbd-general mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/nbd-general
