xref: /minix3/lib/libc/sys/symlink.2 (revision 84d9c625bfea59e274550651111ae9edfdc40fbd)
1*84d9c625SLionel Sambuc.\"	$NetBSD: symlink.2,v 1.26 2013/07/29 11:40:04 njoly Exp $
22fe8fb19SBen Gras.\"
32fe8fb19SBen Gras.\" Copyright (c) 1983, 1991, 1993
42fe8fb19SBen Gras.\"	The Regents of the University of California.  All rights reserved.
52fe8fb19SBen Gras.\"
62fe8fb19SBen Gras.\" Redistribution and use in source and binary forms, with or without
72fe8fb19SBen Gras.\" modification, are permitted provided that the following conditions
82fe8fb19SBen Gras.\" are met:
92fe8fb19SBen Gras.\" 1. Redistributions of source code must retain the above copyright
102fe8fb19SBen Gras.\"    notice, this list of conditions and the following disclaimer.
112fe8fb19SBen Gras.\" 2. Redistributions in binary form must reproduce the above copyright
122fe8fb19SBen Gras.\"    notice, this list of conditions and the following disclaimer in the
132fe8fb19SBen Gras.\"    documentation and/or other materials provided with the distribution.
142fe8fb19SBen Gras.\" 3. Neither the name of the University nor the names of its contributors
152fe8fb19SBen Gras.\"    may be used to endorse or promote products derived from this software
162fe8fb19SBen Gras.\"    without specific prior written permission.
172fe8fb19SBen Gras.\"
182fe8fb19SBen Gras.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
192fe8fb19SBen Gras.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
202fe8fb19SBen Gras.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
212fe8fb19SBen Gras.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
222fe8fb19SBen Gras.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
232fe8fb19SBen Gras.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
242fe8fb19SBen Gras.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
252fe8fb19SBen Gras.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
262fe8fb19SBen Gras.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
272fe8fb19SBen Gras.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
282fe8fb19SBen Gras.\" SUCH DAMAGE.
292fe8fb19SBen Gras.\"
302fe8fb19SBen Gras.\"     @(#)symlink.2	8.1 (Berkeley) 6/4/93
312fe8fb19SBen Gras.\"
32*84d9c625SLionel Sambuc.Dd July 29, 2013
332fe8fb19SBen Gras.Dt SYMLINK 2
342fe8fb19SBen Gras.Os
352fe8fb19SBen Gras.Sh NAME
36*84d9c625SLionel Sambuc.Nm symlink ,
37*84d9c625SLionel Sambuc.Nm symlinkat
382fe8fb19SBen Gras.Nd make symbolic link to a file
392fe8fb19SBen Gras.Sh LIBRARY
402fe8fb19SBen Gras.Lb libc
412fe8fb19SBen Gras.Sh SYNOPSIS
422fe8fb19SBen Gras.In unistd.h
432fe8fb19SBen Gras.Ft int
442fe8fb19SBen Gras.Fn symlink "const char *name1" "const char *name2"
45*84d9c625SLionel Sambuc.Ft int
46*84d9c625SLionel Sambuc.Fn symlinkat "const char *name1" "int fd" "const char *name2"
472fe8fb19SBen Gras.Sh DESCRIPTION
482fe8fb19SBen GrasA symbolic link
492fe8fb19SBen Gras.Fa name2
502fe8fb19SBen Grasis created to
512fe8fb19SBen Gras.Fa name1
522fe8fb19SBen Gras.Pf ( Fa name2
532fe8fb19SBen Grasis the name of the
542fe8fb19SBen Grasfile created,
552fe8fb19SBen Gras.Fa name1
562fe8fb19SBen Grasis the string
572fe8fb19SBen Grasused in creating the symbolic link).
582fe8fb19SBen GrasEither name may be an arbitrary path name; the files need neither
592fe8fb19SBen Grasto be on the same file system nor to exist.
60*84d9c625SLionel Sambuc.Pp
61*84d9c625SLionel Sambuc.Fn symlinkat
62*84d9c625SLionel Sambucworks the same way as
63*84d9c625SLionel Sambuc.Fn symlink
64*84d9c625SLionel Sambucexcept if
65*84d9c625SLionel Sambuc.Fa path2
66*84d9c625SLionel Sambucis relative.
67*84d9c625SLionel SambucIn that case, it is looked up from a directory whose file
68*84d9c625SLionel Sambucdescriptor was passed as
69*84d9c625SLionel Sambuc.Fa fd .
70*84d9c625SLionel SambucSearch permission is required on this directory.
71*84d9c625SLionel Sambuc.\"    (These alternatives await a decision about the semantics of O_SEARCH)
72*84d9c625SLionel Sambuc.\" Search permission is required on this directory
73*84d9c625SLionel Sambuc.\" except if
74*84d9c625SLionel Sambuc.\" .Fa fd
75*84d9c625SLionel Sambuc.\" was opened with the
76*84d9c625SLionel Sambuc.\" .Dv O_SEARCH
77*84d9c625SLionel Sambuc.\" flag.
78*84d9c625SLionel Sambuc.\"    - or -
79*84d9c625SLionel Sambuc.\" This file descriptor must have been opened with the
80*84d9c625SLionel Sambuc.\" .Dv O_SEARCH
81*84d9c625SLionel Sambuc.\" flag.
82*84d9c625SLionel Sambuc.Fa fd
83*84d9c625SLionel Sambuccan be set to
84*84d9c625SLionel Sambuc.Dv AT_FDCWD
85*84d9c625SLionel Sambucin order to specify the current directory.
862fe8fb19SBen Gras.Sh RETURN VALUES
87*84d9c625SLionel Sambuc.Rv -std symlink symlinkat
882fe8fb19SBen Gras.Sh ERRORS
89*84d9c625SLionel Sambuc.Fn symlink
90*84d9c625SLionel Sambucand
91*84d9c625SLionel Sambuc.Fn symlinkat
92*84d9c625SLionel Sambucwill fail and no link will be created if:
932fe8fb19SBen Gras.Bl -tag -width Er
94*84d9c625SLionel Sambuc.It Bq Er EACCES
952fe8fb19SBen GrasA component of the
962fe8fb19SBen Gras.Fa name2
97*84d9c625SLionel Sambucpath prefix denies search permission.
98*84d9c625SLionel Sambuc.It Bq Er EDQUOT
99*84d9c625SLionel SambucThe directory in which the entry for the new symbolic link
100*84d9c625SLionel Sambucis being placed cannot be extended because the
101*84d9c625SLionel Sambucuser's quota of disk blocks on the file system
102*84d9c625SLionel Sambuccontaining the directory has been exhausted.
103*84d9c625SLionel SambucOr, the new symbolic link cannot be created because the user's
104*84d9c625SLionel Sambucquota of disk blocks on the file system that will
105*84d9c625SLionel Sambuccontain the symbolic link has been exhausted.
106*84d9c625SLionel SambucOr, the user's quota of inodes on the file system on
107*84d9c625SLionel Sambucwhich the symbolic link is being created has been exhausted.
108*84d9c625SLionel Sambuc.It Bq Er EEXIST
109*84d9c625SLionel Sambuc.Fa name2
110*84d9c625SLionel Sambucalready exists.
111*84d9c625SLionel Sambuc.It Bq Er EFAULT
112*84d9c625SLionel Sambuc.Fa name1
113*84d9c625SLionel Sambucor
114*84d9c625SLionel Sambuc.Fa name2
115*84d9c625SLionel Sambucpoints outside the process's allocated address space.
116*84d9c625SLionel Sambuc.It Bq Er EIO
117*84d9c625SLionel SambucAn I/O error occurred while making the directory entry for
118*84d9c625SLionel Sambuc.Fa name2 ,
119*84d9c625SLionel Sambucor allocating the inode for
120*84d9c625SLionel Sambuc.Fa name2 ,
121*84d9c625SLionel Sambucor writing out the link contents of
122*84d9c625SLionel Sambuc.Fa name2 .
123*84d9c625SLionel SambucOr, an I/O error occurred while making the directory entry or allocating the inode.
124*84d9c625SLionel Sambuc.It Bq Er ELOOP
125*84d9c625SLionel SambucToo many symbolic links were encountered in translating the pathname.
1262fe8fb19SBen Gras.It Bq Er ENAMETOOLONG
1272fe8fb19SBen GrasA component of a pathname exceeded
1282fe8fb19SBen Gras.Brq Dv NAME_MAX
1292fe8fb19SBen Grascharacters, or an entire path name exceeded
1302fe8fb19SBen Gras.Brq Dv PATH_MAX
1312fe8fb19SBen Grascharacters.
1322fe8fb19SBen Gras.It Bq Er ENOENT
1332fe8fb19SBen GrasA component of the
1342fe8fb19SBen Gras.Fa name2
1352fe8fb19SBen Graspath does not exist.
1362fe8fb19SBen Gras.It Bq Er ENOSPC
1372fe8fb19SBen GrasThe directory in which the entry for the new symbolic link is being placed
1382fe8fb19SBen Grascannot be extended because there is no space left on the file
1392fe8fb19SBen Grassystem containing the directory.
140*84d9c625SLionel SambucOr, the new symbolic link cannot be created because there
1412fe8fb19SBen Grasthere is no space left on the file
1422fe8fb19SBen Grassystem that will contain the symbolic link.
143*84d9c625SLionel SambucOr, there are no free inodes on the file system on which the
1442fe8fb19SBen Grassymbolic link is being created.
145*84d9c625SLionel Sambuc.It Bq Er ENOTDIR
146*84d9c625SLionel SambucA component of the
1472fe8fb19SBen Gras.Fa name2
148*84d9c625SLionel Sambucprefix is not a directory.
149*84d9c625SLionel Sambuc.It Bq Er EROFS
150*84d9c625SLionel SambucThe file
151*84d9c625SLionel Sambuc.Fa name2
152*84d9c625SLionel Sambucwould reside on a read-only file system.
153*84d9c625SLionel Sambuc.El
154*84d9c625SLionel Sambuc.Pp
155*84d9c625SLionel SambucIn addition,
156*84d9c625SLionel Sambuc.Fn symlinkat
157*84d9c625SLionel Sambucwill fail if:
158*84d9c625SLionel Sambuc.Bl -tag -width Er
159*84d9c625SLionel Sambuc.It Bq Er EBADF
160*84d9c625SLionel Sambuc.Fa name2
161*84d9c625SLionel Sambucdoes not specify an absolute path and
162*84d9c625SLionel Sambuc.Fa fd
163*84d9c625SLionel Sambucis neither
164*84d9c625SLionel Sambuc.Dv AT_FDCWD
165*84d9c625SLionel Sambucnor a valid file descriptor open for reading or searching.
166*84d9c625SLionel Sambuc.It Bq Er ENOTDIR
167*84d9c625SLionel Sambuc.Fa name2
168*84d9c625SLionel Sambucis not an absolute path and
169*84d9c625SLionel Sambuc.Fa fd
170*84d9c625SLionel Sambucis a file descriptor associated with a non-directory file.
1712fe8fb19SBen Gras.El
1722fe8fb19SBen Gras.Sh SEE ALSO
1732fe8fb19SBen Gras.Xr ln 1 ,
1742fe8fb19SBen Gras.Xr link 2 ,
1752fe8fb19SBen Gras.Xr readlink 2 ,
1762fe8fb19SBen Gras.Xr unlink 2 ,
1772fe8fb19SBen Gras.Xr symlink 7
178*84d9c625SLionel Sambuc.Sh STANDARDS
179*84d9c625SLionel SambucThe
180*84d9c625SLionel Sambuc.Fn symlink
181*84d9c625SLionel Sambucfunction conforms to
182*84d9c625SLionel Sambuc.St -p1003.1-90 .
183*84d9c625SLionel Sambuc.Fn symlinkat
184*84d9c625SLionel Sambucconforms to
185*84d9c625SLionel Sambuc.St -p1003.1-2008 .
1862fe8fb19SBen Gras.Sh HISTORY
1872fe8fb19SBen GrasThe
1882fe8fb19SBen Gras.Fn symlink
1892fe8fb19SBen Grasfunction call appeared in
1902fe8fb19SBen Gras.Bx 4.2 .
191