1 .\" Copyright 2013 Michael Kerrisk <mtk.manpages@gmail.com>
2 .\" (Replaces an earlier page by Walter Harms and Michael Kerrisk)
4 .\" %%%LICENSE_START(VERBATIM)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date. The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein. The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
26 .TH CANONICALIZE_FILE_NAME 3 2021-03-22 "GNU" "Linux Programmer's Manual"
28 canonicalize_file_name \- return the canonicalized absolute pathname
31 .BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */"
32 .B #include <stdlib.h>
34 .BI "char *canonicalize_file_name(const char *" path ");"
38 .BR canonicalize_file_name ()
39 function returns a null-terminated string containing
40 the canonicalized absolute pathname corresponding to
42 In the returned string, symbolic links are resolved, as are
49 characters are replaced by a single slash.
51 The returned string is dynamically allocated by
52 .BR canonicalize_file_name ()
53 and the caller should deallocate it with
55 when it is no longer required.
58 .I canonicalize_file_name(path)
59 is equivalent to the call:
64 .BR canonicalize_file_name ()
65 returns a null-terminated string.
66 On error (e.g., a pathname component is unreadable or does not exist),
67 .BR canonicalize_file_name ()
70 to indicate the error.
75 For an explanation of the terms used in this section, see
83 Interface Attribute Value
85 .BR canonicalize_file_name ()
86 T} Thread safety MT-Safe
92 This function is a GNU extension.