sys-stat.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * <sys/stat.h> wrapper functions.
  3. *
  4. * Authors:
  5. * Jonathan Pryor ([email protected])
  6. *
  7. * Copyright (C) 2004-2006 Jonathan Pryor
  8. */
  9. #ifndef _GNU_SOURCE
  10. #define _GNU_SOURCE
  11. #endif /* ndef _GNU_SOURCE */
  12. #include <sys/types.h>
  13. #include <sys/stat.h>
  14. #include <unistd.h>
  15. #include <fcntl.h>
  16. #include <errno.h>
  17. #include "map.h"
  18. #include "mph.h"
  19. G_BEGIN_DECLS
  20. gint32
  21. Mono_Posix_Syscall_stat (const char *file_name, struct Mono_Posix_Stat *buf)
  22. {
  23. int r;
  24. struct stat _buf;
  25. if (buf == NULL) {
  26. errno = EFAULT;
  27. return -1;
  28. }
  29. r = stat (file_name, &_buf);
  30. if (r != -1 && Mono_Posix_ToStat (&_buf, buf) == -1)
  31. r = -1;
  32. return r;
  33. }
  34. gint32
  35. Mono_Posix_Syscall_fstat (int filedes, struct Mono_Posix_Stat *buf)
  36. {
  37. int r;
  38. struct stat _buf;
  39. if (buf == NULL) {
  40. errno = EFAULT;
  41. return -1;
  42. }
  43. r = fstat (filedes, &_buf);
  44. if (r != -1 && Mono_Posix_ToStat (&_buf, buf) == -1)
  45. r = -1;
  46. return r;
  47. }
  48. gint32
  49. Mono_Posix_Syscall_lstat (const char *file_name, struct Mono_Posix_Stat *buf)
  50. {
  51. int r;
  52. struct stat _buf;
  53. if (buf == NULL) {
  54. errno = EFAULT;
  55. return -1;
  56. }
  57. r = lstat (file_name, &_buf);
  58. if (r != -1 && Mono_Posix_ToStat (&_buf, buf) == -1)
  59. r = -1;
  60. return r;
  61. }
  62. gint32
  63. Mono_Posix_Syscall_mknod (const char *pathname, guint32 mode, mph_dev_t dev)
  64. {
  65. if (Mono_Posix_FromFilePermissions (mode, &mode) == -1)
  66. return -1;
  67. return mknod (pathname, mode, dev);
  68. }
  69. G_END_DECLS
  70. /*
  71. * vim: noexpandtab
  72. */