xfs
[Top] [All Lists]

Re: O_DIRECT wierd behavior..

To: Suresh Gopalakrishnan <gsuresh@xxxxxxxxxxxxxx>
Subject: Re: O_DIRECT wierd behavior..
From: Keith Owens <kaos@xxxxxxxxxxxxxxxxx>
Date: Sun, 16 Dec 2001 12:03:33 +1100
Cc: linux-xfs@xxxxxxxxxxx
In-reply-to: Your message of "Sat, 15 Dec 2001 19:18:55 CDT." <Pine.GSO.4.02A.10112151915120.14453-100000@aramis.rutgers.edu>
Sender: owner-linux-xfs@xxxxxxxxxxx
On Sat, 15 Dec 2001 19:18:55 -0500 (EST), 
Suresh Gopalakrishnan <gsuresh@xxxxxxxxxxxxxx> wrote:
>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;
>}

Works for me using gcc 2.96, glibc 2.2.2.

write returns 8192
write returns 1

Different architectures have different bit values and they have changed
since 2.4.2.  Does O_DIRECT match the value of O_DIRECT in
include/asm-$(ARCH)/fcntl.h?

You omitted the mode on open, when O_CREAT is specified you must add a
mode.

  fd = open("/tmp/blah", O_CREAT | O_RDWR | O_DIRECT, 0777);


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