symlink(S-osr5)
symlink --
creates symbolic link to a file
Syntax
cc ... -lc
int symlink(path, newpath)
char *path, *newpath;
Description
The symlink function creates a symbolic link.
The argument path is the name and location of the object to
which the symbolic link points.
The argument newpath is the name and location of the symbolic link
being created.
The object, path, that the symbolic link, newpath, points
to, must be specified either as an absolute path, or as a relative path leading
from the directory containing the symbolic link
to the object path.
path and newpath need not be on the
same file systems.
The object path need not exist for the symbolic
link to be created.
Neither path nor newpath can be a
null string.
Symbolic links are used only to find objects, therefore they can point
to any object supported by the filesystem, including, but not limited to,
regular files, directories, block, character and FIFO special files and
other symbolic links.
A call to
stat(S-osr5)
with the symbolic link newpath
returns information about the file, path, as if
stat(S-osr5)
had been called on path directly. A call to
lstat(S-osr5)
returns information about the symbolic link, newpath.
Both of these routines are described on the
stat(S-osr5)
manual page.
Calls to
symlink(S-osr5)
or
lstat(S-osr5)
made on a kernel on which these calls are not supported,
such as SCO UNIX System V Release 3.2 Version 2.0,
produce the signal SIGSYS.
Programs can be made to operate correctly on kernels that do and
do not support these routines by first calling
lstat(S-osr5)
and then calling
stat(S-osr5)
if SIGSYS is produced by the first call.
readlink(S-osr5)
can be used to read the contents of a symbolic link.
An error is returned if any of the following is true:
[EACCES]-
Search permission denied for a component of the path prefix of
newpath.
[EEXIST]-
The file specified in newpath already exists.
[EFAULT]-
path or newpath points outside the process's
allocated address space.
[EINVAL]-
-
The filesystem on which newpath is created
does not support symbolic links
-
The path argument is a null string
[ELOOP]-
Too many symbolic links were encountered in translating the
newpath file argument. The maximum number of symbolic links,
that can be found in a pathname, is defined by _POSIX_SYMLOOP
in the <sys/unistd.h> header file. This value is compiled into
the kernel so changing this value does not affect the limit unless the kernel
is recompiled.
[ENAMETOOLONG]-
-
The length of a component of newpath exceeds the
allowable length of a pathname component on the filesystem
on which it is to be created, for example, 255 characters
on VxFS or HTFS, or 14 characters for S51K.
-
The length of either path or newpath exceeds 1024
characters.
[ENOENT]-
A component of the path prefix of the newpath file
argument does not exist.
[ENOSPC]-
-
The directory in which the entry for the new symbolic link is
being placed cannot be extended because no space is left on the
filesystem containing the directory.
-
The new symbolic link cannot be created because no space is left
on the filesystem containing the link.
-
No free inodes are available on the filesystem containing the
link.
[ENOTDIR]-
A component of the path prefix of the newpath file
argument is not a directory.
[EROFS]-
The file specified in newpath would reside on a read-only
filesystem.
Return value
Upon successful completion, zero (0) is returned. If an error
occurs, an error is returned in errno and -1 is
returned to the calling routine.
See also
link(S-osr5),
ln(C),
lstat(S-osr5),
readlink(S-osr5),
stat(S-osr5),
unlink(S-osr5)
Standards conformance
symlink is not part of any currently supported standard;
it is an extension of AT&T System V developed by the Santa Cruz Operation
and maintained by The SCO Group.
.
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005