qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] pwrite64 error because of argument position


From: Alex Barcelo
Subject: [Qemu-devel] pwrite64 error because of argument position
Date: Sun, 30 Sep 2012 20:50:28 +0200

This error may be a PPC specific problem, but I don't have another
environment where I can test it (i386 doesn't seem to use pwrite64),
so I ask for a bit of help/check.

I am in a 32bit linux testing the qemu-ppc.

My test program:

// -------------------------------
#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int main (void) {
    int fd, len;

    char* asd = "This is a random test";
    char asd2[20];

    fd = open ("./test.pwrite", O_RDWR | O_CREAT);

    printf ( "fd: %d\n", fd);
    pwrite ( fd, asd, 15, 0 );
    pwrite ( fd, asd+5, 6, 10);
    pwrite ( fd, asd, 4, 30);

    len = pread ( fd, asd2, 5, 5);
    asd2[len]='\0';     
    printf ( "Read %d bytes: %s", len, asd2);

    // This is to force two int arguments for 64bit
    //len = pread ( fd, asd2, -1, -1);
    close(fd);
    return 0;
}
// -------------------------------

Then I do
$ powerpc-linux-gnu-gcc -g --static -o pwrite-alien pwrite-test.c

and when I launch a qemu-ppc to test, it should be (on the file)
This is a is a rThis

instead I get:
This rs a randorThis

and if I print some debug information inside pwrite64 and pread64 I see:
syscall: pwrite arg_i: 3 268909324 15 0 0 0 0 0
syscall: pwrite arg_i: 3 268909329 6 0 0 10 0 0
syscall: pwrite arg_i: 3 268909324 4 0 0 30 0 0
syscall: pread  arg_i: 3 1082133156 5 0 0 5 0 0
(those are arg1, arg2, arg3, arg4, arg5, arg6 and the unused arg7 and arg8)

As can be seen, arg4 is not used, and the line
ret = get_errno(pwrite64(arg1, p, arg3, target_offset64(arg4, arg5)));
should be, in my case
ret = get_errno(pwrite64(arg1, p, arg3, target_offset64(arg5, arg6)));

With this changes, the qemu "Works For Me (TM)".

So, anybody can confirm it or (if it is indeed my problem) can give me
some pointers? I will not post this as a patch until I understand the
problem... and first step is making sure that it really is a qemu
problem. And not my toolchain or something random.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]