1LINK(2) System Calls Manual LINK(2)
2
3
4
6 link - make a hard link to a file
7
9 link(name1, name2)
10 char *name1, *name2;
11
13 A hard link to name1 is created; the link has the name name2. Name1
14 must exist.
15
16 With hard links, both name1 and name2 must be in the same file system.
17 Unless the caller is the super-user, name1 must not be a directory.
18 Both the old and the new link share equal access and rights to the
19 underlying object.
20
22 Upon successful completion, a value of 0 is returned. Otherwise, a
23 value of -1 is returned and errno is set to indicate the error.
24
26 Link will fail and no link will be created if one or more of the fol‐
27 lowing are true:
28
29 [ENOTDIR] A component of either path prefix is not a directory.
30
31 [EINVAL] Either pathname contains a character with the high-order
32 bit set.
33
34 [ENAMETOOLONG] A component of either pathname exceeded 255 characters,
35 or entire length of either path name exceeded 1023 char‐
36 acters.
37
38 [ENOENT] A component of either path prefix does not exist.
39
40 [EACCES] A component of either path prefix denies search permis‐
41 sion.
42
43 [EACCES] The requested link requires writing in a directory with
44 a mode that denies write permission.
45
46 [ELOOP] Too many symbolic links were encountered in translating
47 one of the pathnames.
48
49 [ENOENT] The file named by name1 does not exist.
50
51 [EEXIST] The link named by name2 does exist.
52
53 [EPERM] The file named by name1 is a directory and the effective
54 user ID is not super-user.
55
56 [EXDEV] The link named by name2 and the file named by name1 are
57 on different file systems.
58
59 [ENOSPC] The directory in which the entry for the new link is
60 being placed cannot be extended because there is no
61 space left on the file system containing the directory.
62
63 [EDQUOT] The directory in which the entry for the new link is
64 being placed cannot be extended because the user's quota
65 of disk blocks on the file system containing the direc‐
66 tory has been exhausted.
67
68 [EIO] An I/O error occurred while reading from or writing to
69 the file system to make the directory entry.
70
71 [EROFS] The requested link requires writing in a directory on a
72 read-only file system.
73
74 [EFAULT] One of the pathnames specified is outside the process's
75 allocated address space.
76
78 symlink(2), unlink(2)
79
80
81
824th Berkeley Distribution August 26, 1985 LINK(2)