diff options
Diffstat (limited to 'lib/stat.c')
| -rw-r--r-- | lib/stat.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/lib/stat.c b/lib/stat.c index f07370dd06b..1397aa93290 100644 --- a/lib/stat.c +++ b/lib/stat.c | |||
| @@ -16,10 +16,13 @@ | |||
| 16 | 16 | ||
| 17 | /* written by Eric Blake */ | 17 | /* written by Eric Blake */ |
| 18 | 18 | ||
| 19 | /* If the user's config.h happens to include <sys/stat.h>, let it include only | ||
| 20 | the system's <sys/stat.h> here, so that orig_stat doesn't recurse to | ||
| 21 | rpl_stat. */ | ||
| 22 | #define __need_system_sys_stat_h | ||
| 19 | #include <config.h> | 23 | #include <config.h> |
| 20 | 24 | ||
| 21 | /* Get the original definition of stat. It might be defined as a macro. */ | 25 | /* Get the original definition of stat. It might be defined as a macro. */ |
| 22 | #define __need_system_sys_stat_h | ||
| 23 | #include <sys/types.h> | 26 | #include <sys/types.h> |
| 24 | #include <sys/stat.h> | 27 | #include <sys/stat.h> |
| 25 | #undef __need_system_sys_stat_h | 28 | #undef __need_system_sys_stat_h |
| @@ -31,7 +34,10 @@ orig_stat (const char *filename, struct stat *buf) | |||
| 31 | } | 34 | } |
| 32 | 35 | ||
| 33 | /* Specification. */ | 36 | /* Specification. */ |
| 34 | #include <sys/stat.h> | 37 | /* Write "sys/stat.h" here, not <sys/stat.h>, otherwise OSF/1 5.1 DTK cc |
| 38 | eliminates this include because of the preliminary #include <sys/stat.h> | ||
| 39 | above. */ | ||
| 40 | #include "sys/stat.h" | ||
| 35 | 41 | ||
| 36 | #include <errno.h> | 42 | #include <errno.h> |
| 37 | #include <limits.h> | 43 | #include <limits.h> |
| @@ -40,6 +46,15 @@ orig_stat (const char *filename, struct stat *buf) | |||
| 40 | #include "dosname.h" | 46 | #include "dosname.h" |
| 41 | #include "verify.h" | 47 | #include "verify.h" |
| 42 | 48 | ||
| 49 | #if REPLACE_FUNC_STAT_DIR | ||
| 50 | # include "pathmax.h" | ||
| 51 | /* The only known systems where REPLACE_FUNC_STAT_DIR is needed also | ||
| 52 | have a constant PATH_MAX. */ | ||
| 53 | # ifndef PATH_MAX | ||
| 54 | # error "Please port this replacement to your platform" | ||
| 55 | # endif | ||
| 56 | #endif | ||
| 57 | |||
| 43 | /* Store information about NAME into ST. Work around bugs with | 58 | /* Store information about NAME into ST. Work around bugs with |
| 44 | trailing slashes. Mingw has other bugs (such as st_ino always | 59 | trailing slashes. Mingw has other bugs (such as st_ino always |
| 45 | being 0 on success) which this wrapper does not work around. But | 60 | being 0 on success) which this wrapper does not work around. But |
| @@ -64,11 +79,6 @@ rpl_stat (char const *name, struct stat *st) | |||
| 64 | } | 79 | } |
| 65 | #endif /* REPLACE_FUNC_STAT_FILE */ | 80 | #endif /* REPLACE_FUNC_STAT_FILE */ |
| 66 | #if REPLACE_FUNC_STAT_DIR | 81 | #if REPLACE_FUNC_STAT_DIR |
| 67 | /* The only known systems where REPLACE_FUNC_STAT_DIR is needed also | ||
| 68 | have a constant PATH_MAX. */ | ||
| 69 | # ifndef PATH_MAX | ||
| 70 | # error "Please port this replacement to your platform" | ||
| 71 | # endif | ||
| 72 | 82 | ||
| 73 | if (result == -1 && errno == ENOENT) | 83 | if (result == -1 && errno == ENOENT) |
| 74 | { | 84 | { |