From 911bb682835cde01efde41f102975afd8846bd28 Mon Sep 17 00:00:00 2001
From: Cyrill Gorcunov <gorcunov@openvz.org>
Date: Wed, 26 Aug 2015 17:15:00 +0300
Subject: [PATCH] test: mntns_deleted -- Add bindmount for regular files

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
---
 test/zdtm/live/static/mntns_deleted.c | 29 +++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/test/zdtm/live/static/mntns_deleted.c b/test/zdtm/live/static/mntns_deleted.c
index bd1a58b6dc..c6e24d85d0 100644
--- a/test/zdtm/live/static/mntns_deleted.c
+++ b/test/zdtm/live/static/mntns_deleted.c
@@ -29,9 +29,13 @@ TEST_OPTION(dirname, string, "directory name", 1);
 #define TEST_DIR_SRC	"test-src"
 #define TEST_DIR_DST	"test-dst"
 
+#define TEST_FILE_SRC	"mntns-deleted-src"
+#define TEST_FILE_DST	"mntns-deleted-dst"
+
 int main(int argc, char *argv[])
 {
 	char path_src[PATH_MAX], path_dst[PATH_MAX];
+	int fd1, fd2;
 
 	test_init(argc, argv);
 
@@ -51,22 +55,47 @@ int main(int argc, char *argv[])
 	rmdir(path_src);
 	rmdir(path_dst);
 
+	unlink(TEST_FILE_SRC);
+	unlink(TEST_FILE_DST);
+
 	if (mkdir(path_src, 0700) ||
 	    mkdir(path_dst, 0700)) {
 		err("mkdir");
 		return 1;
 	}
 
+	if ((fd1 = open(TEST_FILE_SRC, O_WRONLY | O_CREAT | O_TRUNC) < 0)) {
+		err("touching %s", TEST_FILE_SRC);
+		return 1;
+	}
+	close(fd1);
+
+	if ((fd2 = open(TEST_FILE_DST, O_WRONLY | O_CREAT | O_TRUNC) < 0)) {
+		err("touching %s", TEST_FILE_DST);
+		return 1;
+	}
+	close(fd2);
+
 	if (mount(path_src, path_dst, NULL, MS_BIND | MS_MGC_VAL, NULL)) {
 		err("mount %s -> %s", path_src, path_dst);
 		return 1;
 	}
 
+	if (mount(TEST_FILE_SRC, TEST_FILE_DST, NULL, MS_BIND | MS_MGC_VAL, NULL)) {
+		err("mount %s -> %s", TEST_FILE_SRC, TEST_FILE_DST);
+		return 1;
+	}
+
 	if (rmdir(path_src)) {
 		err("rmdir %s", path_src);
 		return 1;
 	}
 
+	if (unlink(TEST_FILE_SRC)) {
+		err("unlink %s", TEST_FILE_SRC);
+		return 1;
+	}
+
 	test_daemon();
 	test_waitsig();