Skip to contentSkip to conversation

syscalls/mkdir01, 03: Cleanup && Convert to new API

PATCH New Xu 3 participants 4 messages Apr 19, 2018

lore
Share & tools
lore

Xu

#0 lore raw

PATCH 2/5 syscalls/mkdir01, 03: Cleanup && Convert to new API

Quoted 3 lines

Hi!
The mkdir03 was rewritten meanwhile by Sandeep Patil, sorry for not reviewing your patch sooner. I've pushed the part of this patch that removes mkdir01 since the case is covered by the mkdir03 already, thanks.

Hi
I know mkdir03 has been written by Sandeep Patil, but this patch applies tst_get_bad_addr function to mkdir03 and simplifies the test.

Thanks
Yang Xu

Quoted 3 lines

--
Cyril Hrubis
[email protected]

#1 lore raw

PATCH 2/5 syscalls/mkdir01, 03: Cleanup && Convert to new API

Hi!

Quoted 2 lines

I know mkdir03 has been written by Sandeep Patil, but this patch applies tst_get_bad_addr function to mkdir03 and simplifies the test.

Feel free to send a patch to fixes that for the mkdir03.

I was simply trying to explain that the original patch does not apply because we got conflicting patch accepted meanwhile, sorry for the trouble...

Signature · 2 lines
Cyril Hrubis
[email protected]
#2 lore raw

PATCH 1/1 syscalls/mkdir03: Use tst_get_bad_addr()

1) Remove useless struct member

---
 testcases/kernel/syscalls/mkdir/mkdir03.c | 32 ++++++++++++-------------------
 1 file changed, 12 insertions(+), 20 deletions(-)
testcases/kernel/syscalls/mkdir/mkdir03.c +12 -20
index 5d7f1e1..9441afe 100644
@@ -46,20 +46,18 @@ static char long_dir[PATH_MAX + 2] = {[0 ... PATH_MAX + 1] = 'a'};
 static char loop_dir[PATH_MAX] = ".";
 
 struct tcase;
-static void prot_none_pathname(struct tcase *tc);
 
 static struct tcase {
 	char *pathname;
 	int exp_errno;
-	void (*setupfunc)(struct tcase *tc);
 } TC[] = {
-	{NULL, EFAULT, prot_none_pathname},
-	{long_dir, ENAMETOOLONG, NULL},
-	{TST_EEXIST, EEXIST, NULL},
-	{TST_ENOENT, ENOENT, NULL},
-	{TST_ENOTDIR_DIR, ENOTDIR, NULL},
-	{loop_dir, ELOOP, NULL},
-	{TST_EROFS, EROFS, NULL},
+	{NULL, EFAULT},
+	{long_dir, ENAMETOOLONG},
+	{TST_EEXIST, EEXIST},
+	{TST_ENOENT, ENOENT},
+	{TST_ENOTDIR_DIR, ENOTDIR},
+	{loop_dir, ELOOP},
+	{TST_EROFS, EROFS},
 };
 
 static void verify_mkdir(unsigned int n)
@@ -82,12 +80,6 @@ static void verify_mkdir(unsigned int n)
 	}
 }
 
-static void prot_none_pathname(struct tcase *tc)
-{
-	tc->pathname = SAFE_MMAP(0, 1, PROT_NONE,
-		MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
-}
-
 static void setup(void)
 {
 	unsigned int i;
@@ -95,15 +87,15 @@ static void setup(void)
 	SAFE_TOUCH(TST_EEXIST, MODE, NULL);
 	SAFE_TOUCH(TST_ENOTDIR_FILE, MODE, NULL);
 
+	for (i = 0; i < ARRAY_SIZE(TC); i++) {
+		if (TC[i].exp_errno == EFAULT)
+			TC[i].pathname = tst_get_bad_addr(NULL);
+	}
+
 	SAFE_MKDIR("test_eloop", DIR_MODE);
 	SAFE_SYMLINK("../test_eloop", "test_eloop/test_eloop");
 	for (i = 0; i < 43; i++)
 		strcat(loop_dir, "/test_eloop");
-
-	for (i = 0; i < ARRAY_SIZE(TC); i++) {
-		if (TC[i].setupfunc)
-			TC[i].setupfunc(&TC[i]);
-	}
 }
 
 static struct tst_test test = {
Signature · 1 line
1.8.3.1