X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fstat.c;h=fe5b1ac4934470305d61419c084b1c31002bf83a;hb=21c918ecedb2e44a857c1ff2fe2e4964a2f67312;hp=8aa770940702e50fd81cbc0fd52e640247a32e8e;hpb=c9d72f69bd201a1ab31464d91f234ea1817fe0e1;p=gnulib.git diff --git a/lib/stat.c b/lib/stat.c index 8aa770940..fe5b1ac49 100644 --- a/lib/stat.c +++ b/lib/stat.c @@ -1,5 +1,5 @@ /* Work around platform bugs in stat. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -16,10 +16,13 @@ /* written by Eric Blake */ +/* If the user's config.h happens to include , let it include only + the system's here, so that orig_stat doesn't recurse to + rpl_stat. */ +#define __need_system_sys_stat_h #include /* Get the original definition of stat. It might be defined as a macro. */ -#define __need_system_sys_stat_h #include #include #undef __need_system_sys_stat_h @@ -31,12 +34,24 @@ orig_stat (const char *filename, struct stat *buf) } /* Specification. */ -#include +/* Write "sys/stat.h" here, not , otherwise OSF/1 5.1 DTK cc + eliminates this include because of the preliminary #include + above. */ +#include "sys/stat.h" #include #include #include #include +#include "dosname.h" +#include "verify.h" + +#if REPLACE_FUNC_STAT_DIR +# include "pathmax.h" +# ifndef PATH_MAX +# error "Please port this replacement to your platform" +# endif +#endif /* Store information about NAME into ST. Work around bugs with trailing slashes. Mingw has other bugs (such as st_ino always @@ -55,13 +70,16 @@ rpl_stat (char const *name, struct stat *st) { size_t len = strlen (name); if (ISSLASH (name[len - 1])) - { - errno = ENOTDIR; - return -1; - } + { + errno = ENOTDIR; + return -1; + } } #endif /* REPLACE_FUNC_STAT_FILE */ #if REPLACE_FUNC_STAT_DIR + /* The only known systems where REPLACE_FUNC_STAT_DIR is needed also + have a constant PATH_MAX. */ + if (result == -1 && errno == ENOENT) { /* Due to mingw's oddities, there are some directories (like @@ -76,6 +94,7 @@ rpl_stat (char const *name, struct stat *st) char fixed_name[PATH_MAX + 1] = {0}; size_t len = strlen (name); bool check_dir = false; + verify (PATH_MAX <= 4096); if (PATH_MAX <= len) errno = ENAMETOOLONG; else if (len)