Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Xiaobo07
rt-thread
提交
991c25dd
R
rt-thread
项目概览
Xiaobo07
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
2
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
991c25dd
编写于
1月 30, 2021
作者:
还_没_想_好
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[finsh] add mount/umount cmd
上级
45963a16
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
93 addition
and
13 deletion
+93
-13
components/finsh/msh_file.c
components/finsh/msh_file.c
+93
-13
未找到文件。
components/finsh/msh_file.c
浏览文件 @
991c25dd
...
...
@@ -347,10 +347,17 @@ int cmd_rm(int argc, char **argv)
{
switch
(
argv
[
1
][
n
])
{
case
'f'
:
f
=
1
;
break
;
case
'r'
:
r
=
1
;
break
;
case
'v'
:
v
=
1
;
break
;
case
'-'
:
break
;
case
'f'
:
f
=
1
;
break
;
case
'r'
:
r
=
1
;
break
;
case
'v'
:
v
=
1
;
break
;
case
'-'
:
break
;
default:
rt_kprintf
(
"Error: Bad option: %c
\n
"
,
argv
[
1
][
n
]);
return
0
;
...
...
@@ -363,7 +370,7 @@ int cmd_rm(int argc, char **argv)
for
(
index
=
1
;
index
<
argc
;
index
++
)
{
struct
stat
s
;
if
(
stat
(
argv
[
index
],
&
s
)
==
0
)
if
(
stat
(
argv
[
index
],
&
s
)
==
0
)
{
if
(
s
.
st_mode
&
S_IFDIR
)
{
...
...
@@ -469,8 +476,81 @@ int cmd_mkfs(int argc, char **argv)
}
FINSH_FUNCTION_EXPORT_ALIAS
(
cmd_mkfs
,
__cmd_mkfs
,
format
disk
with
file
system
);
extern
struct
dfs_filesystem
filesystem_table
[];
int
cmd_mount
(
int
argc
,
char
*
argv
[])
{
if
(
argc
==
1
)
{
struct
dfs_filesystem
*
iter
;
/* display the mount history */
rt_kprintf
(
"filesystem device mountpoint
\n
"
);
rt_kprintf
(
"---------- ------ ----------
\n
"
);
for
(
iter
=
&
filesystem_table
[
0
];
iter
<
&
filesystem_table
[
DFS_FILESYSTEMS_MAX
];
iter
++
)
{
if
((
iter
!=
NULL
)
&&
(
iter
->
path
!=
NULL
))
{
rt_kprintf
(
"%-10s %-6s %-s
\n
"
,
iter
->
ops
->
name
,
iter
->
dev_id
->
parent
.
name
,
iter
->
path
);
}
}
return
0
;
}
else
if
(
argc
==
4
)
{
char
*
device
=
argv
[
1
];
char
*
path
=
argv
[
2
];
char
*
fstype
=
argv
[
3
];
/* mount a filesystem to the specified directory */
rt_kprintf
(
"mount device %s(%s) onto %s ... "
,
device
,
fstype
,
path
);
if
(
dfs_mount
(
device
,
path
,
fstype
,
0
,
0
)
==
0
)
{
rt_kprintf
(
"succeed!
\n
"
);
return
0
;
}
else
{
rt_kprintf
(
"failed!
\n
"
);
return
-
1
;
}
}
else
{
rt_kprintf
(
"Usage: mount <device> <mountpoint> <fstype>.
\n
"
);
return
-
1
;
}
}
FINSH_FUNCTION_EXPORT_ALIAS
(
cmd_mount
,
__cmd_mount
,
mount
<
device
>
<
mountpoint
>
<
fstype
>
);
/* unmount the filesystem from the specified mountpoint */
int
cmd_umount
(
int
argc
,
char
*
argv
[])
{
char
*
path
=
argv
[
1
];
if
(
argc
!=
2
)
{
rt_kprintf
(
"Usage: unmount <mountpoint>.
\n
"
);
return
-
1
;
}
rt_kprintf
(
"unmount %s ... "
,
path
);
if
(
dfs_unmount
(
path
)
<
0
)
{
rt_kprintf
(
"failed!
\n
"
);
return
-
1
;
}
else
{
rt_kprintf
(
"succeed!
\n
"
);
return
0
;
}
}
FINSH_FUNCTION_EXPORT_ALIAS
(
cmd_umount
,
__cmd_umount
,
Unmount
device
from
file
system
);
extern
int
df
(
const
char
*
path
);
int
cmd_df
(
int
argc
,
char
**
argv
)
int
cmd_df
(
int
argc
,
char
**
argv
)
{
if
(
argc
!=
2
)
{
...
...
@@ -492,7 +572,7 @@ int cmd_df(int argc, char** argv)
}
FINSH_FUNCTION_EXPORT_ALIAS
(
cmd_df
,
__cmd_df
,
disk
free
);
int
cmd_echo
(
int
argc
,
char
**
argv
)
int
cmd_echo
(
int
argc
,
char
**
argv
)
{
if
(
argc
==
2
)
{
...
...
@@ -505,7 +585,7 @@ int cmd_echo(int argc, char** argv)
fd
=
open
(
argv
[
2
],
O_RDWR
|
O_APPEND
|
O_CREAT
,
0
);
if
(
fd
>=
0
)
{
write
(
fd
,
argv
[
1
],
strlen
(
argv
[
1
]));
write
(
fd
,
argv
[
1
],
strlen
(
argv
[
1
]));
close
(
fd
);
}
else
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录