summaryrefslogtreecommitdiff
path: root/components/dfs
diff options
context:
space:
mode:
authorbernard.xiong <[email protected]>2010-04-22 09:33:25 +0000
committerbernard.xiong <[email protected]>2010-04-22 09:33:25 +0000
commitc4a21b445684bf39f39ece3e1a4d069ce5a08f41 (patch)
tree1459ca790ff3b0439964069b24fba4c97e1b5d56 /components/dfs
parentc988a222ed97c399dd83ec32f92ce4df294dbebb (diff)
add more options to filesystem mount function invoke.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@665 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'components/dfs')
-rw-r--r--components/dfs/filesystems/elmfat/dfs_elm.c2
-rw-r--r--components/dfs/include/dfs_fs.h2
-rw-r--r--components/dfs/src/dfs_fs.c42
3 files changed, 27 insertions, 19 deletions
diff --git a/components/dfs/filesystems/elmfat/dfs_elm.c b/components/dfs/filesystems/elmfat/dfs_elm.c
index f7289fcadc..3112d30bc4 100644
--- a/components/dfs/filesystems/elmfat/dfs_elm.c
+++ b/components/dfs/filesystems/elmfat/dfs_elm.c
@@ -49,7 +49,7 @@ static int elm_result_to_dfs(FRESULT result)
return status;
}
-int dfs_elm_mount(struct dfs_filesystem* fs)
+int dfs_elm_mount(struct dfs_filesystem* fs, unsigned long rwflag, const void* data)
{
FATFS *fat;
FRESULT result;
diff --git a/components/dfs/include/dfs_fs.h b/components/dfs/include/dfs_fs.h
index 2431765856..c31d9585a2 100644
--- a/components/dfs/include/dfs_fs.h
+++ b/components/dfs/include/dfs_fs.h
@@ -28,7 +28,7 @@ struct dfs_filesystem_operation
{
char name[DFS_FS_NAME_MAX + 1];
- int (*mount) (struct dfs_filesystem* fs);
+ int (*mount) (struct dfs_filesystem* fs, unsigned long rwflag, const void* data);
int (*unmount) (struct dfs_filesystem* fs);
int (*open) (struct dfs_fd* fd);
diff --git a/components/dfs/src/dfs_fs.c b/components/dfs/src/dfs_fs.c
index a20b9b26c0..9745ea0c41 100644
--- a/components/dfs/src/dfs_fs.c
+++ b/components/dfs/src/dfs_fs.c
@@ -206,13 +206,21 @@ int dfs_mount(const char* device_name, const char* path,
int index;
/* open specific device */
- dev_id = rt_device_find(device_name);
- if (dev_id == RT_NULL)
- {
- /* no this device */
- rt_set_errno(-DFS_STATUS_ENODEV);
- return -1;
- }
+ if (device_name != RT_NULL)
+ {
+ dev_id = rt_device_find(device_name);
+ if (dev_id == RT_NULL)
+ {
+ /* no this device */
+ rt_set_errno(-DFS_STATUS_ENODEV);
+ return -1;
+ }
+ }
+ else
+ {
+ /* which is a non-device filesystem mount */
+ dev_id = RT_NULL;
+ }
/* find out specific filesystem */
dfs_lock();
@@ -289,11 +297,12 @@ int dfs_mount(const char* device_name, const char* path,
/* release filesystem_table lock */
dfs_unlock();
- /* open device, but do not check the status of device */
- rt_device_open(fs->dev_id, RT_DEVICE_OFLAG_RDWR);
+ /* open device, but do not check the status of device */
+ if (dev_id != RT_NULL) rt_device_open(fs->dev_id, RT_DEVICE_OFLAG_RDWR);
- if ( ops->mount == RT_NULL ) /* there is no mount implementation */
+ if (ops->mount == RT_NULL) /* there is no mount implementation */
{
+ if (dev_id != RT_NULL) rt_device_close(dev_id);
dfs_lock();
/* clear filesystem table entry */
rt_memset(fs, 0, sizeof(struct dfs_filesystem));
@@ -303,19 +312,18 @@ int dfs_mount(const char* device_name, const char* path,
return -1;
}
/* call mount of this filesystem */
- else if ( ops->mount(fs) < 0 )
+ else if (ops->mount(fs, rwflag, data) < 0)
{
- /* mount failed */
- dfs_lock();
-
/* close device */
- rt_device_close(fs->dev_id);
+ if (dev_id != RT_NULL) rt_device_close(fs->dev_id);
+ /* mount failed */
+ dfs_lock();
/* clear filesystem table entry */
rt_memset(fs, 0, sizeof(struct dfs_filesystem));
-
dfs_unlock();
- return -1;
+
+ return -1;
}
return 0;