From 2f26f8aae1ece618ff7ade997609509f0b60d400 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 6 Sep 2021 11:52:09 +0200
Subject: [PATCH] lib/path: fstat dir itself

Signed-off-by: Karel Zak <kzak@redhat.com>
---
 lib/path.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/lib/path.c b/lib/path.c
index 21f9bd1..f0b010e 100644
--- a/lib/path.c
+++ b/lib/path.c
@@ -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
-- 
2.33.0

