Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party NuttX
提交
104b11c7
T
Third Party NuttX
项目概览
OpenHarmony
/
Third Party NuttX
大约 1 年 前同步成功
通知
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,发现更多精彩内容 >>
提交
104b11c7
编写于
4月 28, 2021
作者:
O
openharmony_ci
提交者:
Gitee
4月 28, 2021
浏览文件
操作
浏览文件
下载
差异文件
!33 remove redundant code in fs
Merge pull request !33 from 野生毛霉君/master
上级
7380346f
03ca8e86
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
21 addition
and
180 deletion
+21
-180
fs/driver/fs_closeblockdriver.c
fs/driver/fs_closeblockdriver.c
+20
-21
fs/driver/fs_findblockdriver.c
fs/driver/fs_findblockdriver.c
+0
-59
fs/mount/fs_foreachmountpoint.c
fs/mount/fs_foreachmountpoint.c
+0
-99
fs/vfs/fs_truncate.c
fs/vfs/fs_truncate.c
+1
-1
未找到文件。
fs/driver/fs_closeblockdriver.c
浏览文件 @
104b11c7
...
...
@@ -67,28 +67,37 @@
int
close_blockdriver
(
struct
Vnode
*
vnode_ptr
)
{
#ifdef VFS_IMPL_LATER
int
ret
=
0
;
/* Assume success */
los_part
*
part
=
NULL
;
los_disk
*
disk
=
NULL
;
struct
block_operations
*
bop
=
NULL
;
/* Sanity checks */
if
(
!
vnode_ptr
||
!
vnode_ptr
->
u
.
i_bops
)
if
(
vnode_ptr
==
NULL
||
vnode_ptr
->
data
==
NULL
)
{
ret
=
-
EINVAL
;
goto
errout
;
}
bop
=
(
struct
block_operations
*
)(((
struct
drv_data
*
)
vnode_ptr
->
data
)
->
ops
);
if
(
bop
==
NULL
)
{
PRINT_ERR
(
"vnode ops is null, not a valid block driver
\n
"
);
ret
=
-
EINVAL
;
goto
errout
;
}
/* Verify that the vnode is a block driver. */
if
(
!
INODE_IS_BLOCK
(
vnode_ptr
)
)
if
(
vnode_ptr
->
type
!=
VNODE_TYPE_BLK
)
{
fdbg
(
"vnode is not a block driver
\n
"
);
PRINT_ERR
(
"vnode is not a block driver
\n
"
);
ret
=
-
ENOTBLK
;
goto
errout
;
}
part
=
los_part_find
(
vnode_ptr
);
if
(
part
!=
NULL
)
{
...
...
@@ -96,15 +105,15 @@ int close_blockdriver(struct Vnode *vnode_ptr)
if
(
disk
==
NULL
)
{
ret
=
-
EINVAL
;
goto
errout
_with_vnode
;
goto
errout
;
}
if
(
pthread_mutex_lock
(
&
disk
->
disk_mutex
)
!=
ENOERR
)
{
PRINT_ERR
(
"%s %d, mutex lock fail!
\n
"
,
__FUNCTION__
,
__LINE__
);
vnode_release
(
vnode_ptr
);
return
-
1
;
return
-
EAGAIN
;
}
if
(
disk
->
disk_status
==
STAT_INUSED
)
{
/* Close the block driver. Not that no mutually exclusive access
...
...
@@ -112,36 +121,26 @@ int close_blockdriver(struct Vnode *vnode_ptr)
* if needed.
*/
if
(
vnode_ptr
->
u
.
i_bops
->
close
!=
NULL
)
if
(
bop
->
close
!=
NULL
)
{
ret
=
vnode_ptr
->
u
.
i_bops
->
close
(
vnode_ptr
);
ret
=
bop
->
close
(
vnode_ptr
);
}
}
if
(
pthread_mutex_unlock
(
&
disk
->
disk_mutex
)
!=
ENOERR
)
{
PRINT_ERR
(
"%s %d, mutex unlock fail!
\n
"
,
__FUNCTION__
,
__LINE__
);
vnode_release
(
vnode_ptr
);
return
-
1
;
}
}
else
{
if
(
(
vnode_ptr
->
i_flags
&
FSNODEFLAG_DELETED
)
==
0
&&
vnode_ptr
->
u
.
i_bops
->
close
!=
NULL
)
if
(
bop
->
close
!=
NULL
)
{
ret
=
vnode_ptr
->
u
.
i_bops
->
close
(
vnode_ptr
);
ret
=
bop
->
close
(
vnode_ptr
);
}
}
errout_with_vnode:
/* Then release the reference on the vnode */
vnode_release
(
vnode_ptr
);
errout:
return
ret
;
#endif
return
0
;
}
fs/driver/fs_findblockdriver.c
浏览文件 @
104b11c7
...
...
@@ -115,62 +115,3 @@ errout:
VnodeDrop
();
return
ret
;
}
#ifdef VFS_IMPL_LATER
int
find_blockdriver
(
FAR
const
char
*
pathname
,
int
mountflags
,
FAR
struct
inode
**
ppinode
)
{
FAR
struct
inode
*
inode_ptr
=
NULL
;
int
ret
=
0
;
/* Assume success */
struct
inode_search_s
desc
;
/* Sanity checks */
#ifdef CONFIG_DEBUG
if
(
pathname
==
NULL
||
ppinode
==
NULL
)
{
ret
=
-
EINVAL
;
goto
errout
;
}
#endif
/* Find the inode registered with this pathname */
SETUP_SEARCH
(
&
desc
,
pathname
,
false
);
ret
=
inode_find
(
&
desc
);
if
(
ret
<
0
)
{
ret
=
-
EACCES
;
goto
errout
;
}
/* Get the search results */
inode_ptr
=
desc
.
node
;
/* Verify that the inode is a block driver. */
if
(
!
INODE_IS_BLOCK
(
inode_ptr
))
{
fdbg
(
"%s is not a block driver
\n
"
,
pathname
);
ret
=
-
ENOTBLK
;
goto
errout_with_inode
;
}
/* Make sure that the inode supports the requested access */
if
(
inode_ptr
->
u
.
i_bops
==
NULL
||
inode_ptr
->
u
.
i_bops
->
read
==
NULL
||
(
inode_ptr
->
u
.
i_bops
->
write
==
NULL
&&
(
mountflags
&
MS_RDONLY
)
==
0
))
{
fdbg
(
"%s does not support requested access
\n
"
,
pathname
);
ret
=
-
EACCES
;
goto
errout_with_inode
;
}
*
ppinode
=
inode_ptr
;
return
OK
;
errout_with_inode:
inode_release
(
inode_ptr
);
errout:
return
ret
;
}
#endif
fs/mount/fs_foreachmountpoint.c
浏览文件 @
104b11c7
...
...
@@ -36,110 +36,11 @@
/****************************************************************************
* Included Files
****************************************************************************/
#include "vfs_config.h"
#include "sys/statfs.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "assert.h"
#include "errno.h"
#include "fs/fs.h"
#include "fs/vnode.h"
#include "limits.h"
#ifndef CONFIG_DISABLE_MOUNTPOINT
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/* This structure just remembers the final consumer of the mountpoint
* information (and its argument).
*/
struct
enum_mountpoint_s
{
foreach_mountpoint_t
handler
;
void
*
arg
;
};
/****************************************************************************
* Private Functions
****************************************************************************/
#ifdef VFS_IMPL_LATER
static
int
mountpoint_filter
(
struct
Vnode
*
node
,
char
dirpath
[
PATH_MAX
],
void
*
arg
)
{
struct
enum_mountpoint_s
*
info
=
(
struct
enum_mountpoint_s
*
)
arg
;
struct
statfs
statbuf
;
int
pathlen
;
int
namlen
;
int
ret
=
OK
;
DEBUGASSERT
(
node
&&
info
&&
info
->
handler
);
/* Check if the vnode is a mountpoint. Mountpoints must support statfs.
* If this one does not for some reason, then it will be ignored.
*
* The root node is a special case: It has no operations (u.i_mops == NULL)
*/
if
(
INODE_IS_MOUNTPT
(
node
)
&&
node
->
u
.
i_mops
&&
node
->
u
.
i_mops
->
statfs
)
{
/* Yes... get the full path to the vnode by concatenating the vnode
* name and the path to the directory containing the vnode.
*/
pathlen
=
strlen
(
dirpath
);
namlen
=
strlen
(
node
->
i_name
)
+
1
;
/* Make sure that this would not exceed the maximum path length */
if
(
pathlen
+
namlen
>=
PATH_MAX
)
{
return
-
ENAMETOOLONG
;
}
/* Append the vnode name to the directory path */
ret
=
snprintf_s
(
&
dirpath
[
pathlen
],
PATH_MAX
-
pathlen
,
PATH_MAX
-
pathlen
-
1
,
"/%s"
,
node
->
i_name
);
if
(
ret
<
0
)
{
return
-
ENAMETOOLONG
;
}
/* Get the status of the file system */
ret
=
node
->
u
.
i_mops
->
statfs
(
node
,
&
statbuf
);
if
(
ret
==
OK
)
{
/* And pass the full path and file system status to the handler */
if
(
strlen
(
dirpath
)
>
1
)
{
dirpath
[
strlen
(
dirpath
)
-
1
]
=
'\0'
;
}
ret
=
info
->
handler
(
dirpath
,
&
statbuf
,
info
->
arg
);
}
/* Truncate the path name back to the correct length */
dirpath
[
pathlen
]
=
'\0'
;
}
return
ret
;
}
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
...
...
fs/vfs/fs_truncate.c
浏览文件 @
104b11c7
...
...
@@ -78,7 +78,7 @@ static int file_truncate(struct file *filep, off_t length)
vnode
=
filep
->
f_vnode
;
if
(
!
vnode
||
!
vnode
->
vop
||
!
vnode
->
vop
->
Truncate
)
{
err
=
E
BADF
;
err
=
E
NOSYS
;
goto
errout
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录