fs: make file system description const

There's no reason the table of pointers to file system functions needs
to be mutable at runtime.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
This commit is contained in:
Peter A. Bigot 2020-06-01 11:36:52 -05:00 committed by Carles Cufí
commit 353336d632
5 changed files with 10 additions and 10 deletions

View file

@ -16,9 +16,9 @@ pulled out through a file system registration API.
.. code-block:: c .. code-block:: c
int fs_register(enum fs_type type, struct fs_file_system_t *fs); int fs_register(enum fs_type type, const struct fs_file_system_t *fs);
int fs_unregister(enum fs_type type, struct fs_file_system_t *fs); int fs_unregister(enum fs_type type, const struct fs_file_system_t *fs);
Zephyr RTOS supports multiple instances of a file system by making use of Zephyr RTOS supports multiple instances of a file system by making use of
the mount point as the disk volume name, which is used by the file system library the mount point as the disk volume name, which is used by the file system library

View file

@ -494,7 +494,7 @@ int fs_statvfs(const char *path, struct fs_statvfs *stat);
* @retval 0 Success * @retval 0 Success
* @retval -ERRNO errno code if error * @retval -ERRNO errno code if error
*/ */
int fs_register(enum fs_type type, struct fs_file_system_t *fs); int fs_register(enum fs_type type, const struct fs_file_system_t *fs);
/** /**
* @brief Unregister a file system * @brief Unregister a file system
@ -507,7 +507,7 @@ int fs_register(enum fs_type type, struct fs_file_system_t *fs);
* @retval 0 Success * @retval 0 Success
* @retval -ERRNO errno code if error * @retval -ERRNO errno code if error
*/ */
int fs_unregister(enum fs_type type, struct fs_file_system_t *fs); int fs_unregister(enum fs_type type, const struct fs_file_system_t *fs);
/** /**
* @} * @}

View file

@ -407,7 +407,7 @@ static int fatfs_unmount(struct fs_mount_t *mountp)
} }
/* File system interface */ /* File system interface */
static struct fs_file_system_t fatfs_fs = { static const struct fs_file_system_t fatfs_fs = {
.open = fatfs_open, .open = fatfs_open,
.close = fatfs_close, .close = fatfs_close,
.read = fatfs_read, .read = fatfs_read,

View file

@ -24,7 +24,7 @@ static sys_dlist_t fs_mnt_list;
static struct k_mutex mutex; static struct k_mutex mutex;
/* file system map table */ /* file system map table */
static struct fs_file_system_t *fs_map[FS_TYPE_END]; static const struct fs_file_system_t *fs_map[FS_TYPE_END];
static int fs_get_mnt_point(struct fs_mount_t **mnt_pntp, static int fs_get_mnt_point(struct fs_mount_t **mnt_pntp,
const char *name, size_t *match_len) const char *name, size_t *match_len)
@ -526,7 +526,7 @@ int fs_statvfs(const char *abs_path, struct fs_statvfs *stat)
int fs_mount(struct fs_mount_t *mp) int fs_mount(struct fs_mount_t *mp)
{ {
struct fs_mount_t *itr; struct fs_mount_t *itr;
struct fs_file_system_t *fs; const struct fs_file_system_t *fs;
sys_dnode_t *node; sys_dnode_t *node;
int rc = -EINVAL; int rc = -EINVAL;
@ -664,7 +664,7 @@ int fs_readmount(int *number, const char **name)
} }
/* Register File system */ /* Register File system */
int fs_register(enum fs_type type, struct fs_file_system_t *fs) int fs_register(enum fs_type type, const struct fs_file_system_t *fs)
{ {
int rc = 0; int rc = 0;
@ -682,7 +682,7 @@ reg_err:
} }
/* Unregister File system */ /* Unregister File system */
int fs_unregister(enum fs_type type, struct fs_file_system_t *fs) int fs_unregister(enum fs_type type, const struct fs_file_system_t *fs)
{ {
int rc = 0; int rc = 0;

View file

@ -722,7 +722,7 @@ static int littlefs_unmount(struct fs_mount_t *mountp)
} }
/* File system interface */ /* File system interface */
static struct fs_file_system_t littlefs_fs = { static const struct fs_file_system_t littlefs_fs = {
.open = littlefs_open, .open = littlefs_open,
.close = littlefs_close, .close = littlefs_close,
.read = littlefs_read, .read = littlefs_read,