]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/symlink.2
ttyslot.3: Fix feature test macro requirements
[thirdparty/man-pages.git] / man2 / symlink.2
CommitLineData
fea681da
MK
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.
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.
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.\"
cc4615cc 32.TH SYMLINK 2 2007-07-26 "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 ():
47_BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 || _POSIX_C_SOURCE\ >=\ 200112L
48.ad b
fea681da 49.SH DESCRIPTION
e511ffb6 50.BR symlink ()
fea681da
MK
51creates a symbolic link named
52.I newpath
53which contains the string
54.IR oldpath .
55
cf50118f 56Symbolic links are interpreted at run time as if the contents of the
fea681da
MK
57link had been substituted into the path being followed to find a file or
58directory.
59
60Symbolic links may contain
836f07c1 61.I ..
fea681da
MK
62path components, which (if used at the start of the link) refer to the
63parent directories of that in which the link resides.
64
65A symbolic link (also known as a soft link) may point to an existing
66file or to a nonexistent one; the latter case is known as a dangling
67link.
68
69The permissions of a symbolic link are irrelevant; the ownership is
70ignored when following the link, but is checked when removal or
71renaming of the link is requested and the link is in a directory with
72the sticky bit
73.RB ( S_ISVTX )
74set.
75
76If
77.I newpath
78exists it will
79.I not
80be overwritten.
81.SH "RETURN VALUE"
c13182ef
MK
82On success, zero is returned.
83On error, \-1 is returned, and
fea681da
MK
84.I errno
85is set appropriately.
86.SH ERRORS
87.TP
88.B EACCES
89Write access to the directory containing
90.I newpath
91is denied, or one of the directories in the path prefix of
0daa9e92 92.I newpath
fea681da
MK
93did not allow search permission.
94(See also
ad7cc990 95.BR path_resolution (7).)
fea681da
MK
96.TP
97.B EEXIST
98.I newpath
99already exists.
100.TP
101.B EFAULT
102.IR oldpath " or " newpath " points outside your accessible address space."
103.TP
104.B EIO
105An I/O error occurred.
106.TP
107.B ELOOP
108Too many symbolic links were encountered in resolving
109.IR newpath .
110.TP
111.B ENAMETOOLONG
112.IR oldpath " or " newpath " was too long."
113.TP
114.B ENOENT
115A directory component in
116.I newpath
117does not exist or is a dangling symbolic link, or
118.I oldpath
119is the empty string.
120.TP
121.B ENOMEM
122Insufficient kernel memory was available.
123.TP
124.B ENOSPC
125The device containing the file has no room for the new directory
126entry.
127.TP
128.B ENOTDIR
129A component used as a directory in
0daa9e92 130.I newpath
fea681da
MK
131is not, in fact, a directory.
132.TP
133.B EPERM
24d01c53 134The file system containing
0daa9e92 135.I newpath
fea681da
MK
136does not support the creation of symbolic links.
137.TP
138.B EROFS
139.I newpath
24d01c53 140is on a read-only file system.
2dd578fd
MK
141.SH "CONFORMING TO"
142SVr4, 4.3BSD, POSIX.1-2001.
143.\" SVr4 documents additional error codes EDQUOT and ENOSYS.
144.\" See
145.\" .BR open (2)
146.\" re multiple files with the same name, and NFS.
fea681da
MK
147.SH NOTES
148No checking of
149.I oldpath
150is done.
151
152Deleting the name referred to by a symlink will actually delete the
7c93fec0 153file (unless it also has other hard links).
d9bfdb9c 154If this behavior is not desired, use
0bfa087b 155.BR link (2).
fea681da
MK
156.SH "SEE ALSO"
157.BR ln (1),
a3bf8022 158.BR lchown (2),
fea681da
MK
159.BR link (2),
160.BR lstat (2),
161.BR open (2),
fea681da
MK
162.BR readlink (2),
163.BR rename (2),
f5958902 164.BR symlinkat (2),
0c2b92ba 165.BR unlink (2),
a9cfde1d 166.BR path_resolution (7),
ad22ad55 167.BR symlink (7)