Commit 47513625 authored by Andrei Vagin's avatar Andrei Vagin

zdtm: add a test to check O_TMPFILE

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.
...
Reviewed-by: 's avatarDmitry Safonov <0x7f454c46@gmail.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent f992f469
...@@ -307,6 +307,7 @@ TST_DIR = \ ...@@ -307,6 +307,7 @@ TST_DIR = \
cgroup_ifpriomap \ cgroup_ifpriomap \
cgroup_stray \ cgroup_stray \
unlink_fstat04 \ unlink_fstat04 \
unlink_fstat041 \
mntns_remap \ mntns_remap \
mntns_open \ mntns_open \
mntns_link_remap \ mntns_link_remap \
...@@ -489,6 +490,7 @@ mlock_setuid: get_smaps_bits.o ...@@ -489,6 +490,7 @@ mlock_setuid: get_smaps_bits.o
inotify01: CFLAGS += -DINOTIFY01 inotify01: CFLAGS += -DINOTIFY01
unlink_fstat01+: CFLAGS += -DUNLINK_OVER unlink_fstat01+: CFLAGS += -DUNLINK_OVER
unlink_fstat04: CFLAGS += -DUNLINK_FSTAT04 unlink_fstat04: CFLAGS += -DUNLINK_FSTAT04
unlink_fstat041: CFLAGS += -DUNLINK_FSTAT041 -DUNLINK_FSTAT04
ghost_holes01: CFLAGS += -DTAIL_HOLE ghost_holes01: CFLAGS += -DTAIL_HOLE
ghost_holes02: CFLAGS += -DHEAD_HOLE ghost_holes02: CFLAGS += -DHEAD_HOLE
sk-freebind-false: CFLAGS += -DZDTM_FREEBIND_FALSE sk-freebind-false: CFLAGS += -DZDTM_FREEBIND_FALSE
......
...@@ -40,7 +40,11 @@ int main(int argc, char ** argv) ...@@ -40,7 +40,11 @@ int main(int argc, char ** argv)
mkdir(dirname, 0700); mkdir(dirname, 0700);
#endif #endif
#ifndef UNLINK_FSTAT041
fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, 0644); fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, 0644);
#else
fd = open(dirname, O_RDWR | O_TMPFILE, 0644);
#endif
if (fd < 0) { if (fd < 0) {
pr_perror("can't open %s", filename); pr_perror("can't open %s", filename);
exit(1); exit(1);
...@@ -58,10 +62,12 @@ int main(int argc, char ** argv) ...@@ -58,10 +62,12 @@ int main(int argc, char ** argv)
goto failed; goto failed;
} }
#ifndef UNLINK_FSTAT041
if (unlink(filename) < 0) { if (unlink(filename) < 0) {
pr_perror("can't unlink %s", filename); pr_perror("can't unlink %s", filename);
goto failed; goto failed;
} }
#endif
/* Change file size */ /* Change file size */
if (fst.st_size != 0) { if (fst.st_size != 0) {
pr_perror("%s file size eq %ld", filename, (long)fst.st_size); pr_perror("%s file size eq %ld", filename, (long)fst.st_size);
......
unlink_fstat00.c
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment