* Implement support for NBD_SET_TIMEOUT in anticipation of it being
accepted into the kernel. #ifdef'ed out for the time being, anyway.
<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 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>
</cmdsynopsis>
<cmdsynopsis>
<command>&dhpackage;</command>
char *hostname, *nbddev;
int swap=0;
int cont=0;
char *hostname, *nbddev;
int swap=0;
int cont=0;
err("Can not open NBD: %m");
++argv; --argc; /* skip device */
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;
if (argc!=0) {
if(strncmp(argv[0], "-swap", 5)==0) {
swap=1;
+ 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);
argv=NULL; argc=0; /* don't use it later suddenly */
negotiate(sock, &size64, &flags);
+#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");
do {
if (ioctl(nbd, NBD_DO_IT) < 0) {
fprintf(stderr, "Kernel call returned: %m");