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

Submitted by Andrei Vagin on Feb. 26, 2018, 9:37 p.m.

Details

Message ID 20180226213753.29529-1-avagin@openvz.org
State New
Series "Series without cover letter"
Headers show

Commit Message

Andrei Vagin Feb. 26, 2018, 9:37 p.m.
[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@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@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

--
2.13.6

Patch hide | download patch | download mbox

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

Comments

Dmitry Safonov Feb. 27, 2018, 12:59 p.m.
2018-02-26 21:37 GMT+00:00 Andrei Vagin <avagin@openvz.org>:
> [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@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@virtuozzo.com>

For both two patches:
Reviewed-by: Dmitry Safonov <0x7f454c46@gmail.com>