From: Theodore Ts'o Date: Fri, 25 May 2001 17:14:23 +0000 (+0000) Subject: ChangeLog, ismounted.c: X-Git-Tag: E2FSPROGS-1_20~5 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=d5f858dd7f02532ad90e4121537c358e86d0eecf;p=tools%2Fe2fsprogs.git ChangeLog, ismounted.c: 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. --- diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog index 526a163..632ec4a 100644 --- a/lib/ext2fs/ChangeLog +++ b/lib/ext2fs/ChangeLog @@ -1,3 +1,10 @@ +2001-05-25 Theodore Tso + + * 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 * ismounted.c: Add check for root device which doesn't depend on diff --git a/lib/ext2fs/ismounted.c b/lib/ext2fs/ismounted.c index 1b719de..30b67d1 100644 --- a/lib/ext2fs/ismounted.c +++ b/lib/ext2fs/ismounted.c @@ -67,7 +67,7 @@ static errcode_t check_mntent_file(const char *mtab_file, const char *file, if (st_root.st_dev == st_file.st_rdev) { *mount_flags = EXT2_MF_MOUNTED; if (mtpt) - strcpy(mtpt, "/"); + strncpy(mtpt, "/", mtlen); goto is_root; } } @@ -117,9 +117,8 @@ static errcode_t check_mntent(const char *file, int *mount_flags, 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) { @@ -174,6 +173,7 @@ errcode_t ext2fs_check_mount_point(const char *device, int *mount_flags, #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 */ @@ -182,7 +182,7 @@ errcode_t ext2fs_check_mount_point(const char *device, int *mount_flags, /* * ext2fs_check_if_mounted() sets the mount_flags EXT2_MF_MOUNTED and - * EXT2_MF_READONLY + * EXT2_MF_READONLY, and EXT2_MF_ROOT * */ #ifdef __TURBOC__ @@ -190,22 +190,12 @@ errcode_t ext2fs_check_mount_point(const char *device, int *mount_flags, #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) {