1CANONICALIZE_FILE_NAME(3) Linux Programmer's Manual CANONICALIZE_FILE_NAME(3)
2
3
4
6 canonicalize_file_name - return the canonicalized absolute pathname
7
9 #define _GNU_SOURCE /* See feature_test_macros(7) */
10 #include <stdlib.h>
11
12 char *canonicalize_file_name(const char *path);
13
15 The canonicalize_file_name() function returns a null-terminated string
16 containing the canonicalized absolute pathname corresponding to path.
17 In the returned string, symbolic links are resolved, as are . and ..
18 pathname components. Consecutive slash (/) characters are replaced by
19 a single slash.
20
21 The returned string is dynamically allocated by canonical‐
22 ize_file_name() and the caller should deallocate it with free(3) when
23 it is no longer required.
24
25 The call canonicalize_file_name(path) is equivalent to the call:
26
27 realpath(path, NULL);
28
30 On success, canonicalize_file_name() returns a null-terminated string.
31 On error (e.g., a pathname component is unreadable or does not exist),
32 canonicalize_file_name() returns NULL and sets errno to indicate the
33 error.
34
36 See realpath(3).
37
39 For an explanation of the terms used in this section, see at‐
40 tributes(7).
41
42 ┌────────────────────────────────────────────┬───────────────┬─────────┐
43 │Interface │ Attribute │ Value │
44 ├────────────────────────────────────────────┼───────────────┼─────────┤
45 │canonicalize_file_name() │ Thread safety │ MT-Safe │
46 └────────────────────────────────────────────┴───────────────┴─────────┘
47
49 This function is a GNU extension.
50
52 readlink(2), realpath(3)
53
55 This page is part of release 5.13 of the Linux man-pages project. A
56 description of the project, information about reporting bugs, and the
57 latest version of this page, can be found at
58 https://www.kernel.org/doc/man-pages/.
59
60
61
62GNU 2021-03-22 CANONICALIZE_FILE_NAME(3)