fs/littlefs: Make all struct and enum names conform to the NuttX coding standard.

This commit is contained in:
Gregory Nutt 2019-01-10 06:37:53 -06:00
parent a76773acf1
commit 444ff759cd
3 changed files with 68 additions and 68 deletions

View File

@ -48,11 +48,11 @@
* Included Files
****************************************************************************/
#include <inttypes.h>
#include "lfs.h"
#include "lfs_util.h"
#include <inttypes.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@ -61,7 +61,7 @@
* Private Types
****************************************************************************/
struct lfs_region
struct lfs_region_s
{
lfs_off_t oldoff;
lfs_size_t oldlen;
@ -473,7 +473,7 @@ static void lfs_alloc_ack(FAR lfs_t *lfs)
/* Endian swapping functions */
static void lfs_dir_fromle32(FAR struct lfs_disk_dir *d)
static void lfs_dir_fromle32(FAR struct lfs_disk_dir_s *d)
{
d->rev = lfs_fromle32(d->rev);
d->size = lfs_fromle32(d->size);
@ -481,7 +481,7 @@ static void lfs_dir_fromle32(FAR struct lfs_disk_dir *d)
d->tail[1] = lfs_fromle32(d->tail[1]);
}
static void lfs_dir_tole32(FAR struct lfs_disk_dir *d)
static void lfs_dir_tole32(FAR struct lfs_disk_dir_s *d)
{
d->rev = lfs_tole32(d->rev);
d->size = lfs_tole32(d->size);
@ -489,19 +489,19 @@ static void lfs_dir_tole32(FAR struct lfs_disk_dir *d)
d->tail[1] = lfs_tole32(d->tail[1]);
}
static void lfs_entry_fromle32(FAR struct lfs_disk_entry *d)
static void lfs_entry_fromle32(FAR struct lfs_disk_entry_s *d)
{
d->u.dir[0] = lfs_fromle32(d->u.dir[0]);
d->u.dir[1] = lfs_fromle32(d->u.dir[1]);
}
static void lfs_entry_tole32(FAR struct lfs_disk_entry *d)
static void lfs_entry_tole32(FAR struct lfs_disk_entry_s *d)
{
d->u.dir[0] = lfs_tole32(d->u.dir[0]);
d->u.dir[1] = lfs_tole32(d->u.dir[1]);
}
static void lfs_superblock_fromle32(FAR struct lfs_disk_superblock *d)
static void lfs_superblock_fromle32(FAR struct lfs_disk_superblock_s *d)
{
d->root[0] = lfs_fromle32(d->root[0]);
d->root[1] = lfs_fromle32(d->root[1]);
@ -510,7 +510,7 @@ static void lfs_superblock_fromle32(FAR struct lfs_disk_superblock *d)
d->version = lfs_fromle32(d->version);
}
static void lfs_superblock_tole32(FAR struct lfs_disk_superblock *d)
static void lfs_superblock_tole32(FAR struct lfs_disk_superblock_s *d)
{
d->root[0] = lfs_tole32(d->root[0]);
d->root[1] = lfs_tole32(d->root[1]);
@ -611,7 +611,7 @@ static int lfs_dir_fetch(FAR lfs_t *lfs, FAR lfs_dir_t *dir,
for (i = 0; i < 2; i++)
{
struct lfs_disk_dir test;
struct lfs_disk_dir_s test;
uint32_t crc;
int err = lfs_bd_read(lfs, tpair[i], 0, &test, sizeof(test));
lfs_dir_fromle32(&test);
@ -677,7 +677,7 @@ static int lfs_dir_fetch(FAR lfs_t *lfs, FAR lfs_dir_t *dir,
}
static int lfs_dir_commit(FAR lfs_t *lfs, FAR lfs_dir_t *dir,
FAR const struct lfs_region *regions, int count)
FAR const struct lfs_region_s *regions, int count)
{
FAR lfs_dir_t *d;
lfs_block_t oldpair[2];
@ -880,7 +880,7 @@ static int lfs_dir_update(FAR lfs_t *lfs, FAR lfs_dir_t *dir,
lfs_entry_tole32(&entry->d);
err = lfs_dir_commit(
lfs, dir,
(struct lfs_region[])
(FAR struct lfs_region_s[])
{
{
entry->off, sizeof(entry->d), &entry->d, sizeof(entry->d)
@ -908,7 +908,7 @@ static int lfs_dir_append(FAR lfs_t *lfs, FAR lfs_dir_t *dir,
lfs_entry_tole32(&entry->d);
int err =
lfs_dir_commit(lfs, dir,
(struct lfs_region[])
(FAR struct lfs_region_s[])
{
{
entry->off, 0, &entry->d, sizeof(entry->d)
@ -938,7 +938,7 @@ static int lfs_dir_append(FAR lfs_t *lfs, FAR lfs_dir_t *dir,
entry->off = dir->d.size - 4;
lfs_entry_tole32(&entry->d);
err = lfs_dir_commit(lfs, dir,
(struct lfs_region[])
(FAR struct lfs_region_s[])
{
{
entry->off, 0, &entry->d, sizeof(entry->d)
@ -999,7 +999,7 @@ static int lfs_dir_remove(FAR lfs_t *lfs, FAR lfs_dir_t *dir,
/* shift out the entry */
err = lfs_dir_commit(lfs, dir,
(struct lfs_region[])
(FAR struct lfs_region_s[])
{
{
entry->off, lfs_entry_size(entry), NULL, 0
@ -1633,7 +1633,7 @@ static void lfs_deinit(FAR lfs_t *lfs)
}
}
static int lfs_init(FAR lfs_t *lfs, FAR const struct lfs_config *cfg)
static int lfs_init(FAR lfs_t *lfs, FAR const struct lfs_config_s *cfg)
{
lfs->cfg = cfg;
@ -2047,7 +2047,7 @@ int lfs_dir_close(FAR lfs_t *lfs, FAR lfs_dir_t *dir)
}
int lfs_dir_read(FAR lfs_t *lfs, FAR lfs_dir_t *dir,
FAR struct lfs_info *info)
FAR struct lfs_info_s *info)
{
lfs_entry_t entry;
@ -2183,7 +2183,7 @@ int lfs_dir_rewind(FAR lfs_t *lfs, FAR lfs_dir_t *dir)
int lfs_file_opencfg(FAR lfs_t *lfs, FAR lfs_file_t *file,
FAR const char *path, int flags,
FAR const struct lfs_file_config *cfg)
FAR const struct lfs_file_config_s *cfg)
{
lfs_dir_t cwd;
lfs_entry_t entry;
@ -2740,7 +2740,7 @@ lfs_soff_t lfs_file_size(FAR lfs_t *lfs, FAR lfs_file_t *file)
/* General fs operations */
int lfs_stat(FAR lfs_t *lfs, FAR const char *path,
FAR struct lfs_info *info)
FAR struct lfs_info_s *info)
{
lfs_dir_t cwd;
lfs_entry_t entry;
@ -2992,7 +2992,7 @@ int lfs_rename(FAR lfs_t *lfs, FAR const char *oldpath,
return 0;
}
int lfs_format(FAR lfs_t *lfs, FAR const struct lfs_config *cfg)
int lfs_format(FAR lfs_t *lfs, FAR const struct lfs_config_s *cfg)
{
lfs_superblock_t superblock;
bool valid;
@ -3071,7 +3071,7 @@ int lfs_format(FAR lfs_t *lfs, FAR const struct lfs_config *cfg)
{
err = lfs_dir_commit(
lfs, &superdir,
(struct lfs_region[])
(struct lfs_region_s[])
{
{
sizeof(superdir.d), sizeof(superblock.d),
@ -3110,7 +3110,7 @@ cleanup:
return err;
}
int lfs_mount(FAR lfs_t *lfs, FAR const struct lfs_config *cfg)
int lfs_mount(FAR lfs_t *lfs, FAR const struct lfs_config_s *cfg)
{
int err = 0;
if (true)

View File

@ -106,7 +106,7 @@ typedef uint32_t lfs_block_t;
* valid positive return values
*/
enum lfs_error
enum lfs_error_e
{
LFS_ERR_OK = 0, /* No error */
LFS_ERR_IO = -5, /* Error during device operation */
@ -125,7 +125,7 @@ enum lfs_error
/* File types */
enum lfs_type
enum lfs_type_e
{
LFS_TYPE_REG = 0x11,
LFS_TYPE_DIR = 0x22,
@ -134,7 +134,7 @@ enum lfs_type
/* File open flags */
enum lfs_open_flags
enum lfs_open_flags_e
{
/* open flags */
@ -156,7 +156,7 @@ enum lfs_open_flags
/* File seek flags */
enum lfs_whence_flags
enum lfs_whence_flags_e
{
LFS_SEEK_SET = 0, /* Seek relative to an absolute position */
LFS_SEEK_CUR = 1, /* Seek relative to the current file position */
@ -165,7 +165,7 @@ enum lfs_whence_flags
/* Configuration provided during initialization of the littlefs */
struct lfs_config
struct lfs_config_s
{
/* Opaque user provided context that can be used to pass
* information to the block device operations
@ -177,7 +177,7 @@ struct lfs_config
* to the user.
*/
CODE int (*read)(const struct lfs_config *c, lfs_block_t block,
CODE int (*read)(FAR const struct lfs_config_s *c, lfs_block_t block,
lfs_off_t off, FAR void *buffer, lfs_size_t size);
/* Program a region in a block. The block must have previously
@ -185,7 +185,7 @@ struct lfs_config
* May return LFS_ERR_CORRUPT if the block should be considered bad.
*/
CODE int (*prog)(FAR const struct lfs_config *c, lfs_block_t block,
CODE int (*prog)(FAR const struct lfs_config_s *c, lfs_block_t block,
lfs_off_t off, const void *buffer, lfs_size_t size);
/* Erase a block. A block must be erased before being programmed.
@ -194,13 +194,13 @@ struct lfs_config
* May return LFS_ERR_CORRUPT if the block should be considered bad.
*/
CODE int (*erase)(FAR const struct lfs_config *c, lfs_block_t block);
CODE int (*erase)(FAR const struct lfs_config_s *c, lfs_block_t block);
/* Sync the state of the underlying block device. Negative error codes
* are propagated to the user.
*/
CODE int (*sync)(FAR const struct lfs_config *c);
CODE int (*sync)(FAR const struct lfs_config_s *c);
/* Minimum size of a block read. This determines the size of read buffers.
* This may be larger than the physical read size to improve performance
@ -260,7 +260,7 @@ struct lfs_config
/* Optional configuration provided during lfs_file_opencfg */
struct lfs_file_config
struct lfs_file_config_s
{
/* Optional, statically allocated buffer for files. Must be program sized.
* If NULL, malloc will be used by default.
@ -271,7 +271,7 @@ struct lfs_file_config
/* File info structure */
struct lfs_info
struct lfs_info_s
{
/* Type of the file, either LFS_TYPE_REG or LFS_TYPE_DIR */
@ -289,11 +289,11 @@ struct lfs_info
/* littlefs data structures */
typedef struct lfs_entry
typedef struct lfs_entry_s
{
lfs_off_t off;
struct lfs_disk_entry
struct lfs_disk_entry_s
{
uint8_t type;
uint8_t elen;
@ -311,23 +311,23 @@ typedef struct lfs_entry
} d;
} lfs_entry_t;
typedef struct lfs_cache
typedef struct lfs_cache_s
{
lfs_block_t block;
lfs_off_t off;
FAR uint8_t *buffer;
} lfs_cache_t;
typedef struct lfs_file
typedef struct lfs_file_s
{
struct lfs_file *next;
FAR struct lfs_file_s *next;
lfs_block_t pair[2];
lfs_off_t poff;
lfs_block_t head;
lfs_size_t size;
FAR const struct lfs_file_config *cfg;
FAR const struct lfs_file_config_s *cfg;
uint32_t flags;
lfs_off_t pos;
lfs_block_t block;
@ -335,16 +335,16 @@ typedef struct lfs_file
lfs_cache_t cache;
} lfs_file_t;
typedef struct lfs_dir
typedef struct lfs_dir_s
{
struct lfs_dir *next;
FAR struct lfs_dir_s *next;
lfs_block_t pair[2];
lfs_off_t off;
lfs_block_t head[2];
lfs_off_t pos;
struct lfs_disk_dir
struct lfs_disk_dir_s
{
uint32_t rev;
lfs_size_t size;
@ -352,11 +352,11 @@ typedef struct lfs_dir
} d;
} lfs_dir_t;
typedef struct lfs_superblock
typedef struct lfs_superblock_s
{
lfs_off_t off;
struct lfs_disk_superblock
struct lfs_disk_superblock_s
{
uint8_t type;
uint8_t elen;
@ -370,7 +370,7 @@ typedef struct lfs_superblock
} d;
} lfs_superblock_t;
typedef struct lfs_free
typedef struct lfs_free_s
{
lfs_block_t off;
lfs_block_t size;
@ -381,9 +381,9 @@ typedef struct lfs_free
/* The littlefs type */
typedef struct lfs
typedef struct lfs_s
{
FAR const struct lfs_config *cfg;
FAR const struct lfs_config_s *cfg;
lfs_block_t root[2];
FAR lfs_file_t *files;
@ -421,7 +421,7 @@ extern "C"
* Returns a negative error code on failure.
*/
int lfs_format(FAR lfs_t *lfs, FAR const struct lfs_config *config);
int lfs_format(FAR lfs_t *lfs, FAR const struct lfs_config_s *config);
/* Mounts a littlefs
*
@ -433,7 +433,7 @@ int lfs_format(FAR lfs_t *lfs, FAR const struct lfs_config *config);
* Returns a negative error code on failure.
*/
int lfs_mount(FAR lfs_t *lfs, FAR const struct lfs_config *config);
int lfs_mount(FAR lfs_t *lfs, FAR const struct lfs_config_s *config);
/* Unmounts a littlefs
*
@ -471,7 +471,7 @@ int lfs_rename(FAR lfs_t *lfs, FAR const char *oldpath, FAR
*/
int lfs_stat(FAR lfs_t *lfs, FAR const char *path,
FAR struct lfs_info *info);
FAR struct lfs_info_s *info);
/* File operations */
@ -500,7 +500,7 @@ int lfs_file_open(FAR lfs_t *lfs, FAR lfs_file_t *file,
int lfs_file_opencfg(FAR lfs_t *lfs, FAR lfs_file_t *file,
FAR const char *path, int flags,
FAR const struct lfs_file_config *config);
FAR const struct lfs_file_config_s *config);
/* Close a file
*
@ -612,7 +612,7 @@ int lfs_dir_close(FAR lfs_t *lfs, FAR lfs_dir_t *dir);
*/
int lfs_dir_read(FAR lfs_t *lfs, FAR lfs_dir_t *dir,
FAR struct lfs_info *info);
FAR struct lfs_info_s *info);
/* Change the position of the directory
*

View File

@ -50,35 +50,35 @@
#include <nuttx/config.h>
#include <sys/stat.h>
#include <sys/statfs.h>
#include <assert.h>
#include <debug.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <nuttx/kmalloc.h>
#include <queue.h>
#include <semaphore.h>
#include <stdint.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/statfs.h>
#include "lfs.h"
#include "lfs_util.h"
#include <nuttx/kmalloc.h>
#include <nuttx/fs/dirent.h>
#include <nuttx/fs/fs.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/kmalloc.h>
#include <nuttx/mtd/mtd.h>
#include "lfs.h"
#include "lfs_util.h"
/****************************************************************************
* Private Types
****************************************************************************/
struct littefs_s
{
struct lfs lfs;
struct lfs_config cfg;
struct lfs_s lfs;
struct lfs_config_s cfg;
FAR struct mtd_dev_s *mtd;
struct mtd_geometry_s geo;
sem_t fs_sem;
@ -92,7 +92,7 @@ static void littlefs_semgive(FAR struct littefs_s *fs);
static void littlefs_semtake(FAR struct littefs_s *fs);
static void littlefs_tostat(FAR struct stat *st,
FAR struct lfs_info *info);
FAR struct lfs_info_s *info);
static int littlefs_open(FAR struct file *filep,
FAR const char *relpath, int oflags,
@ -308,7 +308,7 @@ static int lfs_result_to_vfs(int result)
return status;
}
static int _lfs_flash_read(FAR const struct lfs_config *cfg,
static int _lfs_flash_read(FAR const struct lfs_config_s *cfg,
lfs_block_t block, lfs_off_t off,
FAR void *buffer, lfs_size_t size)
{
@ -326,7 +326,7 @@ static int _lfs_flash_read(FAR const struct lfs_config *cfg,
return LFS_ERR_OK;
}
static int _lfs_flash_prog(FAR const struct lfs_config *cfg,
static int _lfs_flash_prog(FAR const struct lfs_config_s *cfg,
lfs_block_t block, lfs_off_t off,
FAR const void *buffer, lfs_size_t size)
{
@ -344,7 +344,7 @@ static int _lfs_flash_prog(FAR const struct lfs_config *cfg,
return LFS_ERR_OK;
}
static int _lfs_flash_erase(FAR const struct lfs_config *cfg,
static int _lfs_flash_erase(FAR const struct lfs_config_s *cfg,
lfs_block_t block)
{
FAR struct mtd_dev_s *mtd;
@ -361,7 +361,7 @@ static int _lfs_flash_erase(FAR const struct lfs_config *cfg,
return LFS_ERR_OK;
}
static int _lfs_flash_sync(FAR const struct lfs_config *cfg)
static int _lfs_flash_sync(FAR const struct lfs_config_s *cfg)
{
return LFS_ERR_OK;
}
@ -504,7 +504,7 @@ static int littlefs_readdir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir)
{
FAR struct littefs_s *fs = mountpt->i_private;
struct lfs_info info;
struct lfs_info_s info;
int ret = OK;
DEBUGASSERT(mountpt != NULL && mountpt->i_private != NULL);
@ -866,7 +866,7 @@ static int littlefs_stat(FAR struct inode *mountpt, FAR const char *relpath,
FAR struct stat *buf)
{
FAR struct littefs_s *fs = mountpt->i_private;
struct lfs_info info;
struct lfs_info_s info;
int ret = OK;
finfo("littlefs_stat\n");
@ -890,7 +890,7 @@ breakout:
return lfs_result_to_vfs(ret);
}
static void littlefs_tostat(struct stat *st, struct lfs_info *info)
static void littlefs_tostat(struct stat *st, struct lfs_info_s *info)
{
memset(st, 0, sizeof(struct stat));
st->st_size = info->size;