30 argument is unused. If path is relative and dirfd has the value
31 AT_FDCWD, defined in <fcntl.h>, unlinkat() also behaves the same as
32 unlink(). Otherwise, path is resolved relative to the directory
33 referenced by the dirfd argument.
34
35
36 If the flag argument is set to the value AT_REMOVEDIR, defined in
37 <fcntl.h>, unlinkat() behaves the same as rmdir(2) except in the
38 processing of the path argument as described above.
39
40
41 When the file's link count becomes 0 and no process has the file open,
42 the space occupied by the file will be freed and the file is no longer
43 accessible. If one or more processes have the file open when the last
44 link is removed, the link is removed before unlink() or unlinkat()
45 returns, but the removal of the file contents is postponed until all
46 references to the file are closed.
47
48
49 If the path argument is a directory and the filesystem supports
50 unlink() and unlinkat() on directories, the directory is unlinked from
51 its parent with no cleanup being performed. In UFS, the disconnected
52 directory will be found the next time the filesystem is checked with
53 fsck(1M). The unlink() and unlinkat() functions will not fail simply
54 because a directory is not empty. The user with appropriate privileges
55 can orphan a non-empty directory without generating an error message.
56
57
58 If the path argument is a directory and the filesystem does not support
59 unlink() and unlink() on directories (for example, ZFS), the call will
60 fail with errno set to EPERM.
61
62
63 Upon successful completion, unlink() and unlinkat() will mark for
64 update the st_ctime and st_mtime fields of the parent directory. If
65 the file's link count is not 0, the st_ctime field of the file will be
66 marked for update.
67
68 RETURN VALUES
69 Upon successful completion, 0 is returned. Otherwise, -1 is returned,
70 errno is set to indicate the error, and the file is not unlinked.
71
72 ERRORS
73 The unlink() and unlinkat() functions will fail if:
74
75 EACCES
163 ATTRIBUTES
164 See attributes(5) for descriptions of the following attributes:
165
166
167
168
169 +--------------------+----------------------------------------------+
170 | ATTRIBUTE TYPE | ATTRIBUTE VALUE |
171 +--------------------+----------------------------------------------+
172 |Interface Stability | unlink() is Standard; unlinkat() is Evolving |
173 +--------------------+----------------------------------------------+
174 |MT-Level | Async-Signal-Safe |
175 +--------------------+----------------------------------------------+
176
177 SEE ALSO
178 rm(1), close(2), link(2), open(2), rmdir(2), remove(3C), attributes(5),
179 privileges(5), fsattr(5)
180
181
182
183 May 18, 2007 UNLINK(2)
|
30 argument is unused. If path is relative and dirfd has the value
31 AT_FDCWD, defined in <fcntl.h>, unlinkat() also behaves the same as
32 unlink(). Otherwise, path is resolved relative to the directory
33 referenced by the dirfd argument.
34
35
36 If the flag argument is set to the value AT_REMOVEDIR, defined in
37 <fcntl.h>, unlinkat() behaves the same as rmdir(2) except in the
38 processing of the path argument as described above.
39
40
41 When the file's link count becomes 0 and no process has the file open,
42 the space occupied by the file will be freed and the file is no longer
43 accessible. If one or more processes have the file open when the last
44 link is removed, the link is removed before unlink() or unlinkat()
45 returns, but the removal of the file contents is postponed until all
46 references to the file are closed.
47
48
49 If the path argument is a directory and the filesystem supports
50 unlink() and unlinkat() on directories the behaviour is dependent on
51 the filesystem.
52
53
54 If the path argument is a directory and the filesystem does not support
55 unlink() and unlink() on directories (for example, ZFS), the call will
56 fail with errno set to EPERM.
57
58
59 Upon successful completion, unlink() and unlinkat() will mark for
60 update the st_ctime and st_mtime fields of the parent directory. If
61 the file's link count is not 0, the st_ctime field of the file will be
62 marked for update.
63
64 RETURN VALUES
65 Upon successful completion, 0 is returned. Otherwise, -1 is returned,
66 errno is set to indicate the error, and the file is not unlinked.
67
68 ERRORS
69 The unlink() and unlinkat() functions will fail if:
70
71 EACCES
159 ATTRIBUTES
160 See attributes(5) for descriptions of the following attributes:
161
162
163
164
165 +--------------------+----------------------------------------------+
166 | ATTRIBUTE TYPE | ATTRIBUTE VALUE |
167 +--------------------+----------------------------------------------+
168 |Interface Stability | unlink() is Standard; unlinkat() is Evolving |
169 +--------------------+----------------------------------------------+
170 |MT-Level | Async-Signal-Safe |
171 +--------------------+----------------------------------------------+
172
173 SEE ALSO
174 rm(1), close(2), link(2), open(2), rmdir(2), remove(3C), attributes(5),
175 privileges(5), fsattr(5)
176
177
178
179 December 15, 2016 UNLINK(2)
|