Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ihbai
rt-thread
提交
32e07e51
R
rt-thread
项目概览
ihbai
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
32e07e51
编写于
3月 16, 2020
作者:
B
Bernard Xiong
提交者:
GitHub
3月 16, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3457 from cliff-cmc/msc
Support msc mode automatic switching
上级
a7bcf90d
1c68bd9d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
61 addition
and
1 deletion
+61
-1
components/dfs/include/dfs_fs.h
components/dfs/include/dfs_fs.h
+1
-0
components/dfs/src/dfs_fs.c
components/dfs/src/dfs_fs.c
+48
-0
components/drivers/usb/usbdevice/class/mstorage.c
components/drivers/usb/usbdevice/class/mstorage.c
+12
-1
未找到文件。
components/dfs/include/dfs_fs.h
浏览文件 @
32e07e51
...
...
@@ -91,6 +91,7 @@ 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
}
...
...
components/dfs/src/dfs_fs.c
浏览文件 @
32e07e51
...
...
@@ -555,6 +555,54 @@ int dfs_mount_device(rt_device_t dev)
rt_kprintf
(
"can't find device:%s to be mounted.
\n
"
,
dev
->
parent
.
name
);
return
-
RT_ERROR
;
}
int
dfs_unmount_device
(
rt_device_t
dev
)
{
struct
dfs_filesystem
*
iter
;
struct
dfs_filesystem
*
fs
=
NULL
;
/* lock filesystem */
dfs_lock
();
for
(
iter
=
&
filesystem_table
[
0
];
iter
<
&
filesystem_table
[
DFS_FILESYSTEMS_MAX
];
iter
++
)
{
/* check if the PATH is mounted */
if
((
iter
->
dev_id
->
parent
.
name
!=
NULL
)
&&
(
strcmp
(
iter
->
dev_id
->
parent
.
name
,
dev
->
parent
.
name
)
==
0
))
{
fs
=
iter
;
break
;
}
}
if
(
fs
==
NULL
||
fs
->
ops
->
unmount
==
NULL
||
fs
->
ops
->
unmount
(
fs
)
<
0
)
{
goto
err1
;
}
/* close device, but do not check the status of device */
if
(
fs
->
dev_id
!=
NULL
)
rt_device_close
(
fs
->
dev_id
);
if
(
fs
->
path
!=
NULL
)
rt_free
(
fs
->
path
);
/* clear this filesystem table entry */
memset
(
fs
,
0
,
sizeof
(
struct
dfs_filesystem
));
dfs_unlock
();
return
0
;
err1:
dfs_unlock
();
return
-
1
;
}
#endif
#ifdef RT_USING_FINSH
...
...
components/drivers/usb/usbdevice/class/mstorage.c
浏览文件 @
32e07e51
...
...
@@ -16,6 +16,10 @@
#include "drivers/usb_device.h"
#include "mstorage.h"
#ifdef RT_USING_DFS_MNTTABLE
#include "dfs_fs.h"
#endif
#ifdef RT_USB_DEVICE_MSTORAGE
enum
STAT
...
...
@@ -955,7 +959,7 @@ static rt_err_t _function_enable(ufunction_t func)
struct
mstorage
*
data
;
RT_ASSERT
(
func
!=
RT_NULL
);
RT_DEBUG_LOG
(
RT_DEBUG_USB
,
(
"Mass storage function enabled
\n
"
));
data
=
(
struct
mstorage
*
)
func
->
user_data
;
data
=
(
struct
mstorage
*
)
func
->
user_data
;
data
->
disk
=
rt_device_find
(
RT_USB_MSTORAGE_DISK_NAME
);
if
(
data
->
disk
==
RT_NULL
)
...
...
@@ -964,6 +968,10 @@ static rt_err_t _function_enable(ufunction_t func)
return
-
RT_ERROR
;
}
#ifdef RT_USING_DFS_MNTTABLE
dfs_unmount_device
(
data
->
disk
);
#endif
if
(
rt_device_open
(
data
->
disk
,
RT_DEVICE_OFLAG_RDWR
)
!=
RT_EOK
)
{
rt_kprintf
(
"disk open error
\n
"
);
...
...
@@ -1029,6 +1037,9 @@ static rt_err_t _function_disable(ufunction_t func)
if
(
data
->
disk
!=
RT_NULL
)
{
rt_device_close
(
data
->
disk
);
#ifdef RT_USING_DFS_MNTTABLE
dfs_mount_device
(
data
->
disk
);
#endif
data
->
disk
=
RT_NULL
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录