Commit c6908011 authored by Pavel Emelyanov's avatar Pavel Emelyanov

zdtm: Send two descriptors via unix socket

Reviewed-by: 's avatarKirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 00468aa8
...@@ -155,6 +155,7 @@ TST_NOFILE := \ ...@@ -155,6 +155,7 @@ TST_NOFILE := \
remap_dead_pid_root \ remap_dead_pid_root \
scm00 \ scm00 \
scm01 \ scm01 \
scm02 \
aio00 \ aio00 \
aio01 \ aio01 \
fd \ fd \
...@@ -441,6 +442,7 @@ mnt_ext_manual: CFLAGS += -D ZDTM_EXTMAP_MANUAL ...@@ -441,6 +442,7 @@ mnt_ext_manual: CFLAGS += -D ZDTM_EXTMAP_MANUAL
sigpending: LDLIBS += -lrt sigpending: LDLIBS += -lrt
vdso01: LDLIBS += -lrt vdso01: LDLIBS += -lrt
scm01: CFLAGS += -DKEEP_SENT_FD scm01: CFLAGS += -DKEEP_SENT_FD
scm02: CFLAGS += -DSEND_BOTH
mntns_link_remap: CFLAGS += -DZDTM_LINK_REMAP mntns_link_remap: CFLAGS += -DZDTM_LINK_REMAP
mntns_shared_bind02: CFLAGS += -DSHARED_BIND02 mntns_shared_bind02: CFLAGS += -DSHARED_BIND02
mntns_root_bind02: CFLAGS += -DROOT_BIND02 mntns_root_bind02: CFLAGS += -DROOT_BIND02
......
...@@ -91,12 +91,20 @@ int main(int argc, char **argv) ...@@ -91,12 +91,20 @@ int main(int argc, char **argv)
#ifndef KEEP_SENT_FD #ifndef KEEP_SENT_FD
close(p[0]); close(p[0]);
#ifdef SEND_BOTH
if (send_fd(sk[0], p[1]) < 0) {
pr_perror("Can't send 2nd descriptor");
exit(1);
}
close(p[1]);
p[0] = p[1] = -1;
#else
/* Swap pipe ends to make scm recv put pipe into different place */ /* Swap pipe ends to make scm recv put pipe into different place */
dup2(p[1], p[0]); dup2(p[1], p[0]);
close(p[1]); close(p[1]);
p[1] = p[0]; p[1] = p[0];
p[0] = -1; p[0] = -1;
#endif
#endif #endif
test_daemon(); test_daemon();
...@@ -107,6 +115,16 @@ int main(int argc, char **argv) ...@@ -107,6 +115,16 @@ int main(int argc, char **argv)
fail("Can't recv pipe back (%d)", p[0]); fail("Can't recv pipe back (%d)", p[0]);
goto out; goto out;
} }
#ifdef SEND_BOTH
test_msg("Recv 2nd end\n");
p[1] = recv_fd(sk[1]);
if (p[1] < 0) {
fail("Can't recv 2nd pipe back (%d)", p[1]);
goto out;
}
#endif
#ifdef KEEP_SENT_FD #ifdef KEEP_SENT_FD
if (rfd == p[0]) { if (rfd == p[0]) {
fail("Original descriptor not kept"); fail("Original descriptor not kept");
......
scm00.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