[lkml]   [2001]   [Dec]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectO_DIRECT wierd behavior..

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 and /tmp is ext2. (It runs fine on 2.4.2).

Any idea why this happens and how to fix this?


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:14    [W:0.096 / U:10.484 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site