1SYMLINK(2) Linux Programmer's Manual SYMLINK(2)
2
3
4
6 symlink - make a new name for a file
7
9 #include <unistd.h>
10
11 int symlink(const char *oldpath, const char *newpath);
12
13 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
14
15 symlink():
16 _BSD_SOURCE || _XOPEN_SOURCE >= 500 ||
17 _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED ||
18 _POSIX_C_SOURCE >= 200112L
19
21 symlink() creates a symbolic link named newpath which contains the
22 string oldpath.
23
24 Symbolic links are interpreted at run time as if the contents of the
25 link had been substituted into the path being followed to find a file
26 or directory.
27
28 Symbolic links may contain .. path components, which (if used at the
29 start of the link) refer to the parent directories of that in which the
30 link resides.
31
32 A symbolic link (also known as a soft link) may point to an existing
33 file or to a nonexistent one; the latter case is known as a dangling
34 link.
35
36 The permissions of a symbolic link are irrelevant; the ownership is
37 ignored when following the link, but is checked when removal or renam‐
38 ing of the link is requested and the link is in a directory with the
39 sticky bit (S_ISVTX) set.
40
41 If newpath exists it will not be overwritten.
42
44 On success, zero is returned. On error, -1 is returned, and errno is
45 set appropriately.
46
48 EACCES Write access to the directory containing newpath is denied, or
49 one of the directories in the path prefix of newpath did not
50 allow search permission. (See also path_resolution(7).)
51
52 EDQUOT The user's quota of resources on the file system has been
53 exhausted. The resources could be inodes or disk blocks,
54 depending on the file system implementation.
55
56 EEXIST newpath already exists.
57
58 EFAULT oldpath or newpath points outside your accessible address space.
59
60 EIO An I/O error occurred.
61
62 ELOOP Too many symbolic links were encountered in resolving newpath.
63
64 ENAMETOOLONG
65 oldpath or newpath was too long.
66
67 ENOENT A directory component in newpath does not exist or is a dangling
68 symbolic link, or oldpath is the empty string.
69
70 ENOMEM Insufficient kernel memory was available.
71
72 ENOSPC The device containing the file has no room for the new directory
73 entry.
74
75 ENOTDIR
76 A component used as a directory in newpath is not, in fact, a
77 directory.
78
79 EPERM The file system containing newpath does not support the creation
80 of symbolic links.
81
82 EROFS newpath is on a read-only file system.
83
85 SVr4, 4.3BSD, POSIX.1-2001.
86
88 No checking of oldpath is done.
89
90 Deleting the name referred to by a symlink will actually delete the
91 file (unless it also has other hard links). If this behavior is not
92 desired, use link(2).
93
95 ln(1), lchown(2), link(2), lstat(2), open(2), readlink(2), rename(2),
96 symlinkat(2), unlink(2), path_resolution(7), symlink(7)
97
99 This page is part of release 3.53 of the Linux man-pages project. A
100 description of the project, and information about reporting bugs, can
101 be found at http://www.kernel.org/doc/man-pages/.
102
103
104
105Linux 2013-01-27 SYMLINK(2)