[CRIU] [PATCH 3/3] test: rmdir_open -- Delete two levels of directories

Cyrill Gorcunov gorcunov at openvz.org
Fri Nov 18 06:51:24 PST 2016


One level always been handled properly but
two levels may cause problems.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 test/zdtm/static/rmdir_open.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/test/zdtm/static/rmdir_open.c b/test/zdtm/static/rmdir_open.c
index a4fb5b0f20e4..279aa78988e4 100644
--- a/test/zdtm/static/rmdir_open.c
+++ b/test/zdtm/static/rmdir_open.c
@@ -4,6 +4,7 @@
 #include <sys/stat.h>
 #include <string.h>
 #include <fcntl.h>
+#include <limits.h>
 
 #include "zdtmtst.h"
 
@@ -15,23 +16,25 @@ TEST_OPTION(dirname, string, "directory name", 1);
 
 int main(int argc, char **argv)
 {
+	char subdir[PATH_MAX];
 	int fd;
 	struct stat st;
 
 	test_init(argc, argv);
 
-	if (mkdir(dirname, 0700)) {
+	sprintf(subdir, "%s/subdir", dirname);
+	if (mkdir(dirname, 0700) || mkdir(subdir, 0700)) {
 		pr_perror("Can't make dir");
 		goto out;
 	}
 
-	fd = open(dirname, O_DIRECTORY);
+	fd = open(subdir, O_DIRECTORY);
 	if (fd < 0) {
 		pr_perror("Can't open dir");
 		goto outr;
 	}
 
-	if (rmdir(dirname)) {
+	if (rmdir(subdir) || rmdir(dirname)) {
 		pr_perror("Can't remove dir");
 		goto outr;
 	}
-- 
2.7.4



More information about the CRIU mailing list