All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] lseek beyond 2GB offset for qemu-arm user
@ 2016-08-11 16:06 Chanho Park
  2016-08-11 17:20 ` Peter Maydell
  0 siblings, 1 reply; 2+ messages in thread
From: Chanho Park @ 2016-08-11 16:06 UTC (permalink / raw)
  To: QEMU Developers; +Cc: Peter Maydell

Hi,

When I executed below source in qemu-arm user binary, It was failed
with Invalid Argument.

gcc lseek_test.c -o lseek_test -D_FILE_OFFSET_BITS=64
./lseek_test
error: Invalid argument

It seems the qemu-arm user does not support the D_FILE_OFFSET_BITS flag.
Is it a known issue or I had wrong test procedure on qemu-arm user environment?

#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <sys/stat.h>
#include <fcntl.h>

int main()
{
        int fd, ret;
        off_t pos = 2*1024*1024*1024 + 10; // over 2G

        fd = open("large_file", O_CREAT | O_WRONLY | O_TRUNC, 0666);
        if (fd < 0){
                fprintf(stderr, "%s\n", strerror(errno));
                exit(1);
        }

        if (lseek(fd, pos, SEEK_SET) < 0) {
                //fprintf(stderr, "Failed seeking to %zu, %d\n", pos, errno);
                perror("error");
                exit(1);
        }

        write(fd, "TEST", 4);
        close(fd);

        close(fd);

        return 0;
}

-- 
Best Regards,
Chanho Park

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] lseek beyond 2GB offset for qemu-arm user
  2016-08-11 16:06 [Qemu-devel] lseek beyond 2GB offset for qemu-arm user Chanho Park
@ 2016-08-11 17:20 ` Peter Maydell
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Maydell @ 2016-08-11 17:20 UTC (permalink / raw)
  To: Chanho Park; +Cc: QEMU Developers

On 11 August 2016 at 17:06, Chanho Park <parkch98@gmail.com> wrote:
> Hi,
>
> When I executed below source in qemu-arm user binary, It was failed
> with Invalid Argument.
>
> gcc lseek_test.c -o lseek_test -D_FILE_OFFSET_BITS=64
> ./lseek_test
> error: Invalid argument
>
> It seems the qemu-arm user does not support the D_FILE_OFFSET_BITS flag.
> Is it a known issue or I had wrong test procedure on qemu-arm user environment?

When I compile it gcc warns me:

zz9.c: In function ‘main’:
zz9.c:14:32: warning: integer overflow in expression [-Woverflow]

so you have a bug in your code and it isn't seeking to where
you think it is, and it fails EINVAL on real hardware too.

However if you fix this bug (by adding the 'ULL' suffix to
the '2' constant) then it works on real hardware and fails
in QEMU, so there is a bug here. I'll have a look at it.

(Also you close the fd twice.)

thanks
-- PMM

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-08-11 17:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-11 16:06 [Qemu-devel] lseek beyond 2GB offset for qemu-arm user Chanho Park
2016-08-11 17:20 ` Peter Maydell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.