]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
e2fsck: fix kernel compat functions to use kernel error return conventions
authorTheodore Ts'o <tytso@mit.edu>
Wed, 4 Jul 2018 04:18:30 +0000 (00:18 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 4 Jul 2018 04:18:30 +0000 (00:18 -0400)
Fix journal_bmap() and sync_blockdev() to use the kernel error
convetions (e.g., -EIO instead of EIO) since they are called by
reovery.c, which is shared userspace / kernel code.

Without this, e2fsck might print an error message like this:

/sbin/e2fsck: Unknown code ____ 251 while recovering journal of /dev/mapper/thin-vol

instead of what it should have printed which was this:

/sbin/e2fsck: Input/output error while recovering journal of /dev/mapper/thin-vol

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck/journal.c

index c4f58f1b8519f733af4febdc940eae576c6685c7..e83f3a91c0228914515540df641be3aaba934279 100644 (file)
@@ -112,7 +112,7 @@ int journal_bmap(journal_t *journal, blk64_t block, unsigned long long *phys)
        retval= ext2fs_bmap2(inode->i_ctx->fs, inode->i_ino,
                             &inode->i_ext2, NULL, 0, block, 0, &pblk);
        *phys = pblk;
-       return (int) retval;
+       return -1 * ((int) retval);
 #endif
 }
 
@@ -153,7 +153,7 @@ int sync_blockdev(kdev_t kdev)
        else
                io = kdev->k_ctx->journal_io;
 
-       return io_channel_flush(io) ? EIO : 0;
+       return io_channel_flush(io) ? -EIO : 0;
 }
 
 void ll_rw_block(int rw, int nr, struct buffer_head *bhp[])
@@ -289,6 +289,7 @@ static errcode_t e2fsck_get_journal(e2fsck_t ctx, journal_t **ret_journal)
        errcode_t               retval = 0;
        io_manager              io_ptr = 0;
        unsigned long long      start = 0;
+       int                     ret;
        int                     ext_journal = 0;
        int                     tried_backup_jnl = 0;
 
@@ -389,8 +390,10 @@ static errcode_t e2fsck_get_journal(e2fsck_t ctx, journal_t **ret_journal)
 #else
                journal->j_inode = j_inode;
                ctx->journal_io = ctx->fs->io;
-               if ((retval = (errcode_t) journal_bmap(journal, 0, &start)) != 0)
+               if ((ret = journal_bmap(journal, 0, &start)) != 0) {
+                       retval = (errcode_t) (-1 * ret);
                        goto errout;
+               }
 #endif
        } else {
                ext_journal = 1;