comparison lib/chdir-safer.c @ 6912:314715e0260d

Merge from coreutils.
author Paul Eggert <eggert@cs.ucla.edu>
date Mon, 03 Jul 2006 08:32:46 +0000
parents 6b31c8787689
children 3307ae6ea2e5
comparison
equal deleted inserted replaced
6911:8e002ebcf4b6 6912:314715e0260d
28 #include <fcntl.h> 28 #include <fcntl.h>
29 #include <errno.h> 29 #include <errno.h>
30 #include <unistd.h> 30 #include <unistd.h>
31 #include <sys/types.h> 31 #include <sys/types.h>
32 #include <sys/stat.h> 32 #include <sys/stat.h>
33 #include "same-inode.h"
33 34
34 #ifndef O_DIRECTORY 35 #ifndef O_DIRECTORY
35 # define O_DIRECTORY 0 36 # define O_DIRECTORY 0
36 #endif 37 #endif
37 38
38 #ifndef O_NOFOLLOW 39 #ifndef O_NOFOLLOW
39 # define O_NOFOLLOW 0 40 # define O_NOFOLLOW 0
40 #endif 41 #endif
41
42 #define SAME_INODE(Stat_buf_1, Stat_buf_2) \
43 ((Stat_buf_1).st_ino == (Stat_buf_2).st_ino \
44 && (Stat_buf_1).st_dev == (Stat_buf_2).st_dev)
45 42
46 /* Like chdir, but fail if DIR is a symbolic link to a directory (or 43 /* Like chdir, but fail if DIR is a symbolic link to a directory (or
47 similar funny business), or if DIR is not readable. This avoids a 44 similar funny business), or if DIR is not readable. This avoids a
48 minor race condition between when a directory is created or statted 45 minor race condition between when a directory is created or statted
49 and when the process chdirs into it. */ 46 and when the process chdirs into it. */