On Tue, Mar 25, 2008 at 10:17:23AM +0100, Wouter Verhelst wrote: > On Wed, Mar 19, 2008 at 09:54:43AM -0700, Vagrant Cascadian wrote: > > i've often wondered how difficult it would be to provide a test for > > nbd-client to see if a device is active ... something like: > > > > nbd-client --active /dev/nbd0 > > > > would return 0 if a device was connected and (basically) functional, and > > non-zero if the device (maybe with different return codes for different > > cases). > This used to be very difficult, because the kernel did not expose > anything for a connected device; thus, you basically had to parse the > /proc tree and see whether any of the running processes is an nbd-client > process, and then parse its command line to figure out what it's doing. > Very ugly.
indeed. currently using "pgrep" to figure this stuff out. > However, as of 2.6.24, you can check for the existence of a file > "/sys/block/nbdN/pid"; if it exists, then the device is connected and > the pid file contains the PID of the nbd-client. Also, recent kernels > will set the size of an unconnected NBD device to 0 rather than > OFFT_MAX, which can help, too. this is surely useful! > If that satisfies you, please close this bug. it would still be nice if nbd-client or some other tool were available, because kernel interfaces tend to change over time. the tools themselves could handle these changes, as the authors and maintainers of nbd* are in a better position to stay updated on interface changes... but that requires someone maintaining code and tracking changes, which i'm not prepared to do at the moment. i could probably write a simple shell scripts to handle it- maybe that would at least be useful in doc/examples? thanks. live well, vagrant -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

