Skip to content

Commit

Permalink
basic: add fallback in chase_symlinks_and_opendir() for cases when /p…
Browse files Browse the repository at this point in the history
  • Loading branch information
msekletar authored and keszybz committed Dec 2, 2022
1 parent 6accdcc commit 3e22dfc
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/basic/chase-symlinks.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,14 +552,22 @@ int chase_symlinks_and_opendir(
return 0;
}

r = chase_symlinks(path, root, chase_flags, ret_path ? &p : NULL, &path_fd);
r = chase_symlinks(path, root, chase_flags, &p, &path_fd);
if (r < 0)
return r;
assert(path_fd >= 0);

d = opendir(FORMAT_PROC_FD_PATH(path_fd));
if (!d)
return -errno;
if (!d) {
/* Hmm, we have the fd already but we got ENOENT, most likely /proc is not mounted.
* Let's try opendir() again on the full path. */
if (errno == ENOENT) {
d = opendir(p);
if (!d)
return -errno;
} else
return -errno;
}

if (ret_path)
*ret_path = TAKE_PTR(p);
Expand Down

0 comments on commit 3e22dfc

Please sign in to comment.