Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party NuttX
提交
83c5f1a1
T
Third Party NuttX
项目概览
OpenHarmony
/
Third Party NuttX
9 个月 前同步成功
通知
5
Star
19
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party NuttX
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
83c5f1a1
编写于
1月 17, 2023
作者:
O
openharmony_ci
提交者:
Gitee
1月 17, 2023
浏览文件
操作
浏览文件
下载
差异文件
!151 支持mnt容器及增强能力
Merge pull request !151 from zhushengle/mnt_container
上级
9171b603
d44cf51d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
138 addition
and
2 deletion
+138
-2
fs/inode/fs_files.c
fs/inode/fs_files.c
+21
-0
fs/mount/fs_mount.c
fs/mount/fs_mount.c
+55
-1
fs/mount/fs_umount.c
fs/mount/fs_umount.c
+62
-1
未找到文件。
fs/inode/fs_files.c
浏览文件 @
83c5f1a1
...
...
@@ -787,6 +787,13 @@ struct files_struct *alloc_files(void)
(
VOID
)
LOS_MemFree
(
m_aucSysMem0
,
files
);
return
NULL
;
}
#ifdef LOSCFG_CHROOT
if
(
VnodeGetRoot
()
!=
NULL
)
{
VnodeGetRoot
()
->
useCount
++
;
}
files
->
rootVnode
=
VnodeGetRoot
();
#endif
return
files
;
}
...
...
@@ -824,6 +831,13 @@ struct files_struct *dup_fd(struct files_struct *old_files)
}
copy_fd_table
(
new_fdt
,
old_fdt
);
files
->
fdt
=
new_fdt
;
#ifdef LOSCFG_CHROOT
if
(
old_files
->
rootVnode
!=
NULL
)
{
old_files
->
rootVnode
->
useCount
++
;
}
files
->
rootVnode
=
old_files
->
rootVnode
;
#endif
return
files
;
}
...
...
@@ -900,6 +914,13 @@ struct files_struct *create_files_snapshot(const struct files_struct *old_files)
}
copy_fds
((
const
struct
fd_table_s
*
)
new_fdt
,
(
const
struct
fd_table_s
*
)
old_fdt
);
files
->
fdt
=
new_fdt
;
#ifdef LOSCFG_CHROOT
if
(
old_files
->
rootVnode
!=
NULL
)
{
old_files
->
rootVnode
->
useCount
++
;
}
files
->
rootVnode
=
old_files
->
rootVnode
;
#endif
return
files
;
...
...
fs/mount/fs_mount.c
浏览文件 @
83c5f1a1
...
...
@@ -49,7 +49,9 @@
#ifdef LOSCFG_FS_ZPFS
#include "zpfs.h"
#endif
#ifdef LOSCFG_MNT_CONTAINER
#include "los_mnt_container_pri.h"
#endif
/* At least one filesystem must be defined, or this file will not compile.
* It may be desire-able to make filesystems dynamically registered at
...
...
@@ -206,11 +208,48 @@ int mount(const char *source, const char *target,
}
if
(
mountpt_vnode
->
flag
&
VNODE_FLAG_MOUNT_NEW
)
{
#ifdef LOSCFG_MNT_CONTAINER
struct
Mount
*
tMnt
=
NULL
;
LOS_DL_LIST_FOR_EACH_ENTRY
(
tMnt
,
GetMountList
(),
struct
Mount
,
mountList
)
{
if
(
tMnt
->
vnodeCovered
==
mountpt_vnode
)
{
PRINT_ERR
(
"can't mount to %s, already mounted.
\n
"
,
target
);
errcode
=
-
EINVAL
;
goto
errout_with_lock
;
}
}
#else
PRINT_ERR
(
"can't mount to %s, already mounted.
\n
"
,
target
);
errcode
=
-
EINVAL
;
goto
errout_with_lock
;
#endif
}
#ifdef LOSCFG_MNT_CONTAINER
struct
Mount
*
cacheMnt
=
NULL
;
if
(
source
!=
NULL
)
{
LOS_DL_LIST_FOR_EACH_ENTRY
(
cacheMnt
,
GetMountCache
(),
struct
Mount
,
mountList
)
{
if
(
strcmp
(
cacheMnt
->
devName
,
source
)
==
0
)
{
struct
Mount
*
newMnt
=
(
struct
Mount
*
)
zalloc
(
sizeof
(
struct
Mount
));
if
(
newMnt
==
NULL
)
{
PRINT_ERR
(
"New mount alloc failed no memory!
\n
"
);
errcode
=
-
EINVAL
;
goto
errout
;
}
*
newMnt
=
*
cacheMnt
;
LOS_ListTailInsert
(
GetMountList
(),
&
(
newMnt
->
mountList
));
cacheMnt
->
vnodeCovered
->
mntCount
++
;
VnodeDrop
();
return
OK
;
}
}
}
#endif
/* Bind the block driver to an instance of the file system. The file
* system returns a reference to some opaque, fs-dependent structure
* that encapsulates this binding.
...
...
@@ -306,6 +345,21 @@ int mount(const char *source, const char *target,
mount_list
=
GetMountList
();
LOS_ListAdd
(
mount_list
,
&
mnt
->
mountList
);
#ifdef LOSCFG_MNT_CONTAINER
if
(
source
!=
NULL
)
{
struct
Mount
*
newMnt
=
(
struct
Mount
*
)
zalloc
(
sizeof
(
struct
Mount
));
if
(
newMnt
==
NULL
)
{
PRINT_ERR
(
"New mount alloc failed no memory!
\n
"
);
errcode
=
-
EINVAL
;
goto
errout
;
}
*
newMnt
=
*
mnt
;
LOS_ListTailInsert
(
GetMountCache
(),
&
(
newMnt
->
mountList
));
}
#endif
if
(
!
strcmp
(
"/"
,
target
))
{
ChangeRoot
(
mnt
->
vnodeCovered
);
...
...
fs/mount/fs_umount.c
浏览文件 @
83c5f1a1
...
...
@@ -47,6 +47,9 @@
#include "string.h"
#include "disk.h"
#include "fs/mount.h"
#ifdef LOSCFG_MNT_CONTAINER
#include "los_mnt_container_pri.h"
#endif
/****************************************************************************
* Public Functions
...
...
@@ -114,6 +117,35 @@ int umount(const char *target)
goto
errout
;
}
#ifdef LOSCFG_MNT_CONTAINER
/* Verify that the vnode is a mountpoint */
struct
Mount
*
tMnt
=
NULL
;
bool
found
=
false
;
LOS_DL_LIST_FOR_EACH_ENTRY
(
tMnt
,
GetMountList
(),
struct
Mount
,
mountList
)
{
if
(
tMnt
->
vnodeCovered
==
mountpt_vnode
)
{
found
=
true
;
break
;
}
}
if
(
!
found
)
{
ret
=
-
EINVAL
;
goto
errout
;
}
if
(
tMnt
->
vnodeCovered
->
mntCount
>
0
)
{
tMnt
->
vnodeCovered
->
mntCount
--
;
LOS_ListDelete
(
&
tMnt
->
mountList
);
free
(
tMnt
);
VnodeDrop
();
return
OK
;
}
#endif
/* Get mount point covered vnode and mount structure */
mnt
=
mountpt_vnode
->
originMount
;
if
(
!
mnt
)
...
...
@@ -158,9 +190,21 @@ int umount(const char *target)
{
goto
errout
;
}
#ifdef LOSCFG_MNT_CONTAINER
struct
Mount
*
tCacheMnt
=
NULL
;
LOS_DL_LIST_FOR_EACH_ENTRY
(
tCacheMnt
,
GetMountCache
(),
struct
Mount
,
mountList
)
{
if
(
tCacheMnt
->
vnodeCovered
==
mountpt_vnode
)
{
LOS_ListDelete
(
&
tCacheMnt
->
mountList
);
free
(
tCacheMnt
);
break
;
}
}
#endif
VnodeFree
(
mountpt_vnode
);
LOS_ListDelete
(
&
mnt
->
mountList
);
free
(
mnt
);
/* Did the unbind method return a contained block driver */
...
...
@@ -170,7 +214,24 @@ int umount(const char *target)
}
covered_vnode
->
newMount
=
NULL
;
#ifdef LOSCFG_MNT_CONTAINER
tCacheMnt
=
NULL
;
found
=
false
;
LOS_DL_LIST_FOR_EACH_ENTRY
(
tCacheMnt
,
GetMountCache
(),
struct
Mount
,
mountList
)
{
if
(
tCacheMnt
->
vnodeBeCovered
==
covered_vnode
)
{
found
=
true
;
break
;
}
}
if
(
!
found
)
{
covered_vnode
->
flag
&=
~
(
VNODE_FLAG_MOUNT_ORIGIN
);
}
#else
covered_vnode
->
flag
&=
~
(
VNODE_FLAG_MOUNT_ORIGIN
);
#endif
VnodeDrop
();
return
OK
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录