make raw functions static. formatting tweaks

This commit is contained in:
Bill Gesner 2020-11-20 17:01:04 +00:00 committed by Christopher Haster
parent d0f055d321
commit fc6988c7c3
2 changed files with 98 additions and 120 deletions

187
lfs.c
View File

@ -10,6 +10,15 @@
#define LFS_BLOCK_NULL ((lfs_block_t)-1)
#define LFS_BLOCK_INLINE ((lfs_block_t)-2)
static int lfs_dir_rewind_raw(lfs_t *lfs, lfs_dir_t *dir);
static int lfs_file_close_raw(lfs_t *lfs, lfs_file_t *file);
static lfs_ssize_t lfs_file_read_raw(lfs_t *lfs, lfs_file_t *file, void *buffer, lfs_size_t size);
static lfs_soff_t lfs_file_size_raw(lfs_t *lfs, lfs_file_t *file);
static int lfs_file_sync_raw(lfs_t *lfs, lfs_file_t *file);
static lfs_ssize_t lfs_file_write_raw(lfs_t *lfs, lfs_file_t *file, const void *buffer, lfs_size_t size);
static lfs_ssize_t lfs_fs_size_raw(lfs_t *lfs);
static int lfs_unmount_raw(lfs_t *lfs);
/// Caching block device operations ///
static inline void lfs_cache_drop(lfs_t *lfs, lfs_cache_t *rcache) {
// do not zero, cheaper if cache is readonly or only going to be
@ -1906,7 +1915,7 @@ compact:
/// Top level directory operations ///
int lfs_mkdir_raw(lfs_t *lfs, const char *path) {
static int lfs_mkdir_raw(lfs_t *lfs, const char *path) {
LFS_TRACE("lfs_mkdir(%p, \"%s\")", (void*)lfs, path);
// deorphan if we haven't yet, needed at most once after poweron
int err = lfs_fs_forceconsistency(lfs);
@ -2005,7 +2014,7 @@ int lfs_mkdir_raw(lfs_t *lfs, const char *path) {
return 0;
}
int lfs_dir_open_raw(lfs_t *lfs, lfs_dir_t *dir, const char *path) {
static int lfs_dir_open_raw(lfs_t *lfs, lfs_dir_t *dir, const char *path) {
LFS_TRACE("lfs_dir_open(%p, %p, \"%s\")", (void*)lfs, (void*)dir, path);
lfs_stag_t tag = lfs_dir_find(lfs, &dir->m, &path, NULL);
if (tag < 0) {
@ -2056,7 +2065,7 @@ int lfs_dir_open_raw(lfs_t *lfs, lfs_dir_t *dir, const char *path) {
return 0;
}
int lfs_dir_close_raw(lfs_t *lfs, lfs_dir_t *dir) {
static int lfs_dir_close_raw(lfs_t *lfs, lfs_dir_t *dir) {
LFS_TRACE("lfs_dir_close(%p, %p)", (void*)lfs, (void*)dir);
// remove from list of mdirs
for (struct lfs_mlist **p = &lfs->mlist; *p; p = &(*p)->next) {
@ -2070,7 +2079,7 @@ int lfs_dir_close_raw(lfs_t *lfs, lfs_dir_t *dir) {
return 0;
}
int lfs_dir_read_raw(lfs_t *lfs, lfs_dir_t *dir, struct lfs_info *info) {
static int lfs_dir_read_raw(lfs_t *lfs, lfs_dir_t *dir, struct lfs_info *info) {
LFS_TRACE("lfs_dir_read(%p, %p, %p)",
(void*)lfs, (void*)dir, (void*)info);
memset(info, 0, sizeof(*info));
@ -2123,7 +2132,7 @@ int lfs_dir_read_raw(lfs_t *lfs, lfs_dir_t *dir, struct lfs_info *info) {
return true;
}
int lfs_dir_seek_raw(lfs_t *lfs, lfs_dir_t *dir, lfs_off_t off) {
static int lfs_dir_seek_raw(lfs_t *lfs, lfs_dir_t *dir, lfs_off_t off) {
LFS_TRACE("lfs_dir_seek(%p, %p, %"PRIu32")",
(void*)lfs, (void*)dir, off);
// simply walk from head dir
@ -2166,14 +2175,14 @@ int lfs_dir_seek_raw(lfs_t *lfs, lfs_dir_t *dir, lfs_off_t off) {
return 0;
}
lfs_soff_t lfs_dir_tell_raw(lfs_t *lfs, lfs_dir_t *dir) {
static lfs_soff_t lfs_dir_tell_raw(lfs_t *lfs, lfs_dir_t *dir) {
LFS_TRACE("lfs_dir_tell(%p, %p)", (void*)lfs, (void*)dir);
(void)lfs;
LFS_TRACE("lfs_dir_tell -> %"PRId32, dir->pos);
return dir->pos;
}
int lfs_dir_rewind_raw(lfs_t *lfs, lfs_dir_t *dir) {
static int lfs_dir_rewind_raw(lfs_t *lfs, lfs_dir_t *dir) {
LFS_TRACE("lfs_dir_rewind(%p, %p)", (void*)lfs, (void*)dir);
// reload the head dir
int err = lfs_dir_fetch(lfs, &dir->m, dir->head);
@ -2380,7 +2389,7 @@ static int lfs_ctz_traverse(lfs_t *lfs,
/// Top level file operations ///
int lfs_file_opencfg_raw(lfs_t *lfs, lfs_file_t *file,
static int lfs_file_opencfg_raw(lfs_t *lfs, lfs_file_t *file,
const char *path, int flags,
const struct lfs_file_config *cfg) {
LFS_TRACE("lfs_file_opencfg(%p, %p, \"%s\", %x, %p {"
@ -2534,7 +2543,7 @@ cleanup:
return err;
}
int lfs_file_open_raw(lfs_t *lfs, lfs_file_t *file,
static int lfs_file_open_raw(lfs_t *lfs, lfs_file_t *file,
const char *path, int flags) {
LFS_TRACE("lfs_file_open(%p, %p, \"%s\", %x)",
(void*)lfs, (void*)file, path, flags);
@ -2544,7 +2553,7 @@ int lfs_file_open_raw(lfs_t *lfs, lfs_file_t *file,
return err;
}
int lfs_file_close_raw(lfs_t *lfs, lfs_file_t *file) {
static int lfs_file_close_raw(lfs_t *lfs, lfs_file_t *file) {
LFS_TRACE("lfs_file_close(%p, %p)", (void*)lfs, (void*)file);
LFS_ASSERT(file->flags & LFS_F_OPENED);
@ -2731,7 +2740,7 @@ relocate:
return 0;
}
int lfs_file_sync_raw(lfs_t *lfs, lfs_file_t *file) {
static int lfs_file_sync_raw(lfs_t *lfs, lfs_file_t *file) {
LFS_TRACE("lfs_file_sync(%p, %p)", (void*)lfs, (void*)file);
LFS_ASSERT(file->flags & LFS_F_OPENED);
@ -2788,7 +2797,7 @@ int lfs_file_sync_raw(lfs_t *lfs, lfs_file_t *file) {
return 0;
}
lfs_ssize_t lfs_file_read_raw(lfs_t *lfs, lfs_file_t *file,
static lfs_ssize_t lfs_file_read_raw(lfs_t *lfs, lfs_file_t *file,
void *buffer, lfs_size_t size) {
LFS_TRACE("lfs_file_read(%p, %p, %p, %"PRIu32")",
(void*)lfs, (void*)file, buffer, size);
@ -2868,7 +2877,7 @@ lfs_ssize_t lfs_file_read_raw(lfs_t *lfs, lfs_file_t *file,
return size;
}
lfs_ssize_t lfs_file_write_raw(lfs_t *lfs, lfs_file_t *file,
static lfs_ssize_t lfs_file_write_raw(lfs_t *lfs, lfs_file_t *file,
const void *buffer, lfs_size_t size) {
LFS_TRACE("lfs_file_write(%p, %p, %p, %"PRIu32")",
(void*)lfs, (void*)file, buffer, size);
@ -2999,7 +3008,7 @@ relocate:
return size;
}
lfs_soff_t lfs_file_seek_raw(lfs_t *lfs, lfs_file_t *file,
static lfs_soff_t lfs_file_seek_raw(lfs_t *lfs, lfs_file_t *file,
lfs_soff_t off, int whence) {
LFS_TRACE("lfs_file_seek(%p, %p, %"PRId32", %d)",
(void*)lfs, (void*)file, off, whence);
@ -3034,7 +3043,7 @@ lfs_soff_t lfs_file_seek_raw(lfs_t *lfs, lfs_file_t *file,
return npos;
}
int lfs_file_truncate_raw(lfs_t *lfs, lfs_file_t *file, lfs_off_t size) {
static int lfs_file_truncate_raw(lfs_t *lfs, lfs_file_t *file, lfs_off_t size) {
LFS_TRACE("lfs_file_truncate(%p, %p, %"PRIu32")",
(void*)lfs, (void*)file, size);
LFS_ASSERT(file->flags & LFS_F_OPENED);
@ -3098,7 +3107,7 @@ int lfs_file_truncate_raw(lfs_t *lfs, lfs_file_t *file, lfs_off_t size) {
return 0;
}
lfs_soff_t lfs_file_tell_raw(lfs_t *lfs, lfs_file_t *file) {
static lfs_soff_t lfs_file_tell_raw(lfs_t *lfs, lfs_file_t *file) {
LFS_TRACE("lfs_file_tell(%p, %p)", (void*)lfs, (void*)file);
LFS_ASSERT(file->flags & LFS_F_OPENED);
(void)lfs;
@ -3106,7 +3115,7 @@ lfs_soff_t lfs_file_tell_raw(lfs_t *lfs, lfs_file_t *file) {
return file->pos;
}
int lfs_file_rewind_raw(lfs_t *lfs, lfs_file_t *file) {
static int lfs_file_rewind_raw(lfs_t *lfs, lfs_file_t *file) {
LFS_TRACE("lfs_file_rewind(%p, %p)", (void*)lfs, (void*)file);
lfs_soff_t res = lfs_file_seek_raw(lfs, file, 0, LFS_SEEK_SET);
if (res < 0) {
@ -3118,7 +3127,7 @@ int lfs_file_rewind_raw(lfs_t *lfs, lfs_file_t *file) {
return 0;
}
lfs_soff_t lfs_file_size_raw(lfs_t *lfs, lfs_file_t *file) {
static lfs_soff_t lfs_file_size_raw(lfs_t *lfs, lfs_file_t *file) {
LFS_TRACE("lfs_file_size(%p, %p)", (void*)lfs, (void*)file);
LFS_ASSERT(file->flags & LFS_F_OPENED);
(void)lfs;
@ -3134,7 +3143,7 @@ lfs_soff_t lfs_file_size_raw(lfs_t *lfs, lfs_file_t *file) {
/// General fs operations ///
int lfs_stat_raw(lfs_t *lfs, const char *path, struct lfs_info *info) {
static int lfs_stat_raw(lfs_t *lfs, const char *path, struct lfs_info *info) {
LFS_TRACE("lfs_stat(%p, \"%s\", %p)", (void*)lfs, path, (void*)info);
lfs_mdir_t cwd;
lfs_stag_t tag = lfs_dir_find(lfs, &cwd, &path, NULL);
@ -3148,7 +3157,7 @@ int lfs_stat_raw(lfs_t *lfs, const char *path, struct lfs_info *info) {
return err;
}
int lfs_remove_raw(lfs_t *lfs, const char *path) {
static int lfs_remove_raw(lfs_t *lfs, const char *path) {
LFS_TRACE("lfs_remove(%p, \"%s\")", (void*)lfs, path);
// deorphan if we haven't yet, needed at most once after poweron
int err = lfs_fs_forceconsistency(lfs);
@ -3229,7 +3238,7 @@ int lfs_remove_raw(lfs_t *lfs, const char *path) {
return 0;
}
int lfs_rename_raw(lfs_t *lfs, const char *oldpath, const char *newpath) {
static int lfs_rename_raw(lfs_t *lfs, const char *oldpath, const char *newpath) {
LFS_TRACE("lfs_rename(%p, \"%s\", \"%s\")", (void*)lfs, oldpath, newpath);
// deorphan if we haven't yet, needed at most once after poweron
@ -3374,7 +3383,7 @@ int lfs_rename_raw(lfs_t *lfs, const char *oldpath, const char *newpath) {
return 0;
}
lfs_ssize_t lfs_getattr_raw(lfs_t *lfs, const char *path,
static lfs_ssize_t lfs_getattr_raw(lfs_t *lfs, const char *path,
uint8_t type, void *buffer, lfs_size_t size) {
LFS_TRACE("lfs_getattr(%p, \"%s\", %"PRIu8", %p, %"PRIu32")",
(void*)lfs, path, type, buffer, size);
@ -3437,7 +3446,7 @@ static int lfs_commitattr(lfs_t *lfs, const char *path,
{LFS_MKTAG(LFS_TYPE_USERATTR + type, id, size), buffer}));
}
int lfs_setattr_raw(lfs_t *lfs, const char *path,
static int lfs_setattr_raw(lfs_t *lfs, const char *path,
uint8_t type, const void *buffer, lfs_size_t size) {
LFS_TRACE("lfs_setattr(%p, \"%s\", %"PRIu8", %p, %"PRIu32")",
(void*)lfs, path, type, buffer, size);
@ -3451,7 +3460,7 @@ int lfs_setattr_raw(lfs_t *lfs, const char *path,
return err;
}
int lfs_removeattr_raw(lfs_t *lfs, const char *path, uint8_t type) {
static int lfs_removeattr_raw(lfs_t *lfs, const char *path, uint8_t type) {
LFS_TRACE("lfs_removeattr(%p, \"%s\", %"PRIu8")", (void*)lfs, path, type);
int err = lfs_commitattr(lfs, path, type, NULL, 0x3ff);
LFS_TRACE("lfs_removeattr -> %d", err);
@ -3584,7 +3593,7 @@ static int lfs_deinit(lfs_t *lfs) {
return 0;
}
int lfs_format_raw(lfs_t *lfs, const struct lfs_config *cfg) {
static int lfs_format_raw(lfs_t *lfs, const struct lfs_config *cfg) {
LFS_TRACE("lfs_format(%p, %p {.context=%p, "
".read=%p, .prog=%p, .erase=%p, .sync=%p, "
".read_size=%"PRIu32", .prog_size=%"PRIu32", "
@ -3665,7 +3674,7 @@ cleanup:
return err;
}
int lfs_mount_raw(lfs_t *lfs, const struct lfs_config *cfg) {
static int lfs_mount_raw(lfs_t *lfs, const struct lfs_config *cfg) {
LFS_TRACE("lfs_mount(%p, %p {.context=%p, "
".read=%p, .prog=%p, .erase=%p, .sync=%p, "
".read_size=%"PRIu32", .prog_size=%"PRIu32", "
@ -3809,7 +3818,7 @@ cleanup:
return err;
}
int lfs_unmount_raw(lfs_t *lfs) {
static int lfs_unmount_raw(lfs_t *lfs) {
LFS_TRACE("lfs_unmount(%p)", (void*)lfs);
int err = lfs_deinit(lfs);
LFS_TRACE("lfs_unmount -> %d", err);
@ -3914,7 +3923,7 @@ int lfs_fs_traverseraw(lfs_t *lfs,
return 0;
}
int lfs_fs_traverse_raw(lfs_t *lfs,
static int lfs_fs_traverse_raw(lfs_t *lfs,
int (*cb)(void *data, lfs_block_t block), void *data) {
LFS_TRACE("lfs_fs_traverse(%p, %p, %p)",
(void*)lfs, (void*)(uintptr_t)cb, data);
@ -4235,7 +4244,7 @@ static int lfs_fs_size_count(void *p, lfs_block_t block) {
return 0;
}
lfs_ssize_t lfs_fs_size_raw(lfs_t *lfs) {
static lfs_ssize_t lfs_fs_size_raw(lfs_t *lfs) {
LFS_TRACE("lfs_fs_size(%p)", (void*)lfs);
lfs_size_t size = 0;
int err = lfs_fs_traverseraw(lfs, lfs_fs_size_count, &size, false);
@ -4669,7 +4678,7 @@ static int lfs1_unmount(lfs_t *lfs) {
}
/// v1 migration ///
int lfs_migrate_raw(lfs_t *lfs, const struct lfs_config *cfg) {
static int lfs_migrate_raw(lfs_t *lfs, const struct lfs_config *cfg) {
LFS_TRACE("lfs_migrate(%p, %p {.context=%p, "
".read=%p, .prog=%p, .erase=%p, .sync=%p, "
".read_size=%"PRIu32", .prog_size=%"PRIu32", "
@ -4914,7 +4923,7 @@ cleanup:
#if LFS_THREADSAFE
int lfs_format (lfs_t * lfs, const struct lfs_config * config) {
int lfs_format(lfs_t *lfs, const struct lfs_config *config) {
int err = config->lock(config);
if (err) {
return err;
@ -4926,7 +4935,7 @@ int lfs_format (lfs_t * lfs, const struct lfs_config * config) {
return err;
}
int lfs_mount (lfs_t * lfs, const struct lfs_config * config) {
int lfs_mount(lfs_t *lfs, const struct lfs_config *config) {
int err = config->lock(config);
if (err) {
return err;
@ -4938,7 +4947,7 @@ int lfs_mount (lfs_t * lfs, const struct lfs_config * config) {
return err;
}
int lfs_unmount (lfs_t * lfs) {
int lfs_unmount(lfs_t *lfs) {
int err = lfs->cfg->lock(lfs->cfg);
if (err) {
return err;
@ -4950,7 +4959,7 @@ int lfs_unmount (lfs_t * lfs) {
return err;
}
int lfs_remove (lfs_t * lfs, const char * path) {
int lfs_remove(lfs_t *lfs, const char *path) {
int err = lfs->cfg->lock(lfs->cfg);
if (err) {
return err;
@ -4962,7 +4971,7 @@ int lfs_remove (lfs_t * lfs, const char * path) {
return err;
}
int lfs_rename (lfs_t * lfs, const char * oldpath, const char * newpath) {
int lfs_rename(lfs_t *lfs, const char *oldpath, const char *newpath) {
int err = lfs->cfg->lock(lfs->cfg);
if (err) {
return err;
@ -4975,7 +4984,7 @@ int lfs_rename (lfs_t * lfs, const char * oldpath, const char * newpath) {
return err;
}
int lfs_stat (lfs_t * lfs, const char * path, struct lfs_info * info) {
int lfs_stat(lfs_t *lfs, const char *path, struct lfs_info *info) {
int err = lfs->cfg->lock(lfs->cfg);
if (err) {
return err;
@ -4988,7 +4997,7 @@ int lfs_stat (lfs_t * lfs, const char * path, struct lfs_info * info) {
return err;
}
lfs_ssize_t lfs_getattr (lfs_t * lfs, const char * path, uint8_t type, void * buffer, lfs_size_t size) {
lfs_ssize_t lfs_getattr(lfs_t *lfs, const char *path, uint8_t type, void *buffer, lfs_size_t size) {
int err = lfs->cfg->lock(lfs->cfg);
if (err) {
return err;
@ -5001,7 +5010,7 @@ lfs_ssize_t lfs_getattr (lfs_t * lfs, const char * path, uint8_t type, void * bu
return err;
}
int lfs_setattr (lfs_t * lfs, const char * path, uint8_t type, const void * buffer, lfs_size_t size) {
int lfs_setattr(lfs_t *lfs, const char *path, uint8_t type, const void *buffer, lfs_size_t size) {
int err = lfs->cfg->lock(lfs->cfg);
if (err) {
return err;
@ -5014,7 +5023,7 @@ int lfs_setattr (lfs_t * lfs, const char * path, uint8_t type, const void * buff
return err;
}
int lfs_removeattr (lfs_t * lfs, const char * path, uint8_t type) {
int lfs_removeattr(lfs_t *lfs, const char *path, uint8_t type) {
int err = lfs->cfg->lock(lfs->cfg);
if (err) {
return err;
@ -5027,7 +5036,7 @@ int lfs_removeattr (lfs_t * lfs, const char * path, uint8_t type) {
return err;
}
int lfs_file_open (lfs_t * lfs, lfs_file_t * file, const char * path, int flags) {
int lfs_file_open(lfs_t *lfs, lfs_file_t *file, const char *path, int flags) {
int err = lfs->cfg->lock(lfs->cfg);
if (err) {
return err;
@ -5053,7 +5062,7 @@ int lfs_file_opencfg(lfs_t *lfs, lfs_file_t *file, const char *path, int flags,
return err;
}
int lfs_file_close (lfs_t * lfs, lfs_file_t * file) {
int lfs_file_close(lfs_t *lfs, lfs_file_t *file) {
int err = lfs->cfg->lock(lfs->cfg);
if (err) {
return err;
@ -5066,7 +5075,7 @@ int lfs_file_close (lfs_t * lfs, lfs_file_t * file) {
return err;
}
int lfs_file_sync (lfs_t * lfs, lfs_file_t * file) {
int lfs_file_sync(lfs_t *lfs, lfs_file_t *file) {
int err = lfs->cfg->lock(lfs->cfg);
if (err) {
return err;
@ -5079,7 +5088,7 @@ int lfs_file_sync (lfs_t * lfs, lfs_file_t * file) {
return err;
}
lfs_ssize_t lfs_file_read (lfs_t * lfs, lfs_file_t * file, void * buffer, lfs_size_t size) {
lfs_ssize_t lfs_file_read(lfs_t *lfs, lfs_file_t *file, void *buffer, lfs_size_t size) {
int err = lfs->cfg->lock(lfs->cfg);
if (err) {
return err;
@ -5092,7 +5101,7 @@ lfs_ssize_t lfs_file_read (lfs_t * lfs, lfs_file_t * file, void * buffer, lfs_si
return err;
}
lfs_ssize_t lfs_file_write (lfs_t * lfs, lfs_file_t * file, const void * buffer, lfs_size_t size) {
lfs_ssize_t lfs_file_write(lfs_t *lfs, lfs_file_t *file, const void *buffer, lfs_size_t size) {
int err = lfs->cfg->lock(lfs->cfg);
if (err) {
return err;
@ -5105,7 +5114,7 @@ lfs_ssize_t lfs_file_write (lfs_t * lfs, lfs_file_t * file, const void * buffer,
return err;
}
lfs_soff_t lfs_file_seek (lfs_t * lfs, lfs_file_t * file, lfs_soff_t off, int whence) {
lfs_soff_t lfs_file_seek(lfs_t *lfs, lfs_file_t *file, lfs_soff_t off, int whence) {
int err = lfs->cfg->lock(lfs->cfg);
if (err) {
return err;
@ -5118,7 +5127,7 @@ lfs_soff_t lfs_file_seek (lfs_t * lfs, lfs_file_t * file, lfs_soff_t off, int wh
return err;
}
int lfs_file_truncate (lfs_t * lfs, lfs_file_t * file, lfs_off_t size) {
int lfs_file_truncate(lfs_t *lfs, lfs_file_t *file, lfs_off_t size) {
int err = lfs->cfg->lock(lfs->cfg);
if (err) {
return err;
@ -5131,7 +5140,7 @@ int lfs_file_truncate (lfs_t * lfs, lfs_file_t * file, lfs_off_t size) {
return err;
}
lfs_soff_t lfs_file_tell (lfs_t * lfs, lfs_file_t * file) {
lfs_soff_t lfs_file_tell(lfs_t *lfs, lfs_file_t *file) {
int err = lfs->cfg->lock(lfs->cfg);
if (err) {
return err;
@ -5144,7 +5153,7 @@ lfs_soff_t lfs_file_tell (lfs_t * lfs, lfs_file_t * file) {
return err;
}
int lfs_file_rewind (lfs_t * lfs, lfs_file_t * file) {
int lfs_file_rewind(lfs_t *lfs, lfs_file_t *file) {
int err = lfs->cfg->lock(lfs->cfg);
if (err) {
return err;
@ -5157,7 +5166,7 @@ int lfs_file_rewind (lfs_t * lfs, lfs_file_t * file) {
return err;
}
lfs_soff_t lfs_file_size (lfs_t * lfs, lfs_file_t * file) {
lfs_soff_t lfs_file_size(lfs_t *lfs, lfs_file_t *file) {
int err = lfs->cfg->lock(lfs->cfg);
if (err) {
return err;
@ -5170,7 +5179,7 @@ lfs_soff_t lfs_file_size (lfs_t * lfs, lfs_file_t * file) {
return err;
}
int lfs_mkdir (lfs_t * lfs, const char * path) {
int lfs_mkdir(lfs_t *lfs, const char *path) {
int err = lfs->cfg->lock(lfs->cfg);
if (err) {
return err;
@ -5183,7 +5192,7 @@ int lfs_mkdir (lfs_t * lfs, const char * path) {
return err;
}
int lfs_dir_open (lfs_t * lfs, lfs_dir_t * dir, const char * path) {
int lfs_dir_open(lfs_t *lfs, lfs_dir_t *dir, const char *path) {
int err = lfs->cfg->lock(lfs->cfg);
if (err) {
return err;
@ -5196,7 +5205,7 @@ int lfs_dir_open (lfs_t * lfs, lfs_dir_t * dir, const char * path) {
return err;
}
int lfs_dir_close (lfs_t * lfs, lfs_dir_t * dir) {
int lfs_dir_close(lfs_t *lfs, lfs_dir_t *dir) {
int err = lfs->cfg->lock(lfs->cfg);
if (err) {
return err;
@ -5209,7 +5218,7 @@ int lfs_dir_close (lfs_t * lfs, lfs_dir_t * dir) {
return err;
}
int lfs_dir_read (lfs_t * lfs, lfs_dir_t * dir, struct lfs_info * info) {
int lfs_dir_read(lfs_t *lfs, lfs_dir_t *dir, struct lfs_info *info) {
int err = lfs->cfg->lock(lfs->cfg);
if (err) {
return err;
@ -5222,7 +5231,7 @@ int lfs_dir_read (lfs_t * lfs, lfs_dir_t * dir, struct lfs_info * info) {
return err;
}
int lfs_dir_seek (lfs_t * lfs, lfs_dir_t * dir, lfs_off_t off) {
int lfs_dir_seek(lfs_t *lfs, lfs_dir_t *dir, lfs_off_t off) {
int err = lfs->cfg->lock(lfs->cfg);
if (err) {
return err;
@ -5235,7 +5244,7 @@ int lfs_dir_seek (lfs_t * lfs, lfs_dir_t * dir, lfs_off_t off) {
return err;
}
lfs_soff_t lfs_dir_tell (lfs_t * lfs, lfs_dir_t * dir) {
lfs_soff_t lfs_dir_tell(lfs_t *lfs, lfs_dir_t *dir) {
int err = lfs->cfg->lock(lfs->cfg);
if (err) {
return err;
@ -5248,7 +5257,7 @@ lfs_soff_t lfs_dir_tell (lfs_t * lfs, lfs_dir_t * dir) {
return err;
}
int lfs_dir_rewind (lfs_t * lfs, lfs_dir_t * dir) {
int lfs_dir_rewind(lfs_t *lfs, lfs_dir_t *dir) {
int err = lfs->cfg->lock(lfs->cfg);
if (err) {
return err;
@ -5261,7 +5270,7 @@ int lfs_dir_rewind (lfs_t * lfs, lfs_dir_t * dir) {
return err;
}
lfs_ssize_t lfs_fs_size (lfs_t * lfs) {
lfs_ssize_t lfs_fs_size(lfs_t *lfs) {
int err = lfs->cfg->lock(lfs->cfg);
if (err) {
return err;
@ -5274,7 +5283,7 @@ lfs_ssize_t lfs_fs_size (lfs_t * lfs) {
return err;
}
int lfs_fs_traverse (lfs_t * lfs, int (* cb)(void *, lfs_block_t), void * data) {
int lfs_fs_traverse(lfs_t *lfs, int (*cb)(void *, lfs_block_t), void *data) {
int err = lfs->cfg->lock(lfs->cfg);
if (err) {
return err;
@ -5289,7 +5298,7 @@ int lfs_fs_traverse (lfs_t * lfs, int (* cb)(void *, lfs_block_t), void * data)
#ifdef LFS_MIGRATE
int lfs_migrate (lfs_t * lfs, const struct lfs_config * cfg) {
int lfs_migrate(lfs_t *lfs, const struct lfs_config *cfg) {
int err = lfs->cfg->lock(lfs->cfg);
if (err) {
return err;
@ -5305,125 +5314,125 @@ int lfs_migrate (lfs_t * lfs, const struct lfs_config * cfg) {
#endif
#else
int lfs_format (lfs_t * lfs, const struct lfs_config * config) {
int lfs_format(lfs_t *lfs, const struct lfs_config *config) {
return lfs_format_raw(lfs, config);
}
int lfs_mount (lfs_t * lfs, const struct lfs_config * config) {
int lfs_mount(lfs_t *lfs, const struct lfs_config *config) {
return lfs_mount_raw(lfs, config);
}
int lfs_unmount (lfs_t * lfs) {
int lfs_unmount(lfs_t *lfs) {
return lfs_unmount_raw(lfs);
}
int lfs_remove (lfs_t * lfs, const char * path) {
int lfs_remove(lfs_t *lfs, const char *path) {
return lfs_remove_raw(lfs, path);
}
int lfs_rename (lfs_t * lfs, const char * oldpath, const char * newpath) {
int lfs_rename(lfs_t *lfs, const char *oldpath, const char *newpath) {
return lfs_rename_raw(lfs, oldpath, newpath);
}
int lfs_stat (lfs_t * lfs, const char * path, struct lfs_info * info) {
int lfs_stat(lfs_t *lfs, const char *path, struct lfs_info *info) {
return lfs_stat_raw(lfs, path, info);
}
lfs_ssize_t lfs_getattr (lfs_t * lfs, const char * path, uint8_t type, void * buffer, lfs_size_t size) {
lfs_ssize_t lfs_getattr(lfs_t *lfs, const char *path, uint8_t type, void *buffer, lfs_size_t size) {
return lfs_getattr_raw(lfs, path, type, buffer, size);
}
int lfs_setattr (lfs_t * lfs, const char * path, uint8_t type, const void * buffer, lfs_size_t size) {
int lfs_setattr(lfs_t *lfs, const char *path, uint8_t type, const void *buffer, lfs_size_t size) {
return lfs_setattr_raw(lfs, path, type, buffer, size);
}
int lfs_removeattr (lfs_t * lfs, const char * path, uint8_t type) {
int lfs_removeattr(lfs_t *lfs, const char *path, uint8_t type) {
return lfs_removeattr_raw(lfs, path, type);
}
int lfs_file_open (lfs_t * lfs, lfs_file_t * file, const char * path, int flags) {
int lfs_file_open(lfs_t *lfs, lfs_file_t *file, const char *path, int flags) {
return lfs_file_open_raw(lfs, file, path, flags);
}
int lfs_file_opencfg_ts(lfs_t *lfs, lfs_file_t *file, const char *path, int flags, const struct lfs_file_config *config) {
int lfs_file_opencfg(lfs_t *lfs, lfs_file_t *file, const char *path, int flags, const struct lfs_file_config *config) {
return lfs_file_opencfg_raw(lfs, file, path, flags, config);
}
int lfs_file_close (lfs_t * lfs, lfs_file_t * file) {
int lfs_file_close(lfs_t *lfs, lfs_file_t *file) {
return lfs_file_close_raw(lfs, file);
}
int lfs_file_sync (lfs_t * lfs, lfs_file_t * file) {
int lfs_file_sync(lfs_t *lfs, lfs_file_t *file) {
return lfs_file_sync_raw(lfs, file);
}
lfs_ssize_t lfs_file_read (lfs_t * lfs, lfs_file_t * file, void * buffer, lfs_size_t size) {
lfs_ssize_t lfs_file_read(lfs_t *lfs, lfs_file_t *file, void *buffer, lfs_size_t size) {
return lfs_file_read_raw(lfs, file, buffer, size);
}
lfs_ssize_t lfs_file_write (lfs_t * lfs, lfs_file_t * file, const void * buffer, lfs_size_t size) {
lfs_ssize_t lfs_file_write(lfs_t *lfs, lfs_file_t *file, const void *buffer, lfs_size_t size) {
return lfs_file_write_raw(lfs, file, buffer, size);
}
lfs_soff_t lfs_file_seek (lfs_t * lfs, lfs_file_t * file, lfs_soff_t off, int whence) {
lfs_soff_t lfs_file_seek(lfs_t *lfs, lfs_file_t *file, lfs_soff_t off, int whence) {
return lfs_file_seek_raw(lfs, file, off, whence);
}
int lfs_file_truncate (lfs_t * lfs, lfs_file_t * file, lfs_off_t size) {
int lfs_file_truncate(lfs_t *lfs, lfs_file_t *file, lfs_off_t size) {
return lfs_file_truncate_raw(lfs, file, size);
}
lfs_soff_t lfs_file_tell (lfs_t * lfs, lfs_file_t * file) {
lfs_soff_t lfs_file_tell(lfs_t *lfs, lfs_file_t *file) {
return lfs_file_tell_raw(lfs, file);
}
int lfs_file_rewind (lfs_t * lfs, lfs_file_t * file) {
int lfs_file_rewind(lfs_t *lfs, lfs_file_t *file) {
return lfs_file_rewind_raw(lfs, file);
}
lfs_soff_t lfs_file_size (lfs_t * lfs, lfs_file_t * file) {
lfs_soff_t lfs_file_size(lfs_t *lfs, lfs_file_t *file) {
return lfs_file_size_raw(lfs, file);
}
int lfs_mkdir (lfs_t * lfs, const char * path) {
int lfs_mkdir(lfs_t *lfs, const char *path) {
return lfs_mkdir_raw(lfs, path);
}
int lfs_dir_open (lfs_t * lfs, lfs_dir_t * dir, const char * path) {
int lfs_dir_open(lfs_t *lfs, lfs_dir_t *dir, const char *path) {
return lfs_dir_open_raw(lfs, dir, path);
}
int lfs_dir_close (lfs_t * lfs, lfs_dir_t * dir) {
int lfs_dir_close(lfs_t *lfs, lfs_dir_t *dir) {
return lfs_dir_close_raw(lfs, dir);
}
int lfs_dir_read (lfs_t * lfs, lfs_dir_t * dir, struct lfs_info * info) {
int lfs_dir_read(lfs_t *lfs, lfs_dir_t *dir, struct lfs_info *info) {
return lfs_dir_read_raw(lfs, dir, info);
}
int lfs_dir_seek (lfs_t * lfs, lfs_dir_t * dir, lfs_off_t off) {
int lfs_dir_seek(lfs_t *lfs, lfs_dir_t *dir, lfs_off_t off) {
return lfs_dir_seek_raw(lfs, dir, off);
}
lfs_soff_t lfs_dir_tell (lfs_t * lfs, lfs_dir_t * dir) {
lfs_soff_t lfs_dir_tell(lfs_t *lfs, lfs_dir_t *dir) {
return lfs_dir_tell_raw(lfs, dir);
}
int lfs_dir_rewind (lfs_t * lfs, lfs_dir_t * dir) {
int lfs_dir_rewind(lfs_t *lfs, lfs_dir_t *dir) {
return lfs_dir_rewind_raw(lfs, dir);
}
lfs_ssize_t lfs_fs_size (lfs_t * lfs) {
lfs_ssize_t lfs_fs_size(lfs_t *lfs) {
return lfs_fs_size_raw(lfs);
}
int lfs_fs_traverse (lfs_t * lfs, int (* cb)(void *, lfs_block_t), void * data) {
int lfs_fs_traverse(lfs_t *lfs, int (*cb)(void *, lfs_block_t), void *data) {
return lfs_fs_traverse_raw(lfs, cb, data);
}
#ifdef LFS_MIGRATE
int lfs_migrate (lfs_t * lfs, const struct lfs_config * cfg) {
int lfs_migrate(lfs_t *lfs, const struct lfs_config *cfg) {
return lfs_migrate_raw(lfs, cfg);
}

31
lfs.h
View File

@ -657,37 +657,6 @@ int lfs_fs_traverse(lfs_t *lfs, int (*cb)(void*, lfs_block_t), void *data);
int lfs_migrate(lfs_t *lfs, const struct lfs_config *cfg);
#endif
int lfs_format_raw(lfs_t *lfs, const struct lfs_config *config);
int lfs_mount_raw(lfs_t *lfs, const struct lfs_config *config);
int lfs_unmount_raw(lfs_t *lfs);
int lfs_remove_raw(lfs_t *lfs, const char *path);
int lfs_rename_raw(lfs_t *lfs, const char *oldpath, const char *newpath);
int lfs_stat_raw(lfs_t *lfs, const char *path, struct lfs_info *info);
lfs_ssize_t lfs_getattr_raw(lfs_t *lfs, const char *path, uint8_t type, void *buffer, lfs_size_t size);
int lfs_setattr_raw(lfs_t *lfs, const char *path, uint8_t type, const void *buffer, lfs_size_t size);
int lfs_removeattr_raw(lfs_t *lfs, const char *path, uint8_t type);
int lfs_file_open_raw(lfs_t *lfs, lfs_file_t *file, const char *path, int flags);
int lfs_file_opencfg_raw(lfs_t *lfs, lfs_file_t *file, const char *path, int flags, const struct lfs_file_config *config);
int lfs_file_close_raw(lfs_t *lfs, lfs_file_t *file);
int lfs_file_sync_raw(lfs_t *lfs, lfs_file_t *file);
lfs_ssize_t lfs_file_read_raw(lfs_t *lfs, lfs_file_t *file, void *buffer, lfs_size_t size);
lfs_ssize_t lfs_file_write_raw(lfs_t *lfs, lfs_file_t *file, const void *buffer, lfs_size_t size);
lfs_soff_t lfs_file_seek_raw(lfs_t *lfs, lfs_file_t *file, lfs_soff_t off, int whence);
int lfs_file_truncate_raw(lfs_t *lfs, lfs_file_t *file, lfs_off_t size);
lfs_soff_t lfs_file_tell_raw(lfs_t *lfs, lfs_file_t *file);
int lfs_file_rewind_raw(lfs_t *lfs, lfs_file_t *file);
lfs_soff_t lfs_file_size_raw(lfs_t *lfs, lfs_file_t *file);
int lfs_mkdir_raw(lfs_t *lfs, const char *path);
int lfs_dir_open_raw(lfs_t *lfs, lfs_dir_t *dir, const char *path);
int lfs_dir_close_raw(lfs_t *lfs, lfs_dir_t *dir);
int lfs_dir_read_raw(lfs_t *lfs, lfs_dir_t *dir, struct lfs_info *info);
int lfs_dir_seek_raw(lfs_t *lfs, lfs_dir_t *dir, lfs_off_t off);
lfs_soff_t lfs_dir_tell_raw(lfs_t *lfs, lfs_dir_t *dir);
int lfs_dir_rewind_raw(lfs_t *lfs, lfs_dir_t *dir);
lfs_ssize_t lfs_fs_size_raw(lfs_t *lfs);
int lfs_fs_traverse_raw(lfs_t *lfs, int (*cb)(void*, lfs_block_t), void *data);
int lfs_migrate_raw(lfs_t *lfs, const struct lfs_config *cfg);
#ifdef __cplusplus
} /* extern "C" */
#endif