Skip to contentSkip to conversation

nfs01_open_files: Fix pattern for deleted files

PATCH In review Petr Vorel 2 participants 4 messages Mar 11, 2022

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

PATCH 1/1 nfs01_open_files: Fix pattern for deleted files

Fixes 0989fe65f3 ("Corrected the export lines in nfs01 ...")
---
 testcases/network/nfs/nfs_stress/nfs01_open_files.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
testcases/network/nfs/nfs_stress/nfs01_open_files.c +3 -2
index 9342f11ba9..c5627058dc 100644
@@ -10,7 +10,8 @@
 #include <sys/stat.h>
 #include <unistd.h>
 
-#define TEMPLATE "ltpXXXXXX"
+#define TEMPLATE_PREFIX "ltp"
+#define TEMPLATE TEMPLATE_PREFIX "XXXXXX"
 
 int write_something(int);
 void delete_files(void);
@@ -101,7 +102,7 @@ void delete_files(void)
 
 	dirp = opendir(".");
 	for (entp = readdir(dirp); entp; entp = readdir(dirp))
-		if (!strncmp(entp->d_name, "apt", 3)) {
+		if (!strncmp(entp->d_name, TEMPLATE_PREFIX, 3)) {
 			if (stat(entp->d_name, &stat_buffer))
 				abortx("stat() failed for \"%s\", errno = %d",
 				       entp->d_name, errno);
Signature · 5 lines
2.35.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#1 lore raw
Quoted 1 line
Fixes 0989fe65f3 ("Corrected the export lines in nfs01 ...")

commit 0989fe65f306 in 2001 changed the names of created files from apt to ltp, but didn't change the names of deleted files.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 1/1
#2 lore raw
In reply to Petr Vorel

Hi!

Quoted 21 lines
---
 testcases/network/nfs/nfs_stress/nfs01_open_files.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
testcases/network/nfs/nfs_stress/nfs01_open_files.c +2 -1
index 9342f11ba9..c5627058dc 100644
@@ -10,7 +10,8 @@
 #include <sys/stat.h>
 #include <unistd.h>
 
-#define TEMPLATE "ltpXXXXXX"
+#define TEMPLATE_PREFIX "ltp"
+#define TEMPLATE TEMPLATE_PREFIX "XXXXXX"
 
 int write_something(int);
 void delete_files(void);

testcases/network/nfs/nfs_stress/nfs01_open_files.c void delete_files(void) · line 105

Quoted 5 lines
testcases/network/nfs/nfs_stress/nfs01_open_files.c +1 -1
@@ -101,7 +102,7 @@ void delete_files(void)
 
 	dirp = opendir(".");
 	for (entp = readdir(dirp); entp; entp = readdir(dirp))
-		if (!strncmp(entp->d_name, "apt", 3)) {
+		if (!strncmp(entp->d_name, TEMPLATE_PREFIX, 3)) {

Maybe we should also do:

#define TEMPLATE_PREFIX_LEN (sizeof(TEMPLATE_PREFIX) - 1)

And use TEMPLATE_PREFIX_LEN instead of the hardcoded 3

Otherwise it looks obviously correct:

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#3 lore raw

Hi Cyril,

...

Quoted 5 lines

Maybe we should also do:

#define TEMPLATE_PREFIX_LEN (sizeof(TEMPLATE_PREFIX) - 1)

And use TEMPLATE_PREFIX_LEN instead of the hardcoded 3

+1, thanks, merged with this change.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp