1SYMLINK(2)                 Linux Programmer's Manual                SYMLINK(2)
2
3
4

NAME

6       symlink - make a new name for a file
7

SYNOPSIS

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(): _BSD_SOURCE || _XOPEN_SOURCE >= 500 ||
16       _POSIX_C_SOURCE >= 200112L
17

DESCRIPTION

19       symlink() creates a symbolic link  named  newpath  which  contains  the
20       string oldpath.
21
22       Symbolic  links  are  interpreted at run time as if the contents of the
23       link had been substituted into the path being followed to find  a  file
24       or directory.
25
26       Symbolic  links  may contain ..  path components, which (if used at the
27       start of the link) refer to the parent directories of that in which the
28       link resides.
29
30       A  symbolic  link  (also known as a soft link) may point to an existing
31       file or to a nonexistent one; the latter case is known  as  a  dangling
32       link.
33
34       The  permissions  of  a  symbolic link are irrelevant; the ownership is
35       ignored when following the link, but is checked when removal or  renam‐
36       ing  of  the  link is requested and the link is in a directory with the
37       sticky bit (S_ISVTX) set.
38
39       If newpath exists it will not be overwritten.
40

RETURN VALUE

42       On success, zero is returned.  On error, -1 is returned, and  errno  is
43       set appropriately.
44

ERRORS

46       EACCES Write  access  to the directory containing newpath is denied, or
47              one of the directories in the path prefix  of  newpath  did  not
48              allow search permission.  (See also path_resolution(7).)
49
50       EEXIST newpath already exists.
51
52       EFAULT oldpath or newpath points outside your accessible address space.
53
54       EIO    An I/O error occurred.
55
56       ELOOP  Too many symbolic links were encountered in resolving newpath.
57
58       ENAMETOOLONG
59              oldpath or newpath was too long.
60
61       ENOENT A directory component in newpath does not exist or is a dangling
62              symbolic link, or oldpath is the empty string.
63
64       ENOMEM Insufficient kernel memory was available.
65
66       ENOSPC The device containing the file has no room for the new directory
67              entry.
68
69       ENOTDIR
70              A  component  used  as a directory in newpath is not, in fact, a
71              directory.
72
73       EPERM  The file system containing newpath does not support the creation
74              of symbolic links.
75
76       EROFS  newpath is on a read-only file system.
77

CONFORMING TO

79       SVr4, 4.3BSD, POSIX.1-2001.
80

NOTES

82       No checking of oldpath is done.
83
84       Deleting  the  name  referred  to by a symlink will actually delete the
85       file (unless it also has other hard links).  If this  behavior  is  not
86       desired, use link(2).
87

SEE ALSO

89       ln(1),  lchown(2),  link(2), lstat(2), open(2), readlink(2), rename(2),
90       symlinkat(2), unlink(2), path_resolution(7), symlink(7)
91

COLOPHON

93       This page is part of release 3.22 of the Linux  man-pages  project.   A
94       description  of  the project, and information about reporting bugs, can
95       be found at http://www.kernel.org/doc/man-pages/.
96
97
98
99Linux                             2007-07-26                        SYMLINK(2)
Impressum