1 /* Struct statx to stat/stat64 conversion for Linux. 2 Copyright (C) 2018-2022 Free Software Foundation, Inc. 3 This file is part of the GNU C Library. 4 5 The GNU C Library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) any later version. 9 10 The GNU C Library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Lesser General Public License for more details. 14 15 You should have received a copy of the GNU Lesser General Public 16 License along with the GNU C Library. If not, see 17 <https://www.gnu.org/licenses/>. */ 18 19 #include <stddef.h> 20 #include <string.h> 21 #include <sys/stat.h> 22 23 #include <statx_cp.h> 24 25 #if !defined(__NR_fstat64) || !defined(__NR_fstatat64) 26 void __cp_stat64_statx(struct stat64 * to,struct statx * from)27__cp_stat64_statx (struct stat64 *to, struct statx *from) 28 { 29 memset (to, 0, sizeof (struct stat64)); 30 to->st_dev = ((from->stx_dev_minor & 0xff) | (from->stx_dev_major << 8) 31 | ((from->stx_dev_minor & ~0xff) << 12)); 32 to->st_rdev = ((from->stx_rdev_minor & 0xff) | (from->stx_rdev_major << 8) 33 | ((from->stx_rdev_minor & ~0xff) << 12)); 34 to->st_ino = from->stx_ino; 35 to->st_mode = from->stx_mode; 36 to->st_nlink = from->stx_nlink; 37 to->st_uid = from->stx_uid; 38 to->st_gid = from->stx_gid; 39 to->st_atime = from->stx_atime.tv_sec; 40 to->st_atim.tv_nsec = from->stx_atime.tv_nsec; 41 to->st_mtime = from->stx_mtime.tv_sec; 42 to->st_mtim.tv_nsec = from->stx_mtime.tv_nsec; 43 to->st_ctime = from->stx_ctime.tv_sec; 44 to->st_ctim.tv_nsec = from->stx_ctime.tv_nsec; 45 to->st_size = from->stx_size; 46 to->st_blocks = from->stx_blocks; 47 to->st_blksize = from->stx_blksize; 48 } 49 #endif 50