statx_cp.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* Struct statx to stat/stat64 conversion for Linux.
  2. Copyright (C) 2018-2019 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, see
  14. <http://www.gnu.org/licenses/>. */
  15. #include <stddef.h>
  16. #include <string.h>
  17. #include <sys/stat.h>
  18. #include <statx_cp.h>
  19. #if !defined(__NR_fstat64) || !defined(__NR_fstatat64)
  20. void
  21. __cp_stat64_statx (struct stat64 *to, struct statx *from)
  22. {
  23. memset (to, 0, sizeof (struct stat64));
  24. to->st_dev = ((from->stx_dev_minor & 0xff) | (from->stx_dev_major << 8)
  25. | ((from->stx_dev_minor & ~0xff) << 12));
  26. to->st_rdev = ((from->stx_rdev_minor & 0xff) | (from->stx_rdev_major << 8)
  27. | ((from->stx_rdev_minor & ~0xff) << 12));
  28. to->st_ino = from->stx_ino;
  29. to->st_mode = from->stx_mode;
  30. to->st_nlink = from->stx_nlink;
  31. to->st_uid = from->stx_uid;
  32. to->st_gid = from->stx_gid;
  33. to->st_atime = from->stx_atime.tv_sec;
  34. to->st_atim.tv_nsec = from->stx_atime.tv_nsec;
  35. to->st_mtime = from->stx_mtime.tv_sec;
  36. to->st_mtim.tv_nsec = from->stx_mtime.tv_nsec;
  37. to->st_ctime = from->stx_ctime.tv_sec;
  38. to->st_ctim.tv_nsec = from->stx_ctime.tv_nsec;
  39. to->st_size = from->stx_size;
  40. to->st_blocks = from->stx_blocks;
  41. to->st_blksize = from->stx_blksize;
  42. }
  43. #endif