tracefile: Added --local.
This commit is contained in:
parent
2598055fcb
commit
29c5881869
|
@ -6,9 +6,9 @@ tracefile - list files being accessed
|
||||||
|
|
||||||
=head1 SYNOPSIS
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
B<tracefile> [-adefnruw] I<command>
|
B<tracefile> [-adeflnruw] I<command>
|
||||||
|
|
||||||
B<tracefile> [-adefnruw] -p I<pid>
|
B<tracefile> [-adeflnruw] -p I<pid>
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
=head1 DESCRIPTION
|
||||||
|
|
||||||
|
@ -51,6 +51,14 @@ List only existing files.
|
||||||
List only normal files.
|
List only normal files.
|
||||||
|
|
||||||
|
|
||||||
|
=item B<-l>
|
||||||
|
|
||||||
|
=item B<--local>
|
||||||
|
|
||||||
|
List only files in current directory. Useful to avoid matching at
|
||||||
|
system files.
|
||||||
|
|
||||||
|
|
||||||
=item B<-n>
|
=item B<-n>
|
||||||
|
|
||||||
=item B<--nonexist>
|
=item B<--nonexist>
|
||||||
|
@ -243,9 +251,6 @@ $Global::progname = "tracefile";
|
||||||
Getopt::Long::Configure("bundling","require_order");
|
Getopt::Long::Configure("bundling","require_order");
|
||||||
get_options_from_array(\@ARGV) || die_usage();
|
get_options_from_array(\@ARGV) || die_usage();
|
||||||
init_functions();
|
init_functions();
|
||||||
if(not ($opt::exists or $opt::nonexists or $opt::all or $opt::dir or $opt::file)) {
|
|
||||||
$opt::all = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
my @cmd = shell_quote(@ARGV);
|
my @cmd = shell_quote(@ARGV);
|
||||||
my $dir = ".";
|
my $dir = ".";
|
||||||
|
@ -258,7 +263,7 @@ while(<IN>) {
|
||||||
}
|
}
|
||||||
# [pid 30817] stat("t/tar.gz", {st_mode=S_IFREG|0644, st_size=140853248, ...}) = 0
|
# [pid 30817] stat("t/tar.gz", {st_mode=S_IFREG|0644, st_size=140853248, ...}) = 0
|
||||||
# openat(AT_FDCWD, "/tmp/a", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = 3
|
# openat(AT_FDCWD, "/tmp/a", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = 3
|
||||||
if(/^(\[[^]]\])? # Match pid
|
if(/^(\[[^]]+\])? # Match pid
|
||||||
\s*([^\" ]+) # function
|
\s*([^\" ]+) # function
|
||||||
[(] # (
|
[(] # (
|
||||||
[^"]* # E.g. AT_FDCWD
|
[^"]* # E.g. AT_FDCWD
|
||||||
|
@ -272,6 +277,10 @@ while(<IN>) {
|
||||||
my $addinfo = $5;
|
my $addinfo = $5;
|
||||||
# Relative to $dir
|
# Relative to $dir
|
||||||
$file =~ s:^([^/]):$dir/$1:;
|
$file =~ s:^([^/]):$dir/$1:;
|
||||||
|
$file =~ s:/./:/:g; # /./ => /
|
||||||
|
$file =~ s:/[^/]+/../:/:g; # /foo/../ => /
|
||||||
|
# Match files in $PWD or starting with ./
|
||||||
|
my $local = ($file =~ m<^(\Q$ENV{'PWD'}\E|\./)>);
|
||||||
my $read = readfunc($function,$addinfo);
|
my $read = readfunc($function,$addinfo);
|
||||||
my $write = writefunc($function,$addinfo);
|
my $write = writefunc($function,$addinfo);
|
||||||
my $print = 1;
|
my $print = 1;
|
||||||
|
@ -285,6 +294,8 @@ while(<IN>) {
|
||||||
or
|
or
|
||||||
($opt::exists and not -e $file)
|
($opt::exists and not -e $file)
|
||||||
or
|
or
|
||||||
|
($opt::local and not $local)
|
||||||
|
or
|
||||||
($opt::nonexists and -e $file)
|
($opt::nonexists and -e $file)
|
||||||
or
|
or
|
||||||
($opt::unique and $seen{$file}++)) {
|
($opt::unique and $seen{$file}++)) {
|
||||||
|
@ -292,7 +303,6 @@ while(<IN>) {
|
||||||
}
|
}
|
||||||
$print and print $file,"\n";
|
$print and print $file,"\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -366,6 +376,7 @@ sub options_hash {
|
||||||
"uniq|unique|u" => \$opt::unique,
|
"uniq|unique|u" => \$opt::unique,
|
||||||
"exists|exist|e" => \$opt::exists,
|
"exists|exist|e" => \$opt::exists,
|
||||||
"nonexists|nonexist|non-exists|non-exist|n" => \$opt::nonexists,
|
"nonexists|nonexist|non-exists|non-exist|n" => \$opt::nonexists,
|
||||||
|
"local|l" => \$opt::local,
|
||||||
"read|r" => \$opt::read,
|
"read|r" => \$opt::read,
|
||||||
"write|w" => \$opt::write,
|
"write|w" => \$opt::write,
|
||||||
"all|a" => \$opt::all,
|
"all|a" => \$opt::all,
|
||||||
|
|
Loading…
Reference in a new issue