]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/symlink.2
Global change of email address for MTK (now: mtk-manpages@gmx.net)
[thirdparty/man-pages.git] / man2 / symlink.2
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\"
3 .\" This manpage is Copyright (C) 1992 Drew Eckhardt;
4 .\" 1993 Michael Haardt, Ian Jackson.
5 .\"
6 .\" Permission is granted to make and distribute verbatim copies of this
7 .\" manual provided the copyright notice and this permission notice are
8 .\" preserved on all copies.
9 .\"
10 .\" Permission is granted to copy and distribute modified versions of this
11 .\" manual under the conditions for verbatim copying, provided that the
12 .\" entire resulting derived work is distributed under the terms of a
13 .\" permission notice identical to this one.
14 .\"
15 .\" Since the Linux kernel and libraries are constantly changing, this
16 .\" manual page may be incorrect or out-of-date. The author(s) assume no
17 .\" responsibility for errors or omissions, or for damages resulting from
18 .\" the use of the information contained herein. The author(s) may not
19 .\" have taken the same level of care in the production of this manual,
20 .\" which is licensed free of charge, as they might when working
21 .\" professionally.
22 .\"
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
25 .\"
26 .\" Modified 1993-07-24 by Rik Faith
27 .\" Modified 1996-04-26 by Nick Duffek <nsd@bbc.com>
28 .\" Modified 1996-11-06 by Eric S. Raymond <esr@thyrsus.com>
29 .\" Modified 1997-01-31 by Eric S. Raymond <esr@thyrsus.com>
30 .\" Modified 2004-06-23 by Michael Kerrisk <mtk-manpages@gmx.net>
31 .\"
32 .TH SYMLINK 2 2004-06-23 "Linux 2.6.7" "Linux Programmer's Manual"
33 .SH NAME
34 symlink \- make a new name for a file
35 .SH SYNOPSIS
36 .B #include <unistd.h>
37 .sp
38 .BI "int symlink(const char *" oldpath ", const char *" newpath );
39 .SH DESCRIPTION
40 .B symlink
41 creates a symbolic link named
42 .I newpath
43 which contains the string
44 .IR oldpath .
45
46 Symbolic links are interpreted at run-time as if the contents of the
47 link had been substituted into the path being followed to find a file or
48 directory.
49
50 Symbolic links may contain
51 .B ..
52 path components, which (if used at the start of the link) refer to the
53 parent directories of that in which the link resides.
54
55 A symbolic link (also known as a soft link) may point to an existing
56 file or to a nonexistent one; the latter case is known as a dangling
57 link.
58
59 The permissions of a symbolic link are irrelevant; the ownership is
60 ignored when following the link, but is checked when removal or
61 renaming of the link is requested and the link is in a directory with
62 the sticky bit
63 .RB ( S_ISVTX )
64 set.
65
66 If
67 .I newpath
68 exists it will
69 .I not
70 be overwritten.
71 .SH "RETURN VALUE"
72 On success, zero is returned. On error, \-1 is returned, and
73 .I errno
74 is set appropriately.
75 .SH ERRORS
76 .TP
77 .B EACCES
78 Write access to the directory containing
79 .I newpath
80 is denied, or one of the directories in the path prefix of
81 .IR newpath
82 did not allow search permission.
83 (See also
84 .BR path_resolution (2).)
85 .TP
86 .B EEXIST
87 .I newpath
88 already exists.
89 .TP
90 .B EFAULT
91 .IR oldpath " or " newpath " points outside your accessible address space."
92 .TP
93 .B EIO
94 An I/O error occurred.
95 .TP
96 .B ELOOP
97 Too many symbolic links were encountered in resolving
98 .IR newpath .
99 .TP
100 .B ENAMETOOLONG
101 .IR oldpath " or " newpath " was too long."
102 .TP
103 .B ENOENT
104 A directory component in
105 .I newpath
106 does not exist or is a dangling symbolic link, or
107 .I oldpath
108 is the empty string.
109 .TP
110 .B ENOMEM
111 Insufficient kernel memory was available.
112 .TP
113 .B ENOSPC
114 The device containing the file has no room for the new directory
115 entry.
116 .TP
117 .B ENOTDIR
118 A component used as a directory in
119 .IR newpath
120 is not, in fact, a directory.
121 .TP
122 .B EPERM
123 The filesystem containing
124 .IR newpath
125 does not support the creation of symbolic links.
126 .TP
127 .B EROFS
128 .I newpath
129 is on a read-only filesystem.
130 .SH NOTES
131 No checking of
132 .I oldpath
133 is done.
134
135 Deleting the name referred to by a symlink will actually delete the
136 file (unless it also has other hard links). If this behaviour is not
137 desired, use
138 .BR link .
139 .SH "CONFORMING TO"
140 SVr4, SVID, POSIX, BSD 4.3. SVr4 documents additional error codes
141 SVr4, SVID, BSD 4.3, X/OPEN. SVr4 documents additional error codes
142 EDQUOT and ENOSYS.
143 See
144 .BR open (2)
145 re multiple files with the same name, and NFS.
146 .SH "SEE ALSO"
147 .BR ln (1),
148 .BR link (2),
149 .BR lstat (2),
150 .BR open (2),
151 .BR path_resolution (2),
152 .BR readlink (2),
153 .BR rename (2),
154 .BR unlink (2)