OSDN Git Service

LDP: Update original to LDP v3.79
[linuxjm/LDP_man-pages.git] / original / man3 / canonicalize_file_name.3
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 2013-05-11 "GNU" "Linux Programmer's Manual"
27 .SH NAME
28 canonicalize_file_name \- return the canonicalized absolute pathname
29 .SH SYNOPSIS
30 .BR "#define _GNU_SOURCE" "         /* See feature_test_macros(7) */"
31 .br
32 .B #include <stdlib.h>
33 .sp
34 .BI "char *canonicalize_file_name(const char *" path ");"
35 .SH DESCRIPTION
36 The
37 .BR canonicalize_file_name ()
38 function returns a null-terminated string containing
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.
46 Consecutive slash
47 .RI ( / )
48 characters are replaced by a single slash.
49
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.
55
56 The call
57 .I canonicalize_file_name(path)
58 is equivalent to the call:
59
60     realpath(path, NULL);
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).
73 .SH CONFORMING TO
74 This function is a GNU extension.
75 .SH SEE ALSO
76 .BR readlink (2),
77 .BR realpath (3)
78 .SH COLOPHON
79 This page is part of release 3.79 of the Linux
80 .I man-pages
81 project.
82 A description of the project,
83 information about reporting bugs,
84 and the latest version of this page,
85 can be found at
86 \%http://www.kernel.org/doc/man\-pages/.