mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-12-26 09:08:25 +00:00
[dfs] add poll/select
1. Add poll/select APIs; 2. Add wait queue implementation; 3. Remove DFS_STATUS_* code and use errno; 4. Add pipe API; 5. Use a standalone fops in DFS;
This commit is contained in:
@@ -25,20 +25,24 @@
|
||||
#ifndef __DFS_FS_H__
|
||||
#define __DFS_FS_H__
|
||||
|
||||
#include <dfs_def.h>
|
||||
#include <dfs.h>
|
||||
|
||||
#define DFS_FS_FLAG_DEFAULT 0x00 /* default flag */
|
||||
#define DFS_FS_FLAG_FULLPATH 0x01 /* set full path to underlaying file system */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Pre-declaration */
|
||||
struct dfs_filesystem;
|
||||
struct dfs_fd;
|
||||
|
||||
/* File system operations struct */
|
||||
struct dfs_filesystem_operation
|
||||
/* File system operations */
|
||||
struct dfs_filesystem_ops
|
||||
{
|
||||
char *name;
|
||||
rt_uint32_t flags; /* flags for file system operations */
|
||||
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);
|
||||
@@ -48,15 +52,6 @@ struct dfs_filesystem_operation
|
||||
int (*mkfs) (rt_device_t devid);
|
||||
int (*statfs) (struct dfs_filesystem *fs, struct statfs *buf);
|
||||
|
||||
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, rt_size_t count);
|
||||
int (*write) (struct dfs_fd *fd, const void *buf, rt_size_t count);
|
||||
int (*flush) (struct dfs_fd *fd);
|
||||
int (*lseek) (struct dfs_fd *fd, rt_off_t offset);
|
||||
int (*getdents) (struct dfs_fd *fd, struct dirent *dirp, rt_uint32_t count);
|
||||
|
||||
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);
|
||||
@@ -68,7 +63,7 @@ struct dfs_filesystem
|
||||
rt_device_t dev_id; /* Attached device */
|
||||
|
||||
char *path; /* File system mount point */
|
||||
const struct dfs_filesystem_operation *ops; /* Operations for file system type */
|
||||
const struct dfs_filesystem_ops *ops; /* Operations for file system type */
|
||||
|
||||
void *data; /* Specific file system data */
|
||||
};
|
||||
@@ -76,47 +71,42 @@ struct dfs_filesystem
|
||||
/* file system partition table */
|
||||
struct dfs_partition
|
||||
{
|
||||
rt_uint8_t type; /* file system type */
|
||||
rt_off_t offset; /* partition start offset */
|
||||
rt_size_t size; /* partition size */
|
||||
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;
|
||||
const char *device_name;
|
||||
const char *path;
|
||||
const char *filesystemtype;
|
||||
unsigned long rwflag;
|
||||
const void *data;
|
||||
};
|
||||
|
||||
int dfs_register(const struct dfs_filesystem_operation *ops);
|
||||
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);
|
||||
|
||||
rt_err_t dfs_filesystem_get_partition(struct dfs_partition *part,
|
||||
rt_uint8_t *buf,
|
||||
rt_uint32_t pindex);
|
||||
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,
|
||||
rt_uint32_t rwflag,
|
||||
unsigned long rwflag,
|
||||
const void *data);
|
||||
int dfs_unmount(const char *specialfile);
|
||||
|
||||
/* extern variable */
|
||||
extern const struct dfs_filesystem_operation *filesystem_operation_table[];
|
||||
extern struct dfs_filesystem filesystem_table[];
|
||||
extern const struct dfs_mount_tbl mount_table[];
|
||||
|
||||
extern char working_directory[];
|
||||
|
||||
void dfs_lock(void);
|
||||
void dfs_unlock(void);
|
||||
int dfs_mkfs(const char *fs_name, const char *device_name);
|
||||
int dfs_statfs(const char *path, struct statfs *buffer);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user