00001 // Copyright (C) 2006-2007 Benedikt Böhm <hollow@gentoo.org> 00002 // 00003 // This program is free software; you can redistribute it and/or 00004 // modify it under the terms of the GNU General Public License 00005 // as published by the Free Software Foundation; either version 2 00006 // of the License, or (at your option) any later version. 00007 // 00008 // This program is distributed in the hope that it will be useful, 00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 // GNU General Public License for more details. 00012 // 00013 // You should have received a copy of the GNU General Public License 00014 // along with this program; if not, write to the Free Software 00015 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 00016 00017 #include <sys/stat.h> 00018 00019 #include "mem.h" 00020 #include "misc.h" 00021 #include "str.h" 00022 00023 int ismount(const char *path) 00024 { 00025 struct stat sb_path, sb_parent; 00026 int rc = 1; 00027 00028 if (str_isempty(path)) 00029 return 0; 00030 00031 if (str_equal(path, "/")) 00032 return 1; 00033 00034 char *parent = str_path_dirname(path); 00035 00036 if (lstat(path, &sb_path) == -1 || 00037 !S_ISDIR(sb_path.st_mode) || 00038 lstat(parent, &sb_parent) == -1 || 00039 sb_path.st_dev == sb_parent.st_dev) 00040 rc = 0; 00041 00042 mem_free(parent); 00043 return rc; 00044 }