More instances of failure to report (unlikely) readdir errors.
In one case, I chose to ignore them, given that a readdir error
would be no different than timing out on the loop, where the
fallback path behaves correctly either way.
* src/storage/storage_backend.c (virStorageBackendStablePath):
Ignore readdir errors.
* src/storage/storage_backend_fs.c
(virStorageBackendFileSystemRefresh): Report readdir errors.
* src/storage/storage_backend_iscsi.c
(virStorageBackendISCSIGetHostNumber): Likewise.
* src/storage/storage_backend_scsi.c (getNewStyleBlockDevice)
(getBlockDevice, virStorageBackendSCSIFindLUs): Likewise.
Signed-off-by: Eric Blake <eblake@redhat.com>
char *stablepath;
int opentries = 0;
int retry = 0;
+ int direrr;
/* Short circuit if pool has no target, or if its /dev */
if (pool->def->target.path == NULL ||
* to this device node.
*
* And it might need some time till the stable path shows
- * up, so add timeout to retry here.
+ * up, so add timeout to retry here. Ignore readdir failures,
+ * since we have a fallback.
*/
retry:
- while ((dent = readdir(dh)) != NULL) {
+ while ((direrr = virDirRead(dh, &dent, NULL)) > 0) {
if (dent->d_name[0] == '.')
continue;
VIR_FREE(stablepath);
}
- if (loop && ++retry < 100) {
+ if (!direrr && loop && ++retry < 100) {
usleep(100 * 1000);
goto retry;
}
struct dirent *ent;
struct statvfs sb;
virStorageVolDefPtr vol = NULL;
+ int direrr;
if (!(dir = opendir(pool->def->target.path))) {
virReportSystemError(errno,
goto cleanup;
}
- while ((ent = readdir(dir)) != NULL) {
+ while ((direrr = virDirRead(dir, &ent, pool->def->target.path)) > 0) {
int ret;
char *backingStore;
int backingStoreFormat;
if (VIR_APPEND_ELEMENT(pool->volumes.objs, pool->volumes.count, vol) < 0)
goto cleanup;
}
+ if (direrr < 0)
+ goto cleanup;
closedir(dir);
-
if (statvfs(pool->def->target.path, &sb) < 0) {
virReportSystemError(errno,
_("cannot statvfs path '%s'"),
int retval = 0;
DIR *sysdir = NULL;
struct dirent *dirent = NULL;
+ int direrr;
VIR_DEBUG("Finding host number from '%s'", sysfs_path);
goto out;
}
- while ((dirent = readdir(sysdir))) {
+ while ((direrr = virDirRead(sysdir, &dirent, sysfs_path)) > 0) {
if (STREQLEN(dirent->d_name, "target", strlen("target"))) {
if (sscanf(dirent->d_name,
"target%u:", host) != 1) {
}
}
}
+ if (direrr < 0)
+ retval = -1;
closedir(sysdir);
out:
DIR *block_dir = NULL;
struct dirent *block_dirent = NULL;
int retval = 0;
+ int direrr;
if (virAsprintf(&block_path, "%s/block", lun_path) < 0)
goto out;
goto out;
}
- while ((block_dirent = readdir(block_dir))) {
+ while ((direrr = virDirRead(block_dir, &block_dirent, block_path)) > 0) {
if (STREQLEN(block_dirent->d_name, ".", 1)) {
continue;
break;
}
+ if (direrr < 0)
+ retval = -1;
closedir(block_dir);
DIR *lun_dir = NULL;
struct dirent *lun_dirent = NULL;
int retval = 0;
+ int direrr;
if (virAsprintf(&lun_path, "/sys/bus/scsi/devices/%u:%u:%u:%u",
host, bus, target, lun) < 0)
goto out;
}
- while ((lun_dirent = readdir(lun_dir))) {
+ while ((direrr = virDirRead(lun_dir, &lun_dirent, lun_path)) > 0) {
if (STREQLEN(lun_dirent->d_name, "block", 5)) {
if (strlen(lun_dirent->d_name) == 5) {
retval = getNewStyleBlockDevice(lun_path,
snprintf(devicepattern, sizeof(devicepattern), "%u:%%u:%%u:%%u\n", scanhost);
- while ((lun_dirent = readdir(devicedir))) {
+ while ((retval = virDirRead(devicedir, &lun_dirent, device_path)) > 0) {
if (sscanf(lun_dirent->d_name, devicepattern,
&bus, &target, &lun) != 3) {
continue;