The issue of resolving symlinks (symbolic links) is often addressed on
this forum, and on others. Related are the concepts of relative,
absolute (or full), and canonical (or resolved) pathnames. Two now
standard utilities are available, for example in GNU core utilities,
to resolve symlinks, and, among other things, produce canonical
pathnames: readlink
and realpath
.
Why do we need canonical paths?
Can you give examples where canonical paths are required, and non-canonical absolute paths will not be acceptable?
Side question: why do people get "canonical path" answers for "absolute path" questions? But is this technology or sociology ?
/data/README.txt
can be on a volume which is mounted on /home. You need to know whether it happens to be a link to e.g./home/user/README.txt
. – Hauke Laging May 29 '13 at 08:50man 2 lstat
(dev_t) – Hauke Laging May 29 '13 at 22:27df
for that purpose. – babou May 30 '13 at 20:55df
for that purpose ? Well, I realize I should have made my original question more precise. I was thinking mainly of a shell user. Canonical paths seem possibly more likely to be useful when programming in C. But both contexts sare interesting. My initial question was motivated by my puzzlement over the design ofreadlink
as a shell command, compared torealpath
. But then the explanation is probably that designing the shell utilities should be different from designing a library. – babou May 30 '13 at 21:18df
for that. – Hauke Laging May 30 '13 at 21:30