SYMLINK(2) | System Calls | SYMLINK(2) |
symlink - make a symbolic link to a file
#include <unistd.h> int symlink(const char *name1, const char *name2);
int symlinkat(const char *name1, int fd, const char *name2);
The symlink() function creates a symbolic link name2 to the file name1. Either name may be an arbitrary pathname, the files need not be on the same file system, and name1 may be nonexistent.
The file to which the symbolic link points is used when an open(2) operation is performed on the link. A stat() operation performed on a symbolic link returns the linked-to file, while an lstat() operation returns information about the link itself. See stat(2). Unexpected results may occur when a symbolic link is made to a directory. To avoid confusion in applications, the readlink(2) call can be used to read the contents of a symbolic link.
The symlinkat() function behaves similarly to symlink(); however, when path2 is a relative path, then it will be looked up relative to the directory specified by the file descriptor fd. To look up something in the current working directory, the special value AT_FDCWD may be passed into fd.
Upon successful completion, 0 is returned. Otherwise, −1 is returned, errno is set to indicate the error, and the symbolic link is not made.
The symlink() and symlinkat() functions will fail if:
EACCES
EDQUOT
EEXIST
EFAULT
EILSEQ
EIO
ELOOP
ENAMETOOLONG
ENOENT
ENOSPC
ENOSYS
ENOTDIR
EROFS
The symlinkat() function will fail if:
EBADF
See attributes(7) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
Interface Stability | Standard |
cp(1), link(2), open(2), readlink(2), stat(2), unlink(2), attributes(7)
May 18, 2007 | OmniOS |