]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
nodedev: Use access instead of stat
authorOsier Yang <jyang@redhat.com>
Mon, 7 Jan 2013 17:05:30 +0000 (01:05 +0800)
committerOsier Yang <jyang@redhat.com>
Mon, 25 Mar 2013 12:46:05 +0000 (20:46 +0800)
The use of 'stat' in nodeDeviceVportCreateDelete is only to check
if the file exists or not, it's a bit overkill, and safe to replace
with the wrapper of access(2) (virFileExists).

src/node_device/node_device_driver.c

index 64fd8316e3ac6b59be2b6fe0e7bf30f36fd7a09c..87e7e3ea3a7c39d6db4c44a1a49ce53389c88732 100644 (file)
@@ -28,7 +28,6 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <time.h>
-#include <sys/stat.h>
 
 #include "virerror.h"
 #include "datatypes.h"
@@ -422,7 +421,6 @@ nodeDeviceVportCreateDelete(const int parent_host,
     int retval = 0;
     char *operation_path = NULL, *vport_name = NULL;
     const char *operation_file = NULL;
-    struct stat st;
 
     switch (operation) {
     case VPORT_CREATE:
@@ -450,7 +448,7 @@ nodeDeviceVportCreateDelete(const int parent_host,
         goto cleanup;
     }
 
-    if (stat(operation_path, &st) != 0) {
+    if (!virFileExists(operation_path)) {
         VIR_FREE(operation_path);
         if (virAsprintf(&operation_path,
                         "%shost%d%s",
@@ -462,7 +460,7 @@ nodeDeviceVportCreateDelete(const int parent_host,
             goto cleanup;
         }
 
-        if (stat(operation_path, &st) != 0) {
+        if (!virFileExists(operation_path)) {
             VIR_ERROR(_("No vport operation path found for host%d"),
                       parent_host);
             retval = -1;