Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Kernel Liteos M
提交
044cf595
K
Kernel Liteos M
项目概览
OpenHarmony
/
Kernel Liteos M
大约 1 年 前同步成功
通知
20
Star
28
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel Liteos M
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
044cf595
编写于
9月 22, 2022
作者:
O
openharmony_ci
提交者:
Gitee
9月 22, 2022
浏览文件
操作
浏览文件
下载
差异文件
!825 M核用例编译问题修复, 内核补充fcntl
Merge pull request !825 from wangchen/0917_m
上级
3398937b
0adbafb9
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
129 addition
and
32 deletion
+129
-32
components/fs/vfs/los_fs.h
components/fs/vfs/los_fs.h
+4
-0
components/fs/vfs/vfs_fs.c
components/fs/vfs/vfs_fs.c
+24
-14
kal/libc/musl/fs.c
kal/libc/musl/fs.c
+31
-0
kal/libc/newlib/porting/src/fs.c
kal/libc/newlib/porting/src/fs.c
+25
-4
testsuites/unittest/posix/src/fs/posix_fs_func_test.c
testsuites/unittest/posix/src/fs/posix_fs_func_test.c
+44
-14
testsuites/unittest/posix/src/string/strstr_test.c
testsuites/unittest/posix/src/string/strstr_test.c
+1
-0
未找到文件。
components/fs/vfs/los_fs.h
浏览文件 @
044cf595
...
...
@@ -44,6 +44,7 @@
#include "sys/stat.h"
#include "sys/uio.h"
#include "unistd.h"
#include <stdarg.h>
#ifdef __cplusplus
#if __cplusplus
...
...
@@ -83,6 +84,9 @@ int LOS_FsMount(const char *source, const char *target,
const
char
*
fsType
,
unsigned
long
mountflags
,
const
void
*
data
);
int
OsFcntl
(
int
fd
,
int
cmd
,
va_list
ap
);
int
OsIoctl
(
int
fd
,
int
req
,
va_list
ap
);
struct
PartitionCfg
{
/* partition low-level read func */
int
(
*
readFunc
)(
int
partition
,
UINT32
*
offset
,
void
*
buf
,
UINT32
size
);
...
...
components/fs/vfs/vfs_fs.c
浏览文件 @
044cf595
...
...
@@ -582,17 +582,13 @@ static int VfsRename(const char *old, const char *new)
return
ret
;
}
static
int
VfsIoctl
(
int
fd
,
int
func
,
...
)
static
int
VfsIoctl
(
int
fd
,
int
func
,
va_list
ap
)
{
va_list
ap
;
unsigned
long
arg
;
struct
File
*
file
=
NULL
;
int
ret
=
(
int
)
LOS_NOK
;
va_start
(
ap
,
func
);
arg
=
va_arg
(
ap
,
unsigned
long
);
va_end
(
ap
);
file
=
VfsAttachFileReady
(
fd
);
if
(
file
==
NULL
)
{
return
ret
;
...
...
@@ -1143,12 +1139,10 @@ int LOS_Fstat(int fd, struct stat *buf)
return
ret
;
}
int
LOS_Fcntl
(
int
fd
,
int
cmd
,
...
)
int
OsFcntl
(
int
fd
,
int
cmd
,
va_list
ap
)
{
struct
File
*
filep
=
NULL
;
va_list
ap
;
int
ret
;
va_start
(
ap
,
cmd
);
if
(
fd
<
CONFIG_NFILE_DESCRIPTORS
)
{
filep
=
VfsAttachFileReady
(
fd
);
...
...
@@ -1159,13 +1153,10 @@ int LOS_Fcntl(int fd, int cmd, ...)
#ifdef LOSCFG_NET_LWIP_SACK
int
arg
=
va_arg
(
ap
,
int
);
ret
=
lwip_fcntl
(
fd
,
(
long
)
cmd
,
arg
);
va_end
(
ap
);
return
ret
;
#endif
/* LOSCFG_NET_LWIP_SACK */
}
va_end
(
ap
);
if
(
ret
<
0
)
{
VFS_ERRNO_SET
(
-
ret
);
ret
=
(
int
)
LOS_NOK
;
...
...
@@ -1173,11 +1164,21 @@ int LOS_Fcntl(int fd, int cmd, ...)
return
ret
;
}
int
LOS_
Ioctl
(
int
fd
,
int
req
,
...)
int
LOS_
Fcntl
(
int
fd
,
int
cmd
,
...)
{
int
ret
;
va_list
ap
;
va_start
(
ap
,
req
);
int
ret
;
va_start
(
ap
,
cmd
);
ret
=
OsFcntl
(
fd
,
cmd
,
ap
);
va_end
(
ap
);
return
ret
;
}
int
OsIoctl
(
int
fd
,
int
req
,
va_list
ap
)
{
int
ret
;
if
(
fd
<
CONFIG_NFILE_DESCRIPTORS
)
{
ret
=
VfsIoctl
(
fd
,
req
,
ap
);
}
else
{
...
...
@@ -1188,6 +1189,15 @@ int LOS_Ioctl(int fd, int req, ...)
#endif
/* LOSCFG_NET_LWIP_SACK */
}
return
ret
;
}
int
LOS_Ioctl
(
int
fd
,
int
req
,
...)
{
int
ret
;
va_list
ap
;
va_start
(
ap
,
req
);
ret
=
OsIoctl
(
fd
,
req
,
ap
);
va_end
(
ap
);
return
ret
;
}
...
...
kal/libc/musl/fs.c
浏览文件 @
044cf595
...
...
@@ -176,6 +176,28 @@ int access(const char *path, int mode)
return
0
;
}
int
fcntl
(
int
fd
,
int
cmd
,
...)
{
int
ret
;
va_list
vaList
;
va_start
(
vaList
,
cmd
);
ret
=
OsFcntl
(
fd
,
cmd
,
vaList
);
va_end
(
vaList
);
return
ret
;
}
int
ioctl
(
int
fd
,
int
req
,
...)
{
int
ret
;
va_list
vaList
;
va_start
(
vaList
,
req
);
ret
=
OsIoctl
(
fd
,
req
,
vaList
);
va_end
(
vaList
);
return
ret
;
}
#else
/* #ifdef LOSCFG_FS_VFS */
int
mount
(
const
char
*
source
,
const
char
*
target
,
...
...
@@ -295,4 +317,13 @@ int access(const char *path, int mode)
return
-
1
;
}
int
fcntl
(
int
fd
,
int
cmd
,
...)
{
return
-
1
;
}
int
ioctl
(
int
fd
,
int
req
,
...)
{
return
-
1
;
}
#endif
kal/libc/newlib/porting/src/fs.c
浏览文件 @
044cf595
...
...
@@ -148,13 +148,25 @@ int ftruncate(int fd, off_t length)
return
LOS_Ftruncate
(
fd
,
length
);
}
int
fcntl
(
int
fd
,
int
cmd
,
...)
{
int
ret
;
va_list
vaList
;
va_start
(
vaList
,
cmd
);
ret
=
OsFcntl
(
fd
,
cmd
,
vaList
);
va_end
(
vaList
);
return
ret
;
}
int
ioctl
(
int
fd
,
int
req
,
...)
{
va_list
ap
;
va_start
(
ap
,
req
);
int
ret
;
ret
=
LOS_Ioctl
(
fd
,
req
,
ap
);
va_end
(
ap
);
va_list
vaList
;
va_start
(
vaList
,
req
);
ret
=
OsIoctl
(
fd
,
req
,
vaList
);
va_end
(
vaList
);
return
ret
;
}
...
...
@@ -247,4 +259,13 @@ int remove(const char *filename)
return
-
1
;
}
int
fcntl
(
int
fd
,
int
cmd
,
...)
{
return
-
1
;
}
int
ioctl
(
int
fd
,
int
req
,
...)
{
return
-
1
;
}
#endif
testsuites/unittest/posix/src/fs/posix_fs_func_test.c
浏览文件 @
044cf595
...
...
@@ -90,6 +90,7 @@ static BOOL PosixFsFuncTestSuiteTearDown(void)
return
TRUE
;
}
#if (LOSCFG_LIBC_MUSL == 1)
/* *
* @tc.number SUB_KERNEL_FS_DIRNAME_001
* @tc.name dirname basic function test
...
...
@@ -162,6 +163,7 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsDirname004, Function | MediumTest | L
TEST_ASSERT_EQUAL_STRING
(
"."
,
workDir
);
return
0
;
}
#endif
/* *
* @tc.number SUB_KERNEL_FS_FOPEN_FCLOSE_001
...
...
@@ -1443,7 +1445,7 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsUnlink001, Function | MediumTest | Le
char
tmpFileName
[]
=
FILE1
;
fd
=
open
(
tmpFileName
,
O_CREAT
|
O_RDWR
,
0777
);
TEST_ASSERT_TRUE
(
ret
!=
-
1
);
TEST_ASSERT_TRUE
(
fd
!=
-
1
);
(
void
)
close
(
fd
);
...
...
@@ -1454,7 +1456,7 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsUnlink001, Function | MediumTest | Le
/* *
* @tc.number SUB_KERNEL_FS_STAT_001
* @tc.name
unlink
* @tc.name
stat
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE
(
PosixFsFuncTestSuite
,
testFsStat001
,
Function
|
MediumTest
|
Level1
)
...
...
@@ -1466,7 +1468,7 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsStat001, Function | MediumTest | Leve
remove
(
FILE1
);
fd
=
open
(
tmpFileName
,
O_CREAT
|
O_RDWR
,
0777
);
TEST_ASSERT_TRUE
(
ret
!=
-
1
);
TEST_ASSERT_TRUE
(
fd
!=
-
1
);
(
void
)
close
(
fd
);
...
...
@@ -1477,7 +1479,7 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsStat001, Function | MediumTest | Leve
/* *
* @tc.number SUB_KERNEL_FS_STAT_002
* @tc.name
unlink
* @tc.name
stat
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE
(
PosixFsFuncTestSuite
,
testFsStat002
,
Function
|
MediumTest
|
Level1
)
...
...
@@ -1491,7 +1493,7 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsStat002, Function | MediumTest | Leve
remove
(
FILE1
);
fd
=
open
(
tmpFileName
,
O_CREAT
|
O_RDWR
,
0777
);
TEST_ASSERT_TRUE
(
ret
!=
-
1
);
TEST_ASSERT_TRUE
(
fd
!=
-
1
);
size
=
write
(
fd
,
writeBuf
,
sizeof
(
writeBuf
));
TEST_ASSERT_TRUE
(
ret
!=
-
1
);
...
...
@@ -1507,7 +1509,7 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsStat002, Function | MediumTest | Leve
/* *
* @tc.number SUB_KERNEL_FS_STAT_003
* @tc.name
unlink
* @tc.name
stat
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE
(
PosixFsFuncTestSuite
,
testFsStat003
,
Function
|
MediumTest
|
Level1
)
...
...
@@ -1521,7 +1523,7 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsStat003, Function | MediumTest | Leve
(
void
)
memset_s
(
&
buf
,
sizeof
(
buf
),
0
,
sizeof
(
buf
));
fd
=
open
(
tmpFileName
,
O_CREAT
|
O_RDWR
,
0777
);
TEST_ASSERT_TRUE
(
ret
!=
-
1
);
TEST_ASSERT_TRUE
(
fd
!=
-
1
);
size
=
write
(
fd
,
writeBuf
,
sizeof
(
writeBuf
));
TEST_ASSERT_TRUE
(
ret
!=
-
1
);
...
...
@@ -1541,7 +1543,7 @@ extern off_t lseek(int fd, off_t offset, int whence);
/* *
* @tc.number SUB_KERNEL_FS_WRITE_001
* @tc.name
unlink
* @tc.name
write
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE
(
PosixFsFuncTestSuite
,
testFsWrite001
,
Function
|
MediumTest
|
Level1
)
...
...
@@ -1557,7 +1559,7 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsWrite001, Function | MediumTest | Lev
}
fd
=
open
(
tmpFileName
,
O_CREAT
|
O_RDWR
,
0777
);
TEST_ASSERT_TRUE
(
ret
!=
-
1
);
TEST_ASSERT_TRUE
(
fd
!=
-
1
);
ret
=
write
(
fd
,
writeBuf
,
TEST_RW_SIZE
);
TEST_ASSERT_TRUE
(
ret
!=
-
1
);
...
...
@@ -1577,7 +1579,7 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsWrite001, Function | MediumTest | Lev
/* *
* @tc.number SUB_KERNEL_FS_WRITE_002
* @tc.name
unlink
* @tc.name
write
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE
(
PosixFsFuncTestSuite
,
testFsWrite002
,
Function
|
MediumTest
|
Level1
)
...
...
@@ -1591,7 +1593,7 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsWrite002, Function | MediumTest | Lev
remove
(
FILE1
);
fd
=
open
(
tmpFileName
,
O_CREAT
|
O_RDWR
,
0777
);
TEST_ASSERT_TRUE
(
ret
!=
-
1
);
TEST_ASSERT_TRUE
(
fd
!=
-
1
);
for
(
i
=
0
;
i
<
TEST_LOOPUP_TIME
;
i
++
)
{
ret
=
write
(
fd
,
writeBuf
,
sizeof
(
writeBuf
));
...
...
@@ -1607,6 +1609,34 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsWrite002, Function | MediumTest | Lev
return
0
;
}
#if (LOSCFG_LIBC_MUSL == 1)
/* *
* @tc.number SUB_KERNEL_FS_FCNTL_001
* @tc.name fcntl
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE
(
PosixFsFuncTestSuite
,
testFsFcntl001
,
Function
|
MediumTest
|
Level1
)
{
int
fd
=
0
;
int
flags
=
0
;
char
tmpFileName
[]
=
FILE1
;
fd
=
open
(
tmpFileName
,
O_CREAT
|
O_RDWR
,
0777
);
TEST_ASSERT_TRUE
(
fd
!=
-
1
);
flags
=
fcntl
(
fd
,
F_GETFL
);
TEST_ASSERT_TRUE
(
flags
==
O_CREAT
|
O_RDWR
);
fcntl
(
fd
,
F_SETFL
,
flags
|
O_APPEND
);
flags
=
fcntl
(
fd
,
F_GETFL
);
TEST_ASSERT_TRUE
(
flags
==
O_CREAT
|
O_RDWR
|
O_APPEND
);
(
void
)
close
(
fd
);
return
0
;
}
#endif
RUN_TEST_SUITE
(
PosixFsFuncTestSuite
);
void
PosixFsFuncTest
()
...
...
@@ -1621,12 +1651,13 @@ void PosixFsFuncTest()
RUN_ONE_TESTCASE
(
testFsWrite001
);
RUN_ONE_TESTCASE
(
testFsWrite002
);
#if (LOSCFG_LIBC_MUSL == 1)
RUN_ONE_TESTCASE
(
testFsDirname001
);
RUN_ONE_TESTCASE
(
testFsDirname002
);
RUN_ONE_TESTCASE
(
testFsDirname003
);
RUN_ONE_TESTCASE
(
testFsDirname004
);
RUN_ONE_TESTCASE
(
testFsFcntl001
);
#endif
RUN_ONE_TESTCASE
(
testFsReaddir001
);
RUN_ONE_TESTCASE
(
testFsReaddir002
);
...
...
@@ -1688,6 +1719,5 @@ void PosixFsFuncTest()
RUN_ONE_TESTCASE
(
testFsFreadFwrite007
);
RUN_ONE_TESTCASE
(
testFsFreadFwrite008
);
RUN_ONE_TESTCASE
(
testFsFreadFwrite009
);
return
;
}
testsuites/unittest/posix/src/string/strstr_test.c
浏览文件 @
044cf595
...
...
@@ -31,6 +31,7 @@
#include "ohos_types.h"
#include "posix_test.h"
#include "log.h"
#include "los_config.h"
#include "kernel_test.h"
#include <ctype.h>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录