Lines Matching full:fs
13 #include <zephyr/fs/fs.h>
14 #include <zephyr/fs/fs_sys.h>
20 #include <zephyr/fs/littlefs.h>
91 static inline void fs_lock(struct fs_littlefs *fs) in fs_lock() argument
93 k_mutex_lock(&fs->mutex, K_FOREVER); in fs_lock()
96 static inline void fs_unlock(struct fs_littlefs *fs) in fs_unlock() argument
98 k_mutex_unlock(&fs->mutex); in fs_unlock()
292 struct fs_littlefs *fs = fp->mp->fs_data; in littlefs_open() local
293 struct lfs *lfs = &fs->lfs; in littlefs_open()
314 fs_lock(fs); in littlefs_open()
316 ret = lfs_file_opencfg(&fs->lfs, &fdp->file, in littlefs_open()
319 fs_unlock(fs); in littlefs_open()
330 struct fs_littlefs *fs = fp->mp->fs_data; in littlefs_close() local
332 fs_lock(fs); in littlefs_close()
334 int ret = lfs_file_close(&fs->lfs, LFS_FILEP(fp)); in littlefs_close()
336 fs_unlock(fs); in littlefs_close()
345 struct fs_littlefs *fs = mountp->fs_data; in littlefs_unlink() local
349 fs_lock(fs); in littlefs_unlink()
351 int ret = lfs_remove(&fs->lfs, path); in littlefs_unlink()
353 fs_unlock(fs); in littlefs_unlink()
360 struct fs_littlefs *fs = mountp->fs_data; in littlefs_rename() local
365 fs_lock(fs); in littlefs_rename()
367 int ret = lfs_rename(&fs->lfs, from, to); in littlefs_rename()
369 fs_unlock(fs); in littlefs_rename()
375 struct fs_littlefs *fs = fp->mp->fs_data; in littlefs_read() local
377 fs_lock(fs); in littlefs_read()
379 ssize_t ret = lfs_file_read(&fs->lfs, LFS_FILEP(fp), ptr, len); in littlefs_read()
381 fs_unlock(fs); in littlefs_read()
387 struct fs_littlefs *fs = fp->mp->fs_data; in littlefs_write() local
389 fs_lock(fs); in littlefs_write()
391 ssize_t ret = lfs_file_write(&fs->lfs, LFS_FILEP(fp), ptr, len); in littlefs_write()
393 fs_unlock(fs); in littlefs_write()
403 struct fs_littlefs *fs = fp->mp->fs_data; in littlefs_seek() local
405 fs_lock(fs); in littlefs_seek()
407 off_t ret = lfs_file_seek(&fs->lfs, LFS_FILEP(fp), off, whence); in littlefs_seek()
409 fs_unlock(fs); in littlefs_seek()
420 struct fs_littlefs *fs = fp->mp->fs_data; in littlefs_tell() local
422 fs_lock(fs); in littlefs_tell()
424 off_t ret = lfs_file_tell(&fs->lfs, LFS_FILEP(fp)); in littlefs_tell()
426 fs_unlock(fs); in littlefs_tell()
432 struct fs_littlefs *fs = fp->mp->fs_data; in littlefs_truncate() local
434 fs_lock(fs); in littlefs_truncate()
436 int ret = lfs_file_truncate(&fs->lfs, LFS_FILEP(fp), length); in littlefs_truncate()
438 fs_unlock(fs); in littlefs_truncate()
444 struct fs_littlefs *fs = fp->mp->fs_data; in littlefs_sync() local
446 fs_lock(fs); in littlefs_sync()
448 int ret = lfs_file_sync(&fs->lfs, LFS_FILEP(fp)); in littlefs_sync()
450 fs_unlock(fs); in littlefs_sync()
456 struct fs_littlefs *fs = mountp->fs_data; in littlefs_mkdir() local
459 fs_lock(fs); in littlefs_mkdir()
461 int ret = lfs_mkdir(&fs->lfs, path); in littlefs_mkdir()
463 fs_unlock(fs); in littlefs_mkdir()
469 struct fs_littlefs *fs = dp->mp->fs_data; in littlefs_opendir() local
479 fs_lock(fs); in littlefs_opendir()
481 int ret = lfs_dir_open(&fs->lfs, dp->dirp, path); in littlefs_opendir()
483 fs_unlock(fs); in littlefs_opendir()
503 struct fs_littlefs *fs = dp->mp->fs_data; in littlefs_readdir() local
505 fs_lock(fs); in littlefs_readdir()
508 int ret = lfs_dir_read(&fs->lfs, dp->dirp, &info); in littlefs_readdir()
510 fs_unlock(fs); in littlefs_readdir()
524 struct fs_littlefs *fs = dp->mp->fs_data; in littlefs_closedir() local
526 fs_lock(fs); in littlefs_closedir()
528 int ret = lfs_dir_close(&fs->lfs, dp->dirp); in littlefs_closedir()
530 fs_unlock(fs); in littlefs_closedir()
540 struct fs_littlefs *fs = mountp->fs_data; in littlefs_stat() local
544 fs_lock(fs); in littlefs_stat()
547 int ret = lfs_stat(&fs->lfs, path, &info); in littlefs_stat()
549 fs_unlock(fs); in littlefs_stat()
562 struct fs_littlefs *fs = mountp->fs_data; in littlefs_statvfs() local
563 struct lfs *lfs = &fs->lfs; in littlefs_statvfs()
571 fs_lock(fs); in littlefs_statvfs()
575 fs_unlock(fs); in littlefs_statvfs()
650 static int littlefs_flash_init(struct fs_littlefs *fs, void *dev_id) in littlefs_flash_init() argument
653 const struct flash_area **fap = (const struct flash_area **)&fs->backend; in littlefs_flash_init()
664 LOG_DBG("FS area %u at 0x%x for %u bytes", area_id, in littlefs_flash_init()
674 fs->backend = (void *) *fap; in littlefs_flash_init()
679 static int littlefs_init_backend(struct fs_littlefs *fs, void *dev_id, int flags) in littlefs_init_backend() argument
691 fs->backend = dev_id; in littlefs_init_backend()
692 ret = disk_access_init((char *) fs->backend); in littlefs_init_backend()
701 ret = littlefs_flash_init(fs, dev_id); in littlefs_init_backend()
710 static int littlefs_init_cfg(struct fs_littlefs *fs, int flags) in littlefs_init_cfg() argument
722 struct lfs_config *lcp = &fs->cfg; in littlefs_init_cfg()
748 int ret = disk_access_ioctl((char *) fs->backend, in littlefs_init_cfg()
760 block_size = get_block_size((struct flash_area *)fs->backend); in littlefs_init_cfg()
805 int ret = disk_access_ioctl((char *) fs->backend, in littlefs_init_cfg()
812 LOG_INF("FS at %s: is %u 0x%x-byte blocks with %u cycle", in littlefs_init_cfg()
813 (char *) fs->backend, block_count, block_size, in littlefs_init_cfg()
820 block_count = ((struct flash_area *)fs->backend)->fa_size in littlefs_init_cfg()
823 flash_area_get_device((struct flash_area *)fs->backend); in littlefs_init_cfg()
824 LOG_INF("FS at %s:0x%x is %u 0x%x-byte blocks with %u cycle", in littlefs_init_cfg()
826 (uint32_t)((struct flash_area *)fs->backend)->fa_off, in littlefs_init_cfg()
844 lcp->context = fs->backend; in littlefs_init_cfg()
877 __ASSERT((((struct flash_area *)fs->backend)->fa_size % in littlefs_init_cfg()
906 static int littlefs_init_fs(struct fs_littlefs *fs, void *dev_id, int flags) in littlefs_init_fs() argument
914 if (fs->backend) { in littlefs_init_fs()
918 ret = littlefs_init_backend(fs, dev_id, flags); in littlefs_init_fs()
923 ret = littlefs_init_cfg(fs, flags); in littlefs_init_fs()
933 struct fs_littlefs *fs = mountp->fs_data; in littlefs_mount() local
936 k_mutex_init(&fs->mutex); in littlefs_mount()
937 fs_lock(fs); in littlefs_mount()
939 ret = littlefs_init_fs(fs, mountp->storage_dev, mountp->flags); in littlefs_mount()
945 ret = lfs_mount(&fs->lfs, &fs->cfg); in littlefs_mount()
950 ret = lfs_format(&fs->lfs, &fs->cfg); in littlefs_mount()
962 ret = lfs_mount(&fs->lfs, &fs->cfg); in littlefs_mount()
977 fs->backend = NULL; in littlefs_mount()
980 fs_unlock(fs); in littlefs_mount()
992 struct fs_littlefs *fs = &fs_cfg; in littlefs_mkfs() local
995 fs = (struct fs_littlefs *)cfg; in littlefs_mkfs()
998 fs->backend = NULL; in littlefs_mkfs()
1001 k_mutex_init(&fs->mutex); in littlefs_mkfs()
1002 fs_lock(fs); in littlefs_mkfs()
1004 ret = littlefs_init_fs(fs, UINT_TO_POINTER(dev_id), flags); in littlefs_mkfs()
1009 ret = lfs_format(&fs->lfs, &fs->cfg); in littlefs_mkfs()
1016 fs->backend = NULL; in littlefs_mkfs()
1017 fs_unlock(fs); in littlefs_mkfs()
1025 struct fs_littlefs *fs = mountp->fs_data; in littlefs_unmount() local
1027 fs_lock(fs); in littlefs_unmount()
1029 lfs_unmount(&fs->lfs); in littlefs_unmount()
1033 flash_area_close(fs->backend); in littlefs_unmount()
1037 fs->backend = NULL; in littlefs_unmount()
1038 fs_unlock(fs); in littlefs_unmount()