xref: /openbsd-src/lib/libc/sys/symlink.2 (revision b2ea75c1b17e1a9a339660e7ed45cd24946b230e)
1.\"	$OpenBSD: symlink.2,v 1.10 1999/06/29 14:10:26 aaron Exp $
2.\"	$NetBSD: symlink.2,v 1.7 1995/02/27 12:38:34 cgd Exp $
3.\"
4.\" Copyright (c) 1983, 1991, 1993
5.\"	The Regents of the University of California.  All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\" 3. All advertising materials mentioning features or use of this software
16.\"    must display the following acknowledgement:
17.\"	This product includes software developed by the University of
18.\"	California, Berkeley and its contributors.
19.\" 4. Neither the name of the University nor the names of its contributors
20.\"    may be used to endorse or promote products derived from this software
21.\"    without specific prior written permission.
22.\"
23.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33.\" SUCH DAMAGE.
34.\"
35.\"     @(#)symlink.2	8.1 (Berkeley) 6/4/93
36.\"
37.Dd June 4, 1993
38.Dt SYMLINK 2
39.Os
40.Sh NAME
41.Nm symlink
42.Nd make symbolic link to a file
43.Sh SYNOPSIS
44.Fd #include <unistd.h>
45.Ft int
46.Fn symlink "const char *name1" "const char *name2"
47.Sh DESCRIPTION
48A symbolic link
49.Fa name2
50is created to
51.Fa name1
52.Pf ( Fa name2
53is the name of the
54file created,
55.Fa name1
56is the string
57used in creating the symbolic link).
58Either name may be an arbitrary path name; the files need not
59be on the same file system, and the file specified by
60.Fa name1
61need not exist at all.
62.Sh RETURN VALUES
63Upon successful completion, a zero value is returned.
64If an error occurs, the error code is stored in
65.Va errno
66and a \-1 value is returned.
67.Sh ERRORS
68The symbolic link succeeds unless:
69.Bl -tag -width Er
70.It Bq Er ENOTDIR
71A component of the
72.Fa name2
73prefix is not a directory.
74.It Bq Er ENAMETOOLONG
75A component of a pathname exceeded
76.Dv {NAME_MAX}
77characters, or an entire path name exceeded
78.Dv {PATH_MAX}
79characters.
80.It Bq Er ENOENT
81The named file does not exist.
82.It Bq Er EACCES
83A component of the
84.Fa name2
85path prefix denies search permission.
86.It Bq Er ELOOP
87Too many symbolic links were encountered in translating the pathname.
88.It Bq Er EEXIST
89.Fa name2
90already exists.
91.It Bq Er EIO
92An I/O error occurred while making the directory entry for
93.Fa name2 ,
94or allocating the inode for
95.Fa name2 ,
96or writing out the link contents of
97.Fa name2 .
98.It Bq Er EROFS
99The file
100.Fa name2
101would reside on a read-only file system.
102.It Bq Er ENOSPC
103The directory in which the entry for the new symbolic link is being placed
104cannot be extended because there is no space left on the file
105system containing the directory.
106.It Bq Er ENOSPC
107The new symbolic link cannot be created because there
108is no space left on the file
109system that will contain the symbolic link.
110.It Bq Er ENOSPC
111There are no free inodes on the file system on which the
112symbolic link is being created.
113.It Bq Er EDQUOT
114The directory in which the entry for the new symbolic link
115is being placed cannot be extended because the
116user's quota of disk blocks on the file system
117containing the directory has been exhausted.
118.It Bq Er EDQUOT
119The new symbolic link cannot be created because the user's
120quota of disk blocks on the file system that will
121contain the symbolic link has been exhausted.
122.It Bq Er EDQUOT
123The user's quota of inodes on the file system on
124which the symbolic link is being created has been exhausted.
125.It Bq Er EIO
126An I/O error occurred while making the directory entry or allocating the inode.
127.It Bq Er EFAULT
128.Fa name1
129or
130.Fa name2
131points outside the process's allocated address space.
132.El
133.Sh SEE ALSO
134.Xr ln 1 ,
135.Xr link 2 ,
136.Xr readlink 2 ,
137.Xr unlink 2 ,
138.Xr symlink 7
139.Sh HISTORY
140The
141.Fn symlink
142function call appeared in
143.Bx 4.2 .
144