summaryrefslogtreecommitdiff
path: root/lib/ext2fs
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2001-06-15 18:33:43 +0000
committerTheodore Ts'o <tytso@mit.edu>2001-06-15 18:33:43 +0000
commit997b820e94468aeb3fb1a6fd38bc52e34af6f9e6 (patch)
tree60a9d891f0a4af98cec704081f67cc0f70922d23 /lib/ext2fs
parenta35bcab0dd7cd39bbce3af398f9069a925c70e09 (diff)
downloade2fsprogs-997b820e94468aeb3fb1a6fd38bc52e34af6f9e6.tar.gz
ChangeLog, ismounted.c:
ismounted.c (check_mntent_file): Use a test file in / to check to see if the root filesystem is mounted read-only. This protects against the case where /etc might not be on /, as well as the case where /etc/mtab doesn't exist. (Both are should-never happen scenarios, but you never know...)
Diffstat (limited to 'lib/ext2fs')
-rw-r--r--lib/ext2fs/ChangeLog8
-rw-r--r--lib/ext2fs/ismounted.c4
2 files changed, 11 insertions, 1 deletions
diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog
index 4e3fd935..db642c23 100644
--- a/lib/ext2fs/ChangeLog
+++ b/lib/ext2fs/ChangeLog
@@ -1,3 +1,11 @@
+2001-06-15 Theodore Tso <tytso@valinux.com>
+
+ * ismounted.c (check_mntent_file): Use a test file in / to check
+ to see if the root filesystem is mounted read-only. This
+ protects against the case where /etc might not be on /, as
+ well as the case where /etc/mtab doesn't exist. (Both are
+ should-never happen scenarios, but you never know...)
+
2001-06-14 Theodore Tso <tytso@valinux.com>
* ismounted.c (ext2fs_check_if_mounted): Fix grammer in comment.
diff --git a/lib/ext2fs/ismounted.c b/lib/ext2fs/ismounted.c
index 6a2acd27..ac785c6b 100644
--- a/lib/ext2fs/ismounted.c
+++ b/lib/ext2fs/ismounted.c
@@ -92,13 +92,15 @@ static errcode_t check_mntent_file(const char *mtab_file, const char *file,
*/
if (!strcmp(mnt->mnt_dir, "/")) {
is_root:
+#define TEST_FILE "/.ismount-test-file"
*mount_flags |= EXT2_MF_ISROOT;
- fd = open(MOUNTED, O_RDWR);
+ fd = open(TEST_FILE, O_RDWR|O_CREAT);
if (fd < 0) {
if (errno == EROFS)
*mount_flags |= EXT2_MF_READONLY;
} else
close(fd);
+ (void) unlink(TEST_FILE);
}
endmntent (f);
return 0;