From d9eb4d52edb19095de66d1a332ec3ff475911da2 Mon Sep 17 00:00:00 2001 From: gkostka Date: Fri, 18 Dec 2015 14:44:59 +0100 Subject: [PATCH] ext4: some style fixes & doxygen comments --- lwext4/ext4.c | 18 +++++++------ lwext4/ext4.h | 74 ++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 81 insertions(+), 11 deletions(-) diff --git a/lwext4/ext4.c b/lwext4/ext4.c index bf06530..5b7d01f 100644 --- a/lwext4/ext4.c +++ b/lwext4/ext4.c @@ -2502,7 +2502,7 @@ Finish: void ext4_dir_entry_rewind(ext4_dir *d) { - d->next_off = 0; + d->next_off = 0; } int ext4_test_journal(const char *mount_point) @@ -2553,8 +2553,8 @@ int ext4_test_journal(const char *mount_point) ext4_bcache_set_dirty(block.buf); - struct jbd_trans *trans = jbd_journal_new_trans(journal); - if (!trans) { + struct jbd_trans *t = jbd_journal_new_trans(journal); + if (!t) { ext4_block_set(mp->fs.bdev, &block); r = ENOMEM; goto out; @@ -2562,25 +2562,27 @@ int ext4_test_journal(const char *mount_point) switch (rand() % 2) { case 0: - r = jbd_trans_add_block(trans, &block); + r = jbd_trans_add_block(t, &block); if (r != EOK) { - jbd_journal_free_trans(journal, trans, true); + jbd_journal_free_trans(journal, t, + true); ext4_block_set(mp->fs.bdev, &block); r = ENOMEM; goto out; } break; case 1: - r = jbd_trans_revoke_block(trans, rand_block); + r = jbd_trans_revoke_block(t, rand_block); if (r != EOK) { - jbd_journal_free_trans(journal, trans, true); + jbd_journal_free_trans(journal, t, + true); ext4_block_set(mp->fs.bdev, &block); r = ENOMEM; goto out; } } ext4_block_set(mp->fs.bdev, &block); - jbd_journal_submit_trans(journal, trans); + jbd_journal_submit_trans(journal, t); jbd_journal_commit_one(journal); } out: diff --git a/lwext4/ext4.h b/lwext4/ext4.h index 208ddb9..09abcbc 100644 --- a/lwext4/ext4.h +++ b/lwext4/ext4.h @@ -136,7 +136,7 @@ typedef struct ext4_file { /*****************************DIRECTORY DESCRIPTOR***************************/ /**@brief Directory entry descriptor. Copy from ext4_types.h*/ -typedef struct { +typedef struct ext4_direntry { uint32_t inode; uint16_t entry_length; uint8_t name_length; @@ -144,7 +144,7 @@ typedef struct { uint8_t name[255]; } ext4_direntry; -typedef struct { +typedef struct ext4_dir { /**@brief File descriptor*/ ext4_file f; /**@brief Current directory entry.*/ @@ -281,7 +281,7 @@ int ext4_flink(const char *path, const char *hardlink_path); int ext4_frename(const char *path, const char *new_path); /**@brief File open function. - * @param filename, (has to start from mount point) + * @param path filename (has to start from mount point) * /my_partition/my_file * @param flags open file flags * |---------------------------------------------------------------| @@ -363,21 +363,80 @@ uint64_t ext4_ftell(ext4_file *f); * @return file size */ uint64_t ext4_fsize(ext4_file *f); +/**@brief Change file/directory/link mode bits + * @param path to file/dir/link + * @param mode new mode bits (for example 0777) + * @return standard error code*/ int ext4_chmod(const char *path, uint32_t mode); + +/**@brief Change file owner and group + * @param path to file/dir/link + * @param uid user id + * @param gid group id + * @return standard error code*/ int ext4_chown(const char *path, uint32_t uid, uint32_t gid); + +/**@brief Set file access time + * @param path to file/dir/link + * @param atime access timestamp + * @return standard error code*/ int ext4_file_set_atime(const char *path, uint32_t atime); + +/**@brief Set file modify time + * @param path to file/dir/link + * @param mtime modify timestamp + * @return standard error code*/ int ext4_file_set_mtime(const char *path, uint32_t mtime); + +/**@brief Set file change time + * @param path to file/dir/link + * @param ctime change timestamp + * @return standard error code*/ int ext4_file_set_ctime(const char *path, uint32_t ctime); +/**@brief Create symbolic link + * @param target destination path + * @param path source entry + * @return standard error code*/ int ext4_fsymlink(const char *target, const char *path); + +/**@brief Read symbolic link payload + * @param path to symlink + * @param buf output buffer + * @param bufsize output buffer max size + * @param rcnt bytes read + * @return standard error code*/ int ext4_readlink(const char *path, char *buf, size_t bufsize, size_t *rcnt); +/**@brief Set extended attribute + * @param path to entry + * + * TODO: write detailed description + */ int ext4_setxattr(const char *path, const char *name, size_t name_len, const void *data, size_t data_size, bool replace); + +/**@brief Get extended attribute + * @param path to entry + * + * TODO: write detailed description + */ int ext4_getxattr(const char *path, const char *name, size_t name_len, void *buf, size_t buf_size, size_t *data_size); + +/**@brief List extended attributes + * @param path to entry + * + * TODO: write detailed description + */ int ext4_listxattr(const char *path, char *list, size_t size, size_t *ret_size); + +/**@brief Remove extended attribute + * @param path to entry + * + * TODO: write detailed description + */ int ext4_removexattr(const char *path, const char *name, size_t name_len); @@ -414,6 +473,15 @@ const ext4_direntry *ext4_dir_entry_next(ext4_dir *d); * @param d directory handle*/ void ext4_dir_entry_rewind(ext4_dir *d); +/**@brief Test journal functionality + * @param mount_point mount point, for example + * - / + * - /my_partition/ + * - /my_second_partition/ + * + * @return standard error code */ +int ext4_test_journal(const char *mount_point); + #ifdef __cplusplus } #endif