diff --git a/include/fs/fs_interface.h b/include/fs/fs_interface.h index 7b4f02d575d..616da92403b 100644 --- a/include/fs/fs_interface.h +++ b/include/fs/fs_interface.h @@ -7,14 +7,6 @@ #ifndef _FS_INTERFACE_H_ #define _FS_INTERFACE_H_ -#ifdef CONFIG_FAT_FILESYSTEM_ELM -#include -#endif - -#ifdef CONFIG_FILE_SYSTEM_NFFS -#include -#endif - #ifdef __cplusplus extern "C" { #endif @@ -30,38 +22,22 @@ struct fs_mount_t; /** * @brief File object representing an open file * - * @param fatfs_fp FATFS file object structure - * @param nffs_fp NFFS file object structure + * @param Pointer to FATFS file object structure * @param mp Pointer to mount point structure */ struct fs_file_t { - union { -#ifdef CONFIG_FAT_FILESYSTEM_ELM - FIL fatfs_fp; -#endif -#ifdef CONFIG_FILE_SYSTEM_NFFS - struct nffs_file *nffs_fp; -#endif - }; + void *filep; const struct fs_mount_t *mp; }; /** * @brief Directory object representing an open directory * - * @param fatfs_dp FATFS directory object structure - * @param nffs_dp NFFS directory object structure + * @param dirp Pointer to directory object structure * @param mp Pointer to mount point structure */ struct fs_dir_t { - union { -#ifdef CONFIG_FAT_FILESYSTEM_ELM - DIR fatfs_dp; -#endif -#ifdef CONFIG_FILE_SYSTEM_NFFS - struct nffs_dir *nffs_dp; -#endif - }; + void *dirp; const struct fs_mount_t *mp; }; diff --git a/subsys/fs/Kconfig b/subsys/fs/Kconfig index 818b420a1da..0b8038e7a73 100644 --- a/subsys/fs/Kconfig +++ b/subsys/fs/Kconfig @@ -55,6 +55,17 @@ config FILE_SYSTEM_SHELL This shell provides basic browsing of the contents of the file system. +menu "FatFs Settings" + visible if FAT_FILESYSTEM_ELM + +config FS_FATFS_NUM_FILES + int "Maximum number of opened files" + default 4 + +config FS_FATFS_NUM_DIRS + int "Maximum number of opened directories" + default 4 +endmenu menu "NFFS Settings" visible if FILE_SYSTEM_NFFS diff --git a/subsys/fs/fat_fs.c b/subsys/fs/fat_fs.c index 2d8b0d6795c..675843afa6c 100644 --- a/subsys/fs/fat_fs.c +++ b/subsys/fs/fat_fs.c @@ -6,14 +6,24 @@ #include #include +#include #include #include #include #include #include +#include #define FATFS_MAX_FILE_NAME 12 /* Uses 8.3 SFN */ +/* Memory pool for FatFs directory objects */ +K_MEM_SLAB_DEFINE(fatfs_dirp_pool, sizeof(DIR), + CONFIG_FS_FATFS_NUM_DIRS, 4); + +/* Memory pool for FatFs file objects */ +K_MEM_SLAB_DEFINE(fatfs_filep_pool, sizeof(FIL), + CONFIG_FS_FATFS_NUM_FILES, 4); + static int translate_error(int error) { switch (error) { @@ -57,10 +67,18 @@ static int fatfs_open(struct fs_file_t *zfp, const char *file_name) { FRESULT res; u8_t fs_mode; + void *ptr; + + if (k_mem_slab_alloc(&fatfs_filep_pool, &ptr, K_NO_WAIT) == 0) { + memset(ptr, 0, sizeof(FIL)); + zfp->filep = ptr; + } else { + return -ENOMEM; + } fs_mode = FA_READ | FA_WRITE | FA_OPEN_ALWAYS; - res = f_open(&zfp->fatfs_fp, file_name, fs_mode); + res = f_open(zfp->filep, &file_name[1], fs_mode); return translate_error(res); } @@ -69,7 +87,10 @@ static int fatfs_close(struct fs_file_t *zfp) { FRESULT res; - res = f_close(&zfp->fatfs_fp); + res = f_close(zfp->filep); + + /* Free file ptr memory */ + k_mem_slab_free(&fatfs_filep_pool, &zfp->filep); return translate_error(res); } @@ -78,7 +99,7 @@ static int fatfs_unlink(struct fs_mount_t *mountp, const char *path) { FRESULT res; - res = f_unlink(path); + res = f_unlink(&path[1]); return translate_error(res); } @@ -88,7 +109,7 @@ static ssize_t fatfs_read(struct fs_file_t *zfp, void *ptr, size_t size) FRESULT res; unsigned int br; - res = f_read(&zfp->fatfs_fp, ptr, size, &br); + res = f_read(zfp->filep, ptr, size, &br); if (res != FR_OK) { return translate_error(res); } @@ -101,7 +122,7 @@ static ssize_t fatfs_write(struct fs_file_t *zfp, const void *ptr, size_t size) FRESULT res; unsigned int bw; - res = f_write(&zfp->fatfs_fp, ptr, size, &bw); + res = f_write(zfp->filep, ptr, size, &bw); if (res != FR_OK) { return translate_error(res); } @@ -119,51 +140,51 @@ static int fatfs_seek(struct fs_file_t *zfp, off_t offset, int whence) pos = offset; break; case FS_SEEK_CUR: - pos = f_tell(&zfp->fatfs_fp) + offset; + pos = f_tell((FIL *)zfp->filep) + offset; break; case FS_SEEK_END: - pos = f_size(&zfp->fatfs_fp) + offset; + pos = f_size((FIL *)zfp->filep) + offset; break; default: return -EINVAL; } - if ((pos < 0) || (pos > f_size(&zfp->fatfs_fp))) { + if ((pos < 0) || (pos > f_size((FIL *)zfp->filep))) { return -EINVAL; } - res = f_lseek(&zfp->fatfs_fp, pos); + res = f_lseek(zfp->filep, pos); return translate_error(res); } static off_t fatfs_tell(struct fs_file_t *zfp) { - return f_tell(&zfp->fatfs_fp); + return f_tell((FIL *)zfp->filep); } static int fatfs_truncate(struct fs_file_t *zfp, off_t length) { FRESULT res = FR_OK; - off_t cur_length = f_size(&zfp->fatfs_fp); + off_t cur_length = f_size((FIL *)zfp->filep); /* f_lseek expands file if new position is larger than file size */ - res = f_lseek(&zfp->fatfs_fp, length); + res = f_lseek(zfp->filep, length); if (res != FR_OK) { return translate_error(res); } if (length < cur_length) { - res = f_truncate(&zfp->fatfs_fp); + res = f_truncate(zfp->filep); } else { /* * Get actual length after expansion. This could be * less if there was not enough space in the volume * to expand to the requested length */ - length = f_tell(&zfp->fatfs_fp); + length = f_tell((FIL *)zfp->filep); - res = f_lseek(&zfp->fatfs_fp, cur_length); + res = f_lseek(zfp->filep, cur_length); if (res != FR_OK) { return translate_error(res); } @@ -178,7 +199,7 @@ static int fatfs_truncate(struct fs_file_t *zfp, off_t length) u8_t c = 0; for (int i = cur_length; i < length; i++) { - res = f_write(&zfp->fatfs_fp, &c, 1, &bw); + res = f_write(zfp->filep, &c, 1, &bw); if (res != FR_OK) { break; } @@ -192,7 +213,7 @@ static int fatfs_sync(struct fs_file_t *zfp) { FRESULT res = FR_OK; - res = f_sync(&zfp->fatfs_fp); + res = f_sync(zfp->filep); return translate_error(res); } @@ -201,7 +222,7 @@ static int fatfs_mkdir(struct fs_mount_t *mountp, const char *path) { FRESULT res; - res = f_mkdir(path); + res = f_mkdir(&path[1]); return translate_error(res); } @@ -209,8 +230,17 @@ static int fatfs_mkdir(struct fs_mount_t *mountp, const char *path) static int fatfs_opendir(struct fs_dir_t *zdp, const char *path) { FRESULT res; + void *ptr; - res = f_opendir(&zdp->fatfs_dp, path); + if (k_mem_slab_alloc(&fatfs_dirp_pool, &ptr, K_NO_WAIT) == 0) { + memset(ptr, 0, sizeof(DIR)); + zdp->dirp = ptr; + } else { + return -ENOMEM; + } + + + res = f_opendir(zdp->dirp, &path[1]); return translate_error(res); } @@ -220,7 +250,7 @@ static int fatfs_readdir(struct fs_dir_t *zdp, struct fs_dirent *entry) FRESULT res; FILINFO fno; - res = f_readdir(&zdp->fatfs_dp, &fno); + res = f_readdir(zdp->dirp, &fno); if (res == FR_OK) { entry->type = ((fno.fattrib & AM_DIR) ? FS_DIR_ENTRY_DIR : FS_DIR_ENTRY_FILE); @@ -235,7 +265,10 @@ static int fatfs_closedir(struct fs_dir_t *zdp) { FRESULT res; - res = f_closedir(&zdp->fatfs_dp); + res = f_closedir(zdp->dirp); + + /* Free file ptr memory */ + k_mem_slab_free(&fatfs_dirp_pool, &zdp->dirp); return translate_error(res); } @@ -246,7 +279,7 @@ static int fatfs_stat(struct fs_mount_t *mountp, FRESULT res; FILINFO fno; - res = f_stat(path, &fno); + res = f_stat(&path[1], &fno); if (res == FR_OK) { entry->type = ((fno.fattrib & AM_DIR) ? FS_DIR_ENTRY_DIR : FS_DIR_ENTRY_FILE); @@ -263,7 +296,7 @@ static int fatfs_statvfs(struct fs_mount_t *mountp, FATFS *fs; FRESULT res; - res = f_getfree("", &stat->f_bfree, &fs); + res = f_getfree(&mountp->mnt_point[1], &stat->f_bfree, &fs); if (res != FR_OK) { return -EIO; } @@ -283,15 +316,17 @@ static int fatfs_mount(struct fs_mount_t *mountp) { FRESULT res; - res = f_mount((FATFS *)mountp->fs_data, "", 1); + res = f_mount((FATFS *)mountp->fs_data, &mountp->mnt_point[1], 1); /* If no file system found then create one */ if (res == FR_NO_FILESYSTEM) { u8_t work[_MAX_SS]; - res = f_mkfs("", (FM_FAT | FM_SFD), 0, work, sizeof(work)); + res = f_mkfs(&mountp->mnt_point[1], + (FM_FAT | FM_SFD), 0, work, sizeof(work)); if (res == FR_OK) { - res = f_mount((FATFS *)mountp->fs_data, "", 1); + res = f_mount((FATFS *)mountp->fs_data, + &mountp->mnt_point[1], 1); } } diff --git a/subsys/fs/fs.c b/subsys/fs/fs.c index 5d4689d9ca2..fd754171f1f 100644 --- a/subsys/fs/fs.c +++ b/subsys/fs/fs.c @@ -23,8 +23,8 @@ static struct k_mutex mutex; /* file system map table */ static struct fs_file_system_t *fs_map[FS_TYPE_END]; -int get_mnt_point(struct fs_mount_t **mnt_pntp, - const char *name, size_t *match_len) +int fs_get_mnt_point(struct fs_mount_t **mnt_pntp, + const char *name, size_t *match_len) { struct fs_mount_t *mnt_p = NULL, *itr; size_t longest_match = 0; @@ -66,7 +66,9 @@ int get_mnt_point(struct fs_mount_t **mnt_pntp, } *mnt_pntp = mnt_p; - *match_len = mnt_p->mountp_len; + if (match_len) + *match_len = mnt_p->mountp_len; + return 0; } @@ -74,7 +76,6 @@ int get_mnt_point(struct fs_mount_t **mnt_pntp, int fs_open(struct fs_file_t *zfp, const char *file_name) { struct fs_mount_t *mp; - size_t match_len; int rc = -EINVAL; if ((file_name == NULL) || @@ -83,7 +84,7 @@ int fs_open(struct fs_file_t *zfp, const char *file_name) return -EINVAL; } - rc = get_mnt_point(&mp, file_name, &match_len); + rc = fs_get_mnt_point(&mp, file_name, NULL); if (rc < 0) { SYS_LOG_ERR("%s:mount point not found!!", __func__); return rc; @@ -92,7 +93,7 @@ int fs_open(struct fs_file_t *zfp, const char *file_name) zfp->mp = mp; if (zfp->mp->fs->open != NULL) { - rc = zfp->mp->fs->open(zfp, &file_name[match_len]); + rc = zfp->mp->fs->open(zfp, file_name); if (rc < 0) { SYS_LOG_ERR("file open error (%d)", rc); return rc; @@ -207,7 +208,6 @@ int fs_sync(struct fs_file_t *zfp) int fs_opendir(struct fs_dir_t *zdp, const char *abs_path) { struct fs_mount_t *mp; - size_t match_len; int rc = -EINVAL; if ((abs_path == NULL) || @@ -216,7 +216,7 @@ int fs_opendir(struct fs_dir_t *zdp, const char *abs_path) return -EINVAL; } - rc = get_mnt_point(&mp, abs_path, &match_len); + rc = fs_get_mnt_point(&mp, abs_path, NULL); if (rc < 0) { SYS_LOG_ERR("%s:mount point not found!!", __func__); return rc; @@ -225,7 +225,7 @@ int fs_opendir(struct fs_dir_t *zdp, const char *abs_path) zdp->mp = mp; if (zdp->mp->fs->opendir != NULL) { - rc = zdp->mp->fs->opendir(zdp, &abs_path[match_len]); + rc = zdp->mp->fs->opendir(zdp, abs_path); if (rc < 0) { SYS_LOG_ERR("directory open error (%d)", rc); } @@ -267,7 +267,6 @@ int fs_closedir(struct fs_dir_t *zdp) int fs_mkdir(const char *abs_path) { struct fs_mount_t *mp; - size_t match_len; int rc = -EINVAL; if ((abs_path == NULL) || @@ -276,14 +275,14 @@ int fs_mkdir(const char *abs_path) return -EINVAL; } - rc = get_mnt_point(&mp, abs_path, &match_len); + rc = fs_get_mnt_point(&mp, abs_path, NULL); if (rc < 0) { SYS_LOG_ERR("%s:mount point not found!!", __func__); return rc; } if (mp->fs->mkdir != NULL) { - rc = mp->fs->mkdir(mp, &abs_path[match_len]); + rc = mp->fs->mkdir(mp, abs_path); if (rc < 0) { SYS_LOG_ERR("failed to create directory (%d)", rc); } @@ -295,7 +294,6 @@ int fs_mkdir(const char *abs_path) int fs_unlink(const char *abs_path) { struct fs_mount_t *mp; - size_t match_len; int rc = -EINVAL; if ((abs_path == NULL) || @@ -304,14 +302,14 @@ int fs_unlink(const char *abs_path) return -EINVAL; } - rc = get_mnt_point(&mp, abs_path, &match_len); + rc = fs_get_mnt_point(&mp, abs_path, NULL); if (rc < 0) { SYS_LOG_ERR("%s:mount point not found!!", __func__); return rc; } if (mp->fs->unlink != NULL) { - rc = mp->fs->unlink(mp, &abs_path[match_len]); + rc = mp->fs->unlink(mp, abs_path); if (rc < 0) { SYS_LOG_ERR("failed to unlink path (%d)", rc); } @@ -332,7 +330,7 @@ int fs_rename(const char *from, const char *to) return -EINVAL; } - rc = get_mnt_point(&mp, from, &match_len); + rc = fs_get_mnt_point(&mp, from, &match_len); if (rc < 0) { SYS_LOG_ERR("%s:mount point not found!!", __func__); return rc; @@ -345,7 +343,7 @@ int fs_rename(const char *from, const char *to) } if (mp->fs->rename != NULL) { - rc = mp->fs->rename(mp, &from[match_len], &to[match_len]); + rc = mp->fs->rename(mp, from, to); if (rc < 0) { SYS_LOG_ERR("failed to rename file or dir (%d)", rc); } @@ -357,7 +355,6 @@ int fs_rename(const char *from, const char *to) int fs_stat(const char *abs_path, struct fs_dirent *entry) { struct fs_mount_t *mp; - size_t match_len; int rc = -EINVAL; if ((abs_path == NULL) || @@ -366,14 +363,14 @@ int fs_stat(const char *abs_path, struct fs_dirent *entry) return -EINVAL; } - rc = get_mnt_point(&mp, abs_path, &match_len); + rc = fs_get_mnt_point(&mp, abs_path, NULL); if (rc < 0) { SYS_LOG_ERR("%s:mount point not found!!", __func__); return rc; } if (mp->fs->stat != NULL) { - rc = mp->fs->stat(mp, &abs_path[match_len], entry); + rc = mp->fs->stat(mp, abs_path, entry); if (rc < 0) { SYS_LOG_ERR("failed get file or dir stat (%d)", rc); } @@ -384,7 +381,6 @@ int fs_stat(const char *abs_path, struct fs_dirent *entry) int fs_statvfs(const char *abs_path, struct fs_statvfs *stat) { struct fs_mount_t *mp; - size_t match_len; int rc; if ((abs_path == NULL) || @@ -393,14 +389,14 @@ int fs_statvfs(const char *abs_path, struct fs_statvfs *stat) return -EINVAL; } - rc = get_mnt_point(&mp, abs_path, &match_len); + rc = fs_get_mnt_point(&mp, abs_path, NULL); if (rc < 0) { SYS_LOG_ERR("%s:mount point not found!!", __func__); return rc; } if (mp->fs->statvfs != NULL) { - rc = mp->fs->statvfs(mp, &abs_path[match_len], stat); + rc = mp->fs->statvfs(mp, abs_path, stat); if (rc < 0) { SYS_LOG_ERR("failed get file or dir stat (%d)", rc); } diff --git a/subsys/fs/nffs_fs.c b/subsys/fs/nffs_fs.c index 8afbe5598a5..527064008bb 100644 --- a/subsys/fs/nffs_fs.c +++ b/subsys/fs/nffs_fs.c @@ -15,6 +15,7 @@ #include #include #include +#include #define NFFS_MAX_FILE_NAME 256 @@ -227,18 +228,19 @@ static int inode_to_dirent(struct nffs_inode_entry *inode, static int nffs_open(struct fs_file_t *zfp, const char *file_name) { - int rc; + int rc, match_len; k_mutex_lock(&nffs_lock, K_FOREVER); - zfp->nffs_fp = NULL; + zfp->filep = NULL; if (!nffs_misc_ready()) { k_mutex_unlock(&nffs_lock); return -ENODEV; } - rc = nffs_file_open(&zfp->nffs_fp, file_name, + match_len = strlen(zfp->mp->mnt_point); + rc = nffs_file_open((struct nffs_file **)&zfp->filep, &file_name[match_len], FS_ACCESS_READ | FS_ACCESS_WRITE); k_mutex_unlock(&nffs_lock); @@ -252,9 +254,9 @@ static int nffs_close(struct fs_file_t *zfp) k_mutex_lock(&nffs_lock, K_FOREVER); - rc = nffs_file_close(zfp->nffs_fp); + rc = nffs_file_close(zfp->filep); if (!rc) { - zfp->nffs_fp = NULL; + zfp->filep = NULL; } k_mutex_unlock(&nffs_lock); @@ -264,11 +266,12 @@ static int nffs_close(struct fs_file_t *zfp) static int nffs_unlink(struct fs_mount_t *mountp, const char *path) { - int rc; + int rc, match_len; k_mutex_lock(&nffs_lock, K_FOREVER); - rc = nffs_path_unlink(path); + match_len = strlen(mountp->mnt_point); + rc = nffs_path_unlink(&path[match_len]); k_mutex_unlock(&nffs_lock); @@ -282,7 +285,7 @@ static ssize_t nffs_read(struct fs_file_t *zfp, void *ptr, size_t size) k_mutex_lock(&nffs_lock, K_FOREVER); - rc = nffs_file_read(zfp->nffs_fp, size, ptr, &br); + rc = nffs_file_read(zfp->filep, size, ptr, &br); k_mutex_unlock(&nffs_lock); @@ -299,7 +302,7 @@ static ssize_t nffs_write(struct fs_file_t *zfp, const void *ptr, size_t size) k_mutex_lock(&nffs_lock, K_FOREVER); - rc = nffs_write_to_file(zfp->nffs_fp, ptr, size); + rc = nffs_write_to_file(zfp->filep, ptr, size); k_mutex_unlock(&nffs_lock); @@ -324,10 +327,10 @@ static int nffs_seek(struct fs_file_t *zfp, off_t offset, int whence) pos = offset; break; case FS_SEEK_CUR: - pos = zfp->nffs_fp->nf_offset + offset; + pos = ((struct nffs_file *)zfp->filep)->nf_offset + offset; break; case FS_SEEK_END: - rc = nffs_inode_data_len(zfp->nffs_fp->nf_inode_entry, &len); + rc = nffs_inode_data_len(((struct nffs_file *)zfp->filep)->nf_inode_entry, &len); if (rc) { k_mutex_unlock(&nffs_lock); return -EINVAL; @@ -339,7 +342,7 @@ static int nffs_seek(struct fs_file_t *zfp, off_t offset, int whence) return -EINVAL; } - rc = nffs_file_seek(zfp->nffs_fp, pos); + rc = nffs_file_seek(zfp->filep, pos); k_mutex_unlock(&nffs_lock); @@ -352,12 +355,12 @@ static off_t nffs_tell(struct fs_file_t *zfp) k_mutex_lock(&nffs_lock, K_FOREVER); - if (!zfp->nffs_fp) { + if (!zfp->filep) { k_mutex_unlock(&nffs_lock); return -EIO; } - offset = zfp->nffs_fp->nf_offset; + offset = ((struct nffs_file *)zfp->filep)->nf_offset; k_mutex_unlock(&nffs_lock); @@ -388,7 +391,7 @@ static int nffs_sync(struct fs_file_t *zfp) static int nffs_mkdir(struct fs_mount_t *mountp, const char *path) { - int rc; + int rc, match_len; k_mutex_lock(&nffs_lock, K_FOREVER); @@ -397,7 +400,8 @@ static int nffs_mkdir(struct fs_mount_t *mountp, const char *path) return -ENODEV; } - rc = nffs_path_new_dir(path, NULL); + match_len = strlen(mountp->mnt_point); + rc = nffs_path_new_dir(&path[match_len], NULL); k_mutex_unlock(&nffs_lock); @@ -406,18 +410,19 @@ static int nffs_mkdir(struct fs_mount_t *mountp, const char *path) static int nffs_opendir(struct fs_dir_t *zdp, const char *path) { - int rc; + int rc, match_len; k_mutex_lock(&nffs_lock, K_FOREVER); - zdp->nffs_dp = NULL; + zdp->dirp = NULL; if (!nffs_misc_ready()) { k_mutex_unlock(&nffs_lock); return -ENODEV; } - rc = nffs_dir_open(path, &zdp->nffs_dp); + match_len = strlen(zdp->mp->mnt_point); + rc = nffs_dir_open(&path[match_len], (struct nffs_dir **)&zdp->dirp); k_mutex_unlock(&nffs_lock); @@ -431,7 +436,7 @@ static int nffs_readdir(struct fs_dir_t *zdp, struct fs_dirent *entry) k_mutex_lock(&nffs_lock, K_FOREVER); - rc = nffs_dir_read(zdp->nffs_dp, &dirent); + rc = nffs_dir_read(zdp->dirp, &dirent); switch (rc) { case 0: rc = inode_to_dirent(dirent->nde_inode_entry, entry); @@ -455,9 +460,9 @@ static int nffs_closedir(struct fs_dir_t *zdp) k_mutex_lock(&nffs_lock, K_FOREVER); - rc = nffs_dir_close(zdp->nffs_dp); + rc = nffs_dir_close(zdp->dirp); if (!rc) { - zdp->nffs_dp = NULL; + zdp->dirp = NULL; } k_mutex_unlock(&nffs_lock); @@ -471,11 +476,12 @@ static int nffs_stat(struct fs_mount_t *mountp, struct nffs_path_parser parser; struct nffs_inode_entry *parent; struct nffs_inode_entry *inode; - int rc; + int rc, match_len; k_mutex_lock(&nffs_lock, K_FOREVER); - nffs_path_parser_new(&parser, path); + match_len = strlen(mountp->mnt_point); + nffs_path_parser_new(&parser, &path[match_len]); rc = nffs_path_find(&parser, &inode, &parent); if (rc == 0) { @@ -501,7 +507,7 @@ static int nffs_statvfs(struct fs_mount_t *mountp, static int nffs_rename(struct fs_mount_t *mountp, const char *from, const char *to) { - int rc; + int rc, match_len; k_mutex_lock(&nffs_lock, K_FOREVER); @@ -510,7 +516,8 @@ static int nffs_rename(struct fs_mount_t *mountp, const char *from, return -ENODEV; } - rc = nffs_path_rename(from, to); + match_len = strlen(mountp->mnt_point); + rc = nffs_path_rename(&from[match_len], &to[match_len]); k_mutex_unlock(&nffs_lock);