internal static unsafe int fstat(int fd, out structStat buf) { int result; if (IntPtr.Size == 4) { stat_layout_32 buf32 = default(stat_layout_32); result = __fxstat(_STAT_VER_LINUX_32, fd, (byte *)&buf32); CopyStat32(ref buf32, out buf); } else { stat_layout_64 buf64 = default(stat_layout_64); result = __fxstat(_STAT_VER_LINUX_64, fd, (byte *)&buf64); CopyStat64(ref buf64, out buf); } return(result); }
private static void CopyStat64(ref stat_layout_64 src, out structStat dst) { dst.st_dev = src.st_dev; dst.st_ino = src.st_ino; dst.st_mode = src.st_mode; dst.st_nlink = src.st_nlink; dst.st_uid = src.st_uid; dst.st_gid = src.st_gid; dst.st_rdev = src.st_rdev; dst.st_size = (long)src.st_size; dst.st_blksize = src.st_blksize; dst.st_blocks = (long)src.st_blocks; dst.st_atime = src.st_atime; dst.st_atimensec = src.st_atimensec; dst.st_mtime = src.st_mtime; dst.st_mtimensec = src.st_mtimensec; dst.st_ctime = src.st_ctime; dst.st_ctimensec = src.st_ctimensec; }
private static void CopyStat64(ref stat_layout_64 src, out structStat dst) { dst.st_dev = src.st_dev; dst.st_ino = src.st_ino; dst.st_mode = src.st_mode; dst.st_nlink = src.st_nlink; dst.st_uid = src.st_uid; dst.st_gid = src.st_gid; dst.st_rdev = src.st_rdev; dst.st_size = src.st_size; dst.st_blksize = src.st_blksize; dst.st_blocks = (long)src.st_blocks; dst.st_atime = src.st_atime; dst.st_atimensec = src.st_atimensec; dst.st_mtime = src.st_mtime; dst.st_mtimensec = src.st_mtimensec; dst.st_ctime = src.st_ctime; dst.st_ctimensec = src.st_ctimensec; }