]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/symlink.2
access.2: Fix outdated NFS information
[thirdparty/man-pages.git] / man2 / symlink.2
CommitLineData
fea681da 1.\" This manpage is Copyright (C) 1992 Drew Eckhardt;
ac56b6a8 2.\" and Copyright (C) 1993 Michael Haardt, Ian Jackson.
fea681da 3.\"
93015253 4.\" %%%LICENSE_START(VERBATIM)
fea681da
MK
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.
c13182ef 13.\"
fea681da
MK
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.
c13182ef 21.\"
fea681da
MK
22.\" Formatted or processed versions of this manual, if unaccompanied by
23.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 24.\" %%%LICENSE_END
fea681da
MK
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>
c11b1abf 30.\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com>
fea681da 31.\"
3fc441b2 32.TH SYMLINK 2 2013-01-27 "Linux" "Linux Programmer's Manual"
fea681da
MK
33.SH NAME
34symlink \- 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 );
cc4615cc
MK
39.sp
40.in -4n
41Feature Test Macro Requirements for glibc (see
42.BR feature_test_macros (7)):
43.in
44.sp
45.ad l
46.BR symlink ():
cde2506f
MK
47.RS 4
48_BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 ||
49_XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED || _POSIX_C_SOURCE\ >=\ 200112L
50.RE
cc4615cc 51.ad b
fea681da 52.SH DESCRIPTION
e511ffb6 53.BR symlink ()
fea681da
MK
54creates a symbolic link named
55.I newpath
56which contains the string
57.IR oldpath .
58
cf50118f 59Symbolic links are interpreted at run time as if the contents of the
fea681da
MK
60link had been substituted into the path being followed to find a file or
61directory.
62
63Symbolic links may contain
836f07c1 64.I ..
fea681da
MK
65path components, which (if used at the start of the link) refer to the
66parent directories of that in which the link resides.
67
68A symbolic link (also known as a soft link) may point to an existing
69file or to a nonexistent one; the latter case is known as a dangling
70link.
71
72The permissions of a symbolic link are irrelevant; the ownership is
73ignored when following the link, but is checked when removal or
74renaming of the link is requested and the link is in a directory with
75the sticky bit
76.RB ( S_ISVTX )
77set.
78
79If
80.I newpath
81exists it will
82.I not
83be overwritten.
47297adb 84.SH RETURN VALUE
c13182ef
MK
85On success, zero is returned.
86On error, \-1 is returned, and
fea681da
MK
87.I errno
88is set appropriately.
89.SH ERRORS
90.TP
91.B EACCES
92Write access to the directory containing
93.I newpath
94is denied, or one of the directories in the path prefix of
0daa9e92 95.I newpath
fea681da
MK
96did not allow search permission.
97(See also
ad7cc990 98.BR path_resolution (7).)
fea681da 99.TP
a1f01685 100.B EDQUOT
9ee4a2b6 101The user's quota of resources on the filesystem has been exhausted.
e3b419fa 102The resources could be inodes or disk blocks, depending on the file
a1f01685
MH
103system implementation.
104.TP
fea681da
MK
105.B EEXIST
106.I newpath
107already exists.
108.TP
109.B EFAULT
110.IR oldpath " or " newpath " points outside your accessible address space."
111.TP
112.B EIO
113An I/O error occurred.
114.TP
115.B ELOOP
116Too many symbolic links were encountered in resolving
117.IR newpath .
118.TP
119.B ENAMETOOLONG
120.IR oldpath " or " newpath " was too long."
121.TP
122.B ENOENT
123A directory component in
124.I newpath
125does not exist or is a dangling symbolic link, or
126.I oldpath
127is the empty string.
128.TP
129.B ENOMEM
130Insufficient kernel memory was available.
131.TP
132.B ENOSPC
133The device containing the file has no room for the new directory
134entry.
135.TP
136.B ENOTDIR
137A component used as a directory in
0daa9e92 138.I newpath
fea681da
MK
139is not, in fact, a directory.
140.TP
141.B EPERM
9ee4a2b6 142The filesystem containing
0daa9e92 143.I newpath
fea681da
MK
144does not support the creation of symbolic links.
145.TP
146.B EROFS
147.I newpath
9ee4a2b6 148is on a read-only filesystem.
47297adb 149.SH CONFORMING TO
2dd578fd
MK
150SVr4, 4.3BSD, POSIX.1-2001.
151.\" SVr4 documents additional error codes EDQUOT and ENOSYS.
152.\" See
153.\" .BR open (2)
154.\" re multiple files with the same name, and NFS.
fea681da
MK
155.SH NOTES
156No checking of
157.I oldpath
158is done.
159
160Deleting the name referred to by a symlink will actually delete the
7c93fec0 161file (unless it also has other hard links).
d9bfdb9c 162If this behavior is not desired, use
0bfa087b 163.BR link (2).
47297adb 164.SH SEE ALSO
fea681da 165.BR ln (1),
a3bf8022 166.BR lchown (2),
fea681da
MK
167.BR link (2),
168.BR lstat (2),
169.BR open (2),
fea681da
MK
170.BR readlink (2),
171.BR rename (2),
f5958902 172.BR symlinkat (2),
0c2b92ba 173.BR unlink (2),
a9cfde1d 174.BR path_resolution (7),
ad22ad55 175.BR symlink (7)