1.1 --- a/tests/dstest_exec.cc Thu Jun 02 01:08:50 2022 +0200
1.2 +++ b/tests/dstest_exec.cc Thu Jun 02 01:09:30 2022 +0200
1.3 @@ -331,11 +331,9 @@
1.4
1.5 /* Obtain metadata from the file. */
1.6
1.7 - char buf[4096];
1.8 - offset_t nread;
1.9 + char *buf = (char *) client_mmap(file, 0, file->size, 0, 0, L4RE_DS_F_R);
1.10
1.11 - nread = client_read(file, buf, EI_NIDENT);
1.12 - if ((nread < EI_NIDENT) || memcmp(buf, "\x7f" "ELF", 4))
1.13 + if ((file->size < EI_NIDENT) || memcmp(buf, "\x7f" "ELF", 4))
1.14 {
1.15 printf("Not an ELF payload: %s\n", argv[1]);
1.16 return 1;
1.17 @@ -349,10 +347,7 @@
1.18 return 1;
1.19 }
1.20
1.21 - client_seek(file, 0, SEEK_SET);
1.22 - nread = client_read(file, buf, payload->header_extent());
1.23 -
1.24 - if (nread < payload->header_extent())
1.25 + if (file->size < payload->header_extent())
1.26 {
1.27 printf("Header incomplete.\n");
1.28 return 1;
1.29 @@ -360,10 +355,7 @@
1.30
1.31 printf("Program start: %lx\n", payload->entry_point());
1.32
1.33 - client_seek(file, 0, SEEK_SET);
1.34 - nread = client_read(file, buf, payload->program_header_extent());
1.35 -
1.36 - if (nread < payload->program_header_extent())
1.37 + if (file->size < payload->program_header_extent())
1.38 {
1.39 printf("Program headers incomplete.\n");
1.40 return 1;
1.41 @@ -410,16 +402,7 @@
1.42
1.43 if (segment->file_contents())
1.44 {
1.45 - flags_t flags;
1.46 -
1.47 - if ((segment->region_flags() & L4RE_RM_F_RW) == L4RE_RM_F_RW)
1.48 - flags = O_RDWR;
1.49 - else if (segment->region_flags() & L4RE_RM_F_W)
1.50 - flags = O_WRONLY;
1.51 - else
1.52 - flags = O_RDONLY;
1.53 -
1.54 - file_t *file = client_open(argv[1], flags);
1.55 + file_t *file = client_open(argv[1], file_opening_flags(segment->region_flags()));
1.56
1.57 if (file == NULL)
1.58 {