summaryrefslogtreecommitdiff
path: root/e2fsck/journal.c
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2018-07-04 00:18:30 -0400
committerTheodore Ts'o <tytso@mit.edu>2018-07-04 00:18:30 -0400
commitd8cbb80348aac26c007f6d13eb879e080c9b01f4 (patch)
treef9ef8902940bf5b0aa6345fd42610b061ca01d6e /e2fsck/journal.c
parent6e2863e445044758518fc4c5276128610da4d203 (diff)
downloade2fsprogs-d8cbb80348aac26c007f6d13eb879e080c9b01f4.tar.gz
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>
Diffstat (limited to 'e2fsck/journal.c')
-rw-r--r--e2fsck/journal.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/e2fsck/journal.c b/e2fsck/journal.c
index c4f58f1b..e83f3a91 100644
--- a/e2fsck/journal.c
+++ b/e2fsck/journal.c
@@ -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;