subsys: fs: Add Virtual File system Switch (VFS) support

Add support for Virtual File system Switch (VFS) by
introducing mount point concept to Zephyr. This allows
the applications to mount multiple file systems at
different mount points (ex: "/fatfs" and "/nffs"). The
mount point structure contains all the necessary info
required to instantiate, mount and operate on file system.

Decouple applications from directly accessing individual
file systems API's or internal functions by introducing
file system registration mechanism in VFS.

Move the file system defination and mount responsibility
to application so that application can decide which file system
to use and where to mount.

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
This commit is contained in:
Ramakrishna Pallala 2018-02-22 13:32:57 +05:30 committed by Anas Nashif
commit 25302b1980
8 changed files with 937 additions and 203 deletions

View file

@ -1,31 +0,0 @@
/*
* Copyright (c) 2016 Intel Corporation.
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _FAT_FS_H_
#define _FAT_FS_H_
#include <sys/types.h>
#include <ff.h>
#ifdef __cplusplus
extern "C" {
#endif
FS_FILE_DEFINE(FIL fp);
FS_DIR_DEFINE(DIR dp);
#define MAX_FILE_NAME 12 /* Uses 8.3 SFN */
static inline off_t fs_tell(struct _fs_file_object *zfp)
{
return f_tell(&zfp->fp);
}
#ifdef __cplusplus
}
#endif
#endif /* _FAT_FS_H_ */

View file

@ -7,46 +7,64 @@
#ifndef _FS_INTERFACE_H_
#define _FS_INTERFACE_H_
#ifdef CONFIG_FAT_FILESYSTEM_ELM
#include <ff.h>
#endif
#ifdef CONFIG_FILE_SYSTEM_NFFS
#include <nffs/nffs.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*
* @brief Macro to define _zfile_object structure
*
* This structure contains information about the open files. This
* structure will be passed to the api functions as an opaque
* pointer.
*
* @param _file_object File structure used by underlying file system
*/
#define FS_FILE_DEFINE(_file_object) \
struct _fs_file_object { \
_file_object; \
}
/*
* @brief Macro to define _zdir_object structure
*
* This structure contains information about the open directories. This
* structure will be passed to the directory api functions as an opaque
* pointer.
*
* @param _dir_object Directory structure used by underlying file system
*/
#define FS_DIR_DEFINE(_dir_object) \
struct _fs_dir_object { \
_dir_object; \
}
#ifdef CONFIG_FAT_FILESYSTEM_ELM
#include <fs/fat_fs.h>
#elif CONFIG_FILE_SYSTEM_NFFS
#include <fs/nffs_fs.h>
#ifdef CONFIG_FILE_SYSTEM_NFFS
#define MAX_FILE_NAME 256
#else /* FAT_FS */
#define MAX_FILE_NAME 12 /* Uses 8.3 SFN */
#endif
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 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
};
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 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
};
const struct fs_mount_t *mp;
};
#ifdef __cplusplus
}
#endif

View file

@ -1,26 +0,0 @@
/*
* Copyright (c) 2017 Codecoup
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _NFFS_FS_H_
#define _NFFS_FS_H_
#include <sys/types.h>
#include <nffs/nffs.h>
#ifdef __cplusplus
extern "C" {
#endif
FS_FILE_DEFINE(struct nffs_file *fp);
FS_DIR_DEFINE(struct nffs_dir *dp);
#define MAX_FILE_NAME 256
#ifdef __cplusplus
}
#endif
#endif /* _NFFS_FS_H_ */