+2001-05-25 Theodore Tso <tytso@valinux.com>
+
+ * ismounted.c: More cleanups for ismounted.c, some from Andreas,
+ some to clean up Andreas's patches. Use strncpy instead
+ of strcpy to save the root's mountpoint. Clean up #ifdef
+ structure. Remove uneeded variable in testing/debug driver.
+
2001-05-24 Andreas Dilger <adilger@turbolinux.com>
* ismounted.c: Add check for root device which doesn't depend on
if (st_root.st_dev == st_file.st_rdev) {
*mount_flags = EXT2_MF_MOUNTED;
if (mtpt)
- strcpy(mtpt, "/");
+ strncpy(mtpt, "/", mtlen);
goto is_root;
}
}
return retval;
}
-#endif
+#elif defined(HAVE_GETMNTINFO)
-#ifdef HAVE_GETMNTINFO
static errcode_t check_getmntinfo(const char *file, int *mount_flags,
char *mtpt, int mtlen)
{
#ifdef HAVE_GETMNTINFO
return check_getmntinfo(device, mount_flags, mtpt, mtlen);
#else
+#warning "Can't use getmntent or getmntinfo to check for mounted filesystems!"
*mount_flags = 0;
return 0;
#endif /* HAVE_GETMNTINFO */
/*
* ext2fs_check_if_mounted() sets the mount_flags EXT2_MF_MOUNTED and
- * EXT2_MF_READONLY
+ * EXT2_MF_READONLY, and EXT2_MF_ROOT
*
*/
#ifdef __TURBOC__
#endif
errcode_t ext2fs_check_if_mounted(const char *file, int *mount_flags)
{
-#ifdef HAVE_MNTENT_H
- return check_mntent(file, mount_flags, NULL, 0);
-#else
-#ifdef HAVE_GETMNTINFO
- return check_getmntinfo(file, mount_flags, NULL, 0);
-#else
- *mount_flags = 0;
- return 0;
-#endif /* HAVE_GETMNTINFO */
-#endif /* HAVE_MNTENT_H */
+ return ext2fs_check_mount_point(file, mount_flags, NULL, 0);
}
#ifdef DEBUG
int main(int argc, char **argv)
{
- blk_t blocks;
int retval, mount_flags;
if (argc < 2) {