e2fsck: fix kernel compat functions to use kernel error return conventions
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>
diff --git a/e2fsck/journal.c b/e2fsck/journal.c
index c4f58f1..e83f3a9 100644
--- a/e2fsck/journal.c
+++ b/e2fsck/journal.c
@@ -112,7 +112,7 @@
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 @@
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 @@
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 @@
#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;