static errcode_t check_mntent(const char *file, int *mount_flags, char *mtpt, int mtlen) { errcode_t retval; #ifdef DEBUG retval = check_mntent_file("/tmp/mtab", file, mount_flags, mtpt, mtlen); if (retval == 0) return 0; #endif /* DEBUG */ #ifdef __linux__ retval = check_mntent_file("/proc/mounts", file, mount_flags, mtpt, mtlen); if (retval == 0 && (*mount_flags != 0)) return 0; #endif /* __linux__ */ #if defined(MOUNTED) || defined(_PATH_MOUNTED) #ifndef MOUNTED #define MOUNTED _PATH_MOUNTED #endif /* MOUNTED */ retval = check_mntent_file(MOUNTED, file, mount_flags, mtpt, mtlen); return retval; #else *mount_flags = 0; return 0; #endif /* defined(MOUNTED) || defined(_PATH_MOUNTED) */ }
int is_mounted(const char *file) { errcode_t retval; int mount_flags = 0; #ifdef __linux__ retval = check_mntent_file("/proc/mounts", file, &mount_flags); if (retval) return 0; if (mount_flags) return 1; #endif /* __linux__ */ retval = check_mntent_file("/etc/mtab", file, &mount_flags); if (retval) return 0; return (mount_flags); }