From e33aa5509a0146c192a0437805d6d2354ded7a4e Mon Sep 17 00:00:00 2001 From: Andrzej Puzdrowski Date: Tue, 27 Feb 2018 12:26:14 +0100 Subject: [PATCH] subsys: fs: add NFFS rename API implementation Added file/directory rename implementation basing on NFFS native support. Signed-off-by: Andrzej Puzdrowski --- subsys/fs/nffs_fs.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/subsys/fs/nffs_fs.c b/subsys/fs/nffs_fs.c index 78c61c725d..8f4908e259 100644 --- a/subsys/fs/nffs_fs.c +++ b/subsys/fs/nffs_fs.c @@ -495,6 +495,25 @@ static int nffs_statvfs(struct fs_mount_t *mountp, return -ENOTSUP; } +static int nffs_rename(struct fs_mount_t *mountp, const char *from, + const char *to) +{ + int rc; + + k_mutex_lock(&nffs_lock, K_FOREVER); + + if (!nffs_misc_ready()) { + k_mutex_unlock(&nffs_lock); + return -ENODEV; + } + + rc = nffs_path_rename(from, to); + + k_mutex_unlock(&nffs_lock); + + return translate_error(rc); +} + static int nffs_mount(struct fs_mount_t *mountp) { struct nffs_area_desc descs[CONFIG_NFFS_FILESYSTEM_MAX_AREAS + 1]; @@ -555,6 +574,7 @@ static struct fs_file_system_t nffs_fs = { .closedir = nffs_closedir, .mount = nffs_mount, .unlink = nffs_unlink, + .rename = nffs_rename, .mkdir = nffs_mkdir, .stat = nffs_stat, .statvfs = nffs_statvfs,