add more options to filesystem mount function invoke.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@665 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
c988a222ed
commit
c4a21b4456
|
@ -5,8 +5,12 @@ Import('rtconfig')
|
||||||
# build each components
|
# build each components
|
||||||
objs = ''
|
objs = ''
|
||||||
|
|
||||||
if 'RT_USING_MINILIBC' in dir(rtconfig) and rtconfig.RT_USING_MINILIBC:
|
if rtconfig.CROSS_TOOL == 'gcc':
|
||||||
objs = objs + SConscript('libc/minilibc/SConscript')
|
if 'RT_USING_NEWLIB' in dir(rtconfig) and rtconfig.RT_USING_NEWLIB:
|
||||||
|
objs = objs + SConscript('libc/newlib/SConscript')
|
||||||
|
else:
|
||||||
|
rtconfig.RT_USING_MINILIBC = True
|
||||||
|
objs = objs + SConscript('libc/minilibc/SConscript')
|
||||||
|
|
||||||
if 'RT_USING_FINSH' in dir(rtconfig) and rtconfig.RT_USING_FINSH:
|
if 'RT_USING_FINSH' in dir(rtconfig) and rtconfig.RT_USING_FINSH:
|
||||||
objs = objs + SConscript('finsh/SConscript')
|
objs = objs + SConscript('finsh/SConscript')
|
||||||
|
|
|
@ -49,7 +49,7 @@ static int elm_result_to_dfs(FRESULT result)
|
||||||
return status;
|
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;
|
FATFS *fat;
|
||||||
FRESULT result;
|
FRESULT result;
|
||||||
|
|
|
@ -28,7 +28,7 @@ struct dfs_filesystem_operation
|
||||||
{
|
{
|
||||||
char name[DFS_FS_NAME_MAX + 1];
|
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 (*unmount) (struct dfs_filesystem* fs);
|
||||||
|
|
||||||
int (*open) (struct dfs_fd* fd);
|
int (*open) (struct dfs_fd* fd);
|
||||||
|
|
|
@ -206,13 +206,21 @@ int dfs_mount(const char* device_name, const char* path,
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
/* open specific device */
|
/* open specific device */
|
||||||
dev_id = rt_device_find(device_name);
|
if (device_name != RT_NULL)
|
||||||
if (dev_id == RT_NULL)
|
{
|
||||||
{
|
dev_id = rt_device_find(device_name);
|
||||||
/* no this device */
|
if (dev_id == RT_NULL)
|
||||||
rt_set_errno(-DFS_STATUS_ENODEV);
|
{
|
||||||
return -1;
|
/* 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 */
|
/* find out specific filesystem */
|
||||||
dfs_lock();
|
dfs_lock();
|
||||||
|
@ -289,11 +297,12 @@ int dfs_mount(const char* device_name, const char* path,
|
||||||
/* release filesystem_table lock */
|
/* release filesystem_table lock */
|
||||||
dfs_unlock();
|
dfs_unlock();
|
||||||
|
|
||||||
/* open device, but do not check the status of device */
|
/* open device, but do not check the status of device */
|
||||||
rt_device_open(fs->dev_id, RT_DEVICE_OFLAG_RDWR);
|
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();
|
dfs_lock();
|
||||||
/* clear filesystem table entry */
|
/* clear filesystem table entry */
|
||||||
rt_memset(fs, 0, sizeof(struct dfs_filesystem));
|
rt_memset(fs, 0, sizeof(struct dfs_filesystem));
|
||||||
|
@ -303,19 +312,18 @@ int dfs_mount(const char* device_name, const char* path,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/* call mount of this filesystem */
|
/* call mount of this filesystem */
|
||||||
else if ( ops->mount(fs) < 0 )
|
else if (ops->mount(fs, rwflag, data) < 0)
|
||||||
{
|
{
|
||||||
|
/* close device */
|
||||||
|
if (dev_id != RT_NULL) rt_device_close(fs->dev_id);
|
||||||
|
|
||||||
/* mount failed */
|
/* mount failed */
|
||||||
dfs_lock();
|
dfs_lock();
|
||||||
|
|
||||||
/* close device */
|
|
||||||
rt_device_close(fs->dev_id);
|
|
||||||
|
|
||||||
/* clear filesystem table entry */
|
/* clear filesystem table entry */
|
||||||
rt_memset(fs, 0, sizeof(struct dfs_filesystem));
|
rt_memset(fs, 0, sizeof(struct dfs_filesystem));
|
||||||
|
|
||||||
dfs_unlock();
|
dfs_unlock();
|
||||||
return -1;
|
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue