]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/canonicalize_file_name.3
_exit.2, bpf.2, cacheflush.2, capget.2, chdir.2, chmod.2, chroot.2, clock_getres...
[thirdparty/man-pages.git] / man3 / canonicalize_file_name.3
CommitLineData
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.\"
fe0fefbf 26.TH CANONICALIZE_FILE_NAME 3 2015-03-02 "GNU" "Linux Programmer's Manual"
bc69fad6 27.SH NAME
231c5539 28canonicalize_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
36The
37.BR canonicalize_file_name ()
50b2aa27 38function returns a null-terminated string containing
231c5539
MK
39the canonicalized absolute pathname corresponding to
40.IR path .
41In the returned string, symbolic links are resolved, as are
42.I .
43and
44.I ..
45pathname components.
50b2aa27 46Consecutive slash
231c5539
MK
47.RI ( / )
48characters are replaced by a single slash.
49
50The returned string is dynamically allocated by
51.BR canonicalize_file_name ()
52and the caller should deallocate it with
53.BR free (3)
54when it is no longer required.
55
4ff2a3ba
MK
56The call
57.I canonicalize_file_name(path)
231c5539
MK
58is equivalent to the call:
59
60 realpath(path, NULL);
231c5539
MK
61.SH RETURN VALUE
62On success,
63.BR canonicalize_file_name ()
64returns a null-terminated string.
65On error (e.g., a pathname component is unreadable or does not exist),
66.BR canonicalize_file_name ()
67returns NULL and sets
68.I errno
69to indicate the error.
70.SH ERRORS
71See
72.BR realpath (3).
e8b8184d 73.SH ATTRIBUTES
60570269 74For an explanation of the terms used in this section, see
e8b8184d
MS
75.BR attributes (7).
76.TS
77allbox;
78lbw24 lb lb
79l l l.
80Interface Attribute Value
81T{
82.BR canonicalize_file_name ()
83T} Thread safety MT-Safe
84.TE
6aa5dcf4
MK
85.SH CONFORMING TO
86This function is a GNU extension.
47297adb 87.SH SEE ALSO
231c5539 88.BR readlink (2),
0a4f8b7b 89.BR realpath (3)