]>
Commit | Line | Data |
---|---|---|
616c2730 | 1 | .\" Copyright 2013 Michael Kerrisk <mtk.manpages@gmail.com> |
231c5539 | 2 | .\" (Replaces an earlier page by Walter Harms and Michael Kerrisk) |
2297bf0e | 3 | .\" |
231c5539 MK |
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. | |
38f20bb9 | 24 | .\" %%%LICENSE_END |
4ff2a3ba | 25 | .\" |
4b8c67d9 | 26 | .TH CANONICALIZE_FILE_NAME 3 2017-09-15 "GNU" "Linux Programmer's Manual" |
bc69fad6 | 27 | .SH NAME |
231c5539 | 28 | canonicalize_file_name \- return the canonicalized absolute pathname |
bc69fad6 | 29 | .SH SYNOPSIS |
b80f966b | 30 | .BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */" |
bc69fad6 MK |
31 | .br |
32 | .B #include <stdlib.h> | |
68e4db0a | 33 | .PP |
b9f02710 | 34 | .BI "char *canonicalize_file_name(const char *" path ");" |
bc69fad6 | 35 | .SH DESCRIPTION |
231c5539 MK |
36 | The |
37 | .BR canonicalize_file_name () | |
50b2aa27 | 38 | function returns a null-terminated string containing |
231c5539 MK |
39 | the canonicalized absolute pathname corresponding to |
40 | .IR path . | |
41 | In the returned string, symbolic links are resolved, as are | |
42 | .I . | |
43 | and | |
44 | .I .. | |
45 | pathname components. | |
50b2aa27 | 46 | Consecutive slash |
231c5539 MK |
47 | .RI ( / ) |
48 | characters are replaced by a single slash. | |
847e0d88 | 49 | .PP |
231c5539 MK |
50 | The returned string is dynamically allocated by |
51 | .BR canonicalize_file_name () | |
52 | and the caller should deallocate it with | |
53 | .BR free (3) | |
54 | when it is no longer required. | |
847e0d88 | 55 | .PP |
4ff2a3ba MK |
56 | The call |
57 | .I canonicalize_file_name(path) | |
231c5539 | 58 | is equivalent to the call: |
847e0d88 | 59 | .PP |
231c5539 | 60 | realpath(path, NULL); |
231c5539 MK |
61 | .SH RETURN VALUE |
62 | On success, | |
63 | .BR canonicalize_file_name () | |
64 | returns a null-terminated string. | |
65 | On error (e.g., a pathname component is unreadable or does not exist), | |
66 | .BR canonicalize_file_name () | |
67 | returns NULL and sets | |
68 | .I errno | |
69 | to indicate the error. | |
70 | .SH ERRORS | |
71 | See | |
72 | .BR realpath (3). | |
e8b8184d | 73 | .SH ATTRIBUTES |
60570269 | 74 | For an explanation of the terms used in this section, see |
e8b8184d MS |
75 | .BR attributes (7). |
76 | .TS | |
77 | allbox; | |
78 | lbw24 lb lb | |
79 | l l l. | |
80 | Interface Attribute Value | |
81 | T{ | |
82 | .BR canonicalize_file_name () | |
83 | T} Thread safety MT-Safe | |
84 | .TE | |
6aa5dcf4 MK |
85 | .SH CONFORMING TO |
86 | This function is a GNU extension. | |
47297adb | 87 | .SH SEE ALSO |
231c5539 | 88 | .BR readlink (2), |
0a4f8b7b | 89 | .BR realpath (3) |