xfs
[Top] [All Lists]

O_DIRECT wierd behavior..

To: linux-xfs@xxxxxxxxxxx
Subject: O_DIRECT wierd behavior..
From: Suresh Gopalakrishnan <gsuresh@xxxxxxxxxxxxxx>
Date: Sat, 15 Dec 2001 19:18:55 -0500 (EST)
Sender: owner-linux-xfs@xxxxxxxxxxx
I tried this small piece of code from an old post in the archive:

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

#define O_DIRECT         040000 /* direct disk access hint */

int main()
{
        char buf[16384];
        int fd;
        char *p;

        p = (char *)((((unsigned long)buf) + 8191) & ~8191L);
        fd = open("/tmp/blah", O_CREAT | O_RDWR | O_DIRECT);

        printf("write returns %i\n", write(fd, buf, 8192));
        printf("write returns %i\n", write(fd, p, 1));

        return 0;
}

Output is:

write returns -1
Filesize limit exceeded (core dumped)

$ ls -l /tmp/blah
----------    1 gsuresh  users    4294967274 Dec 15 19:15 /tmp/blah

The kernel is 2.4.16. (It runs fine on 2.4.2).

Any idea why this happens and how to fix this?

Thanks
--suresh


<Prev in Thread] Current Thread [Next in Thread>