good enough for now
[unix-history] / usr / src / lib / libc / sys / link.2
CommitLineData
dd547749
KM
1.\" Copyright (c) 1980 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
fd690c8b 5.\" @(#)link.2 6.3 (Berkeley) %G%
dd547749 6.\"
7b9d67d2 7.TH LINK 2 ""
dd547749
KM
8.UC 4
9.SH NAME
9142a5ba 10link \- make a hard link to a file
dd547749
KM
11.SH SYNOPSIS
12.nf
9142a5ba
KM
13.ft B
14link(name1, name2)
15char *name1, *name2;
dd547749 16.fi
9142a5ba 17.ft R
dd547749 18.SH DESCRIPTION
9142a5ba 19A hard link
dd547749
KM
20to
21.I name1
22is created;
23the link has the name
24.IR name2 .
9142a5ba
KM
25.I Name1
26must exist.
27.PP
28With hard links,
29both
dd547749 30.I name1
9142a5ba 31and
dd547749 32.I name2
9142a5ba
KM
33must be in the same file system.
34Unless the caller is the super-user,
35.I name1
36must not be a directory.
37Both the old and the new
38.I link
39share equal access and rights to
40the underlying object.
41.SH "RETURN VALUE
42Upon successful completion, a value of 0 is returned. Otherwise,
43a value of \-1 is returned and
44.I errno
45is set to indicate the error.
46.SH "ERRORS
47.I Link
48will fail and no link will be created if one or more of the following
49are true:
50.TP 15
9142a5ba
KM
51[ENOTDIR]
52A component of either path prefix is not a directory.
53.TP 15
b5984ffe
KM
54[EINVAL]
55Either pathname contains a character with the high-order bit set.
56.TP 15
57[ENAMETOOLONG]
58A component of either pathname exceeded 255 characters,
59or entire length of either path name exceeded 1023 characters.
60.TP 15
9142a5ba
KM
61[ENOENT]
62A component of either path prefix does not exist.
63.TP 15
64[EACCES]
65A component of either path prefix denies search permission.
66.TP 15
b5984ffe
KM
67[EACCES]
68The requested link requires writing in a directory with a mode
69that denies write permission.
70.TP 15
71[ELOOP]
72Too many symbolic links were encountered in translating one of the pathnames.
73.TP 15
9142a5ba
KM
74[ENOENT]
75The file named by \fIname1\fP does not exist.
76.TP 15
77[EEXIST]
78The link named by \fIname2\fP does exist.
79.TP 15
80[EPERM]
81The file named by \fIname1\fP is a directory and the effective
82user ID is not super-user.
83.TP 15
84[EXDEV]
85The link named by \fIname2\fP and the file named by \fIname1\fP
86are on different file systems.
87.TP 15
fd690c8b
KM
88[ENOSPC]
89The directory in which the entry for the new link is being placed
90cannot be extended because there is no space left on the file
91system containing the directory.
92.TP 15
93[EDQUOT]
94The directory in which the entry for the new link
95is being placed cannot be extended because the
96user's quota of disk blocks on the file system
97containing the directory has been exhausted.
98.TP 15
b5984ffe 99[EIO]
fd690c8b
KM
100An I/O error occurred while reading from or writing to
101the file system to make the directory entry.
9142a5ba
KM
102.TP 15
103[EROFS]
104The requested link requires writing in a directory on a read-only file
105system.
106.TP 15
107[EFAULT]
108One of the pathnames specified
109is outside the process's allocated address space.
9142a5ba
KM
110.SH "SEE ALSO"
111symlink(2), unlink(2)