From 43b7b054cd3165645c9b22977247674f9465e0e1 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Tue, 7 Jun 2016 11:44:54 -0400 Subject: [PATCH] libext2fs: fix EXT2FS_PRETEND_* on non-Linux systems The debugging environment variables EXT2FS_PRETEND_* were implemented in check_mntent_file(), and this function isn't called on all operating systems. Lift this code up to ext2fs_check_mount_point(), so that these environment variables (which are used in the regression test suite) will work on all platforms. Signed-off-by: Theodore Ts'o --- lib/ext2fs/ismounted.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/ext2fs/ismounted.c b/lib/ext2fs/ismounted.c index e0f69dd..bcac0f1 100644 --- a/lib/ext2fs/ismounted.c +++ b/lib/ext2fs/ismounted.c @@ -102,19 +102,6 @@ static errcode_t check_mntent_file(const char *mtab_file, const char *file, *mount_flags = 0; - if (getenv("EXT2FS_PRETEND_RO_MOUNT")) { - *mount_flags = EXT2_MF_MOUNTED | EXT2_MF_READONLY; - if (getenv("EXT2FS_PRETEND_ROOTFS")) - *mount_flags = EXT2_MF_ISROOT; - return 0; - } - if (getenv("EXT2FS_PRETEND_RW_MOUNT")) { - *mount_flags = EXT2_MF_MOUNTED; - if (getenv("EXT2FS_PRETEND_ROOTFS")) - *mount_flags = EXT2_MF_ISROOT; - return 0; - } - if ((f = setmntent (mtab_file, "r")) == NULL) { if (errno == ENOENT) { if (getenv("EXT2FS_NO_MTAB_OK")) @@ -377,6 +364,19 @@ errcode_t ext2fs_check_mount_point(const char *device, int *mount_flags, { errcode_t retval = 0; + if (getenv("EXT2FS_PRETEND_RO_MOUNT")) { + *mount_flags = EXT2_MF_MOUNTED | EXT2_MF_READONLY; + if (getenv("EXT2FS_PRETEND_ROOTFS")) + *mount_flags = EXT2_MF_ISROOT; + return 0; + } + if (getenv("EXT2FS_PRETEND_RW_MOUNT")) { + *mount_flags = EXT2_MF_MOUNTED; + if (getenv("EXT2FS_PRETEND_ROOTFS")) + *mount_flags = EXT2_MF_ISROOT; + return 0; + } + if (is_swap_device(device)) { *mount_flags = EXT2_MF_MOUNTED | EXT2_MF_SWAP; strncpy(mtpt, "", mtlen); -- 1.8.3.1