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