提交 d91f7dec 编写于 作者: O Osier Yang

nodedev: Use access instead of stat

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).
上级 244ce462
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <time.h> #include <time.h>
#include <sys/stat.h>
#include "virerror.h" #include "virerror.h"
#include "datatypes.h" #include "datatypes.h"
...@@ -422,7 +421,6 @@ nodeDeviceVportCreateDelete(const int parent_host, ...@@ -422,7 +421,6 @@ nodeDeviceVportCreateDelete(const int parent_host,
int retval = 0; int retval = 0;
char *operation_path = NULL, *vport_name = NULL; char *operation_path = NULL, *vport_name = NULL;
const char *operation_file = NULL; const char *operation_file = NULL;
struct stat st;
switch (operation) { switch (operation) {
case VPORT_CREATE: case VPORT_CREATE:
...@@ -450,7 +448,7 @@ nodeDeviceVportCreateDelete(const int parent_host, ...@@ -450,7 +448,7 @@ nodeDeviceVportCreateDelete(const int parent_host,
goto cleanup; goto cleanup;
} }
if (stat(operation_path, &st) != 0) { if (!virFileExists(operation_path)) {
VIR_FREE(operation_path); VIR_FREE(operation_path);
if (virAsprintf(&operation_path, if (virAsprintf(&operation_path,
"%shost%d%s", "%shost%d%s",
...@@ -462,7 +460,7 @@ nodeDeviceVportCreateDelete(const int parent_host, ...@@ -462,7 +460,7 @@ nodeDeviceVportCreateDelete(const int parent_host,
goto cleanup; goto cleanup;
} }
if (stat(operation_path, &st) != 0) { if (!virFileExists(operation_path)) {
VIR_ERROR(_("No vport operation path found for host%d"), VIR_ERROR(_("No vport operation path found for host%d"),
parent_host); parent_host);
retval = -1; retval = -1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册