add flush, statfs, mkfs to device file system interface.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@802 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
bernard.xiong@gmail.com
2010-07-18 16:15:53 +00:00
parent fd12462d57
commit 33feb176d0
12 changed files with 462 additions and 1594 deletions

View File

@@ -1,17 +1,16 @@
/*
+------------------------------------------------------------------------------
| Project : Device Filesystem
+------------------------------------------------------------------------------
| Copyright 2004, 2005 www.fayfayspace.org.
| All rights reserved.
|------------------------------------------------------------------------------
| File : dfs_fs.h, the filesystem related defines of Device FileSystem
|------------------------------------------------------------------------------
| Chang Logs:
| Date Author Notes
| 2005-02-22 ffxz The first version.
+------------------------------------------------------------------------------
*/
* File : dfs_fs.h
* This file is part of Device File System in RT-Thread RTOS
* COPYRIGHT (C) 2004-2010, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE.
*
* Change Logs:
* Date Author Notes
* 2005-02-22 Bernard The first version.
*/
#ifndef __DFS_FS_H__
#define __DFS_FS_H__
@@ -26,16 +25,22 @@ struct dfs_dirent;
/* File system operations struct */
struct dfs_filesystem_operation
{
char name[DFS_FS_NAME_MAX + 1];
char *name;
/* mount and unmount file system */
int (*mount) (struct dfs_filesystem* fs, unsigned long rwflag, const void* data);
int (*unmount) (struct dfs_filesystem* fs);
int (*open) (struct dfs_fd* fd);
/* make a file system */
int (*mkfs) (const char* device_name);
int (*statfs) (struct dfs_filesystem* fs, struct dfs_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 (*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 dfs_dirent* dirp, rt_uint32_t count);
@@ -47,13 +52,12 @@ struct dfs_filesystem_operation
/* Mounted file system */
struct dfs_filesystem
{
rt_device_t dev_id; /* Attached device */
rt_device_t dev_id; /* Attached device */
char path[DFS_PATH_MAX + 1]; /* File system mount point */
struct dfs_filesystem_operation* ops; /* Operations for file system type */
rt_uint32_t block_id; /* Current block_id on attached device */
char* path; /* File system mount point */
const struct dfs_filesystem_operation* ops; /* Operations for file system type */
void *data; /* Specific file system data */
void *data; /* Specific file system data */
};
/* file system partition table */
@@ -65,7 +69,7 @@ struct dfs_partition
rt_sem_t lock;
};
int dfs_register(struct dfs_filesystem_operation* ops);
int dfs_register(const struct dfs_filesystem_operation* ops);
struct dfs_filesystem* dfs_filesystem_lookup(const char *path);
rt_err_t dfs_filesystem_get_partition(struct dfs_partition* part, rt_uint8_t* buf, rt_uint32_t pindex);
@@ -75,12 +79,13 @@ int dfs_mount(const char* device_name, const char* path,
int dfs_unmount(const char *specialfile);
/* extern variable */
extern struct dfs_filesystem_operation* filesystem_operation_table[];
extern const struct dfs_filesystem_operation* filesystem_operation_table[];
extern struct dfs_filesystem filesystem_table[];
extern char working_directory[];
void dfs_lock(void);
void dfs_unlock(void);
int dfs_statfs(const char* path, struct dfs_statfs* buffer);
#endif