]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/path: improve debug message on redirect
authorKarel Zak <kzak@redhat.com>
Tue, 29 May 2018 10:41:48 +0000 (12:41 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 21 Jun 2018 11:19:28 +0000 (13:19 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
lib/path.c

index d35262b891d4232e69f644861c53f484d40ce991..cfc1c23725ae4a1716531cdcd3ae057db584bf2b 100644 (file)
@@ -274,7 +274,6 @@ int ul_path_access(struct path_cxt *pc, int mode, const char *path)
            && pc->redirect_on_enoent
            && pc->redirect_on_enoent(pc, path, &dir) == 0)
                rc = faccessat(dir, path, mode, 0);
-
        return rc;
 }
 
@@ -298,18 +297,19 @@ int ul_path_open(struct path_cxt *pc, int flags, const char *path)
                fd = open(path, flags);
                DBG(CXT, ul_debug("opening '%s'", path));
        } else {
+               int fdx;
                int dir = ul_path_get_dirfd(pc);
                if (dir < 0)
                        return dir;
 
-               fd = openat(dir, path, flags);
+               fdx = fd = openat(dir, path, flags);
 
                if (fd < 0 && errno == ENOENT
                    && pc->redirect_on_enoent
                    && pc->redirect_on_enoent(pc, path, &dir) == 0)
                        fd = openat(dir, path, flags);
 
-               DBG(CXT, ul_debugobj(pc, "opening '%s'", path));
+               DBG(CXT, ul_debugobj(pc, "opening '%s'%s", path, fdx != fd ? " [redirected]" : ""));
        }
        return fd;
 }