dfff9b9bc972c04e21b9109119ca28696a8ad594
[gnulib.git] / doc / posix-functions / unlinkat.texi
1 @node unlinkat
2 @section @code{unlinkat}
3 @findex unlinkat
4
5 POSIX specification: @url{http://www.opengroup.org/onlinepubs/9699919799/functions/unlinkat.html}
6
7 Gnulib module: openat
8
9 Portability problems fixed by Gnulib:
10 @itemize
11 @item
12 This function is missing on some platforms:
13 glibc 2.3.6, MacOS X 10.3, FreeBSD 6.0, NetBSD 3.0, OpenBSD 3.8, AIX
14 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1, Cygwin 1.5.x, mingw, Interix 3.5, BeOS.
15 But the replacement function is not safe to be used in libraries and is not multithread-safe.
16 @item
17 Some systems mistakenly succeed on @code{unlinkat(fd,"file/",flag)}:
18 Solaris 9.
19 @end itemize
20
21 Portability problems not fixed by Gnulib:
22 @itemize
23 @item
24 When @code{unlinkat(fd,name,AT_REMOVEDIR)} fails because the specified
25 directory is not empty, the @code{errno} value is system dependent.
26 @item
27 POSIX requires that @code{unlinkdir(fd,"link-to-empty/",AT_REMOVEDIR)}
28 remove @file{empty} and leave @file{link-to-empty} as a dangling
29 symlink.  This is counter-intuitive, so some systems fail with
30 @code{ENOTDIR} instead:
31 glibc
32 @item
33 Some systems allow a superuser to unlink directories, even though this
34 can cause file system corruption.  The error given if a process is not
35 permitted to unlink directories varies across implementations; it is
36 not always the POSIX value of @code{EPERM}.  Meanwhile, if a process
37 has the ability to unlink directories, POSIX requires that
38 @code{unlinkat(fd,"symlink-to-dir/",0)} remove @file{dir} and leave
39 @file{symlink-to-dir} dangling; this behavior is counter-intuitive.
40 The gnulib module unlinkdir can help determine whether code must be
41 cautious of unlinking directories.
42 @item
43 Removing an open file is non-portable: On Unix this allows the programs that
44 have the file already open to continue working with it; the file's storage
45 is only freed when the no process has the file open any more.  On Windows,
46 the attempt to remove an open file fails.
47 @end itemize