xstatconv.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /* Convert between the kernel's `struct stat' format, and libc's.
  2. Copyright (C) 1991,1995,1996,1997,2000,2002 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, write to the Free
  14. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  15. 02111-1307 USA.
  16. Modified for uClibc by Erik Andersen <andersen@codepoet.org>
  17. */
  18. #define _GNU_SOURCE
  19. #define _LARGEFILE64_SOURCE
  20. #include <features.h>
  21. #undef __OPTIMIZE__
  22. /* We absolutely do _NOT_ want interfaces silently
  23. * * * renamed under us or very bad things will happen... */
  24. #ifdef __USE_FILE_OFFSET64
  25. # undef __USE_FILE_OFFSET64
  26. #endif
  27. #include <sys/stat.h>
  28. #include "xstatconv.h"
  29. void __xstat_conv(struct kernel_stat *kbuf, struct stat *buf)
  30. {
  31. /* Convert to current kernel version of `struct stat'. */
  32. buf->st_dev = kbuf->st_dev;
  33. #ifdef _HAVE_STAT___PAD1
  34. buf->__pad1 = 0;
  35. #endif
  36. buf->st_ino = kbuf->st_ino;
  37. buf->st_mode = kbuf->st_mode;
  38. buf->st_nlink = kbuf->st_nlink;
  39. buf->st_uid = kbuf->st_uid;
  40. buf->st_gid = kbuf->st_gid;
  41. buf->st_rdev = kbuf->st_rdev;
  42. #ifdef _HAVE_STAT___PAD2
  43. buf->__pad2 = 0;
  44. #endif
  45. buf->st_size = kbuf->st_size;
  46. buf->st_blksize = kbuf->st_blksize;
  47. buf->st_blocks = kbuf->st_blocks;
  48. buf->st_atime = kbuf->st_atime;
  49. #ifdef _HAVE_STAT___UNUSED1
  50. buf->__unused1 = 0;
  51. #endif
  52. buf->st_mtime = kbuf->st_mtime;
  53. #ifdef _HAVE_STAT___UNUSED2
  54. buf->__unused2 = 0;
  55. #endif
  56. buf->st_ctime = kbuf->st_ctime;
  57. #ifdef _HAVE_STAT___UNUSED3
  58. buf->__unused3 = 0;
  59. #endif
  60. #ifdef _HAVE_STAT___UNUSED4
  61. buf->__unused4 = 0;
  62. #endif
  63. #ifdef _HAVE_STAT___UNUSED5
  64. buf->__unused5 = 0;
  65. #endif
  66. }
  67. void __xstat64_conv(struct kernel_stat64 *kbuf, struct stat64 *buf)
  68. {
  69. /* Convert to current kernel version of `struct stat64'. */
  70. buf->st_dev = kbuf->st_dev;
  71. #ifdef _HAVE_STAT64___PAD1
  72. buf->__pad1 = 0;
  73. #endif
  74. buf->st_ino = kbuf->st_ino;
  75. #ifdef _HAVE_STAT64___ST_INO
  76. buf->__st_ino = kbuf->st_ino;
  77. #endif
  78. buf->st_mode = kbuf->st_mode;
  79. buf->st_nlink = kbuf->st_nlink;
  80. buf->st_uid = kbuf->st_uid;
  81. buf->st_gid = kbuf->st_gid;
  82. buf->st_rdev = kbuf->st_rdev;
  83. #ifdef _HAVE_STAT64___PAD2
  84. buf->__pad2 = 0;
  85. #endif
  86. buf->st_size = kbuf->st_size;
  87. buf->st_blksize = kbuf->st_blksize;
  88. buf->st_blocks = kbuf->st_blocks;
  89. buf->st_atime = kbuf->st_atime;
  90. #ifdef _HAVE_STAT64___UNUSED1
  91. buf->__unused1 = 0;
  92. #endif
  93. buf->st_mtime = kbuf->st_mtime;
  94. #ifdef _HAVE_STAT64___UNUSED2
  95. buf->__unused2 = 0;
  96. #endif
  97. buf->st_ctime = kbuf->st_ctime;
  98. #ifdef _HAVE_STAT64___UNUSED3
  99. buf->__unused3 = 0;
  100. #endif
  101. #ifdef _HAVE_STAT64___UNUSED4
  102. buf->__unused4 = 0;
  103. #endif
  104. #ifdef _HAVE_STAT64___UNUSED5
  105. buf->__unused5 = 0;
  106. #endif
  107. }