Merge pull request !543 from wcc/fs
This commit is contained in:
openharmony_ci 2021-08-27 07:47:34 +00:00 committed by Gitee
commit a3b480b18e
11 changed files with 127 additions and 17 deletions

View File

@ -502,6 +502,30 @@ int SysExecve(const char *fileName, char *const *argv, char *const *envp)
}
#endif
int SysFchdir(int fd)
{
int ret;
int sysFd;
struct file *file = NULL;
sysFd = GetAssociatedSystemFd(fd);
if (sysFd < 0) {
return -EBADF;
}
ret = fs_getfilep(sysFd, &file);
if (ret < 0) {
return -get_errno();
}
ret = chdir(file->f_path);
if (ret < 0) {
ret = -get_errno();
}
return ret;
}
int SysChdir(const char *path)
{
int ret;

View File

@ -231,6 +231,7 @@ extern int SysSymlinkat(const char *target, int dirfd, const char *linkpath);
extern ssize_t SysReadlinkat(int dirfd, const char *pathname, char *buf, size_t bufsize);
extern int SysUnlink( const char *pathname);
extern int SysExecve(const char *fileName, char *const *argv, char *const *envp);
extern int SysFchdir(int fd);
extern int SysChdir(const char *path);
extern int SysUtimensat(int fd, const char *path, struct timespec times[2], int flag);
extern int SysFchmodat(int fd, const char *path, mode_t mode, int flag);

View File

@ -47,6 +47,7 @@ SYSCALL_HAND_DEF(__NR_execve, SysExecve, int, ARG_NUM_3)
#endif
SYSCALL_HAND_DEF(__NR_sysinfo, SysInfo, int, ARG_NUM_1)
SYSCALL_HAND_DEF(__NR_fchdir, SysFchdir, int, ARG_NUM_1)
SYSCALL_HAND_DEF(__NR_chdir, SysChdir, int, ARG_NUM_1)
SYSCALL_HAND_DEF(__NR_utimensat, SysUtimensat, int, ARG_NUM_4)
SYSCALL_HAND_DEF(__NR_fchmodat, SysFchmodat, int, ARG_NUM_4)

View File

@ -211,8 +211,11 @@ sources_full = [
"jffs/full/it_test_fs_jffs_002.cpp",
"jffs/full/it_test_fs_jffs_003.cpp",
"jffs/full/it_test_fs_jffs_004.cpp",
"jffs/full/it_test_fs_jffs_102.cpp",
"jffs/full/it_test_fs_jffs_103.cpp",
"jffs/full/it_test_fs_jffs_100.cpp",
"jffs/full/it_test_fs_jffs_101.cpp",
"jffs/full/it_test_fs_jffs_106.cpp",
"jffs/full/it_test_fs_jffs_112.cpp",
"jffs/full/it_test_fs_jffs_113.cpp",
"jffs/full/It_jffs_001.cpp",
"jffs/full/It_jffs_002.cpp",
"jffs/full/It_jffs_003.cpp",

View File

@ -271,8 +271,13 @@ void ItTestFsJffs001(void);
void ItTestFsJffs002(void);
void ItTestFsJffs003(void);
void ItTestFsJffs004(void);
void ItTestFsJffs100(void);
void ItTestFsJffs101(void);
void ItTestFsJffs102(void);
void ItTestFsJffs103(void);
void ItTestFsJffs106(void);
void ItTestFsJffs112(void);
void ItTestFsJffs113(void);
VOID ItJffs001(VOID);
VOID ItJffs002(VOID);
VOID ItJffs003(VOID);

View File

@ -28,7 +28,7 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_fs_jffs.h"
#include "It_vfs_jffs.h"
static int TestCase(void)
{

View File

@ -28,7 +28,7 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_fs_jffs.h"
#include "It_vfs_jffs.h"
#define TEST_STRLEN 30
@ -56,6 +56,16 @@ static int TestCase(void)
fd = open(pathname2, O_DIRECTORY);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
/* EBADF */
ret = fchdir(-1);
ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
ret = errno;
ICUNIT_GOTO_EQUAL(ret, EBADF, ret, EXIT1);
ret = chdir(pathname);
ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
pret = getcwd(buf1, TEST_STRLEN);
ICUNIT_GOTO_NOT_EQUAL(pret, NULL, pret, EXIT1);
ICUNIT_GOTO_STRING_EQUAL(buf1, pathname, buf1, EXIT1);

View File

@ -28,7 +28,7 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_fs_jffs.h"
#include "It_vfs_jffs.h"
#define TEST_STR "abcdefghijk"
@ -41,20 +41,30 @@ static int TestCase(void)
CHAR buf[JFFS_STANDARD_NAME_LENGTH] = TEST_STR;
CHAR str[JFFS_STANDARD_NAME_LENGTH] = "";
FILE *ptr = NULL;
fd = open(pathname1, O_CREAT | O_RDWR, 0777);
fd = open(pathname1, O_CREAT, 0777);
ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT);
len = write(fd, buf, JFFS_STANDARD_NAME_LENGTH);
ICUNIT_GOTO_NOT_EQUAL(len, -1, len, EXIT);
ret = close(fd);
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT1);
ptr = freopen(pathname1, "rb", stdin);
ptr = freopen(pathname1, "w+", stdin);
ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT1);
ret = scanf_s("%s", JFFS_STANDARD_NAME_LENGTH, str);
ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT1);
ret = strcmp(buf, str);
ret = fwrite(buf, JFFS_STANDARD_NAME_LENGTH, 1, ptr);
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT1);
ret = fclose(ptr);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
fclose(ptr);
fd = open(pathname1, O_RDWR, 0777);
ret = read(fd, str, JFFS_STANDARD_NAME_LENGTH);
ret = close(fd);
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT1);
ret = strcmp(buf, str);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
ret = unlink(pathname1);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);

