On Wed, Mar 19, 2008 at 09:54:43AM -0700, Vagrant Cascadian wrote: > Package: nbd-client > Version: 1:2.9.9-6 > Severity: wishlist > > 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. 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. If that satisfies you, please close this bug. -- <Lo-lan-do> Home is where you have to wash the dishes. -- #debian-devel, Freenode, 2004-09-22 -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

