Whamcloud - gitweb
libext2fs: Add an explicit error code for missing mtab file
authorTheodore Ts'o <tytso@mit.edu>
Fri, 29 May 2009 04:09:57 +0000 (00:09 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 29 May 2009 04:11:52 +0000 (00:11 -0400)
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" <tytso@mit.edu>
lib/ext2fs/ext2_err.et.in
lib/ext2fs/ismounted.c

index 9ffffbb..406f3ae 100644 (file)
@@ -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
index 4c5500f..b7f17b8 100644 (file)
@@ -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 */