From: Wouter Verhelst Date: Fri, 16 Oct 2009 08:52:18 +0000 (+0200) Subject: Document why this is necessary. X-Git-Url: http://git.alex.org.uk Document why this is necessary. --- diff --git a/nbd-client.c b/nbd-client.c index 9f67da4..9d0ad10 100644 --- a/nbd-client.c +++ b/nbd-client.c @@ -316,6 +316,17 @@ int main(int argc, char *argv[]) { if(!nofork) daemon(0,0); do { if (fork()) { + /* Due to a race, the kernel NBD driver cannot + * call for a reread of the partition table + * in the handling of the NBD_DO_IT ioctl(). + * Therefore, this is done in the first open() + * of the device. We therefore make sure that + * the device is opened at least once after the + * connection was made. This has to be done in a + * separate process, since the NBD_DO_IT ioctl() + * does not return until the NBD device has + * disconnected. + */ while(check_conn(nbddev, 0)) { sleep(1); }