libexplain
1.4.D001
|
00001 /* 00002 * libexplain - Explain errno values returned by libc functions 00003 * Copyright (C) 2008, 2009, 2013 Peter Miller 00004 * Written by Peter Miller <pmiller@opensource.org.au> 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU Lesser General Public License as published by 00008 * the Free Software Foundation; either version 3 of the License, or (at 00009 * your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public License 00017 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00018 */ 00019 00020 #include <libexplain/ac/sys/stat.h> 00021 00022 #include <libexplain/is_same_inode.h> 00023 00024 00025 int 00026 explain_is_same_inode(const struct stat *st1, const struct stat *st2) 00027 { 00028 int t1; 00029 int t2; 00030 00031 t1 = st1->st_mode & S_IFMT; 00032 t2 = st2->st_mode & S_IFMT; 00033 if (t1 != t2) 00034 return 0; 00035 switch (t1) 00036 { 00037 case S_IFBLK: 00038 case S_IFCHR: 00039 return (st1->st_rdev == st2->st_rdev); 00040 00041 default: 00042 break; 00043 } 00044 return (st1->st_dev == st2->st_dev && st1->st_ino == st2->st_ino); 00045 } 00046 00047 00048 /* vim: set ts=8 sw=4 et : */