diff mbox series

tests/tcg/multiarch: fix 32bit linux-test on 64bit host

Message ID 20181113175437.26492-1-laurent@vivier.eu
State New
Headers show
Series tests/tcg/multiarch: fix 32bit linux-test on 64bit host | expand

Commit Message

Laurent Vivier Nov. 13, 2018, 5:54 p.m. UTC
Fix:

  TEST    linux-test on i386
  .../tests/tcg/multiarch/linux-test.c:201: readdir

readdir() calls getdents64() to have the list of the entries in a
directory, and getdents64() can return 64bit d_off values (with ext4,
for instance) that will not fit in the 32bit d_off field of the
readdir() dirent structure.

To avoid that, use readdir64() to use a 64bit d_off field too.

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 tests/tcg/multiarch/linux-test.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Alex Bennée Nov. 14, 2018, 10:23 a.m. UTC | #1
Laurent Vivier <laurent@vivier.eu> writes:

> Fix:
>
>   TEST    linux-test on i386
>   .../tests/tcg/multiarch/linux-test.c:201: readdir
>
> readdir() calls getdents64() to have the list of the entries in a
> directory, and getdents64() can return 64bit d_off values (with ext4,
> for instance) that will not fit in the 32bit d_off field of the
> readdir() dirent structure.
>
> To avoid that, use readdir64() to use a 64bit d_off field too.
>
> Signed-off-by: Laurent Vivier <laurent@vivier.eu>

I guess the only remaining question is do we want to defend the other
case or just say it's not supported and all binaries are expected to use
modern-ish libcs with getdents64?

Anyway:

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

I'm preparing a pull-req with a travis patch, would you like me to
include this as well?


> ---
>  tests/tcg/multiarch/linux-test.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tests/tcg/multiarch/linux-test.c b/tests/tcg/multiarch/linux-test.c
> index e80eccc0ce..fa4243fc04 100644
> --- a/tests/tcg/multiarch/linux-test.c
> +++ b/tests/tcg/multiarch/linux-test.c
> @@ -83,7 +83,7 @@ static void test_file(void)
>      struct utimbuf tbuf;
>      struct iovec vecs[2];
>      DIR *dir;
> -    struct dirent *de;
> +    struct dirent64 *de;
>      /* TODO: make common tempdir creation for tcg tests */
>      char template[] = "/tmp/linux-test-XXXXXX";
>      char *tmpdir = mkdtemp(template);
> @@ -186,7 +186,7 @@ static void test_file(void)
>          error("opendir");
>      len = 0;
>      for(;;) {
> -        de = readdir(dir);
> +        de = readdir64(dir);
>          if (!de)
>              break;
>          if (strcmp(de->d_name, ".") != 0 &&


--
Alex Bennée
Laurent Vivier Nov. 14, 2018, 10:36 a.m. UTC | #2
On 14/11/2018 11:23, Alex Bennée wrote:
> 
> Laurent Vivier <laurent@vivier.eu> writes:
> 
>> Fix:
>>
>>   TEST    linux-test on i386
>>   .../tests/tcg/multiarch/linux-test.c:201: readdir
>>
>> readdir() calls getdents64() to have the list of the entries in a
>> directory, and getdents64() can return 64bit d_off values (with ext4,
>> for instance) that will not fit in the 32bit d_off field of the
>> readdir() dirent structure.
>>
>> To avoid that, use readdir64() to use a 64bit d_off field too.
>>
>> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
> 
> I guess the only remaining question is do we want to defend the other
> case or just say it's not supported and all binaries are expected to use
> modern-ish libcs with getdents64?

IMO, linux-test is only a smoke test to check basic behaviour of qemu
usermode. So it's not really important on what readdir() relies on.

On my side, I generally run full LTP test on x86_64 and ppc64 hosts with
several debian distros and ubuntu guests, so the other cases should be
tested at one point.

> Anyway:
> 
> Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
> 
> I'm preparing a pull-req with a travis patch, would you like me to
> include this as well?

Yes, please.

Thanks,
Laurent
diff mbox series

Patch

diff --git a/tests/tcg/multiarch/linux-test.c b/tests/tcg/multiarch/linux-test.c
index e80eccc0ce..fa4243fc04 100644
--- a/tests/tcg/multiarch/linux-test.c
+++ b/tests/tcg/multiarch/linux-test.c
@@ -83,7 +83,7 @@  static void test_file(void)
     struct utimbuf tbuf;
     struct iovec vecs[2];
     DIR *dir;
-    struct dirent *de;
+    struct dirent64 *de;
     /* TODO: make common tempdir creation for tcg tests */
     char template[] = "/tmp/linux-test-XXXXXX";
     char *tmpdir = mkdtemp(template);
@@ -186,7 +186,7 @@  static void test_file(void)
         error("opendir");
     len = 0;
     for(;;) {
-        de = readdir(dir);
+        de = readdir64(dir);
         if (!de)
             break;
         if (strcmp(de->d_name, ".") != 0 &&