]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/path: fstat dir itself
authorKarel Zak <kzak@redhat.com>
Mon, 6 Sep 2021 09:52:09 +0000 (11:52 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 6 Oct 2021 09:01:54 +0000 (11:01 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
lib/path.c

index 21f9bd1c46c82bba0d871ab8bf5dccd0a0f6ffa5..f0b010e67e509aeda94214c7554903c58da72ee1 100644 (file)
@@ -350,10 +350,12 @@ int ul_path_stat(struct path_cxt *pc, struct stat *sb, const char *path)
                int dir = ul_path_get_dirfd(pc);
                if (dir < 0)
                        return dir;
-               if (*path == '/')
-                       path++;
-
-               rc = fstatat(dir, path, sb, 0);
+               if (path) {
+                       if  (*path == '/')
+                               path++;
+                       rc = fstatat(dir, path, sb, 0);
+               } else
+                       rc = fstat(dir, sb);    /* dir itself */
 
                if (rc && errno == ENOENT
                    && pc->redirect_on_enoent