]> xenbits.xensource.com Git - libvirt.git/commitdiff
virschematest: Replace g_lstat() with virFileIsLink()
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 27 Aug 2024 12:14:37 +0000 (14:14 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 28 Aug 2024 06:46:16 +0000 (08:46 +0200)
Inside of virschematest.c there's testSchemaDir() which iterates
over dentries in given directory but skips some files: those
without ".xml" suffix, hidden files, symlinks, etc.

Now, symlinks are detected as g_lstat() + S_ISLNK() combo which
works, except it fails to compile on mingw where is no concept of
symlinks. Replace the combo with a call to virFileIsLink() which
at least allows us to compile cleanly on mingw.

Fixes: f997fcca71a16b102e6ee663a3fb86bed8de9d7d
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
tests/virschematest.c

index 20ac495f4a5cd3403e418199e2f9dcc40e6d2688..5d3fa32de4455945ee1f3033a1fab6cc60be3486 100644 (file)
@@ -119,14 +119,12 @@ testSchemaDir(const char *schema,
     while ((rc = virDirRead(dir, &ent, dir_path)) > 0) {
         g_autofree char *xml_path = NULL;
         bool exception = false;
-        GStatBuf sb;
 
         if (!virStringHasSuffix(ent->d_name, ".xml"))
             continue;
         if (ent->d_name[0] == '.')
             continue;
-        if (g_lstat(ent->d_name, &sb) >= 0 &&
-            S_ISLNK(sb.st_mode))
+        if (virFileIsLink(ent->d_name))
             continue;
         if (filter &&
             !g_regex_match(filter, ent->d_name, 0, NULL))