1symlink(2) System Calls symlink(2)
2
3
4
6 symlink - make a symbolic link to a file
7
9 #include <unistd.h>
10
11 int symlink(const char *name1, const char *name2);
12
13
15 The symlink() function creates a symbolic link name2 to the file name1.
16 Either name may be an arbitrary pathname, the files need not be on the
17 same file system, and name1 may be nonexistent.
18
19
20 The file to which the symbolic link points is used when an open(2)
21 operation is performed on the link. A stat() operation performed on a
22 symbolic link returns the linked-to file, while an lstat() operation
23 returns information about the link itself. See stat(2). Unexpected
24 results may occur when a symbolic link is made to a directory. To avoid
25 confusion in applications, the readlink(2) call can be used to read the
26 contents of a symbolic link.
27
29 Upon successful completion, 0 is returned. Otherwise, −1 is returned,
30 errno is set to indicate the error, and the symbolic link is not made.
31
33 The symlink() function will fail if:
34
35 EACCES Search permission is denied for a component of the path
36 prefix of name2.
37
38
39 EDQUOT The directory where the entry for the new symbolic link
40 is being placed cannot be extended because the user's
41 quota of disk blocks on that file system has been
42 exhausted; the new symbolic link cannot be created
43 because the user's quota of disk blocks on that file
44 system has been exhausted; or the user's quota of
45 inodes on the file system where the file is being cre‐
46 ated has been exhausted.
47
48
49 EEXIST The file referred to by name2 already exists.
50
51
52 EFAULT The name1 or name2 argument points to an illegal
53 address.
54
55
56 EILSEQ The path argument includes non-UTF8 characters and the
57 file system accepts only file names where all charac‐
58 ters are part of the UTF-8 character codeset.
59
60
61 EIO An I/O error occurs while reading from or writing to
62 the file system.
63
64
65 ELOOP Too many symbolic links are encountered in translating
66 name2.
67
68
69 ENAMETOOLONG The length of the name2 argument exceeds PATH_MAX, or
70 the length of a name2 component exceeds NAME_MAX while
71 _POSIX_NO_TRUNC is in effect.
72
73
74 ENOENT A component of the path prefix of name2 does not exist.
75
76
77 ENOSPC The directory in which the entry for the new symbolic
78 link is being placed cannot be extended because no
79 space is left on the file system containing the direc‐
80 tory; the new symbolic link cannot be created because
81 no space is left on the file system which will contain
82 the link; or there are no free inodes on the file sys‐
83 tem on which the file is being created.
84
85
86 ENOSYS The file system does not support symbolic links.
87
88
89 ENOTDIR A component of the path prefix of name2 is not a direc‐
90 tory.
91
92
93 EROFS The file name2 would reside on a read-only file system.
94
95
97 See attributes(5) for descriptions of the following attributes:
98
99
100
101
102 ┌─────────────────────────────┬─────────────────────────────┐
103 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
104 ├─────────────────────────────┼─────────────────────────────┤
105 │Interface Stability │Standard │
106 └─────────────────────────────┴─────────────────────────────┘
107
109 cp(1), link(2), open(2), readlink(2), stat(2), unlink(2), attributes(5)
110
111
112
113SunOS 5.11 18 May 2007 symlink(2)