SYMLINK(2) | System Calls Manual | SYMLINK(2) |
symlink
, symlinkat
— make symbolic link to a file
#include
<unistd.h>
int
symlink
(const char *path1,
const char *path2);
int
symlinkat
(const
char *name1, int
fd, const char
*name2);
A symbolic link path2 is created to path1 (path2 is the name of the file created, path1 is the string used in creating the symbolic link). Either name may be an arbitrary path name; the files need not be on the same file system.
The
symlinkat
()
system call is equivalent to
symlink
()
except in the case where name2 specifies a relative
path. In this case the symbolic link is created relative to the directory
associated with the file descriptor fd instead of the
current working directory. If symlinkat
() is passed
the special value AT_FDCWD
in the
fd parameter, the current working directory is used
and the behavior is identical to a call to
symlink
().
Upon successful completion, a zero value is returned. If an error occurs, the error code is stored in errno and a -1 value is returned.
The symbolic link succeeds unless:
EACCES
]EACCES
]EDQUOT
]EDQUOT
]EDQUOT
]EEXIST
]EFAULT
]EIO
]EIO
]ELOOP
]ENAMETOOLONG
]{NAME_MAX}
characters, or an entire path name exceeds
{PATH_MAX}
characters.ENOENT
]ENOSPC
]ENOSPC
]ENOSPC
]ENOTDIR
]EROFS
]In addition to the errors returned by the
symlink
(), the symlinkat
()
may fail if:
EBADF
]AT_FDCWD
nor a valid file descriptor open for
searching.ENOTDIR
]AT_FDCWD
nor a
file descriptor associated with a directory.EILSEQ
]The symlinkat
() system call is expected to
conform to POSIX.1-2008 .
The symlink
() function call appeared in
4.2BSD. The symlinkat
()
system call appeared in OS X 10.10
June 4, 1993 | BSD 4.2 |