diff options
| author | ngkaho1234 <ngkaho1234@gmail.com> | 2015-12-12 23:12:05 +0800 |
|---|---|---|
| committer | ngkaho1234 <ngkaho1234@gmail.com> | 2015-12-12 23:12:05 +0800 |
| commit | 8668c0f48be313029675abbe949a5b74c68aa56d (patch) | |
| tree | db74361d99a1cac46b407199a6aed96e8a511e0e | |
| parent | 38ddd83efb42a1ad30873e6a296009fa0e63678a (diff) | |
ext4: journal test code skeleton.
| -rw-r--r-- | lwext4/ext4.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/lwext4/ext4.c b/lwext4/ext4.c index 00c0835..f09ce76 100644 --- a/lwext4/ext4.c +++ b/lwext4/ext4.c @@ -2505,6 +2505,53 @@ void ext4_dir_entry_rewind(ext4_dir *d) d->next_off = 0; } +int ext4_test_journal(const char *mount_point) +{ + struct ext4_mountpoint *mp = ext4_get_mount(mount_point); + if (!mp) + return ENOENT; + + int r = ENOTSUP; + EXT4_MP_LOCK(mp); + if (ext4_sb_feature_com(&mp->fs.sb, EXT4_FCOM_HAS_JOURNAL)) { + struct jbd_fs *jbd_fs = calloc(1, sizeof(struct jbd_fs)); + struct jbd_journal *journal; + if (!jbd_fs) { + r = ENOMEM; + goto Finish; + } + journal = calloc(1, sizeof(struct jbd_journal)); + if (!journal) { + free(jbd_fs); + r = ENOMEM; + goto Finish; + } + + r = jbd_get_fs(&mp->fs, jbd_fs); + if (r != EOK) { + free(jbd_fs); + goto Finish; + } + r = jbd_journal_start(jbd_fs, journal); + if (r != EOK) { + jbd_put_fs(jbd_fs); + free(journal); + free(jbd_fs); + goto Finish; + } + + jbd_journal_stop(journal); + jbd_put_fs(jbd_fs); + free(journal); + free(jbd_fs); + } + + +Finish: + EXT4_MP_UNLOCK(mp); + return r; +} + /** * @} */ |
