lkml.org 
[lkml]   [2002]   [Oct]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: VM BUG, set_page_dirty() buggy?
On Fri, Oct 25 2002, Jens Axboe wrote:
> I've attached oread in its simplicity. System being tested here is a
> dual P3-800MHz, not using preempt (never do). It doesn't matter if the
> input is on /dev/sda or ide disk, scsi cdrom, or atapi cdrom. It behaves
> the same way, data is lost.

Well here it is...

--
Jens Axboe

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>

#ifndef O_DIRECT
#define O_DIRECT 040000
#endif

#define READ_SIZE (65536)
#define ALIGN(buf) (char *) (((unsigned long) (buf) + 4095) & ~(4095))

int main(int argc, char *argv[])
{
char *buffer, *ptr;
int fd_in, fd_out, ret;

if (argc < 3) {
printf("%s: <infile> <outfile>\n", argv[0]);
return 1;
}

printf("%s: infile: %s -> outfile %s\n", argv[0],argv[1],argv[2]);

fd_in = open(argv[1], O_RDONLY | O_DIRECT);
if (fd_in == -1) {
perror("open infile");
return 2;
}

fd_out = open(argv[2], O_WRONLY | O_CREAT | O_TRUNC, 0644);
if (fd_out == -1) {
perror("open outfile");
return 3;
}

ptr = malloc(READ_SIZE + 4095);
buffer = ALIGN(ptr);

do {
ret = read(fd_in, buffer, READ_SIZE);
if (!ret)
break;
else if (ret < 0) {
perror("read infile");
break;
}
write(fd_out, buffer, ret);
} while (1);

free(ptr);
close(fd_in); close(fd_out);
return 0;
}
\
 
 \ /
  Last update: 2005-03-22 13:30    [from the cache]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and my Meterkast|Read the blog