Do not ignore hidden files in /sys and /proc

The directories we iterate over are unlikely to contain any entries
starting with a dot, other than '.' and '..' which is already skipped
by virDirRead.
This commit is contained in:
Ján Tomko 2016-06-21 17:29:47 +02:00
parent 852cd39830
commit 70a033ab42
9 changed files with 2 additions and 35 deletions

View File

@ -115,10 +115,6 @@ qemuHostdevHostSupportsPassthroughVFIO(void)
goto cleanup;
while ((direrr = virDirRead(iommuDir, &iommuGroup, NULL)) > 0) {
/* skip ./ ../ */
if (STRPREFIX(iommuGroup->d_name, "."))
continue;
/* assume we found a group */
break;
}

View File

@ -273,9 +273,6 @@ getNewStyleBlockDevice(const char *lun_path,
}
while ((direrr = virDirRead(block_dir, &block_dirent, block_path)) > 0) {
if (STREQLEN(block_dirent->d_name, ".", 1))
continue;
if (VIR_STRDUP(*block_device, block_dirent->d_name) < 0)
goto cleanup;

View File

@ -3392,7 +3392,6 @@ virCgroupRemoveRecursively(char *grppath)
while ((direrr = virDirRead(grpdir, &ent, NULL)) > 0) {
char *path;
if (ent->d_name[0] == '.') continue;
if (ent->d_type != DT_DIR) continue;
if (virAsprintf(&path, "%s/%s", grppath, ent->d_name) == -1) {

View File

@ -3172,8 +3172,6 @@ virNetDevRDMAFeature(const char *ifname,
goto cleanup;
while (virDirRead(dirp, &dp, SYSFS_INFINIBAND_DIR) > 0) {
if (dp->d_name[0] == '.')
continue;
if (virAsprintf(&ib_devpath, SYSFS_INFINIBAND_DIR "%s/device/resource",
dp->d_name) < 0)
continue;

View File

@ -471,10 +471,6 @@ virPCIDeviceIterDevices(virPCIDeviceIterPredicate predicate,
virPCIDevicePtr check;
char *tmp;
/* Ignore '.' and '..' */
if (entry->d_name[0] == '.')
continue;
/* expected format: <domain>:<bus>:<slot>.<function> */
if (/* domain */
virStrToLong_ui(entry->d_name, &tmp, 16, &domain) < 0 || *tmp != ':' ||
@ -2030,9 +2026,6 @@ virPCIDeviceAddressIOMMUGroupIterate(virPCIDeviceAddressPtr orig,
while ((direrr = virDirRead(groupDir, &ent, groupPath)) > 0) {
virPCIDeviceAddress newDev;
if (ent->d_name[0] == '.')
continue;
if (virPCIDeviceAddressParse(ent->d_name, &newDev) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Found invalid device link '%s' in '%s'"),

View File

@ -619,10 +619,6 @@ int virProcessGetPids(pid_t pid, size_t *npids, pid_t **pids)
long long tmp;
pid_t tmp_pid;
/* Skip . and .. */
if (STRPREFIX(ent->d_name, "."))
continue;
if (virStrToLong_ll(ent->d_name, NULL, 10, &tmp) < 0)
goto cleanup;
tmp_pid = tmp;

View File

@ -134,9 +134,6 @@ virSCSIDeviceGetSgName(const char *sysfs_prefix,
}
while (virDirRead(dir, &entry, path) > 0) {
if (entry->d_name[0] == '.')
continue;
/* Assume a single directory entry */
ignore_value(VIR_STRDUP(sg, entry->d_name));
break;
@ -180,9 +177,6 @@ virSCSIDeviceGetDevName(const char *sysfs_prefix,
}
while (virDirRead(dir, &entry, path) > 0) {
if (entry->d_name[0] == '.')
continue;
ignore_value(VIR_STRDUP(name, entry->d_name));
break;
}

View File

@ -150,7 +150,7 @@ virUSBDeviceSearch(unsigned int vendor,
unsigned int found_prod, found_vend, found_bus, found_devno;
char *tmpstr = de->d_name;
if (de->d_name[0] == '.' || strchr(de->d_name, ':'))
if (strchr(de->d_name, ':'))
continue;
if (virUSBSysReadFile("idVendor", de->d_name,

View File

@ -1868,7 +1868,7 @@ virFindSCSIHostByPCI(const char *sysfs_prefix,
}
while (virDirRead(dir, &entry, prefix) > 0) {
if (entry->d_name[0] == '.' || !virFileIsLink(entry->d_name))
if (!virFileIsLink(entry->d_name))
continue;
if (virAsprintf(&host_link, "%s/%s", prefix, entry->d_name) < 0)
@ -2218,9 +2218,6 @@ virGetFCHostNameByWWN(const char *sysfs_prefix,
} while (0)
while (virDirRead(dir, &entry, prefix) > 0) {
if (entry->d_name[0] == '.')
continue;
if (virAsprintf(&wwnn_path, "%s/%s/node_name", prefix,
entry->d_name) < 0)
goto cleanup;
@ -2303,9 +2300,6 @@ virFindFCHostCapableVport(const char *sysfs_prefix)
unsigned int host;
char *p = NULL;
if (entry->d_name[0] == '.')
continue;
p = entry->d_name + strlen("host");
if (virStrToLong_ui(p, NULL, 10, &host) == -1) {
VIR_DEBUG("Failed to parse host number from '%s'",