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
14 symlink() creates a symbolic link named newpath which contains the
15 string oldpath.
16
17 Symbolic links are interpreted at run-time as if the contents of the
18 link had been substituted into the path being followed to find a file
19 or directory.
20
21 Symbolic links may contain .. path components, which (if used at the
22 start of the link) refer to the parent directories of that in which the
23 link resides.
24
25 A symbolic link (also known as a soft link) may point to an existing
26 file or to a nonexistent one; the latter case is known as a dangling
27 link.
28
29 The permissions of a symbolic link are irrelevant; the ownership is
30 ignored when following the link, but is checked when removal or renam‐
31 ing of the link is requested and the link is in a directory with the
32 sticky bit (S_ISVTX) set.
33
34 If newpath exists it will not be overwritten.
35
37 On success, zero is returned. On error, -1 is returned, and errno is
38 set appropriately.
39
41 EACCES Write access to the directory containing newpath is denied, or
42 one of the directories in the path prefix of newpath did not
43 allow search permission. (See also path_resolution(2).)
44
45 EEXIST newpath already exists.
46
47 EFAULT oldpath or newpath points outside your accessible address space.
48
49 EIO An I/O error occurred.
50
51 ELOOP Too many symbolic links were encountered in resolving newpath.
52
53 ENAMETOOLONG
54 oldpath or newpath was too long.
55
56 ENOENT A directory component in newpath does not exist or is a dangling
57 symbolic link, or oldpath is the empty string.
58
59 ENOMEM Insufficient kernel memory was available.
60
61 ENOSPC The device containing the file has no room for the new directory
62 entry.
63
64 ENOTDIR
65 A component used as a directory in newpath is not, in fact, a
66 directory.
67
68 EPERM The filesystem containing newpath does not support the creation
69 of symbolic links.
70
71 EROFS newpath is on a read-only filesystem.
72
74 No checking of oldpath is done.
75
76 Deleting the name referred to by a symlink will actually delete the
77 file (unless it also has other hard links). If this behaviour is not
78 desired, use link().
79
81 SVr4, 4.3BSD, POSIX.1-2001.
82
84 ln(1), link(2), lstat(2), open(2), path_resolution(2), readlink(2),
85 rename(2), symlinkat(2), unlink(2)
86
87
88
89Linux 2.6.7 2004-06-23 SYMLINK(2)