From 86522281f8be6e5fca0b3ed552786db4979a45a4 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Fri, 29 May 2009 00:09:57 -0400 Subject: [PATCH] libext2fs: Add an explicit error code for missing mtab file To reduce user confusion, if the /etc/mtab file is missing ext2fs_check_mount_point and ext2fs_check_if_mounted will return a new, explicit error code to indicate this case. Addresses-Debian-Bug: #527859 Signed-off-by: "Theodore Ts'o" --- lib/ext2fs/ext2_err.et.in | 3 +++ lib/ext2fs/ismounted.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/ext2fs/ext2_err.et.in b/lib/ext2fs/ext2_err.et.in index 9ffffbb4..406f3ae8 100644 --- a/lib/ext2fs/ext2_err.et.in +++ b/lib/ext2fs/ext2_err.et.in @@ -416,4 +416,7 @@ ec EXT2_ET_EXTENT_INVALID_LENGTH, ec EXT2_ET_IO_CHANNEL_NO_SUPPORT_64, "I/O Channel does not support 64-bit block numbers" +ec EXT2_NO_MTAB_FILE, + "Can't check if filesystem is mounted due to missing mtab file" + end diff --git a/lib/ext2fs/ismounted.c b/lib/ext2fs/ismounted.c index 4c5500f4..b7f17b84 100644 --- a/lib/ext2fs/ismounted.c +++ b/lib/ext2fs/ismounted.c @@ -53,7 +53,7 @@ static errcode_t check_mntent_file(const char *mtab_file, const char *file, *mount_flags = 0; if ((f = setmntent (mtab_file, "r")) == NULL) - return errno; + return (errno == ENOENT ? EXT2_NO_MTAB_FILE : errno); if (stat(file, &st_buf) == 0) { if (S_ISBLK(st_buf.st_mode)) { #ifndef __GNU__ /* The GNU hurd is broken with respect to stat devices */