| Skip Navigation Links | |
| Exit Print View | |
![]() | man pages section 2: System Calls Oracle Solaris 11 Information Library |
- make a symbolic link to a file
#include <unistd.h>intsymlink(const char *path1,const char *path2);
intsymlinkat(const char *path1,intfd,const char *path2);
Thesymlink() function creates a symbolic linkpath2 to the filepath1.Either name may be an arbitrary pathname, the files need not beon the same file system, andpath1 may be nonexistent.
The file to which the symbolic link points is used when anopen(2) operation is performed on the link. Astat() operation performed on asymbolic link returns the linked-to file, while anlstat() operation returns informationabout the link itself. Seestat(2). Unexpected results may occur when asymbolic link is made to a directory. To avoid confusion in applications,thereadlink(2) call can be used to read the contents of asymbolic link.
Thesymlinkat() function is equivalent to thesymlink() function except in thecase wherepath2 specifies a relative path. In this case the symboliclink is created relative to the directory associated with the file descriptorfd instead of the current working directory. If the file descriptor wasopened withoutO_SEARCH, the function checks whether directory searches are permitted usingthe current permissions of the directory underlying the file descriptor. If thefile descriptor was opened withO_SEARCH, the function does not perform the check.
Ifsymlinkat() is passed the special valueAT_FDCWD in thefd parameter,the current working directory is used and the behavior is identical toa call tosymlink().
Upon successful completion,0 is returned. Otherwise,-1 is returned,errnois set to indicate the error, and the symbolic link is notmade.
Thesymlink() andsymlinkat() functions will fail if:
Write permission is denied in the directory where the symbolic link is being created, or search permission is denied for a component of the path prefix ofpath2.
The directory where the entry for the new symbolic link is being placed cannot be extended because the user's quota of disk blocks on that file system has been exhausted; the new symbolic link cannot be created because the user's quota of disk blocks on that file system has been exhausted; or the user's quota of inodes on the file system where the file is being created has been exhausted.
The file referred to bypath2 already exists.
Thepath1 orpath2 argument points to an illegal address.
The path argument includes non-UTF8 characters and the file system accepts only file names where all characters are part of the UTF-8 character codeset.
An I/O error occurs while reading from or writing to the file system.
Too many symbolic links are encountered in translatingpath2.
The length of thepath2 argument exceedsPATH_MAX, or the length of apath2 component exceedsNAME_MAX while_POSIX_NO_TRUNC is in effect.
A component of the path prefix ofpath2 does not exist.
The directory in which the entry for the new symbolic link is being placed cannot be extended because no space is left on the file system containing the directory; the new symbolic link cannot be created because no space is left on the file system which will contain the link; or there are no free inodes on the file system on which the file is being created.
The file system does not support symbolic links.
A component of the path prefix ofpath2 is not a directory.
The filepath2 would reside on a read-only file system.
Thesymlinkat() function will fail if:
fd was not opened withO_SEARCH and the permissions of the directory underlyingfd do not permit directory searches.
Thepath2 argument does not specify an absolute path and thefd argument is neitherAT_FDCWD nor a valid file descriptor open for reading or searching.
Thesymlink() andsymlinkat() functions may fail if:
More than {SYMLOOP_MAX} symbolic links were encountered during resolution of thepath2 argument.
The length of thepath2 argument exceeds {PATH_MAX} or pathname resolution of a symbolic link in thepath2 argument produced an intermediate result with a length that exceeds {PATH_MAX}.
Thesymlinkat() function may fail if:
Thepath2 argument is not an absolute path andfd is neitherAT_FDCWD nor a file descriptor associated with a directory
Seeattributes(5) for descriptions of the following attributes:
|
cp(1),link(2),open(2),readlink(2),stat(2),unlink(2),attributes(5)
Copyright © 2011, Oracle and/or its affiliates. All rights reserved.Legal Notices | ![]() ![]() |