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