]>
Commit | Line | Data |
---|---|---|
fea681da | 1 | .\" This manpage is Copyright (C) 1992 Drew Eckhardt; |
ac56b6a8 | 2 | .\" and Copyright (C) 1993 Michael Haardt, Ian Jackson. |
e7bb1f63 | 3 | .\" and Copyright (C) 2006, 2014 Michael Kerrisk |
fea681da | 4 | .\" |
93015253 | 5 | .\" %%%LICENSE_START(VERBATIM) |
fea681da MK |
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. | |
c13182ef | 14 | .\" |
fea681da MK |
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. | |
c13182ef | 22 | .\" |
fea681da MK |
23 | .\" Formatted or processed versions of this manual, if unaccompanied by |
24 | .\" the source, must acknowledge the copyright and authors of this work. | |
4b72fb64 | 25 | .\" %%%LICENSE_END |
fea681da MK |
26 | .\" |
27 | .\" Modified 1993-07-24 by Rik Faith | |
28 | .\" Modified 1996-04-26 by Nick Duffek <nsd@bbc.com> | |
29 | .\" Modified 1996-11-06 by Eric S. Raymond <esr@thyrsus.com> | |
30 | .\" Modified 1997-01-31 by Eric S. Raymond <esr@thyrsus.com> | |
c11b1abf | 31 | .\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com> |
fea681da | 32 | .\" |
4b8c67d9 | 33 | .TH SYMLINK 2 2017-09-15 "Linux" "Linux Programmer's Manual" |
fea681da | 34 | .SH NAME |
e7bb1f63 | 35 | symlink, symlinkat \- make a new name for a file |
fea681da | 36 | .SH SYNOPSIS |
e7bb1f63 | 37 | .nf |
fea681da | 38 | .B #include <unistd.h> |
68e4db0a | 39 | .PP |
bcd49f31 | 40 | .BI "int symlink(const char *" target ", const char *" linkpath ); |
f90f031e | 41 | |
e7bb1f63 MK |
42 | .BR "#include <fcntl.h> " "/* Definition of AT_* constants */" |
43 | .B #include <unistd.h> | |
68e4db0a | 44 | .PP |
e7bb1f63 MK |
45 | .BI "int symlinkat(const char *" target ", int " newdirfd \ |
46 | ", const char *" linkpath ); | |
68e4db0a | 47 | .PP |
e7bb1f63 | 48 | .fi |
cc4615cc MK |
49 | .in -4n |
50 | Feature Test Macro Requirements for glibc (see | |
51 | .BR feature_test_macros (7)): | |
52 | .in | |
68e4db0a | 53 | .PP |
cc4615cc MK |
54 | .ad l |
55 | .BR symlink (): | |
cde2506f | 56 | .RS 4 |
f8619b6a | 57 | _XOPEN_SOURCE\ >=\ 500 || _POSIX_C_SOURCE\ >=\ 200112L |
cf7fa0a1 | 58 | .\" || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED |
f8619b6a | 59 | || /* Glibc versions <= 2.19: */ _BSD_SOURCE |
cde2506f | 60 | .RE |
68e4db0a | 61 | .PP |
e7bb1f63 MK |
62 | .BR symlinkat (): |
63 | .PD 0 | |
64 | .ad l | |
65 | .RS 4 | |
66 | .TP 4 | |
67 | Since glibc 2.10: | |
b0da7b8b | 68 | _POSIX_C_SOURCE\ >=\ 200809L |
e7bb1f63 MK |
69 | .TP |
70 | Before glibc 2.10: | |
71 | _ATFILE_SOURCE | |
72 | .RE | |
cc4615cc | 73 | .ad b |
e7bb1f63 | 74 | .PD |
fea681da | 75 | .SH DESCRIPTION |
e511ffb6 | 76 | .BR symlink () |
fea681da | 77 | creates a symbolic link named |
f2ae6dde | 78 | .I linkpath |
fea681da | 79 | which contains the string |
bcd49f31 | 80 | .IR target . |
efeece04 | 81 | .PP |
cf50118f | 82 | Symbolic links are interpreted at run time as if the contents of the |
fea681da MK |
83 | link had been substituted into the path being followed to find a file or |
84 | directory. | |
efeece04 | 85 | .PP |
fea681da | 86 | Symbolic links may contain |
836f07c1 | 87 | .I .. |
fea681da MK |
88 | path components, which (if used at the start of the link) refer to the |
89 | parent directories of that in which the link resides. | |
efeece04 | 90 | .PP |
fea681da MK |
91 | A symbolic link (also known as a soft link) may point to an existing |
92 | file or to a nonexistent one; the latter case is known as a dangling | |
93 | link. | |
efeece04 | 94 | .PP |
fea681da MK |
95 | The permissions of a symbolic link are irrelevant; the ownership is |
96 | ignored when following the link, but is checked when removal or | |
97 | renaming of the link is requested and the link is in a directory with | |
98 | the sticky bit | |
99 | .RB ( S_ISVTX ) | |
100 | set. | |
efeece04 | 101 | .PP |
fea681da | 102 | If |
f2ae6dde | 103 | .I linkpath |
ff68e7e2 | 104 | exists, it will |
fea681da MK |
105 | .I not |
106 | be overwritten. | |
e7bb1f63 MK |
107 | .SS symlinkat() |
108 | The | |
109 | .BR symlinkat () | |
110 | system call operates in exactly the same way as | |
cadd38ba | 111 | .BR symlink (), |
e7bb1f63 | 112 | except for the differences described here. |
efeece04 | 113 | .PP |
e7bb1f63 MK |
114 | If the pathname given in |
115 | .I linkpath | |
116 | is relative, then it is interpreted relative to the directory | |
117 | referred to by the file descriptor | |
118 | .I newdirfd | |
119 | (rather than relative to the current working directory of | |
120 | the calling process, as is done by | |
cadd38ba | 121 | .BR symlink () |
e7bb1f63 | 122 | for a relative pathname). |
efeece04 | 123 | .PP |
e7bb1f63 MK |
124 | If |
125 | .I linkpath | |
126 | is relative and | |
127 | .I newdirfd | |
128 | is the special value | |
129 | .BR AT_FDCWD , | |
130 | then | |
131 | .I linkpath | |
132 | is interpreted relative to the current working | |
133 | directory of the calling process (like | |
cadd38ba | 134 | .BR symlink ()). |
efeece04 | 135 | .PP |
e7bb1f63 MK |
136 | If |
137 | .I linkpath | |
138 | is absolute, then | |
139 | .I newdirfd | |
140 | is ignored. | |
47297adb | 141 | .SH RETURN VALUE |
c13182ef MK |
142 | On success, zero is returned. |
143 | On error, \-1 is returned, and | |
fea681da MK |
144 | .I errno |
145 | is set appropriately. | |
146 | .SH ERRORS | |
147 | .TP | |
148 | .B EACCES | |
149 | Write access to the directory containing | |
f2ae6dde | 150 | .I linkpath |
fea681da | 151 | is denied, or one of the directories in the path prefix of |
f2ae6dde | 152 | .I linkpath |
fea681da MK |
153 | did not allow search permission. |
154 | (See also | |
ad7cc990 | 155 | .BR path_resolution (7).) |
fea681da | 156 | .TP |
a1f01685 | 157 | .B EDQUOT |
9ee4a2b6 | 158 | The user's quota of resources on the filesystem has been exhausted. |
28955f15 SP |
159 | The resources could be inodes or disk blocks, depending on the filesystem |
160 | implementation. | |
a1f01685 | 161 | .TP |
fea681da | 162 | .B EEXIST |
f2ae6dde | 163 | .I linkpath |
fea681da MK |
164 | already exists. |
165 | .TP | |
166 | .B EFAULT | |
bcd49f31 | 167 | .IR target " or " linkpath " points outside your accessible address space." |
fea681da MK |
168 | .TP |
169 | .B EIO | |
170 | An I/O error occurred. | |
171 | .TP | |
172 | .B ELOOP | |
173 | Too many symbolic links were encountered in resolving | |
f2ae6dde | 174 | .IR linkpath . |
fea681da MK |
175 | .TP |
176 | .B ENAMETOOLONG | |
bcd49f31 | 177 | .IR target " or " linkpath " was too long." |
fea681da MK |
178 | .TP |
179 | .B ENOENT | |
180 | A directory component in | |
f2ae6dde | 181 | .I linkpath |
fea681da | 182 | does not exist or is a dangling symbolic link, or |
bcd49f31 | 183 | .I target |
32b262a1 MK |
184 | or |
185 | .I linkpath | |
bc5e71f5 | 186 | is an empty string. |
fea681da MK |
187 | .TP |
188 | .B ENOMEM | |
189 | Insufficient kernel memory was available. | |
190 | .TP | |
191 | .B ENOSPC | |
192 | The device containing the file has no room for the new directory | |
193 | entry. | |
194 | .TP | |
195 | .B ENOTDIR | |
196 | A component used as a directory in | |
f2ae6dde | 197 | .I linkpath |
fea681da MK |
198 | is not, in fact, a directory. |
199 | .TP | |
200 | .B EPERM | |
9ee4a2b6 | 201 | The filesystem containing |
f2ae6dde | 202 | .I linkpath |
fea681da MK |
203 | does not support the creation of symbolic links. |
204 | .TP | |
205 | .B EROFS | |
f2ae6dde | 206 | .I linkpath |
9ee4a2b6 | 207 | is on a read-only filesystem. |
e7bb1f63 MK |
208 | .PP |
209 | The following additional errors can occur for | |
210 | .BR symlinkat (): | |
211 | .TP | |
212 | .B EBADF | |
213 | .I newdirfd | |
214 | is not a valid file descriptor. | |
215 | .TP | |
1bc48ce1 MK |
216 | .B ENOENT |
217 | .I linkpath | |
218 | is a relative pathname and | |
219 | .IR newdirfd | |
220 | refers to a directory that has been deleted. | |
221 | .TP | |
e7bb1f63 MK |
222 | .B ENOTDIR |
223 | .I linkpath | |
224 | is relative and | |
225 | .I newdirfd | |
226 | is a file descriptor referring to a file other than a directory. | |
227 | .SH VERSIONS | |
228 | .BR symlinkat () | |
229 | was added to Linux in kernel 2.6.16; | |
230 | library support was added to glibc in version 2.4. | |
47297adb | 231 | .SH CONFORMING TO |
e7bb1f63 | 232 | .BR symlink (): |
dc3884b8 | 233 | SVr4, 4.3BSD, POSIX.1-2001, POSIX.1-2008. |
2dd578fd MK |
234 | .\" SVr4 documents additional error codes EDQUOT and ENOSYS. |
235 | .\" See | |
236 | .\" .BR open (2) | |
237 | .\" re multiple files with the same name, and NFS. | |
efeece04 | 238 | .PP |
e7bb1f63 MK |
239 | .BR symlinkat (): |
240 | POSIX.1-2008. | |
fea681da MK |
241 | .SH NOTES |
242 | No checking of | |
bcd49f31 | 243 | .I target |
fea681da | 244 | is done. |
efeece04 | 245 | .PP |
d44ab9f9 | 246 | Deleting the name referred to by a symbolic link will actually delete the |
7c93fec0 | 247 | file (unless it also has other hard links). |
d9bfdb9c | 248 | If this behavior is not desired, use |
0bfa087b | 249 | .BR link (2). |
23ab2615 MK |
250 | .SS Glibc notes |
251 | On older kernels where | |
252 | .BR symlinkat () | |
253 | is unavailable, the glibc wrapper function falls back to the use of | |
bf7bc8b8 | 254 | .BR symlink (). |
23ab2615 MK |
255 | When |
256 | .I linkpath | |
257 | is a relative pathname, | |
258 | glibc constructs a pathname based on the symbolic link in | |
259 | .IR /proc/self/fd | |
260 | that corresponds to the | |
261 | .IR newdirfd | |
262 | argument. | |
47297adb | 263 | .SH SEE ALSO |
fea681da | 264 | .BR ln (1), |
d097377b | 265 | .BR namei (1), |
a3bf8022 | 266 | .BR lchown (2), |
fea681da MK |
267 | .BR link (2), |
268 | .BR lstat (2), | |
269 | .BR open (2), | |
fea681da MK |
270 | .BR readlink (2), |
271 | .BR rename (2), | |
0c2b92ba | 272 | .BR unlink (2), |
a9cfde1d | 273 | .BR path_resolution (7), |
ad22ad55 | 274 | .BR symlink (7) |