xstatconv.c 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 attribute_hidden __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. buf->st_ino = kbuf->st_ino;
  34. buf->st_mode = kbuf->st_mode;
  35. buf->st_nlink = kbuf->st_nlink;
  36. buf->st_uid = kbuf->st_uid;
  37. buf->st_gid = kbuf->st_gid;
  38. buf->st_rdev = kbuf->st_rdev;
  39. buf->st_size = kbuf->st_size;
  40. buf->st_blksize = kbuf->st_blksize;
  41. buf->st_blocks = kbuf->st_blocks;
  42. buf->st_atime = kbuf->st_atime;
  43. buf->st_mtime = kbuf->st_mtime;
  44. buf->st_ctime = kbuf->st_ctime;
  45. #ifdef STAT_HAVE_NSEC
  46. buf->st_atimensec = kbuf->st_atime_nsec;
  47. buf->st_mtimensec = kbuf->st_mtime_nsec;
  48. buf->st_ctimensec = kbuf->st_ctime_nsec;
  49. #endif
  50. }
  51. #if defined(__UCLIBC_HAS_LFS__)
  52. void attribute_hidden __xstat64_conv(struct kernel_stat64 *kbuf, struct stat64 *buf)
  53. {
  54. /* Convert to current kernel version of `struct stat64'. */
  55. buf->st_dev = kbuf->st_dev;
  56. buf->st_ino = kbuf->st_ino;
  57. #ifdef _HAVE_STAT64___ST_INO
  58. buf->__st_ino = kbuf->__st_ino;
  59. #endif
  60. buf->st_mode = kbuf->st_mode;
  61. buf->st_nlink = kbuf->st_nlink;
  62. buf->st_uid = kbuf->st_uid;
  63. buf->st_gid = kbuf->st_gid;
  64. buf->st_rdev = kbuf->st_rdev;
  65. buf->st_size = kbuf->st_size;
  66. buf->st_blksize = kbuf->st_blksize;
  67. buf->st_blocks = kbuf->st_blocks;
  68. buf->st_atime = kbuf->st_atime;
  69. buf->st_mtime = kbuf->st_mtime;
  70. buf->st_ctime = kbuf->st_ctime;
  71. #ifdef STAT_HAVE_NSEC
  72. buf->st_atimensec = kbuf->st_atime_nsec;
  73. buf->st_mtimensec = kbuf->st_mtime_nsec;
  74. buf->st_ctimensec = kbuf->st_ctime_nsec;
  75. #endif
  76. }
  77. #endif /* __UCLIBC_HAS_LFS__ */