paul@277 | 1 | /* |
paul@277 | 2 | * Utility functions for stat structures. |
paul@277 | 3 | * |
paul@277 | 4 | * Copyright (C) 2022 Paul Boddie <paul@boddie.org.uk> |
paul@277 | 5 | * |
paul@277 | 6 | * This program is free software; you can redistribute it and/or |
paul@277 | 7 | * modify it under the terms of the GNU General Public License as |
paul@277 | 8 | * published by the Free Software Foundation; either version 2 of |
paul@277 | 9 | * the License, or (at your option) any later version. |
paul@277 | 10 | * |
paul@277 | 11 | * This program is distributed in the hope that it will be useful, |
paul@277 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@277 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@277 | 14 | * GNU General Public License for more details. |
paul@277 | 15 | * |
paul@277 | 16 | * You should have received a copy of the GNU General Public License |
paul@277 | 17 | * along with this program; if not, write to the Free Software |
paul@277 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@277 | 19 | * Boston, MA 02110-1301, USA |
paul@277 | 20 | */ |
paul@277 | 21 | |
paul@277 | 22 | #include "stat.h" |
paul@277 | 23 | |
paul@277 | 24 | #define COPY_STAT(s1, s2) \ |
paul@277 | 25 | s1->st_dev = s2->st_dev; \ |
paul@277 | 26 | s1->st_ino = s2->st_ino; \ |
paul@277 | 27 | s1->st_mode = s2->st_mode; \ |
paul@277 | 28 | s1->st_nlink = s2->st_nlink; \ |
paul@277 | 29 | s1->st_uid = s2->st_uid; \ |
paul@277 | 30 | s1->st_gid = s2->st_gid; \ |
paul@277 | 31 | s1->st_rdev = s2->st_rdev; \ |
paul@277 | 32 | s1->st_size = s2->st_size; \ |
paul@277 | 33 | s1->st_atim.tv_sec = s2->st_atim.tv_sec; \ |
paul@277 | 34 | s1->st_atim.tv_nsec = s2->st_atim.tv_nsec; \ |
paul@277 | 35 | s1->st_mtim.tv_sec = s2->st_mtim.tv_sec; \ |
paul@277 | 36 | s1->st_mtim.tv_nsec = s2->st_mtim.tv_nsec; \ |
paul@277 | 37 | s1->st_ctim.tv_sec = s2->st_ctim.tv_sec; \ |
paul@277 | 38 | s1->st_ctim.tv_nsec = s2->st_ctim.tv_nsec; \ |
paul@277 | 39 | s1->st_blksize = s2->st_blksize; \ |
paul@277 | 40 | s1->st_blocks = s2->st_blocks; |
paul@277 | 41 | |
paul@277 | 42 | void systypes_copy_from_sys_stat(struct stat *st, sys_stat_t *sst) |
paul@277 | 43 | { |
paul@277 | 44 | COPY_STAT(st, sst) |
paul@277 | 45 | } |
paul@277 | 46 | |
paul@277 | 47 | void systypes_copy_to_sys_stat(struct stat *st, sys_stat_t *sst) |
paul@277 | 48 | { |
paul@277 | 49 | COPY_STAT(sst, st) |
paul@277 | 50 | } |
paul@277 | 51 | |
paul@277 | 52 | // vim: tabstop=2 expandtab shiftwidth=2 |