View File

@ -28,7 +28,7 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_fs_jffs.h"
#include "It_vfs_jffs.h"
static int TestCase(void)
{

View File

@ -28,15 +28,15 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_fs_jffs.h"
#include "It_vfs_jffs.h"
#include <pthread.h>
static FILE *g_filep;
#define NUM 64
#define COUNT 10
void *DoChild()
void *DoChild(void *)
{
int fd = 0;
int ret, count;
char buf[NUM];

View File

@ -1043,6 +1043,28 @@ HWTEST_F(VfsJffsTest, ItTestFsJffs004, TestSize.Level0)
ItTestFsJffs004();
}
/* *
* @tc.name: ItTestFsJffs100
* @tc.desc: function for VfsJffsTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F(VfsJffsTest, ItTestFsJffs100, TestSize.Level0)
{
ItTestFsJffs100();
}
/* *
* @tc.name: ItTestFsJffs101
* @tc.desc: function for VfsJffsTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F(VfsJffsTest, ItTestFsJffs101, TestSize.Level0)
{
ItTestFsJffs101();
}
/* *
* @tc.name: ItTestFsJffs102
* @tc.desc: function for VfsJffsTest
@ -1064,6 +1086,40 @@ HWTEST_F(VfsJffsTest, ItTestFsJffs103, TestSize.Level0)
{
ItTestFsJffs103();
}
/* *
* @tc.name: ItTestFsJffs106
* @tc.desc: function for VfsJffsTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F(VfsJffsTest, ItTestFsJffs106, TestSize.Level0)
{
ItTestFsJffs106();
}
/* *
* @tc.name: ItTestFsJffs112
* @tc.desc: function for VfsJffsTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F(VfsJffsTest, ItTestFsJffs112, TestSize.Level0)
{
ItTestFsJffs112();
}
/* *
* @tc.name: ItTestFsJffs113
* @tc.desc: function for VfsJffsTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F(VfsJffsTest, ItTestFsJffs113, TestSize.Level0)
{
ItTestFsJffs113();
}
/* *
* @tc.name: IT_JFFS_002
* @tc.desc: function for VfsJffsTest