]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
util: correct retry path in virFileOperation
authorEric Blake <eblake@redhat.com>
Wed, 2 Mar 2011 23:25:57 +0000 (16:25 -0700)
committerEric Blake <eblake@redhat.com>
Thu, 3 Mar 2011 15:12:08 +0000 (08:12 -0700)
In virFileOperation, the parent does a fallback to a non-fork
attempt if it detects that the child returned EACCES.  However,
the child was calling _exit(-EACCES), which does _not_ appear
as EACCES in the parent.

* src/util/util.c (virFileOperation): Correctly pass EACCES from
child to parent.

src/util/util.c

index bac71c80c211b498f561c57932da75b4bd02c609..f41e117d3980b0eabe841f6225b3facdfb9001cb 100644 (file)
@@ -1559,6 +1559,15 @@ parenterror:
         goto childerror;
     }
 childerror:
+    /* ret tracks -errno on failure, but exit value must be positive.
+     * If the child exits with EACCES, then the parent tries again.  */
+    /* XXX This makes assumptions about errno being < 255, which is
+     * not true on Hurd.  */
+    ret = -ret;
+    if ((ret & 0xff) != ret) {
+        VIR_WARN("unable to pass desired return value %d", ret);
+        ret = 0xff;
+    }
     _exit(ret);
 
 }