Journalling(JBD) support skeletal code.
[lwext4.git] / lwext4 / ext4_journal.c
1 /**
2  * @file  ext4_journal.c
3  * @brief Journalling
4  */
5
6 #include "ext4_config.h"
7 #include "ext4_types.h"
8 #include "ext4_fs.h"
9 #include "ext4_errno.h"
10 #include "ext4_blockdev.h"
11 #include "ext4_crc32c.h"
12 #include "ext4_debug.h"
13
14 #include <string.h>
15
16 int jbd_get_fs(struct ext4_fs *fs,
17                struct jbd_fs *jbd_fs)
18 {
19         int rc;
20         uint32_t journal_ino;
21
22         memset(jbd_fs, 0, sizeof(struct jbd_fs));
23         journal_ino = ext4_get32(&fs->sb, journal_inode_number);
24
25         rc = ext4_fs_get_inode_ref(fs,
26                                    journal_ino,
27                                    &jbd_fs->inode_ref);
28         return rc;
29 }
30
31 int jbd_put_fs(struct jbd_fs *jbd_fs)
32 {
33         int rc;
34         rc = ext4_fs_put_inode_ref(&jbd_fs->inode_ref);
35         return rc;
36 }
37
38 int jbd_bmap(struct jbd_fs *jbd_fs,
39              ext4_lblk_t iblock,
40              ext4_fsblk_t *fblock)
41 {
42         int rc = ext4_fs_get_inode_data_block_index(
43                         &jbd_fs->inode_ref,
44                         iblock,
45                         fblock,
46                         false);
47         return rc;
48 }