Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Kernel Liteos A
提交
7b7d64cc
K
Kernel Liteos A
项目概览
OpenHarmony
/
Kernel Liteos A
8 个月 前同步成功
通知
450
Star
414
Fork
55
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
4
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel Liteos A
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
4
Issue
4
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
7b7d64cc
编写于
7月 20, 2021
作者:
O
openharmony_ci
提交者:
Gitee
7月 20, 2021
浏览文件
操作
浏览文件
下载
差异文件
!404 mount接口支持MS_RDONLY flag
Merge pull request !404 from Far/master
上级
70c18b4a
8729f6ee
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
333 addition
and
8 deletion
+333
-8
fs/fat/os_adapt/fatfs.c
fs/fat/os_adapt/fatfs.c
+15
-2
fs/jffs2/src/vfs_jffs2.c
fs/jffs2/src/vfs_jffs2.c
+1
-1
fs/vfs/operation/fs_chattr.c
fs/vfs/operation/fs_chattr.c
+7
-0
fs/vfs/operation/fs_utime.c
fs/vfs/operation/fs_utime.c
+8
-0
kernel/common/los_rootfs.c
kernel/common/los_rootfs.c
+14
-5
testsuites/unittest/fs/BUILD.gn
testsuites/unittest/fs/BUILD.gn
+3
-0
testsuites/unittest/fs/jffs/It_vfs_jffs.h
testsuites/unittest/fs/jffs/It_vfs_jffs.h
+3
-0
testsuites/unittest/fs/jffs/full/It_vfs_test_mount_rdonly_001.cpp
...es/unittest/fs/jffs/full/It_vfs_test_mount_rdonly_001.cpp
+93
-0
testsuites/unittest/fs/jffs/full/It_vfs_test_mount_rdonly_002.cpp
...es/unittest/fs/jffs/full/It_vfs_test_mount_rdonly_002.cpp
+79
-0
testsuites/unittest/fs/jffs/full/It_vfs_test_mount_rdonly_003.cpp
...es/unittest/fs/jffs/full/It_vfs_test_mount_rdonly_003.cpp
+95
-0
testsuites/unittest/fs/jffs/vfs_jffs_test.cpp
testsuites/unittest/fs/jffs/vfs_jffs_test.cpp
+15
-0
未找到文件。
fs/fat/os_adapt/fatfs.c
浏览文件 @
7b7d64cc
...
...
@@ -46,6 +46,7 @@
#include "los_tables.h"
#include "user_copy.h"
#include "los_vm_filemap.h"
#include "los_hash.h"
#include <time.h>
#include <errno.h>
#include <dirent.h>
...
...
@@ -53,7 +54,7 @@
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include
"los_hash.h"
#include
<fcntl.h>
struct
VnodeOps
fatfs_vops
;
/* forward define */
...
...
@@ -190,7 +191,7 @@ static int fatfs_sync(unsigned long mountflags, FATFS *fs)
{
#ifdef LOSCFG_FS_FAT_CACHE
los_part
*
part
=
NULL
;
if
(
mountflags
!=
MS_NOSYNC
)
{
if
(
!
(
mountflags
&
(
MS_NOSYNC
|
MS_RDONLY
))
)
{
part
=
get_part
((
INT
)
fs
->
pdrv
);
if
(
part
==
NULL
)
{
return
-
ENODEV
;
...
...
@@ -736,6 +737,7 @@ off64_t fatfs_lseek64(struct file *filep, off64_t offset, int whence)
struct
Vnode
*
vp
=
filep
->
f_vnode
;
DIR_FILE
*
dfp
=
(
DIR_FILE
*
)
vp
->
data
;
FILINFO
*
finfo
=
&
(
dfp
->
fno
);
struct
Mount
*
mount
=
vp
->
originMount
;
FSIZE_t
fpos
;
FRESULT
result
;
int
ret
;
...
...
@@ -773,6 +775,17 @@ off64_t fatfs_lseek64(struct file *filep, off64_t offset, int whence)
if
(
ret
==
FALSE
)
{
return
-
EBUSY
;
}
if
(
fpos
>
finfo
->
fsize
)
{
if
((
filep
->
f_oflags
&
O_ACCMODE
)
==
O_RDONLY
)
{
result
=
FR_DENIED
;
goto
ERROR_EXIT
;
}
if
(
mount
->
mountFlags
&
MS_RDONLY
)
{
result
=
FR_WRITE_PROTECTED
;
goto
ERROR_EXIT
;
}
}
fp
->
obj
.
sclust
=
finfo
->
sclst
;
fp
->
obj
.
objsize
=
finfo
->
fsize
;
...
...
fs/jffs2/src/vfs_jffs2.c
浏览文件 @
7b7d64cc
...
...
@@ -123,7 +123,7 @@ int VfsJffs2Bind(struct Mount *mnt, struct Vnode *blkDriver, const void *data)
partNo
=
p
->
patitionnum
;
ret
=
jffs2_mount
(
partNo
,
&
rootNode
);
ret
=
jffs2_mount
(
partNo
,
&
rootNode
,
mnt
->
mountFlags
);
if
(
ret
!=
0
)
{
LOS_MuxUnlock
(
&
g_jffs2FsLock
);
return
ret
;
...
...
fs/vfs/operation/fs_chattr.c
浏览文件 @
7b7d64cc
...
...
@@ -41,6 +41,8 @@
#include "stdlib.h"
#include "sys/stat.h"
#include "vnode.h"
#include "fs/mount.h"
#include <fcntl.h>
/****************************************************************************
* Static Functions
...
...
@@ -69,6 +71,11 @@ int chattr(const char *pathname, struct IATTR *attr)
goto
errout_with_lock
;
}
if
((
vnode
->
originMount
)
&&
(
vnode
->
originMount
->
mountFlags
&
MS_RDONLY
))
{
ret
=
-
EROFS
;
goto
errout_with_lock
;
}
/* The way we handle the stat depends on the type of vnode that we
* are dealing with.
*/
...
...
fs/vfs/operation/fs_utime.c
浏览文件 @
7b7d64cc
...
...
@@ -37,9 +37,11 @@
#include "vfs_config.h"
#include "sys/stat.h"
#include "vnode.h"
#include "fs/mount.h"
#include "string.h"
#include "stdlib.h"
#include "utime.h"
#include <fcntl.h>
/****************************************************************************
* Global Functions
...
...
@@ -79,6 +81,12 @@ int utime(const char *path, const struct utimbuf *ptimes)
goto
errout_with_path
;
}
if
((
vnode
->
originMount
)
&&
(
vnode
->
originMount
->
mountFlags
&
MS_RDONLY
))
{
VnodeDrop
();
ret
=
-
EROFS
;
goto
errout_with_path
;
}
if
(
vnode
->
vop
&&
vnode
->
vop
->
Chattr
)
{
if
(
ptimes
==
NULL
)
{
/* get current seconds */
...
...
kernel/common/los_rootfs.c
浏览文件 @
7b7d64cc
...
...
@@ -156,10 +156,11 @@ STATIC INT32 AddPartitions(CHAR *dev, UINT64 rootAddr, UINT64 rootSize, UINT64 u
}
STATIC
INT32
ParseRootArgs
(
CHAR
**
dev
,
CHAR
**
fstype
,
UINT64
*
rootAddr
,
UINT64
*
rootSize
)
{
STATIC
INT32
ParseRootArgs
(
CHAR
**
dev
,
CHAR
**
fstype
,
UINT64
*
rootAddr
,
UINT64
*
rootSize
,
UINT32
*
mountFlags
)
{
INT32
ret
;
CHAR
*
rootAddrStr
;
CHAR
*
rootSizeStr
;
CHAR
*
rwTag
;
ret
=
LOS_GetArgValue
(
"root"
,
dev
);
if
(
ret
!=
LOS_OK
)
{
...
...
@@ -186,6 +187,13 @@ STATIC INT32 ParseRootArgs(CHAR **dev, CHAR **fstype, UINT64 *rootAddr, UINT64 *
}
else
{
*
rootSize
=
LOS_SizeStrToNum
(
rootSizeStr
);
}
ret
=
LOS_GetArgValue
(
"ro"
,
&
rwTag
);
if
(
ret
==
LOS_OK
)
{
*
mountFlags
=
MS_RDONLY
;
}
else
{
*
mountFlags
=
0
;
}
return
LOS_OK
;
}
...
...
@@ -212,12 +220,12 @@ STATIC INT32 ParseUserArgs(UINT64 rootAddr, UINT64 rootSize, UINT64 *userAddr, U
return
LOS_OK
;
}
STATIC
INT32
MountPartitions
(
CHAR
*
fsType
)
{
STATIC
INT32
MountPartitions
(
CHAR
*
fsType
,
UINT32
mountFlags
)
{
INT32
ret
;
INT32
err
;
/* Mount rootfs */
ret
=
mount
(
ROOT_DEV_NAME
,
ROOT_DIR_NAME
,
fsType
,
MS_RDONLY
,
NULL
);
ret
=
mount
(
ROOT_DEV_NAME
,
ROOT_DIR_NAME
,
fsType
,
mountFlags
,
NULL
);
if
(
ret
!=
LOS_OK
)
{
err
=
get_errno
();
PRINT_ERR
(
"Failed to mount %s, rootDev %s, errno %d: %s
\n
"
,
ROOT_DIR_NAME
,
ROOT_DEV_NAME
,
err
,
strerror
(
err
));
...
...
@@ -291,8 +299,9 @@ INT32 OsMountRootfs() {
UINT64
rootSize
;
UINT64
userAddr
;
UINT64
userSize
;
UINT32
mountFlags
;
ret
=
ParseRootArgs
(
&
dev
,
&
fstype
,
&
rootAddr
,
&
rootSize
);
ret
=
ParseRootArgs
(
&
dev
,
&
fstype
,
&
rootAddr
,
&
rootSize
,
&
mountFlags
);
if
(
ret
!=
LOS_OK
)
{
return
ret
;
}
...
...
@@ -312,7 +321,7 @@ INT32 OsMountRootfs() {
return
ret
;
}
ret
=
MountPartitions
(
fstype
);
ret
=
MountPartitions
(
fstype
,
mountFlags
);
if
(
ret
!=
LOS_OK
)
{
return
ret
;
}
...
...
testsuites/unittest/fs/BUILD.gn
浏览文件 @
7b7d64cc
...
...
@@ -790,6 +790,9 @@ sources_full = [
"jffs/full/It_vfs_test_symlink_002.cpp",
"jffs/full/It_vfs_test_symlink_003.cpp",
"jffs/full/It_vfs_test_symlinkat_001.cpp",
"jffs/full/It_vfs_test_mount_rdonly_001.cpp",
"jffs/full/It_vfs_test_mount_rdonly_002.cpp",
"jffs/full/It_vfs_test_mount_rdonly_003.cpp",
]
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
...
...
testsuites/unittest/fs/jffs/It_vfs_jffs.h
浏览文件 @
7b7d64cc
...
...
@@ -962,6 +962,9 @@ VOID ItFsTestSymlink001(VOID);
VOID
ItFsTestSymlink002
(
VOID
);
VOID
ItFsTestSymlink003
(
VOID
);
VOID
ItFsTestSymlinkat001
(
VOID
);
VOID
ItFsTestMountRdonly001
(
VOID
);
VOID
ItFsTestMountRdonly002
(
VOID
);
VOID
ItFsTestMountRdonly003
(
VOID
);
#endif
#if defined(LOSCFG_USER_TESTSUIT_SHELL)
...
...
testsuites/unittest/fs/jffs/full/It_vfs_test_mount_rdonly_001.cpp
0 → 100644
浏览文件 @
7b7d64cc
/*
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
static
UINT32
testcase
(
VOID
)
{
INT32
fd
=
-
1
;
INT32
ret
;
CHAR
pathname1
[
JFFS_STANDARD_NAME_LENGTH
]
=
{
JFFS_PATH_NAME0
};
CHAR
pathname2
[
JFFS_STANDARD_NAME_LENGTH
]
=
{
JFFS_PATH_NAME01
};
fd
=
creat
(
pathname1
,
0777
);
ICUNIT_GOTO_NOT_EQUAL
(
fd
,
JFFS_IS_ERROR
,
fd
,
EXIT
);
ret
=
close
(
fd
);
ICUNIT_GOTO_EQUAL
(
ret
,
JFFS_NO_ERROR
,
ret
,
EXIT4
);
ret
=
umount
(
JFFS_MAIN_DIR0
);
ICUNIT_GOTO_NOT_EQUAL
(
ret
,
JFFS_IS_ERROR
,
ret
,
EXIT3
);
ret
=
mount
(
JFFS_DEV_PATH0
,
JFFS_MAIN_DIR0
,
JFFS_FILESYS_TYPE
,
MS_RDONLY
,
NULL
);
ICUNIT_GOTO_NOT_EQUAL
(
ret
,
JFFS_IS_ERROR
,
ret
,
EXIT2
);
fd
=
open
(
pathname1
,
O_RDWR
);
ICUNIT_GOTO_EQUAL
(
fd
,
JFFS_IS_ERROR
,
fd
,
EXIT4
);
ret
=
symlink
(
pathname1
,
pathname2
);
ICUNIT_GOTO_EQUAL
(
ret
,
JFFS_IS_ERROR
,
ret
,
EXIT5
);
ret
=
rename
(
pathname1
,
pathname2
);
ICUNIT_GOTO_EQUAL
(
ret
,
JFFS_IS_ERROR
,
ret
,
EXIT5
);
ret
=
unlink
(
pathname1
);
ICUNIT_GOTO_EQUAL
(
ret
,
JFFS_IS_ERROR
,
ret
,
EXIT3
);
ret
=
umount
(
JFFS_MAIN_DIR0
);
ICUNIT_GOTO_NOT_EQUAL
(
ret
,
JFFS_IS_ERROR
,
ret
,
EXIT3
);
ret
=
mount
(
JFFS_DEV_PATH0
,
JFFS_MAIN_DIR0
,
JFFS_FILESYS_TYPE
,
0
,
NULL
);
ICUNIT_GOTO_NOT_EQUAL
(
ret
,
JFFS_IS_ERROR
,
ret
,
EXIT2
);
ret
=
unlink
(
pathname1
);
ICUNIT_GOTO_NOT_EQUAL
(
ret
,
JFFS_IS_ERROR
,
ret
,
EXIT1
);
return
JFFS_NO_ERROR
;
EXIT5:
unlink
(
pathname2
);
goto
EXIT3
;
EXIT4:
close
(
fd
);
EXIT3:
umount
(
JFFS_MAIN_DIR0
);
EXIT2:
mount
(
JFFS_DEV_PATH0
,
JFFS_MAIN_DIR0
,
JFFS_FILESYS_TYPE
,
0
,
NULL
);
EXIT1:
unlink
(
pathname1
);
EXIT:
return
JFFS_NO_ERROR
;
}
VOID
ItFsTestMountRdonly001
(
VOID
)
{
TEST_ADD_CASE
(
"IT_FS_TEST_MOUNT_RDONLY_001"
,
testcase
,
TEST_VFS
,
TEST_JFFS
,
TEST_LEVEL0
,
TEST_FUNCTION
);
}
\ No newline at end of file
testsuites/unittest/fs/jffs/full/It_vfs_test_mount_rdonly_002.cpp
0 → 100644
浏览文件 @
7b7d64cc
/*
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
static
UINT32
testcase
(
VOID
)
{
INT32
fd
=
-
1
;
INT32
ret
;
CHAR
pathname1
[
JFFS_STANDARD_NAME_LENGTH
]
=
{
JFFS_PATH_NAME0
};
ret
=
umount
(
JFFS_MAIN_DIR0
);
ICUNIT_GOTO_NOT_EQUAL
(
ret
,
JFFS_IS_ERROR
,
ret
,
EXIT
);
ret
=
mount
(
JFFS_DEV_PATH0
,
JFFS_MAIN_DIR0
,
JFFS_FILESYS_TYPE
,
MS_RDONLY
,
NULL
);
ICUNIT_GOTO_NOT_EQUAL
(
ret
,
JFFS_IS_ERROR
,
ret
,
EXIT1
);
fd
=
creat
(
pathname1
,
0755
);
ICUNIT_GOTO_EQUAL
(
fd
,
JFFS_IS_ERROR
,
fd
,
EXIT3
);
fd
=
open
(
pathname1
,
O_CREAT
|
O_RDONLY
,
0755
);
ICUNIT_GOTO_EQUAL
(
fd
,
JFFS_IS_ERROR
,
fd
,
EXIT3
);
fd
=
open
(
pathname1
,
O_CREAT
|
O_RDWR
,
0755
);
ICUNIT_GOTO_EQUAL
(
fd
,
JFFS_IS_ERROR
,
fd
,
EXIT3
);
ret
=
mkdir
(
pathname1
,
0755
);
ICUNIT_GOTO_EQUAL
(
ret
,
JFFS_IS_ERROR
,
ret
,
EXIT2
);
ret
=
umount
(
JFFS_MAIN_DIR0
);
ICUNIT_GOTO_NOT_EQUAL
(
ret
,
JFFS_IS_ERROR
,
ret
,
EXIT1
);
ret
=
mount
(
JFFS_DEV_PATH0
,
JFFS_MAIN_DIR0
,
JFFS_FILESYS_TYPE
,
0
,
NULL
);
ICUNIT_GOTO_NOT_EQUAL
(
ret
,
JFFS_IS_ERROR
,
ret
,
EXIT1
);
return
JFFS_NO_ERROR
;
EXIT3:
close
(
fd
);
EXIT2:
remove
(
pathname1
);
EXIT1:
umount
(
JFFS_MAIN_DIR0
);
mount
(
JFFS_DEV_PATH0
,
JFFS_MAIN_DIR0
,
JFFS_FILESYS_TYPE
,
0
,
NULL
);
EXIT:
return
JFFS_NO_ERROR
;
}
VOID
ItFsTestMountRdonly002
(
VOID
)
{
TEST_ADD_CASE
(
"IT_FS_TEST_MOUNT_RDONLY_002"
,
testcase
,
TEST_VFS
,
TEST_JFFS
,
TEST_LEVEL0
,
TEST_FUNCTION
);
}
\ No newline at end of file
testsuites/unittest/fs/jffs/full/It_vfs_test_mount_rdonly_003.cpp
0 → 100644
浏览文件 @
7b7d64cc
/*
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_vfs_jffs.h"
static
UINT32
testcase
(
VOID
)
{
INT32
fd
=
-
1
;
INT32
ret
;
CHAR
readbuf
[
JFFS_STANDARD_NAME_LENGTH
]
=
{
0
};
const
CHAR
writebuf
[
JFFS_STANDARD_NAME_LENGTH
]
=
"0123456789"
;
CHAR
pathname1
[
JFFS_STANDARD_NAME_LENGTH
]
=
{
JFFS_PATH_NAME0
};
fd
=
creat
(
pathname1
,
0777
);
ICUNIT_GOTO_NOT_EQUAL
(
fd
,
JFFS_IS_ERROR
,
fd
,
EXIT
);
ret
=
write
(
fd
,
writebuf
,
strlen
(
writebuf
));
ICUNIT_GOTO_EQUAL
(
ret
,
strlen
(
writebuf
),
ret
,
EXIT4
);
ret
=
close
(
fd
);
ICUNIT_GOTO_EQUAL
(
ret
,
JFFS_NO_ERROR
,
ret
,
EXIT4
);
ret
=
umount
(
JFFS_MAIN_DIR0
);
ICUNIT_GOTO_NOT_EQUAL
(
ret
,
JFFS_IS_ERROR
,
ret
,
EXIT3
);
ret
=
mount
(
JFFS_DEV_PATH0
,
JFFS_MAIN_DIR0
,
JFFS_FILESYS_TYPE
,
MS_RDONLY
,
NULL
);
ICUNIT_GOTO_NOT_EQUAL
(
ret
,
JFFS_IS_ERROR
,
ret
,
EXIT2
);
fd
=
open
(
pathname1
,
O_RDWR
);
ICUNIT_GOTO_EQUAL
(
fd
,
JFFS_IS_ERROR
,
fd
,
EXIT4
);
fd
=
open
(
pathname1
,
O_RDONLY
);
ICUNIT_GOTO_NOT_EQUAL
(
fd
,
JFFS_IS_ERROR
,
fd
,
EXIT4
);
ret
=
read
(
fd
,
readbuf
,
strlen
(
writebuf
));
ICUNIT_GOTO_EQUAL
(
ret
,
strlen
(
writebuf
),
ret
,
EXIT4
);
ICUNIT_GOTO_STRING_EQUAL
(
readbuf
,
writebuf
,
readbuf
,
EXIT4
);
ret
=
close
(
fd
);
ICUNIT_GOTO_NOT_EQUAL
(
ret
,
JFFS_IS_ERROR
,
ret
,
EXIT4
);
ret
=
umount
(
JFFS_MAIN_DIR0
);
ICUNIT_GOTO_NOT_EQUAL
(
ret
,
JFFS_IS_ERROR
,
ret
,
EXIT3
);
ret
=
mount
(
JFFS_DEV_PATH0
,
JFFS_MAIN_DIR0
,
JFFS_FILESYS_TYPE
,
0
,
NULL
);
ICUNIT_GOTO_NOT_EQUAL
(
ret
,
JFFS_IS_ERROR
,
ret
,
EXIT2
);
ret
=
unlink
(
pathname1
);
ICUNIT_GOTO_NOT_EQUAL
(
ret
,
JFFS_IS_ERROR
,
ret
,
EXIT1
);
return
JFFS_NO_ERROR
;
EXIT4:
close
(
fd
);
EXIT3:
umount
(
JFFS_MAIN_DIR0
);
EXIT2:
mount
(
JFFS_DEV_PATH0
,
JFFS_MAIN_DIR0
,
JFFS_FILESYS_TYPE
,
0
,
NULL
);
EXIT1:
unlink
(
pathname1
);
EXIT:
return
JFFS_NO_ERROR
;
}
VOID
ItFsTestMountRdonly003
(
VOID
)
{
TEST_ADD_CASE
(
"IT_FS_TEST_MOUNT_RDONLY_003"
,
testcase
,
TEST_VFS
,
TEST_JFFS
,
TEST_LEVEL0
,
TEST_FUNCTION
);
}
\ No newline at end of file
testsuites/unittest/fs/jffs/vfs_jffs_test.cpp
浏览文件 @
7b7d64cc
...
...
@@ -6885,6 +6885,21 @@ HWTEST_F(VfsJffsTest, ItFsTestSymlinkat001, TestSize.Level0)
ItFsTestSymlinkat001
();
}
HWTEST_F
(
VfsJffsTest
,
ItFsTestMountRdonly001
,
TestSize
.
Level0
)
{
ItFsTestMountRdonly001
();
}
HWTEST_F
(
VfsJffsTest
,
ItFsTestMountRdonly002
,
TestSize
.
Level0
)
{
ItFsTestMountRdonly002
();
}
HWTEST_F
(
VfsJffsTest
,
ItFsTestMountRdonly003
,
TestSize
.
Level0
)
{
ItFsTestMountRdonly003
();
}
#endif
#if defined(LOSCFG_USER_TEST_SMOKE)
/* *
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录