… | |
… | |
131 | ); |
131 | ); |
132 | } |
132 | } |
133 | |
133 | |
134 | @ARGV = "." unless @ARGV; |
134 | @ARGV = "." unless @ARGV; |
135 | |
135 | |
|
|
136 | my @todo; # list of dirs/files still left to scan |
|
|
137 | |
136 | $opt_grep &&= qr{$opt_grep}s; |
138 | $opt_grep &&= qr{$opt_grep}s; |
137 | |
139 | |
138 | my ($n_dirs, $n_files, $n_stats) = (0, 0, 0); |
140 | my ($n_dirs, $n_files, $n_stats) = (0, 0, 0); |
139 | my ($n_last, $n_start) = (Time::HiRes::time) x 2; |
141 | my ($n_last, $n_start) = (Time::HiRes::time) x 2; |
140 | |
142 | |
… | |
… | |
195 | aio_pathsync [$wd, $_] for @$files; |
197 | aio_pathsync [$wd, $_] for @$files; |
196 | aio_pathsync $wd; |
198 | aio_pathsync $wd; |
197 | }; |
199 | }; |
198 | } |
200 | } |
199 | |
201 | |
200 | &scan ("$path$_") for @$dirs; |
202 | push @todo, "$path$_" |
|
|
203 | for sort { $b cmp $a } @$dirs; |
201 | }; |
204 | }; |
202 | } |
205 | } |
203 | |
206 | |
204 | IO::AIO::max_outstanding 100; # two fds per directory, so limit accordingly |
207 | IO::AIO::max_outstanding 100; # two fds per directory, so limit accordingly |
205 | IO::AIO::min_parallel 20; |
208 | IO::AIO::min_parallel 20; |
206 | |
209 | |
207 | for my $seed (@ARGV) { |
210 | @todo = reverse @ARGV; |
|
|
211 | |
|
|
212 | while () { |
|
|
213 | if (@todo) { |
|
|
214 | printf "(%d)",scalar @todo;$|=1;#d# |
|
|
215 | my $seed = pop @todo; |
208 | $seed =~ s/\/+$//; |
216 | $seed =~ s/\/+$//; |
209 | aio_lstat "$seed/.", sub { |
217 | aio_lstat "$seed/.", sub { |
210 | if ($_[0]) { |
218 | if ($_[0]) { |
211 | print STDERR "$seed: $!\n"; |
219 | print STDERR "$seed: $!\n"; |
212 | } elsif (-d _) { |
220 | } elsif (-d _) { |
213 | scan $seed; |
221 | scan $seed; |
214 | } else { |
222 | } else { |
215 | printfn "", $seed, "/"; |
223 | printfn "", $seed, "/"; |
|
|
224 | } |
216 | } |
225 | }; |
|
|
226 | } else { |
|
|
227 | print "w";$|=1;#d# |
|
|
228 | IO::AIO::poll_wait; |
217 | }; |
229 | } |
218 | } |
|
|
219 | |
230 | |
220 | IO::AIO::flush; |
231 | last unless IO::AIO::nreqs; |
221 | |
232 | |
|
|
233 | IO::AIO::poll_cb; |
|
|
234 | } |
|
|
235 | |