return 0;
}
- errno = 0;
- while ((dent = readdir(dp))) {
+ while ((ret = virDirRead(dp, &dent, conf_dir)) > 0) {
if (virStrToLong_i(dent->d_name, &ext, 10, &vpsid) < 0 ||
*ext++ != '.' ||
STRNEQ(ext, "conf"))
continue;
if (vpsid > 0) /* '0.conf' belongs to the host, ignore it */
openvzSetUUID(vpsid);
- errno = 0;
- }
- if (errno) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Failed to scan configuration directory"));
- ret = -1;
}
closedir(dp);
struct dirent *ent;
char *path = NULL;
int ret = -1;
+ int direrr;
if (!(dir = opendir(pool->def->target.path))) {
virReportSystemError(errno,
return -1;
}
- while ((ent = readdir(dir)) != NULL) {
+ while ((direrr = virDirRead(dir, &ent, pool->def->target.path)) > 0) {
if (!virFileHasSuffix(ent->d_name, ".xml"))
continue;
VIR_FREE(path);
}
+ if (direrr < 0)
+ goto cleanup;
ret = 0;
cleanup:
char *diskPath = NULL, *diskDescPath = NULL;
struct stat sb;
int ret = -1;
+ int direrr;
if (!(dir = opendir(pdom->home))) {
virReportSystemError(errno,
goto cleanup;
}
- while ((ent = readdir(dir)) != NULL) {
+ while ((direrr = virDirRead(dir, &ent, pdom->home)) > 0) {
VIR_FREE(diskPath);
VIR_FREE(diskDescPath);
if (parallelsAddDiskVolume(pool, dom, ent->d_name,
diskPath, diskDescPath))
goto cleanup;
-
}
+ if (direrr < 0)
+ goto cleanup;
ret = 0;
cleanup:
VIR_DOMAIN_SNAPSHOT_PARSE_INTERNAL);
int ret = -1;
virCapsPtr caps = NULL;
+ int direrr;
virObjectLock(vm);
if (virAsprintf(&snapDir, "%s/%s", baseDir, vm->def->name) < 0) {
goto cleanup;
}
- while ((entry = readdir(dir))) {
+ while ((direrr = virDirRead(dir, &entry, NULL)) > 0) {
if (entry->d_name[0] == '.')
continue;
VIR_FREE(fullpath);
VIR_FREE(xmlStr);
}
+ if (direrr < 0)
+ VIR_ERROR(_("Failed to fully read directory %s"), snapDir);
if (vm->current_snapshot != current) {
VIR_ERROR(_("Too many snapshots claiming to be current for domain %s"),
/*
* qemu_hostdev.c: QEMU hostdev management
*
- * Copyright (C) 2006-2007, 2009-2013 Red Hat, Inc.
+ * Copyright (C) 2006-2007, 2009-2014 Red Hat, Inc.
* Copyright (C) 2006 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
DIR *iommuDir = NULL;
struct dirent *iommuGroup = NULL;
bool ret = false;
+ int direrr;
/* condition 1 - /sys/kernel/iommu_groups/ contains entries */
if (!(iommuDir = opendir("/sys/kernel/iommu_groups/")))
goto cleanup;
- while ((iommuGroup = readdir(iommuDir))) {
+ while ((direrr = virDirRead(iommuDir, &iommuGroup, NULL)) > 0) {
/* skip ./ ../ */
if (STRPREFIX(iommuGroup->d_name, "."))
continue;
break;
}
- if (!iommuGroup)
+ if (direrr < 0 || !iommuGroup)
goto cleanup;
/* okay, iommu is on and recognizes groups */
/*
* secret_driver.c: local driver for secret manipulation API
*
- * Copyright (C) 2009-2012, 2014 Red Hat, Inc.
+ * Copyright (C) 2009-2014 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
driver->directory);
goto cleanup;
}
- while ((de = readdir(dir)) != NULL) {
+ while (virDirRead(dir, &de, NULL) > 0) {
virSecretEntryPtr secret;
if (STREQ(de->d_name, ".") || STREQ(de->d_name, ".."))
}
listInsert(&list, secret);
}
- /* Ignore error reported by readdir(), if any. It's better to keep the
+ /* Ignore error reported by readdir, if any. It's better to keep the
secrets we managed to find. */
while (list != NULL) {
* /etc/xen
* /var/lib/xend/domains
*
- * Copyright (C) 2010-2013 Red Hat, Inc.
+ * Copyright (C) 2010-2014 Red Hat, Inc.
* Copyright (C) 2008 VirtualIron
*
* This library is free software; you can redistribute it and/or
struct dirent *ent;
char *path;
xenUnifiedPrivatePtr priv = conn->privateData;
+ int direrr;
virCheckFlags(VIR_CONNECT_RO, -1);
priv->configDir);
return -1;
}
- while ((ent = readdir(dh))) {
+ while ((direrr = virDirRead(dh, &ent, priv->configDir)) > 0) {
if (STRPREFIX(ent->d_name, "."))
continue;
VIR_FREE(path);
}
closedir(dh);
+ if (direrr < 0)
+ return -1;
}
if ((priv->inotifyFD = inotify_init()) < 0) {
return -1;
}
- while ((ent = readdir(dh))) {
+ while ((ret = virDirRead(dh, &ent, priv->configDir)) > 0) {
struct stat st;
char *path;
args.now = now;
args.priv = priv;
virHashRemoveSet(priv->configCache, xenXMConfigReaper, &args);
- ret = 0;
closedir(dh);