Merge branch 'vendor/TCPDUMP'
[dragonfly.git] / lib / libc / 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/libc/sys/link.2,v 1.4 2007/04/26 17:35:03 swildner 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 named file has its immutable or append-only flag set (see
121 .Xr chflags 2 ) .
122 .It Bq Er EPERM
123 The file named by
124 .Fa name1
125 is a directory.
126 .It Bq Er EXDEV
127 The link named by
128 .Fa name2
129 and the file named by
130 .Fa name1
131 are on different file systems.
132 .It Bq Er ENOSPC
133 The directory in which the entry for the new link is being placed
134 cannot be extended because there is no space left on the file
135 system containing the directory.
136 .It Bq Er EDQUOT
137 The directory in which the entry for the new link
138 is being placed cannot be extended because the
139 user's quota of disk blocks on the file system
140 containing the directory has been exhausted.
141 .It Bq Er EIO
142 An I/O error occurred while reading from or writing to
143 the file system to make the directory entry.
144 .It Bq Er EROFS
145 The requested link requires writing in a directory on a read-only file
146 system.
147 .It Bq Er EFAULT
148 One of the pathnames specified
149 is outside the process's allocated address space.
150 .El
151 .Sh SEE ALSO
152 .Xr readlink 2 ,
153 .Xr symlink 2 ,
154 .Xr unlink 2
155 .Sh STANDARDS
156 The
157 .Fn link
158 function call is expected to conform to
159 .St -p1003.1-90 .
160 .Sh HISTORY
161 A
162 .Fn link
163 function call appeared in
164 .At v7 .
165 .Pp
166 The
167 .Fn link
168 system call traditionally allows the super-user to link directories which
169 corrupts the filesystem coherency.  This implementation no longer permits
170 it.