'\"macro stdmacro
.if n .pH g2.symlink @(#)symlink	40.13 of 10/10/89
.\" Copyright 1989 AT&T
.nr X
.if \nX=0 .ds x} symlink 2 "" "\&"
.if \nX=1 .ds x} symlink 2 ""
.if \nX=2 .ds x} symlink 2 "" "\&"
.if \nX=3 .ds x} symlink "" "" "\&"
.TH \*(x}
.SH NAME
\f4symlink\f1 \- make a symbolic link to a file
.SH SYNOPSIS
\f4#include <unistd.h>\f1
.SP
\f4int symlink(const char *name1, const char *name2)\f1;
.IX  symlink  ""  \f4symlink\fP
.IX  "file system"  symlink  ""  \f4symlink\fP
.IX  "create" "symbolic link \(em \f4symlink\fP"
.IX  "symbolic link"  create
.IX  link  "make symbolic"
.SH DESCRIPTION
\f4symlink\fP creates
a symbolic link
\f2name2\f1
to the file
\f2name1\f1.
Either name may be an arbitrary pathname, the files need not
be on the same file system, and \f2name1\f1 may be nonexistent.
.PP
The file to which the symbolic link points is
used when an
\f4open\fP(2)
operation is performed on the link.
A \f4stat\fP(2)
on a symbolic link returns the linked-to file, while an
\f4lstat\fP
returns information about the link itself.  This can lead to
surprising
results when a symbolic link is made to a directory.
To avoid confusion in programs, the
\f4readlink\fP(2)
call can be used to read the contents of a symbolic link.
.PP
The symbolic link is made unless one or more of the following are true:
.TP 20
\f4EACCES\fP
Search permission is denied for a component of the path prefix of
.IR name2 .
.TP
\f4EDQUOT\fP
The directory in which the entry for the new symbolic
link is being placed cannot be extended because the
user's quota of disk blocks on the file system
containing the directory has been exhausted.
.TP
\f4EDQUOT\fP
The new symbolic link cannot be created because the
user's quota of disk blocks on the file system which
will contain the link has been exhausted.
.TP
\f4EDQUOT\fP
The user's quota of inodes on the file system on
which the file is being created has been exhausted.
.TP
\f4EEXIST\fP
The file referred to by
.I name2
already exists.
.TP
\f4EFAULT\fP
.I name1
or
.I name2
points outside the allocated address space for the process.
.TP
\f4EIO\fP
An I/O error occurs while reading from or writing to the file system.
.TP
\f4ELOOP\fP
Too many symbolic links are encountered in translating
.IR name2 .
.TP
\f4ENAMETOOLONG\fP
The length of the \f2name1\f1 or \f2name2\f1 argument exceeds {\f4PATH_MAX\f1},
or the
length of a \f2name1\f1 or \f2name2\f1 component exceeds {\f4NAME_MAX\f1} while
(\f4_POSIX_NO_TRUNC\f1) is in effect.
.TP
\f4ENOENT\fP
A component of the path prefix of
.I name2
does not exist.
.TP
\f4ENOSPC\fP
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.
.TP
\f4ENOSPC\fP
The new symbolic link cannot be created because
no space is left on the file system which will contain the link.
.TP
\f4ENOSPC\fP
There are no free inodes on the file system on which the file is being created.
.TP
\f4ENOSYS\fP
The file system does not support symbolic links
.TP
\f4ENOTDIR\fP
A component of the path prefix of
.I name2
is not a directory.
.TP
\f4EROFS\fP
The file
.I name2
would reside on a read-only file system.
.SH DIAGNOSTICS 
Upon successful completion
\f4symlink\fP returns a value of 0;
otherwise, it returns \-1
and places an error code in
\f4errno\f1.
.SH "SEE ALSO"
\f4link\fP(2), \f4readlink\fP(2), \f4unlink\fP(2).
\f4cp\f1(1) in the \f2User's Reference Manual\f1.
