提交 6b9f40e8 编写于 作者: E Eric Blake

conf: use virDirRead API

When reading configuration files, we were silently ignoring
directory read failures.  While unlikely, we might as well
report them.

* src/conf/domain_conf.c (virDomainObjListLoadAllConfigs): Report
readdir errors.
* src/conf/network_conf.c (virNetworkLoadAllState)
(virNetworkLoadAllConfigs): Likewise.
* src/conf/nwfilter_conf.c (virNWFilterLoadAllConfigs): Likewise.
* src/conf/storage_conf.c (virStoragePoolLoadAllConfigs):
Likewise.
Signed-off-by: NEric Blake <eblake@redhat.com>
上级 92cf75df
......@@ -18219,6 +18219,7 @@ virDomainObjListLoadAllConfigs(virDomainObjListPtr doms,
{
DIR *dir;
struct dirent *entry;
int ret = -1;
VIR_INFO("Scanning for configs in %s", configDir);
......@@ -18233,7 +18234,7 @@ virDomainObjListLoadAllConfigs(virDomainObjListPtr doms,
virObjectLock(doms);
while ((entry = readdir(dir))) {
while ((ret = virDirRead(dir, &entry, configDir)) > 0) {
virDomainObjPtr dom;
if (entry->d_name[0] == '.')
......@@ -18273,7 +18274,7 @@ virDomainObjListLoadAllConfigs(virDomainObjListPtr doms,
closedir(dir);
virObjectUnlock(doms);
return 0;
return ret;
}
int
......
......@@ -3153,6 +3153,7 @@ virNetworkLoadAllState(virNetworkObjListPtr nets,
{
DIR *dir;
struct dirent *entry;
int ret = -1;
if (!(dir = opendir(stateDir))) {
if (errno == ENOENT)
......@@ -3162,7 +3163,7 @@ virNetworkLoadAllState(virNetworkObjListPtr nets,
return -1;
}
while ((entry = readdir(dir))) {
while ((ret = virDirRead(dir, &entry, stateDir)) > 0) {
virNetworkObjPtr net;
if (entry->d_name[0] == '.')
......@@ -3176,7 +3177,7 @@ virNetworkLoadAllState(virNetworkObjListPtr nets,
}
closedir(dir);
return 0;
return ret;
}
......@@ -3186,6 +3187,7 @@ int virNetworkLoadAllConfigs(virNetworkObjListPtr nets,
{
DIR *dir;
struct dirent *entry;
int ret = -1;
if (!(dir = opendir(configDir))) {
if (errno == ENOENT)
......@@ -3196,7 +3198,7 @@ int virNetworkLoadAllConfigs(virNetworkObjListPtr nets,
return -1;
}
while ((entry = readdir(dir))) {
while ((ret = virDirRead(dir, &entry, configDir)) > 0) {
virNetworkObjPtr net;
if (entry->d_name[0] == '.')
......@@ -3216,8 +3218,7 @@ int virNetworkLoadAllConfigs(virNetworkObjListPtr nets,
}
closedir(dir);
return 0;
return ret;
}
int virNetworkDeleteConfig(const char *configDir,
......
......@@ -3097,6 +3097,7 @@ virNWFilterLoadAllConfigs(virNWFilterObjListPtr nwfilters,
{
DIR *dir;
struct dirent *entry;
int ret = -1;
if (!(dir = opendir(configDir))) {
if (errno == ENOENT) {
......@@ -3107,7 +3108,7 @@ virNWFilterLoadAllConfigs(virNWFilterObjListPtr nwfilters,
return -1;
}
while ((entry = readdir(dir))) {
while ((ret = virDirRead(dir, &entry, configDir)) > 0) {
char *path;
virNWFilterObjPtr nwfilter;
......@@ -3128,8 +3129,7 @@ virNWFilterLoadAllConfigs(virNWFilterObjListPtr nwfilters,
}
closedir(dir);
return 0;
return ret;
}
......
......@@ -1862,6 +1862,7 @@ virStoragePoolLoadAllConfigs(virStoragePoolObjListPtr pools,
{
DIR *dir;
struct dirent *entry;
int ret;
if (!(dir = opendir(configDir))) {
if (errno == ENOENT)
......@@ -1871,7 +1872,7 @@ virStoragePoolLoadAllConfigs(virStoragePoolObjListPtr pools,
return -1;
}
while ((entry = readdir(dir))) {
while ((ret = virDirRead(dir, &entry, configDir)) > 0) {
char *path;
char *autostartLink;
virStoragePoolObjPtr pool;
......@@ -1901,8 +1902,7 @@ virStoragePoolLoadAllConfigs(virStoragePoolObjListPtr pools,
}
closedir(dir);
return 0;
return ret;
}
int
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册