in reply to O_DIRECT & O_ASYNC, Linux & Perl
#!/usr/bin/perl use strict; use warnings; use Fcntl qw(:DEFAULT O_ASYNC O_DIRECT); use Sys::Mmap; sysopen(my $FH,"./test.dat", O_WRONLY | O_TRUNC | O_CREAT | O_ASYNC | O_DIRECT, 0666) or die "Couldn't open\n"; my $BUFSIZE = 1048576; my $BUFFER; mmap($BUFFER,$BUFSIZE,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON, STDOUT) or die "Couldn't mmap\n"; for (my $i = 0; $i < 20480; $i++) { my $written = syswrite($FH,$BUFFER,$BUFSIZE); die "System write error: $!\n" unless defined $written; }
Update: use sysopen with the proper flags. Thanks for the correction, jfroebe! Looks like I screwed up the code cleaning it up for posting.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: O_DIRECT & O_ASYNC, Linux & Perl
by jfroebe (Parson) on May 11, 2007 at 03:48 UTC |