1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- #define __need_system_sys_stat_h
- #include <config.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #undef __need_system_sys_stat_h
- static inline int
- orig_fstat (int fd, struct stat *buf)
- {
- return fstat (fd, buf);
- }
- #include "sys/stat.h"
- #include <errno.h>
- #include <unistd.h>
- #if HAVE_MSVC_INVALID_PARAMETER_HANDLER
- # include "msvc-inval.h"
- #endif
- #if HAVE_MSVC_INVALID_PARAMETER_HANDLER
- static inline int
- fstat_nothrow (int fd, struct stat *buf)
- {
- int result;
- TRY_MSVC_INVAL
- {
- result = orig_fstat (fd, buf);
- }
- CATCH_MSVC_INVAL
- {
- result = -1;
- errno = EBADF;
- }
- DONE_MSVC_INVAL;
- return result;
- }
- #else
- # define fstat_nothrow orig_fstat
- #endif
- int
- rpl_fstat (int fd, struct stat *buf)
- {
- #if REPLACE_FCHDIR && REPLACE_OPEN_DIRECTORY
-
- const char *name = _gl_directory_name (fd);
- if (name != NULL)
- return stat (name, buf);
- #endif
- return fstat_nothrow (fd, buf);
- }
|