Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/checkpoint-restore/criu.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@parallels.com>2015-02-12 20:22:23 +0300
committerPavel Emelyanov <xemul@parallels.com>2015-02-13 15:11:38 +0300
commitba66b14b9a4ac7db06a2541b13c6b1d5169108ae (patch)
treee116ca1f65a96a86726039834da350df6fb03d36
parent364979159f1453b5ab5790d72e4957198f258faf (diff)
packet: Get packet_sock_mmap test work in userns
The test uses map_files dir to check for mapping being restored, while this proc directory is only available for CAP_SYS_ADMIN. Fix this by checking less strict /proc/pid/maps. Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
-rwxr-xr-xtest/zdtm.sh1
-rw-r--r--test/zdtm/live/static/packet_sock_mmap.c32
2 files changed, 16 insertions, 17 deletions
diff --git a/test/zdtm.sh b/test/zdtm.sh
index 2d0e8e8ab..77ba3463b 100755
--- a/test/zdtm.sh
+++ b/test/zdtm.sh
@@ -251,7 +251,6 @@ generate_test_list()
ns/static/mlock_setuid
ns/static/sched_prio00
ns/static/sched_policy00
- ns/static/packet_sock_mmap
ns/static/fanotify00
ns/static/fifo-ghost
ns/static/unlink_fifo
diff --git a/test/zdtm/live/static/packet_sock_mmap.c b/test/zdtm/live/static/packet_sock_mmap.c
index 265d61348..28912adca 100644
--- a/test/zdtm/live/static/packet_sock_mmap.c
+++ b/test/zdtm/live/static/packet_sock_mmap.c
@@ -34,24 +34,24 @@ struct tpacket_req3 {
static void check_map_is_there(unsigned long addr, int sk)
{
- char name[128];
- struct stat sk_s, link_s;
-
- sprintf(name, "/proc/self/map_files/%lx-%lx",
- addr, addr + 2 * 4096);
-
- if (stat(name, &link_s) < 0) {
- fail("No socket mapping\n");
- return;
- }
-
- fstat(sk, &sk_s);
- if ((sk_s.st_dev != link_s.st_dev) || (sk_s.st_ino != link_s.st_ino)) {
- fail("Non-socket mapping restored\n");
- return;
+ FILE *f;
+ char line[64];
+ struct stat ss;
+
+ fstat(sk, &ss);
+ f = fopen("/proc/self/maps", "r");
+ while (fgets(line, sizeof(line), f) != NULL) {
+ unsigned long start;
+ int maj, min, ino;
+
+ sscanf(line, "%lx-%*x %*s %*s %x:%x %d %*s", &start, &maj, &min, &ino);
+ if ((start == addr) && ss.st_dev == makedev(maj, min) && ss.st_ino == ino) {
+ pass();
+ return;
+ }
}
- pass();
+ fail("No socket mapping found");
}
int main(int argc, char **argv)