Subversion Repositories Kolibri OS

Rev

Rev 4874 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. /* Reentrant versions of fstat system call.  This implementation just
  2.    calls the fstat system call.  */
  3.  
  4. #include <reent.h>
  5. #include <unistd.h>
  6. #include <sys/stat.h>
  7. #include <_syslist.h>
  8.  
  9. /* Some targets provides their own versions of these functions.  Those
  10.    targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS.  */
  11.  
  12. #ifdef _REENT_ONLY
  13. #ifndef REENTRANT_SYSCALLS_PROVIDED
  14. #define REENTRANT_SYSCALLS_PROVIDED
  15. #endif
  16. #endif
  17.  
  18. #ifdef REENTRANT_SYSCALLS_PROVIDED
  19.  
  20. int _dummy_fstat_syscalls = 1;
  21.  
  22. #else
  23.  
  24. /* We use the errno variable used by the system dependent layer.  */
  25. #undef errno
  26. extern int errno;
  27.  
  28. /*
  29. FUNCTION
  30.         <<_fstat_r>>---Reentrant version of fstat
  31.  
  32. INDEX
  33.         _fstat_r
  34.  
  35. ANSI_SYNOPSIS
  36.         #include <reent.h>
  37.         int _fstat_r(struct _reent *<[ptr]>,
  38.                      int <[fd]>, struct stat *<[pstat]>);
  39.  
  40. TRAD_SYNOPSIS
  41.         #include <reent.h>
  42.         int _fstat_r(<[ptr]>, <[fd]>, <[pstat]>)
  43.         struct _reent *<[ptr]>;
  44.         int <[fd]>;
  45.         struct stat *<[pstat]>;
  46.  
  47. DESCRIPTION
  48.         This is a reentrant version of <<fstat>>.  It
  49.         takes a pointer to the global data block, which holds
  50.         <<errno>>.
  51. */
  52.  
  53. int
  54. _fstat_r (ptr, fd, pstat)
  55.      struct _reent *ptr;
  56.      int fd;
  57.      struct stat *pstat;
  58. {
  59.   int ret;
  60.  
  61.   errno = 0;
  62.   if ((ret = _fstat (fd, pstat)) == -1 && errno != 0)
  63.     ptr->_errno = errno;
  64.   return ret;
  65. }
  66.  
  67. #endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */
  68.