From 845aba61edd01770159e77dd9fb995c6a8e06130 Mon Sep 17 00:00:00 2001 From: "S.J.R. van Schaik" Date: Sun, 11 Jun 2017 17:34:35 +0200 Subject: [PATCH] mufs: rename mufs_read()/mufs_write() to mufs_tree_read()/mufs_tree_write() and expose functions --- source/fs/mufs/dir.c | 14 +++++++------- source/fs/mufs/dir.h | 6 ++++++ source/fs/mufs/tree.c | 4 ++-- source/fs/mufs/tree.h | 6 ++++-- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/source/fs/mufs/dir.c b/source/fs/mufs/dir.c index 8500668..643eb1e 100644 --- a/source/fs/mufs/dir.c +++ b/source/fs/mufs/dir.c @@ -92,7 +92,7 @@ err_free_dir: return NULL; } -static struct mufs_tree *resolve_path(struct mufs *fs, const char *path) +struct mufs_tree *resolve_path(struct mufs *fs, const char *path) { struct mufs_dir *dir; struct mufs_dirent entry; @@ -176,7 +176,7 @@ void mufs_closedir(struct mufs_dir *dir) free(dir); } -static size_t read_dirent(struct mufs *fs, struct mufs_tree *tree, +size_t read_dirent(struct mufs *fs, struct mufs_tree *tree, struct mufs_dirent *dirent, uint32_t va) { struct flash_dev *dev = fs->dev; @@ -191,7 +191,7 @@ static size_t read_dirent(struct mufs *fs, struct mufs_tree *tree, if (va + sizeof(entry) > tree->file_size) return 0; - if (mufs_read(tree, &entry, va, sizeof entry) == 0) + if (mufs_tree_read(tree, &entry, va, sizeof entry) == 0) return 0; if (!entry.type) @@ -204,7 +204,7 @@ static size_t read_dirent(struct mufs *fs, struct mufs_tree *tree, if (va + len > tree->file_size) return 0; - if (mufs_read(tree, dirent->path, va, len) == 0) + if (mufs_tree_read(tree, dirent->path, va, len) == 0) return 0; dirent->path[len] = '\0'; @@ -225,7 +225,7 @@ static size_t read_dirent(struct mufs *fs, struct mufs_tree *tree, return ret; } -static size_t write_dirent(struct mufs_tree *tree, +size_t write_dirent(struct mufs_tree *tree, uint32_t va, struct mufs_dirent *dirent) { struct mufs_dtree dtree; @@ -237,11 +237,11 @@ static size_t write_dirent(struct mufs_tree *tree, entry.tree.depth = dirent->tree.depth; entry.path_len = strlen(dirent->path); - if (mufs_write(tree, dirent->path, va + sizeof entry, + if (mufs_tree_write(tree, dirent->path, va + sizeof entry, entry.path_len) == 0) return 0; - if (mufs_write(tree, &entry, va, sizeof entry) == 0) + if (mufs_tree_write(tree, &entry, va, sizeof entry) == 0) return 0; tree->file_size = max(tree->file_size, va + sizeof entry + entry.path_len); diff --git a/source/fs/mufs/dir.h b/source/fs/mufs/dir.h index 363f63d..453105c 100644 --- a/source/fs/mufs/dir.h +++ b/source/fs/mufs/dir.h @@ -14,3 +14,9 @@ struct mufs_dentry { #define MUFS_FILE BIT(0) #define MUFS_DIR BIT(1) + +struct mufs_tree *resolve_path(struct mufs *fs, const char *path); +size_t read_dirent(struct mufs *fs, struct mufs_tree *tree, + struct mufs_dirent *dirent, uint32_t va); +size_t write_dirent(struct mufs_tree *tree, + uint32_t va, struct mufs_dirent *dirent); diff --git a/source/fs/mufs/tree.c b/source/fs/mufs/tree.c index ac24925..ae34a2e 100644 --- a/source/fs/mufs/tree.c +++ b/source/fs/mufs/tree.c @@ -197,7 +197,7 @@ static size_t mufs_do_read(struct mufs_tree *tree, void *data, uint32_t va, return flash_read(dev, (page << dev->log2_block_size) + offset, data, len); } -size_t mufs_read(struct mufs_tree *tree, void *data, uint32_t va, size_t len) +size_t mufs_tree_read(struct mufs_tree *tree, void *data, uint32_t va, size_t len) { uint8_t *buf = data; size_t ret, nbytes = 0; @@ -236,7 +236,7 @@ static size_t mufs_do_write(struct mufs_tree *tree, len); } -size_t mufs_write(struct mufs_tree *tree, void *data, +size_t mufs_tree_write(struct mufs_tree *tree, void *data, uint32_t va, size_t len) { uint8_t *buf = data; diff --git a/source/fs/mufs/tree.h b/source/fs/mufs/tree.h index 4128ca6..10d554f 100644 --- a/source/fs/mufs/tree.h +++ b/source/fs/mufs/tree.h @@ -7,5 +7,7 @@ int mufs_alloc_page(struct mufs_tree *tree, uint32_t *page, void mufs_free_page(struct mufs_tree *tree, uint32_t va); int mufs_extend_tree(struct mufs_tree *tree, uint8_t depth); int mufs_shrink_tree(struct mufs_tree *tree, uint32_t max_size); -size_t mufs_read(struct mufs_tree *tree, void *data, uint32_t va, size_t len); -size_t mufs_write(struct mufs_tree *tree, void *data, uint32_t va, size_t len); +size_t mufs_tree_read(struct mufs_tree *tree, void *data, uint32_t va, + size_t len); +size_t mufs_tree_write(struct mufs_tree *tree, void *data, uint32_t va, + size_t len);