Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2301_77017865
rt-thread
提交
5bbcb5dc
R
rt-thread
项目概览
2301_77017865
/
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,发现更多精彩内容 >>
未验证
提交
5bbcb5dc
编写于
4月 12, 2023
作者:
G
geniusgogo
提交者:
GitHub
4月 12, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix tmpfs spinlock error. (#7216)
上级
dc243888
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
28 addition
and
26 deletion
+28
-26
components/dfs/dfs_v1/filesystems/tmpfs/dfs_tmpfs.c
components/dfs/dfs_v1/filesystems/tmpfs/dfs_tmpfs.c
+22
-24
components/dfs/dfs_v1/filesystems/tmpfs/dfs_tmpfs.h
components/dfs/dfs_v1/filesystems/tmpfs/dfs_tmpfs.h
+1
-0
include/rthw.h
include/rthw.h
+5
-2
未找到文件。
components/dfs/dfs_v1/filesystems/tmpfs/dfs_tmpfs.c
浏览文件 @
5bbcb5dc
...
...
@@ -84,8 +84,7 @@ static int _free_subdir(struct tmpfs_file *dfile)
{
struct
tmpfs_file
*
file
;
rt_list_t
*
list
,
*
temp_list
;
RT_DEFINE_SPINLOCK
(
lock
);
struct
tmpfs_sb
*
superblock
;
RT_ASSERT
(
dfile
->
type
==
TMPFS_TYPE_DIR
);
...
...
@@ -101,9 +100,14 @@ static int _free_subdir(struct tmpfs_file *dfile)
/* TODO: fix for rt-smart */
rt_free
(
file
->
data
);
}
rt_hw_spin_lock
(
&
lock
);
superblock
=
file
->
sb
;
RT_ASSERT
(
superblock
!=
NULL
);
rt_spin_lock
(
&
superblock
->
lock
);
rt_list_remove
(
&
(
file
->
sibling
));
rt_hw_spin_unlock
(
&
lock
);
rt_spin_unlock
(
&
superblock
->
lock
);
rt_free
(
file
);
}
return
0
;
...
...
@@ -126,6 +130,8 @@ int dfs_tmpfs_mount(struct dfs_filesystem *fs,
rt_list_init
(
&
superblock
->
root
.
sibling
);
rt_list_init
(
&
superblock
->
root
.
subdirs
);
rt_spin_lock_init
(
&
superblock
->
lock
);
fs
->
data
=
superblock
;
return
RT_EOK
;
...
...
@@ -208,8 +214,6 @@ struct tmpfs_file *dfs_tmpfs_lookup(struct tmpfs_sb *superblock,
struct
tmpfs_file
*
file
,
*
curfile
;
rt_list_t
*
list
;
RT_DEFINE_SPINLOCK
(
lock
);
subpath
=
path
;
while
(
*
subpath
==
'/'
&&
*
subpath
)
subpath
++
;
...
...
@@ -234,7 +238,7 @@ find_subpath:
memset
(
subdir_name
,
0
,
TMPFS_NAME_MAX
);
_get_subdir
(
curpath
,
subdir_name
);
rt_
hw_spin_lock
(
&
lock
);
rt_
spin_lock
(
&
superblock
->
lock
);
rt_list_for_each
(
list
,
&
curfile
->
subdirs
)
{
...
...
@@ -245,7 +249,7 @@ find_subpath:
{
*
size
=
file
->
size
;
rt_
hw_spin_unlock
(
&
lock
);
rt_
spin_unlock
(
&
superblock
->
lock
);
return
file
;
}
}
...
...
@@ -254,11 +258,11 @@ find_subpath:
*
size
=
file
->
size
;
curpath
=
subpath
;
curfile
=
file
;
rt_
hw_spin_unlock
(
&
lock
);
rt_
spin_unlock
(
&
superblock
->
lock
);
goto
find_subpath
;
}
}
rt_
hw_spin_unlock
(
&
lock
);
rt_
spin_unlock
(
&
superblock
->
lock
);
/* not found */
return
NULL
;
}
...
...
@@ -357,8 +361,6 @@ int dfs_tmpfs_open(struct dfs_file *file)
struct
dfs_filesystem
*
fs
;
char
parent_path
[
DFS_PATH_MAX
],
file_name
[
TMPFS_NAME_MAX
];
RT_DEFINE_SPINLOCK
(
lock
);
RT_ASSERT
(
file
->
vnode
->
ref_count
>
0
);
if
(
file
->
vnode
->
ref_count
>
1
)
{
...
...
@@ -419,9 +421,9 @@ int dfs_tmpfs_open(struct dfs_file *file)
{
d_file
->
type
=
TMPFS_TYPE_FILE
;
}
rt_
hw_spin_lock
(
&
lock
);
rt_
spin_lock
(
&
superblock
->
lock
);
rt_list_insert_after
(
&
(
p_file
->
subdirs
),
&
(
d_file
->
sibling
));
rt_
hw_spin_unlock
(
&
lock
);
rt_
spin_unlock
(
&
superblock
->
lock
);
}
}
/* Creates a new file.
...
...
@@ -559,8 +561,6 @@ int dfs_tmpfs_unlink(struct dfs_filesystem *fs, const char *path)
struct
tmpfs_sb
*
superblock
;
struct
tmpfs_file
*
d_file
;
RT_DEFINE_SPINLOCK
(
lock
);
superblock
=
(
struct
tmpfs_sb
*
)
fs
->
data
;
RT_ASSERT
(
superblock
!=
NULL
);
...
...
@@ -568,9 +568,9 @@ int dfs_tmpfs_unlink(struct dfs_filesystem *fs, const char *path)
if
(
d_file
==
NULL
)
return
-
ENOENT
;
rt_
hw_spin_lock
(
&
lock
);
rt_
spin_lock
(
&
superblock
->
lock
);
rt_list_remove
(
&
(
d_file
->
sibling
));
rt_
hw_spin_unlock
(
&
lock
);
rt_
spin_unlock
(
&
superblock
->
lock
);
if
(
d_file
->
data
!=
NULL
)
rt_free
(
d_file
->
data
);
...
...
@@ -588,8 +588,6 @@ int dfs_tmpfs_rename(struct dfs_filesystem *fs,
rt_size_t
size
;
char
parent_path
[
DFS_PATH_MAX
],
file_name
[
TMPFS_NAME_MAX
];
RT_DEFINE_SPINLOCK
(
lock
);
superblock
=
(
struct
tmpfs_sb
*
)
fs
->
data
;
RT_ASSERT
(
superblock
!=
NULL
);
...
...
@@ -609,15 +607,15 @@ int dfs_tmpfs_rename(struct dfs_filesystem *fs,
p_file
=
dfs_tmpfs_lookup
(
superblock
,
parent_path
,
&
size
);
RT_ASSERT
(
p_file
!=
NULL
);
rt_
hw_spin_lock
(
&
lock
);
rt_
spin_lock
(
&
superblock
->
lock
);
rt_list_remove
(
&
(
d_file
->
sibling
));
rt_
hw_spin_unlock
(
&
lock
);
rt_
spin_unlock
(
&
superblock
->
lock
);
strncpy
(
d_file
->
name
,
file_name
,
TMPFS_NAME_MAX
);
rt_
hw_spin_lock
(
&
lock
);
rt_
spin_lock
(
&
superblock
->
lock
);
rt_list_insert_after
(
&
(
p_file
->
subdirs
),
&
(
d_file
->
sibling
));
rt_
hw_spin_unlock
(
&
lock
);
rt_
spin_unlock
(
&
superblock
->
lock
);
return
RT_EOK
;
}
...
...
components/dfs/dfs_v1/filesystems/tmpfs/dfs_tmpfs.h
浏览文件 @
5bbcb5dc
...
...
@@ -39,6 +39,7 @@ struct tmpfs_sb
struct
tmpfs_file
root
;
/* root dir */
rt_size_t
df_size
;
/* df size */
rt_list_t
sibling
;
/* sb sibling list */
struct
rt_spinlock
lock
;
/* tmpfs lock */
};
int
dfs_tmpfs_init
(
void
);
...
...
include/rthw.h
浏览文件 @
5bbcb5dc
...
...
@@ -207,8 +207,11 @@ void rt_hw_secondary_cpu_idle_exec(void);
#define rt_hw_spin_lock(lock) *(lock) = rt_hw_interrupt_disable()
#define rt_hw_spin_unlock(lock) rt_hw_interrupt_enable(*(lock))
typedef
int
rt_spinlock_t
;
typedef
rt_ubase_t
rt_spinlock_t
;
struct
rt_spinlock
{
rt_spinlock_t
lock
;
};
#endif
#ifdef RT_USING_CACHE
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录