Return the right value on nbd-client -c
[nbd.git] / nbd-client.c
index 0e1da2b..8ba9264 100644 (file)
@@ -227,9 +227,10 @@ void finish_sock(int sock, int nbd, int swap) {
 
 void usage(void) {
        fprintf(stderr, "nbd-client version %s\n", PACKAGE_VERSION);
-       fprintf(stderr, "Usage: nbd-client [bs=blocksize] [timeout=sec] host port nbd_device [-swap] [-sdp] [-persist] [-nofork]\n");
+       fprintf(stderr, "Usage: nbd-client host port nbd_device [-block-size|-b block size] [-timeout|-t timeout] [-swap|-s] [-sdp|-S] [-persist|-p] [-nofork|-n]\n");
        fprintf(stderr, "Or   : nbd-client -d nbd_device\n");
        fprintf(stderr, "Or   : nbd-client -c nbd_device\n");
+       fprintf(stderr, "Or   : nbd-client -h|--help\n");
        fprintf(stderr, "Default value for blocksize is 1024 (recommended for ethernet)\n");
        fprintf(stderr, "Allowed values for blocksize are 512,1024,2048,4096\n"); /* will be checked in kernel :) */
        fprintf(stderr, "Note, that kernel 2.4.2 and older ones do not work correctly with\n");
@@ -283,6 +284,7 @@ int main(int argc, char *argv[]) {
                { "sdp", no_argument, NULL, 'S' },
                { "swap", no_argument, NULL, 's' },
                { "timeout", required_argument, NULL, 't' },
+               { 0, 0, 0, 0 }, 
        };
 
        logging();
@@ -329,8 +331,7 @@ int main(int argc, char *argv[]) {
                        blocksize=(int)strtol(optarg, NULL, 0);
                        break;
                case 'c':
-                       check_conn(optarg, 1);
-                       exit(EXIT_SUCCESS);
+                       return check_conn(optarg, 1);
                case 'd':
                        disconnect(optarg);
                        exit(EXIT_SUCCESS);