char *ret = NULL;
while (conf_dir_list[i]) {
- if (!access(conf_dir_list[i], F_OK)) {
+ if (virFileExists(conf_dir_list[i])) {
ignore_value(VIR_STRDUP(ret, conf_dir_list[i]));
goto cleanup;
}
"DiskDescriptor", ".xml")))
goto cleanup;
- if (access(diskDescPath, F_OK))
+ if (!virFileExists(diskDescPath))
continue;
/* here we know, that ent->d_name is a disk image directory */
if (!binary)
return 0;
- if (access("/dev/kvm", F_OK) == 0 &&
+ if (virFileExists("/dev/kvm") &&
(virQEMUCapsGet(qemubinCaps, QEMU_CAPS_KVM) ||
virQEMUCapsGet(qemubinCaps, QEMU_CAPS_ENABLE_KVM) ||
kvmbin))
haskvm = true;
- if (access("/dev/kqemu", F_OK) == 0 &&
+ if (virFileExists("/dev/kqemu") &&
virQEMUCapsGet(qemubinCaps, QEMU_CAPS_KQEMU))
haskqemu = true;
#include "domain_audit.h"
#include "virscsi.h"
#include "virstring.h"
+#include "virfile.h"
#define VIR_FROM_THIS VIR_FROM_QEMU
}
for (i = 0; deviceACL[i] != NULL; i++) {
- if (access(deviceACL[i], F_OK) < 0) {
- VIR_DEBUG("Ignoring non-existant device %s",
- deviceACL[i]);
+ if (!virFileExists(deviceACL[i])) {
+ VIR_DEBUG("Ignoring non-existant device %s", deviceACL[i]);
continue;
}
if (vm->def->virtType == VIR_DOMAIN_VIRT_KVM) {
VIR_DEBUG("Checking for KVM availability");
- if (access("/dev/kvm", F_OK) != 0) {
+ if (!virFileExists("/dev/kvm")) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Domain requires KVM, but it is not available. "
"Check that virtualization is enabled in the host BIOS, "
virStoragePoolObjPtr pool,
bool *isActive)
{
- *isActive = false;
if (pool->def->type == VIR_STORAGE_POOL_DIR) {
- if (access(pool->def->target.path, F_OK) == 0)
- *isActive = true;
+ *isActive = virFileExists(pool->def->target.path);
#if WITH_STORAGE_FS
} else {
int ret;
+ *isActive = false;
if ((ret = virStorageBackendFileSystemIsMounted(pool)) != 0) {
if (ret < 0)
return -1;
virStoragePoolObjPtr pool,
bool *isActive)
{
- *isActive = (access(pool->def->target.path, F_OK) == 0);
+ *isActive = virFileExists(pool->def->target.path);
return 0;
}
virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
bool *isActive)
{
- const char *path = "/dev/mpath";
-
- *isActive = false;
-
- if (access(path, F_OK) == 0)
- *isActive = true;
-
+ *isActive = virFileExists("/dev/mpath");
return 0;
}
if (virAsprintf(&path, "/sys/class/scsi_host/host%d", host) < 0)
goto cleanup;
- if (access(path, F_OK) == 0)
- *isActive = true;
+ *isActive = virFileExists(path);
ret = 0;
cleanup:
sa_assert(group->controllers[i].mountPoint);
VIR_DEBUG("Make controller %s", path);
- if (access(path, F_OK) != 0) {
+ if (!virFileExists(path)) {
if (!create ||
mkdir(path, 0755) < 0) {
/* With a kernel that doesn't support multi-level directory
devname) < 0)
return -1;
- if (access(path, F_OK) < 0) {
+ if (!virFileExists(path)) {
if (errno == ENOENT)
ret = 0;
else
dev->name) < 0)
goto error;
- if (access(dev->path, F_OK) != 0) {
+ if (!virFileExists(dev->path)) {
virReportSystemError(errno,
_("Device %s not found: could not access %s"),
dev->name, dev->path);
virAsprintf(&dev->sg_path, "/dev/%s", sg) < 0)
goto cleanup;
- if (access(dev->sg_path, F_OK) != 0) {
+ if (!virFileExists(dev->sg_path)) {
virReportSystemError(errno,
_("SCSI device '%s': could not access %s"),
dev->name, dev->sg_path);
host) < 0)
return false;
- if (access(sysfs_path, F_OK) == 0)
+ if (virFileExists(sysfs_path))
ret = true;
VIR_FREE(sysfs_path);
"vport_create") < 0)
goto cleanup;
- if ((access(fc_host_path, F_OK) == 0) ||
- (access(scsi_host_path, F_OK) == 0))
+ if (virFileExists(fc_host_path) ||
+ virFileExists(scsi_host_path))
ret = true;
cleanup: