r279: * Mention -persist in nbd-client manpage
authoryoe <yoe>
Fri, 24 Aug 2007 21:47:36 +0000 (21:47 +0000)
committeryoe <yoe>
Fri, 24 Aug 2007 21:47:36 +0000 (21:47 +0000)
* Implement support for NBD_SET_TIMEOUT in anticipation of it being
  accepted into the kernel. #ifdef'ed out for the time being, anyway.

nbd-client.8.sgml
nbd-client.c

index e018a24..5362f85 100644 (file)
@@ -60,6 +60,8 @@ manpage.1: manpage.sgml
       <arg choice=plain><option><replaceable>port</replaceable></option></arg>
       <arg choice=plain><option><replaceable>nbd-device</replaceable></option></arg>
       <arg><option>-swap</option></arg>
+      <arg><option>-persist</option></arg>
+      <arg><option>-timeout <replaceable>timeout</replaceable></option></arg>
     </cmdsynopsis>
     <cmdsynopsis>
       <command>&dhpackage;</command>
index f4836c5..8771d40 100644 (file)
@@ -160,6 +160,7 @@ int main(int argc, char *argv[]) {
        char *hostname, *nbddev;
        int swap=0;
        int cont=0;
+       int timeout=0;
        u64 size64;
        u32 flags;
 
@@ -222,7 +223,7 @@ int main(int argc, char *argv[]) {
          err("Can not open NBD: %m");
        ++argv; --argc; /* skip device */
 
-       if (argc>2) goto errmsg;
+       if (argc>3) goto errmsg;
        if (argc!=0) {
                if(strncmp(argv[0], "-swap", 5)==0) {
                        swap=1;
@@ -235,6 +236,17 @@ int main(int argc, char *argv[]) {
                        ++argv;--argc;
                }
        }
+       if(argc!=0) {
+               if(strncmp(argv[0], "-timeout", 8)==0) {
+#ifdef NBD_SET_TIMEOUT
+                       timeout=strtol(++argv, NULL, 0);
+                       ++argv;--argc--;
+#else
+                       fprintf(stderr, "This nbd-client does not support -timeout yet; please recompile on a more recent kernel");
+                       exit(EXIT_FAILURE);
+#endif
+               }
+       }
        argv=NULL; argc=0; /* don't use it later suddenly */
 
        negotiate(sock, &size64, &flags);
@@ -249,6 +261,12 @@ int main(int argc, char *argv[]) {
                exit(0);
 #endif
 
+#ifdef NBD_SET_TIMEOUT
+       if(ioctl(nbd, NBD_SET_TIMEOUT, &timeout)<0) {
+               fprintf(stderr, "Setting timeout failed: %m");
+               exit(EXIT_FAILURE);
+       }
+#endif
        do {
                if (ioctl(nbd, NBD_DO_IT) < 0) {
                        fprintf(stderr, "Kernel call returned: %m");