ioctl_tty.2: Update DTR example
[man-pages.git] / man3 / canonicalize_file_name.3
blobf8f8886a202818403d577e1364462cb5a40f85a3
1 .\" Copyright 2013 Michael Kerrisk <mtk.manpages@gmail.com>
2 .\" (Replaces an earlier page by Walter Harms and Michael Kerrisk)
3 .\"
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.
8 .\"
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.
13 .\"
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
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" %%%LICENSE_END
25 .\"
26 .TH CANONICALIZE_FILE_NAME 3 2021-03-22 "GNU" "Linux Programmer's Manual"
27 .SH NAME
28 canonicalize_file_name \- return the canonicalized absolute pathname
29 .SH SYNOPSIS
30 .nf
31 .BR "#define _GNU_SOURCE" "         /* See feature_test_macros(7) */"
32 .B #include <stdlib.h>
33 .PP
34 .BI "char *canonicalize_file_name(const char *" path ");"
35 .fi
36 .SH DESCRIPTION
37 The
38 .BR canonicalize_file_name ()
39 function returns a null-terminated string containing
40 the canonicalized absolute pathname corresponding to
41 .IR path .
42 In the returned string, symbolic links are resolved, as are
43 .I .
44 and
45 .I ..
46 pathname components.
47 Consecutive slash
48 .RI ( / )
49 characters are replaced by a single slash.
50 .PP
51 The returned string is dynamically allocated by
52 .BR canonicalize_file_name ()
53 and the caller should deallocate it with
54 .BR free (3)
55 when it is no longer required.
56 .PP
57 The call
58 .I canonicalize_file_name(path)
59 is equivalent to the call:
60 .PP
61     realpath(path, NULL);
62 .SH RETURN VALUE
63 On success,
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 ()
68 returns NULL and sets
69 .I errno
70 to indicate the error.
71 .SH ERRORS
72 See
73 .BR realpath (3).
74 .SH ATTRIBUTES
75 For an explanation of the terms used in this section, see
76 .BR attributes (7).
77 .ad l
78 .nh
79 .TS
80 allbox;
81 lbx lb lb
82 l l l.
83 Interface       Attribute       Value
85 .BR canonicalize_file_name ()
86 T}      Thread safety   MT-Safe
87 .TE
88 .hy
89 .ad
90 .sp 1
91 .SH CONFORMING TO
92 This function is a GNU extension.
93 .SH SEE ALSO
94 .BR readlink (2),
95 .BR realpath (3)