[CRIU] [PATCH 1/2] zdtm: add a test to check O_TMPFILE

Andrei Vagin avagin at openvz.org
Tue Feb 27 00:37:52 MSK 2018


[This sender failed our fraud detection checks and may not be who they appear to be. Learn about spoofing at http://aka.ms/LearnAboutSpoofing]

From: Andrei Vagin <avagin at virtuozzo.com>

man 2 open:
...
O_TMPFILE (since Linux 3.11)

Create  an unnamed temporary file.  The pathname argument speci‐ fies a
directory; an unnamed  inode  will  be  created  in  that directory's
filesystem.  Anything written to the resulting file will be lost when
the last file descriptor is closed, unless the file is given a name.
...

Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
---
 test/zdtm/static/Makefile          | 2 ++
 test/zdtm/static/unlink_fstat00.c  | 6 ++++++
 test/zdtm/static/unlink_fstat041.c | 1 +
 3 files changed, 9 insertions(+)
 create mode 120000 test/zdtm/static/unlink_fstat041.c

diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile
index fd333ee0b..ad8bc5bf2 100644
--- a/test/zdtm/static/Makefile
+++ b/test/zdtm/static/Makefile
@@ -317,6 +317,7 @@ TST_DIR             =                               \
                cgroup_ifpriomap                \
                cgroup_stray            \
                unlink_fstat04                  \
+               unlink_fstat041                 \
                mntns_remap                     \
                mntns_open                      \
                mntns_link_remap                \
@@ -497,6 +498,7 @@ mlock_setuid: get_smaps_bits.o
 inotify01:             CFLAGS += -DINOTIFY01
 unlink_fstat01+:       CFLAGS += -DUNLINK_OVER
 unlink_fstat04:                CFLAGS += -DUNLINK_FSTAT04
+unlink_fstat041:               CFLAGS += -DUNLINK_FSTAT041 -DUNLINK_FSTAT04
 ghost_holes01:         CFLAGS += -DTAIL_HOLE
 ghost_holes02:         CFLAGS += -DHEAD_HOLE
 sk-freebind-false:     CFLAGS += -DZDTM_FREEBIND_FALSE
diff --git a/test/zdtm/static/unlink_fstat00.c b/test/zdtm/static/unlink_fstat00.c
index 88a864776..faafb1b7f 100644
--- a/test/zdtm/static/unlink_fstat00.c
+++ b/test/zdtm/static/unlink_fstat00.c
@@ -40,7 +40,11 @@ int main(int argc, char ** argv)

        mkdir(dirname, 0700);
 #endif
+#ifndef UNLINK_FSTAT041
        fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, 0644);
+#else
+       fd = open(dirname, O_RDWR | O_TMPFILE, 0644);
+#endif
        if (fd < 0) {
                pr_perror("can't open %s", filename);
                exit(1);
@@ -58,10 +62,12 @@ int main(int argc, char ** argv)
                goto failed;
        }

+#ifndef UNLINK_FSTAT041
        if (unlink(filename) < 0) {
                pr_perror("can't unlink %s", filename);
                goto failed;
        }
+#endif
        /* Change file size */
        if (fst.st_size != 0) {
                pr_perror("%s file size eq %ld", filename, (long)fst.st_size);
diff --git a/test/zdtm/static/unlink_fstat041.c b/test/zdtm/static/unlink_fstat041.c
new file mode 120000
index 000000000..f51b3c63b
--- /dev/null
+++ b/test/zdtm/static/unlink_fstat041.c
@@ -0,0 +1 @@
+unlink_fstat00.c
\ No newline at end of file
--
2.13.6




More information about the CRIU mailing list