xstatconv.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. #include <sys/syscall.h>
  19. #include <sys/stat.h>
  20. #include <string.h>
  21. #include "xstatconv.h"
  22. void __xstat_conv(struct kernel_stat *kbuf, struct stat *buf)
  23. {
  24. /* Convert to current kernel version of `struct stat'. */
  25. memset(buf, 0x00, sizeof(*buf));
  26. buf->st_dev = kbuf->st_dev;
  27. buf->st_ino = kbuf->st_ino;
  28. buf->st_mode = kbuf->st_mode;
  29. buf->st_nlink = kbuf->st_nlink;
  30. buf->st_uid = kbuf->st_uid;
  31. buf->st_gid = kbuf->st_gid;
  32. buf->st_rdev = kbuf->st_rdev;
  33. buf->st_size = kbuf->st_size;
  34. buf->st_blksize = kbuf->st_blksize;
  35. buf->st_blocks = kbuf->st_blocks;
  36. buf->st_atim = kbuf->st_atim;
  37. buf->st_mtim = kbuf->st_mtim;
  38. buf->st_ctim = kbuf->st_ctim;
  39. }
  40. void __xstat32_conv(struct kernel_stat64 *kbuf, struct stat *buf)
  41. {
  42. /* Convert to current kernel version of `struct stat64'. */
  43. memset(buf, 0x00, sizeof(*buf));
  44. buf->st_dev = kbuf->st_dev;
  45. buf->st_ino = kbuf->st_ino;
  46. buf->st_mode = kbuf->st_mode;
  47. buf->st_nlink = kbuf->st_nlink;
  48. buf->st_uid = kbuf->st_uid;
  49. buf->st_gid = kbuf->st_gid;
  50. buf->st_rdev = kbuf->st_rdev;
  51. buf->st_size = kbuf->st_size;
  52. buf->st_blksize = kbuf->st_blksize;
  53. buf->st_blocks = kbuf->st_blocks;
  54. buf->st_atim = kbuf->st_atim;
  55. buf->st_mtim = kbuf->st_mtim;
  56. buf->st_ctim = kbuf->st_ctim;
  57. }
  58. #ifdef __UCLIBC_HAS_LFS__
  59. void __xstat64_conv(struct kernel_stat64 *kbuf, struct stat64 *buf)
  60. {
  61. /* Convert to current kernel version of `struct stat64'. */
  62. memset(buf, 0x00, sizeof(*buf));
  63. buf->st_dev = kbuf->st_dev;
  64. buf->st_ino = kbuf->st_ino;
  65. # ifdef _HAVE_STAT64___ST_INO
  66. buf->__st_ino = kbuf->__st_ino;
  67. # endif
  68. buf->st_mode = kbuf->st_mode;
  69. buf->st_nlink = kbuf->st_nlink;
  70. buf->st_uid = kbuf->st_uid;
  71. buf->st_gid = kbuf->st_gid;
  72. buf->st_rdev = kbuf->st_rdev;
  73. buf->st_size = kbuf->st_size;
  74. buf->st_blksize = kbuf->st_blksize;
  75. buf->st_blocks = kbuf->st_blocks;
  76. buf->st_atim = kbuf->st_atim;
  77. buf->st_mtim = kbuf->st_mtim;
  78. buf->st_ctim = kbuf->st_ctim;
  79. }
  80. #endif /* __UCLIBC_HAS_LFS__ */