Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lfmiao0
rt-thread
提交
729a1ad3
R
rt-thread
项目概览
lfmiao0
/
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,发现更多精彩内容 >>
未验证
提交
729a1ad3
编写于
3月 05, 2021
作者:
B
Bernard Xiong
提交者:
GitHub
3月 05, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4280 from enkiller/0130-1631
[finsh] add mount/umount cmd
上级
8ba86088
991c25dd
变更
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
浏览文件 @
729a1ad3
...
...
@@ -101,7 +101,7 @@ int msh_exec_script(const char *cmd_line, int size)
int
length
;
line_buf
=
(
char
*
)
rt_malloc
(
RT_CONSOLEBUF_SIZE
);
if
(
line_buf
==
RT_NULL
)
if
(
line_buf
==
RT_NULL
)
{
close
(
fd
);
return
-
RT_ENOMEM
;
...
...
@@ -295,7 +295,7 @@ static void directory_delete_for_msh(const char *pathname, char f, char v)
if
(
dirent
==
RT_NULL
)
break
;
if
(
rt_strcmp
(
"."
,
dirent
->
d_name
)
!=
0
&&
rt_strcmp
(
".."
,
dirent
->
d_name
)
!=
0
)
rt_strcmp
(
".."
,
dirent
->
d_name
)
!=
0
)
{
rt_sprintf
(
full_path
,
"%s/%s"
,
pathname
,
dirent
->
d_name
);
if
(
dirent
->
d_type
==
DT_REG
)
...
...
@@ -347,13 +347,20 @@ 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
;
default:
rt_kprintf
(
"Error: Bad option: %c
\n
"
,
argv
[
1
][
n
]);
return
0
;
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
;
}
}
argc
-=
1
;
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录