ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/IO-AIO/bin/treescan
(Generate patch)

Comparing IO-AIO/bin/treescan (file contents):
Revision 1.1 by root, Mon Sep 10 11:24:20 2007 UTC vs.
Revision 1.2 by root, Wed Apr 9 18:18:41 2008 UTC

1#!/opt/bin/perl 1#!/opt/bin/perl
2 2
3# inspired by treescan by Jamie Lokier <jamie@imbolc.ucc.ie> 3# inspired by treescan by Jamie Lokier <jamie@imbolc.ucc.ie>
4# about 40% faster than the original version (on my fs and raid :) 4# about 40% faster than the original version (on my fs and raid :)
5 5
6use strict;
6use Getopt::Long; 7use Getopt::Long;
7use IO::AIO; 8use IO::AIO;
8 9
9Getopt::Long::Configure ("bundling", "no_ignore_case", "require_order"); 10Getopt::Long::Configure ("bundling", "no_ignore_case", "require_order");
10 11
17; 18;
18 19
19@ARGV = "." unless @ARGV; 20@ARGV = "." unless @ARGV;
20 21
21sub printfn { 22sub printfn {
22 my ($path, $files, $suffix) = @_; 23 my ($prefix, $files, $suffix) = @_;
23 24
24 if ($opt_print0) { 25 if ($opt_print0) {
25 print map "$path/$_$suffix\0", @$files; 26 print map "$prefix$_$suffix\0", @$files;
26 } elsif (!$opt_silent) { 27 } elsif (!$opt_silent) {
27 print map "$path/$_$suffix\n", @$files; 28 print map "$prefix$_$suffix\n", @$files;
28 } 29 }
29} 30}
30 31
31sub scan { 32sub scan {
32 my ($path) = @_; 33 my ($path) = @_;
33 34
35 $path .= "/";
36
37 aioreq_pri -1;
34 aio_scandir $path, 8, sub { 38 aio_scandir $path, 8, sub {
35 my ($dirs, $files) = @_; 39 my ($dirs, $files) = @_;
36 40
41 printfn "", [$path];
42 printfn $path, $files;
43
37 if ($opt_stat) { 44 if ($opt_stat) {
38 aio_stat "$path/$_" for @$files; 45 aio_lstat "$path$_" for @$files;
39 } 46 }
40 47
41 for (@$dirs) { 48 &scan ("$path$_") for @$dirs;
42 printfn $path, $dirs, "/";
43 &scan ("$path/$_")
44 }
45
46 printfn $path, $files;
47 }; 49 };
48} 50}
49 51
50IO::AIO::max_outstanding 64; 52IO::AIO::max_outstanding 64;
51IO::AIO::min_parallel 32; 53IO::AIO::min_parallel 32;
52 54
53for my $seed (@ARGV) { 55for my $seed (@ARGV) {
54 $seed =~ s/\/+$//; 56 $seed =~ s/\/+$//;
55 aio_lstat "$seed/.", sub { 57 aio_lstat "$seed/.", sub {
58 if (-d _) {
56 scan $seed if -d _; 59 scan $seed;
60 } else {
61 printfn "", $seed, "/";
62 }
57 }; 63 };
58} 64}
59 65
60IO::AIO::flush; 66IO::AIO::flush;
61 67

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines