public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* O_DIRECT wierd behavior..
@ 2001-12-16  0:47 Suresh Gopalakrishnan
  2001-12-16  5:59 ` Andrew Morton
                   ` (2 more replies)
  0 siblings, 3 replies; 20+ messages in thread
From: Suresh Gopalakrishnan @ 2001-12-16  0:47 UTC (permalink / raw)
  To: linux-kernel


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?

Thanks
--suresh


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

end of thread, other threads:[~2002-01-20  4:16 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-12-16  0:47 O_DIRECT wierd behavior Suresh Gopalakrishnan
2001-12-16  5:59 ` Andrew Morton
2001-12-16  8:17   ` GOTO Masanori
2001-12-16  8:46     ` Andrew Morton
2001-12-16  9:20       ` Suresh Gopalakrishnan
2001-12-16 13:57         ` Terje Eggestad
2001-12-16 17:43           ` Suresh Gopalakrishnan
2001-12-17  9:04             ` Terje Eggestad
2001-12-17 17:18     ` Andrea Arcangeli
2001-12-17 18:07       ` Hugh Dickins
2001-12-17 18:13         ` Andrea Arcangeli
2001-12-17 18:57         ` Andrew Morton
2001-12-17 19:26           ` Linus Torvalds
2001-12-17 19:53             ` Joel Becker
2001-12-17 19:59               ` Linus Torvalds
2001-12-17 20:20                 ` Joel Becker
2001-12-17 20:38                   ` Andre Hedrick
2001-12-26 14:54             ` Riley Williams
2001-12-16  6:29 ` GOTO Masanori
2002-01-20  4:16 ` multithreaded RPC handling Suresh Gopalakrishnan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox