shithub: lwext4

Download patch

ref: 8f81cab8ae1a5d77fefb69698e92fa0a1dd1cdb4
parent: 890f937d5373c9b76bd954253c6360f9f06bfdfb
author: ngkaho1234 <[email protected]>
date: Sat Nov 14 17:46:30 EST 2015

ext4_journal: add block_get(_noread)/block_set.

--- a/lwext4/ext4_journal.c
+++ b/lwext4/ext4_journal.c
@@ -35,9 +35,9 @@
 	return rc;
 }
 
-int jbd_bmap(struct jbd_fs *jbd_fs,
-	     ext4_lblk_t iblock,
-	     ext4_fsblk_t *fblock)
+int jbd_inode_bmap(struct jbd_fs *jbd_fs,
+		   ext4_lblk_t iblock,
+		   ext4_fsblk_t *fblock)
 {
 	int rc = ext4_fs_get_inode_data_block_index(
 			&jbd_fs->inode_ref,
@@ -45,4 +45,45 @@
 			fblock,
 			false);
 	return rc;
+}
+
+int jbd_block_get(struct jbd_fs *jbd_fs,
+		  struct ext4_block *block,
+		  ext4_fsblk_t fblock)
+{
+	/* TODO: journal device. */
+	int rc;
+	ext4_lblk_t iblock = (ext4_lblk_t)fblock;
+	rc = jbd_inode_bmap(jbd_fs, iblock,
+			    &fblock);
+	if (rc != EOK)
+		return rc;
+
+	struct ext4_blockdev *bdev = jbd_fs->inode_ref.fs->bdev;
+	rc = ext4_block_get(bdev, block, fblock);
+	return rc;
+}
+
+int jbd_block_get_noread(struct jbd_fs *jbd_fs,
+			 struct ext4_block *block,
+			 ext4_fsblk_t fblock)
+{
+	/* TODO: journal device. */
+	int rc;
+	ext4_lblk_t iblock = (ext4_lblk_t)fblock;
+	rc = jbd_inode_bmap(jbd_fs, iblock,
+			    &fblock);
+	if (rc != EOK)
+		return rc;
+
+	struct ext4_blockdev *bdev = jbd_fs->inode_ref.fs->bdev;
+	rc = ext4_block_get_noread(bdev, block, fblock);
+	return rc;
+}
+
+int jbd_block_set(struct jbd_fs *jbd_fs,
+		  struct ext4_block *block)
+{
+	return ext4_block_set(jbd_fs->inode_ref.fs->bdev,
+			      block);
 }