diff options
| author | Bernard Xiong <[email protected]> | 2023-04-04 15:02:56 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-04-04 15:02:56 +0800 |
| commit | 23955edf53422c20127ef0138b889016a1ba2341 (patch) | |
| tree | c9035207dc66d1df690308c7cac9058fc6fc09b5 /components/dfs/include | |
| parent | accab17fa5eafc800c4ba464a0f6fcc1d1e008eb (diff) | |
[DFS] add Kconfig for dfs-v2.0 (#7156)
* [DFS] add Kconfig for dfs-v2.0
* [DFS] Optimize the SConscript.
* [dfs] move old dfs to dfs/dfs_v1
Diffstat (limited to 'components/dfs/include')
| -rw-r--r-- | components/dfs/include/dfs.h | 117 | ||||
| -rw-r--r-- | components/dfs/include/dfs_file.h | 104 | ||||
| -rw-r--r-- | components/dfs/include/dfs_fs.h | 102 | ||||
| -rw-r--r-- | components/dfs/include/dfs_private.h | 28 |
4 files changed, 0 insertions, 351 deletions
diff --git a/components/dfs/include/dfs.h b/components/dfs/include/dfs.h deleted file mode 100644 index b2575fbf4d..0000000000 --- a/components/dfs/include/dfs.h +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2006-2021, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2005-02-22 Bernard The first version. - */ - -#ifndef __DFS_H__ -#define __DFS_H__ - -#include <stdio.h> -#include <stdint.h> -#include <stdlib.h> -#include <string.h> -#include <dirent.h> -#include <fcntl.h> -#include <sys/stat.h> -#include <sys/statfs.h> -#include <sys/time.h> -#include <rtdevice.h> - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef DFS_FILESYSTEMS_MAX -#define DFS_FILESYSTEMS_MAX 4 -#endif - -#ifndef DFS_FD_MAX -#define DFS_FD_MAX 16 -#endif - -/* - * skip stdin/stdout/stderr normally - */ -#ifndef DFS_STDIO_OFFSET -#define DFS_STDIO_OFFSET 3 -#endif - -#ifndef DFS_PATH_MAX -#define DFS_PATH_MAX DIRENT_NAME_MAX -#endif - -#ifndef SECTOR_SIZE -#define SECTOR_SIZE 512 -#endif - -#ifndef DFS_FILESYSTEM_TYPES_MAX -#define DFS_FILESYSTEM_TYPES_MAX 2 -#endif - -#define DFS_FS_FLAG_DEFAULT 0x00 /* default flag */ -#define DFS_FS_FLAG_FULLPATH 0x01 /* set full path to underlaying file system */ - -/* File types */ -#define FT_REGULAR 0 /* regular file */ -#define FT_SOCKET 1 /* socket file */ -#define FT_DIRECTORY 2 /* directory */ -#define FT_USER 3 /* user defined */ -#define FT_DEVICE 4 /* device */ - -/* File flags */ -#define DFS_F_OPEN 0x01000000 -#define DFS_F_DIRECTORY 0x02000000 -#define DFS_F_EOF 0x04000000 -#define DFS_F_ERR 0x08000000 - -struct dfs_fdtable -{ - uint32_t maxfd; - struct dfs_fd **fds; -}; - -/* Initialization of dfs */ -int dfs_init(void); - -char *dfs_normalize_path(const char *directory, const char *filename); -const char *dfs_subdir(const char *directory, const char *filename); - -int fd_is_open(const char *pathname); -struct dfs_fdtable *dfs_fdtable_get(void); - -void dfs_lock(void); -void dfs_unlock(void); - -void dfs_fd_lock(void); -void dfs_fd_unlock(void); - -void dfs_fm_lock(void); -void dfs_fm_unlock(void); - -#ifdef DFS_USING_POSIX -/* FD APIs */ -int fdt_fd_new(struct dfs_fdtable *fdt); -struct dfs_fd *fdt_fd_get(struct dfs_fdtable* fdt, int fd); -void fdt_fd_release(struct dfs_fdtable* fdt, int fd); -int fd_new(void); -int fd_associate(struct dfs_fdtable *fdt, int fd, struct dfs_fd *file); -struct dfs_fd *fd_get(int fd); -int fd_get_fd_index(struct dfs_fd *file); -void fd_release(int fd); - -void fd_init(struct dfs_fd *fd); - -struct dfs_fdtable *dfs_fdtable_get(void); -struct dfs_fdtable *dfs_fdtable_get_global(void); -#endif /* DFS_USING_POSIX */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/components/dfs/include/dfs_file.h b/components/dfs/include/dfs_file.h deleted file mode 100644 index 7258127331..0000000000 --- a/components/dfs/include/dfs_file.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2006-2021, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2005-01-26 Bernard The first version. - */ - -#ifndef __DFS_FILE_H__ -#define __DFS_FILE_H__ - -#include <dfs.h> -#include <dfs_fs.h> - -#ifdef __cplusplus -extern "C" { -#endif - -struct rt_pollreq; - -struct dfs_file_ops -{ - int (*open) (struct dfs_fd *fd); - int (*close) (struct dfs_fd *fd); - int (*ioctl) (struct dfs_fd *fd, int cmd, void *args); - int (*read) (struct dfs_fd *fd, void *buf, size_t count); - int (*write) (struct dfs_fd *fd, const void *buf, size_t count); - int (*flush) (struct dfs_fd *fd); - int (*lseek) (struct dfs_fd *fd, off_t offset); - int (*getdents) (struct dfs_fd *fd, struct dirent *dirp, uint32_t count); - - int (*poll) (struct dfs_fd *fd, struct rt_pollreq *req); -}; - -/* file descriptor */ -#define DFS_FD_MAGIC 0xfdfd - -struct dfs_fnode -{ - uint16_t type; /* Type (regular or socket) */ - - char *path; /* Name (below mount point) */ - char *fullpath; /* Full path is hash key */ - int ref_count; /* Descriptor reference count */ - rt_list_t list; /* The node of vnode hash table */ - - struct dfs_filesystem *fs; - const struct dfs_file_ops *fops; - uint32_t flags; /* self flags, is dir etc.. */ - - size_t size; /* Size in bytes */ - void *data; /* Specific file system data */ -}; - -struct dfs_fd -{ - uint16_t magic; /* file descriptor magic number */ - uint32_t flags; /* Descriptor flags */ - int ref_count; /* Descriptor reference count */ - off_t pos; /* Current file position */ - struct dfs_fnode *vnode; /* file node struct */ - void *data; /* Specific fd data */ -}; - -struct dfs_mmap2_args -{ - void *addr; - size_t length; - int prot; - int flags; - off_t pgoffset; - - void *ret; -}; - -void dfs_fnode_mgr_init(void); -int dfs_file_is_open(const char *pathname); -int dfs_file_open(struct dfs_fd *fd, const char *path, int flags); -int dfs_file_close(struct dfs_fd *fd); -int dfs_file_ioctl(struct dfs_fd *fd, int cmd, void *args); -int dfs_file_read(struct dfs_fd *fd, void *buf, size_t len); -int dfs_file_getdents(struct dfs_fd *fd, struct dirent *dirp, size_t nbytes); -int dfs_file_unlink(const char *path); -int dfs_file_write(struct dfs_fd *fd, const void *buf, size_t len); -int dfs_file_flush(struct dfs_fd *fd); -int dfs_file_lseek(struct dfs_fd *fd, off_t offset); - -int dfs_file_stat(const char *path, struct stat *buf); -int dfs_file_rename(const char *oldpath, const char *newpath); -int dfs_file_ftruncate(struct dfs_fd *fd, off_t length); -int dfs_file_mmap2(struct dfs_fd *fd, struct dfs_mmap2_args *mmap2); - -/* 0x5254 is just a magic number to make these relatively unique ("RT") */ -#define RT_FIOFTRUNCATE 0x52540000U -#define RT_FIOGETADDR 0x52540001U -#define RT_FIOMMAP2 0x52540002U - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/components/dfs/include/dfs_fs.h b/components/dfs/include/dfs_fs.h deleted file mode 100644 index 985017afe0..0000000000 --- a/components/dfs/include/dfs_fs.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2006-2021, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2005-02-22 Bernard The first version. - */ - -#ifndef __DFS_FS_H__ -#define __DFS_FS_H__ - -#include <dfs.h> -#include <sys/types.h> -#include <sys/errno.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/* Pre-declaration */ -struct dfs_filesystem; -struct dfs_fd; - -/* File system operations */ -struct dfs_filesystem_ops -{ - char *name; - uint32_t flags; /* flags for file system operations */ - - /* operations for file */ - const struct dfs_file_ops *fops; - - /* mount and unmount file system */ - int (*mount) (struct dfs_filesystem *fs, unsigned long rwflag, const void *data); - int (*unmount) (struct dfs_filesystem *fs); - - /* make a file system */ - int (*mkfs) (rt_device_t dev_id, const char *fs_name); - int (*statfs) (struct dfs_filesystem *fs, struct statfs *buf); - - int (*unlink) (struct dfs_filesystem *fs, const char *pathname); - int (*stat) (struct dfs_filesystem *fs, const char *filename, struct stat *buf); - int (*rename) (struct dfs_filesystem *fs, const char *oldpath, const char *newpath); -}; - -/* Mounted file system */ -struct dfs_filesystem -{ - rt_device_t dev_id; /* Attached device */ - - char *path; /* File system mount point */ - const struct dfs_filesystem_ops *ops; /* Operations for file system type */ - - void *data; /* Specific file system data */ -}; - -/* file system partition table */ -struct dfs_partition -{ - uint8_t type; /* file system type */ - off_t offset; /* partition start offset */ - size_t size; /* partition size */ - rt_sem_t lock; -}; - -/* mount table */ -struct dfs_mount_tbl -{ - const char *device_name; - const char *path; - const char *filesystemtype; - unsigned long rwflag; - const void *data; -}; - -int dfs_register(const struct dfs_filesystem_ops *ops); -struct dfs_filesystem *dfs_filesystem_lookup(const char *path); -const char *dfs_filesystem_get_mounted_path(struct rt_device *device); - -int dfs_filesystem_get_partition(struct dfs_partition *part, - uint8_t *buf, - uint32_t pindex); - -int dfs_mount(const char *device_name, - const char *path, - const char *filesystemtype, - unsigned long rwflag, - const void *data); -int dfs_unmount(const char *specialfile); - -int dfs_mkfs(const char *fs_name, const char *device_name); -int dfs_statfs(const char *path, struct statfs *buffer); -int dfs_mount_device(rt_device_t dev); -int dfs_unmount_device(rt_device_t dev); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/components/dfs/include/dfs_private.h b/components/dfs/include/dfs_private.h deleted file mode 100644 index e602c21730..0000000000 --- a/components/dfs/include/dfs_private.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2006-2021, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - */ - -#ifndef DFS_PRIVATE_H__ -#define DFS_PRIVATE_H__ - -#include <dfs.h> - -#define DBG_TAG "DFS" -#define DBG_LVL DBG_INFO -#include <rtdbg.h> - -#define NO_WORKING_DIR "system does not support working directory\n" - -/* extern variable */ -extern const struct dfs_filesystem_ops *filesystem_operation_table[]; -extern struct dfs_filesystem filesystem_table[]; -extern const struct dfs_mount_tbl mount_table[]; - -extern char working_directory[]; - -#endif |
