Main index | Section 3 | Options |
The resulting path name may include symbolic links. The abs2rel() function doesn't check whether or not any path exists.
yields:
path == "../../src/sys"
Similarly,
path1 = abs2rel("/usr/src/sys", "/usr", result, MAXPATHLEN);
path2 = abs2rel("/usr/src/sys", "/usr/src/sys", result, MAXPATHLEN);
yields:
path1 == "src/sys"
path2 == "."
[EINVAL] | |
The base directory isn't an absolute path name or the size argument is zero. | |
[ERANGE] | |
The
size
argument is greater than zero but smaller than the length of the pathname plus 1.
| |
char *path = abs2rel("/usr/local/lib", "/sys", result, MAXPATHLEN);
yields:
path == "../usr/local/lib" /* It's wrong!! */
You should convert the base directory into a real path in advance.
path = abs2rel("/sys/kern", realpath("/sys", resolvedname), result, MAXPATHLEN);
yields:
path == "../../../sys/kern" /* It's correct but ... */
That is correct, but a little redundant. If you wish get the simple answer 'kern', do the following.
path = abs2rel(realpath("/sys/kern", r1), realpath("/sys", r2),
result, MAXPATHLEN);
The realpath() function assures correct result, but don't forget that realpath() requires that all but the last component of the path exist.
ABS2REL (3) | August 7, 2022 |
Main index | Section 3 | Options |
Please direct any comments about this manual page service to Ben Bullock. Privacy policy.
“ | I have a natural revulsion to any operating system that shows so little planning as to have to named all of its commands after digestive noises (awk, grep, fsck, nroff). | ” |