From f4c28dd68a53e8a1a579f9528a7032eebdbc487b Mon Sep 17 00:00:00 2001 From: Wouter Verhelst Date: Tue, 4 Aug 2009 09:01:21 +0200 Subject: [PATCH] Make incorrect use of timeout fail. When nbd-client is compiled on a system that does not support the timeout ioctl(), we now fail with an error message. Previously, the option would be silently ignored, which might not be optimal. --- nbd-client.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nbd-client.c b/nbd-client.c index 80dc816..3487eff 100644 --- a/nbd-client.c +++ b/nbd-client.c @@ -178,13 +178,15 @@ void setsizes(int nbd, u64 size64, int blocksize, u32 flags) { } void set_timeout(int nbd, int timeout) { -#ifdef NBD_SET_TIMEOUT if (timeout) { +#ifdef NBD_SET_TIMEOUT if (ioctl(nbd, NBD_SET_TIMEOUT, (unsigned long)timeout) < 0) err("Ioctl NBD_SET_TIMEOUT failed: %m\n"); fprintf(stderr, "timeout=%d\n", timeout); - } +#else + err("Ioctl NBD_SET_TIMEOUT cannot be called when compiled on a system that does not support it\n"); #endif + } } void finish_sock(int sock, int nbd, int swap) { -- 1.7.10.4