1SYMLINK(2) Linux Programmer's Manual SYMLINK(2)
2
3
4
6 symlink, symlinkat - make a new name for a file
7
9 #include <unistd.h>
10
11 int symlink(const char *target, const char *linkpath);
12
13 #include <fcntl.h> /* Definition of AT_* constants */
14 #include <unistd.h>
15
16 int symlinkat(const char *target, int newdirfd, const char *linkpath);
17
18 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
19
20 symlink():
21 _XOPEN_SOURCE >= 500 || _POSIX_C_SOURCE >= 200112L
22 || /* Glibc versions <= 2.19: */ _BSD_SOURCE
23
24 symlinkat():
25 Since glibc 2.10:
26 _POSIX_C_SOURCE >= 200809L
27 Before glibc 2.10:
28 _ATFILE_SOURCE
29
31 symlink() creates a symbolic link named linkpath which contains the
32 string target.
33
34 Symbolic links are interpreted at run time as if the contents of the
35 link had been substituted into the path being followed to find a file
36 or directory.
37
38 Symbolic links may contain .. path components, which (if used at the
39 start of the link) refer to the parent directories of that in which the
40 link resides.
41
42 A symbolic link (also known as a soft link) may point to an existing
43 file or to a nonexistent one; the latter case is known as a dangling
44 link.
45
46 The permissions of a symbolic link are irrelevant; the ownership is
47 ignored when following the link, but is checked when removal or renam‐
48 ing of the link is requested and the link is in a directory with the
49 sticky bit (S_ISVTX) set.
50
51 If linkpath exists, it will not be overwritten.
52
53 symlinkat()
54 The symlinkat() system call operates in exactly the same way as sym‐
55 link(), except for the differences described here.
56
57 If the pathname given in linkpath is relative, then it is interpreted
58 relative to the directory referred to by the file descriptor newdirfd
59 (rather than relative to the current working directory of the calling
60 process, as is done by symlink() for a relative pathname).
61
62 If linkpath is relative and newdirfd is the special value AT_FDCWD,
63 then linkpath is interpreted relative to the current working directory
64 of the calling process (like symlink()).
65
66 If linkpath is absolute, then newdirfd is ignored.
67
69 On success, zero is returned. On error, -1 is returned, and errno is
70 set appropriately.
71
73 EACCES Write access to the directory containing linkpath is denied, or
74 one of the directories in the path prefix of linkpath did not
75 allow search permission. (See also path_resolution(7).)
76
77 EDQUOT The user's quota of