libcr copy: Retarget build paths from ../libc to ../libcr and retarget
[dragonfly.git] / lib / libcr / sys / link.2
1 .\" Copyright (c) 1980, 1991, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\"    must display the following acknowledgement:
14 .\"     This product includes software developed by the University of
15 .\"     California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\"    may be used to endorse or promote products derived from this software
18 .\"    without specific prior written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" SUCH DAMAGE.
31 .\"
32 .\"     @(#)link.2      8.3 (Berkeley) 1/12/94
33 .\" $FreeBSD: src/lib/libc/sys/link.2,v 1.11.2.7 2001/12/14 18:34:01 ru Exp $
34 .\" $DragonFly: src/lib/libcr/sys/Attic/link.2,v 1.2 2003/06/17 04:26:47 dillon Exp $
35 .\"
36 .Dd March 5, 1999
37 .Dt LINK 2
38 .Os
39 .Sh NAME
40 .Nm link
41 .Nd make a hard file link
42 .Sh LIBRARY
43 .Lb libc
44 .Sh SYNOPSIS
45 .In unistd.h
46 .Ft int
47 .Fn link "const char *name1" "const char *name2"
48 .Sh DESCRIPTION
49 The
50 .Fn link
51 function call
52 atomically creates the specified directory entry (hard link)
53 .Fa name2
54 with the attributes of the underlying object pointed at by
55 .Fa name1 .
56 If the link is successful: the link count of the underlying object
57 is incremented;
58 .Fa name1
59 and
60 .Fa name2
61 share equal access and rights
62 to the
63 underlying object.
64 .Pp
65 If
66 .Fa name1
67 is removed, the file
68 .Fa name2
69 is not deleted and the link count of the
70 underlying object is
71 decremented.
72 .Pp
73 .Fa Name1
74 must exist for the hard link to
75 succeed and
76 both
77 .Fa name1
78 and
79 .Fa name2
80 must be in the same file system.
81 .Fa name1
82 may not be a directory.
83 .Sh RETURN VALUES
84 .Rv -std link
85 .Sh ERRORS
86 .Fn Link
87 will fail and no link will be created if:
88 .Bl -tag -width Er
89 .It Bq Er ENOTDIR
90 A component of either path prefix is not a directory.
91 .It Bq Er ENAMETOOLONG
92 A component of either pathname exceeded 255 characters,
93 or entire length of either path name exceeded 1023 characters.
94 .It Bq Er ENOENT
95 A component of either path prefix does not exist.
96 .It Bq Er EOPNOTSUPP
97 The file system containing the file named by
98 .Fa name1
99 does not support links.
100 .It Bq Er EMLINK
101 The link count of the file named by
102 .Fa name1
103 would exceed 32767.
104 .It Bq Er EACCES
105 A component of either path prefix denies search permission.
106 .It Bq Er EACCES
107 The requested link requires writing in a directory with a mode
108 that denies write permission.
109 .It Bq Er ELOOP
110 Too many symbolic links were encountered in translating one of the pathnames.
111 .It Bq Er ENOENT
112 The file named by
113 .Fa name1
114 does not exist.
115 .It Bq Er EEXIST
116 The link named by
117 .Fa name2
118 does exist.
119 .It Bq Er EPERM
120 The file named by
121 .Fa name1
122 is a directory.
123 .It Bq Er EXDEV
124 The link named by
125 .Fa name2
126 and the file named by
127 .Fa name1
128 are on different file systems.
129 .It Bq Er ENOSPC
130 The directory in which the entry for the new link is being placed
131 cannot be extended because there is no space left on the file
132 system containing the directory.
133 .It Bq Er EDQUOT
134 The directory in which the entry for the new link
135 is being placed cannot be extended because the
136 user's quota of disk blocks on the file system
137 containing the directory has been exhausted.
138 .It Bq Er EIO
139 An I/O error occurred while reading from or writing to
140 the file system to make the directory entry.
141 .It Bq Er EROFS
142 The requested link requires writing in a directory on a read-only file
143 system.
144 .It Bq Er EFAULT
145 One of the pathnames specified
146 is outside the process's allocated address space.
147 .El
148 .Sh SEE ALSO
149 .Xr readlink 2 ,
150 .Xr symlink 2 ,
151 .Xr unlink 2
152 .Sh STANDARDS
153 The
154 .Fn link
155 function call is expected to conform to
156 .St -p1003.1-90 .
157 .Sh HISTORY
158 A
159 .Fn link
160 function call appeared in
161 .At v7 .
162 .Pp
163 The
164 .Fn link
165 system call traditionally allows the super-user to link directories which
166 corrupts the filesystem coherency.  This implementation no longer permits
167 it.