Skip to content

Commit fd31965

Browse files
authored
[components][lwp]fix mount param issue (#9333)
fix mount param issue
1 parent d3b9480 commit fd31965

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

components/lwp/lwp_syscall.c

+21-4
Original file line numberDiff line numberDiff line change
@@ -5784,13 +5784,30 @@ sysret_t sys_mount(char *source, char *target,
57845784
{
57855785
copy_source = NULL;
57865786
}
5787-
ret = dfs_mount(copy_source, copy_target, copy_filesystemtype, 0, tmp);
57885787

5789-
if (ret < 0)
5788+
struct stat buf;
5789+
5790+
if (copy_source && stat(copy_source, &buf) && S_ISBLK(buf.st_mode))
57905791
{
5791-
ret = -rt_get_errno();
5792+
char *dev_fullpath = dfs_normalize_path(RT_NULL, copy_source);
5793+
rt_free(copy_source);
5794+
RT_ASSERT(rt_strncmp(dev_fullpath, "/dev/", sizeof("/dev/") - 1) == 0);
5795+
ret = dfs_mount(dev_fullpath + sizeof("/dev/") - 1, copy_target, copy_filesystemtype, 0, tmp);
5796+
if (ret < 0)
5797+
{
5798+
ret = -rt_get_errno();
5799+
}
5800+
rt_free(dev_fullpath);
5801+
}
5802+
else
5803+
{
5804+
ret = dfs_mount(copy_source, copy_target, copy_filesystemtype, 0, tmp);
5805+
if (ret < 0)
5806+
{
5807+
ret = -rt_get_errno();
5808+
}
5809+
rt_free(copy_source);
57925810
}
5793-
rt_free(copy_source);
57945811

57955812
return ret;
57965813
}

0 commit comments

Comments
 (0)