提交 b6a2bd4a 编写于 作者: D Daniel P. Berrangé

nss: remove use for virDir helper APIs

Use the plain libc APIs to avoid a dependancy on the main libvirt
code from the nss module.
Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
上级 2b0d5976
...@@ -1338,7 +1338,7 @@ exclude_file_name_regexp--sc_prohibit_always-defined_macros = \ ...@@ -1338,7 +1338,7 @@ exclude_file_name_regexp--sc_prohibit_always-defined_macros = \
^tests/virtestmock.c$$ ^tests/virtestmock.c$$
exclude_file_name_regexp--sc_prohibit_readdir = \ exclude_file_name_regexp--sc_prohibit_readdir = \
^tests/(.*mock|virfilewrapper)\.c$$ ^(tests/(.*mock|virfilewrapper)\.c|tools/nss/libvirt_nss\.c)$$
exclude_file_name_regexp--sc_prohibit_cross_inclusion = \ exclude_file_name_regexp--sc_prohibit_cross_inclusion = \
^(src/util/virclosecallbacks\.h|src/util/virhostdev\.h)$$ ^(src/util/virclosecallbacks\.h|src/util/virhostdev\.h)$$
......
...@@ -281,7 +281,8 @@ findLease(const char *name, ...@@ -281,7 +281,8 @@ findLease(const char *name,
goto cleanup; goto cleanup;
} }
if (virDirOpenQuiet(&dir, leaseDir) < 0) { dir = opendir(leaseDir);
if (!dir) {
ERROR("Failed to open dir '%s'", leaseDir); ERROR("Failed to open dir '%s'", leaseDir);
goto cleanup; goto cleanup;
} }
...@@ -292,7 +293,7 @@ findLease(const char *name, ...@@ -292,7 +293,7 @@ findLease(const char *name,
} }
DEBUG("Dir: %s", leaseDir); DEBUG("Dir: %s", leaseDir);
while ((ret = virDirRead(dir, &entry, leaseDir)) > 0) { while ((entry = readdir(dir)) != NULL) {
char *path; char *path;
if (virStringHasSuffix(entry->d_name, ".status")) { if (virStringHasSuffix(entry->d_name, ".status")) {
...@@ -324,8 +325,11 @@ findLease(const char *name, ...@@ -324,8 +325,11 @@ findLease(const char *name,
nMacmaps++; nMacmaps++;
VIR_FREE(path); VIR_FREE(path);
} }
errno = 0;
} }
VIR_DIR_CLOSE(dir); closedir(dir);
dir = NULL;
nleases = virJSONValueArraySize(leases_array); nleases = virJSONValueArraySize(leases_array);
DEBUG("Read %zd leases", nleases); DEBUG("Read %zd leases", nleases);
...@@ -363,7 +367,8 @@ findLease(const char *name, ...@@ -363,7 +367,8 @@ findLease(const char *name,
cleanup: cleanup:
*errnop = errno; *errnop = errno;
VIR_DIR_CLOSE(dir); if (dir)
closedir(dir);
while (nMacmaps) while (nMacmaps)
virObjectUnref(macmaps[--nMacmaps]); virObjectUnref(macmaps[--nMacmaps]);
return ret; return ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册