From 93b3e0c2979b99ac49d99a608095f3a627396dff Mon Sep 17 00:00:00 2001 From: anwleung Date: Thu, 15 Mar 2007 18:20:49 +0000 Subject: [PATCH] script to first spit out all dirs used in a trace git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1238 29311d96-e01e-0410-9327-a35deaab8ce9 --- branches/aleung/security1/ceph/mkdir_trace.pl | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100755 branches/aleung/security1/ceph/mkdir_trace.pl diff --git a/branches/aleung/security1/ceph/mkdir_trace.pl b/branches/aleung/security1/ceph/mkdir_trace.pl new file mode 100755 index 0000000000000..bc27c33632f58 --- /dev/null +++ b/branches/aleung/security1/ceph/mkdir_trace.pl @@ -0,0 +1,71 @@ +#!/usr/bin/perl -w + +use strict; +use IO::Dir; +use IO::File; + +my @files; +my $file_handle; +my @file_data; +my %seen_paths = (); + +opendir(DIR, "."); +@files = readdir(DIR); +closedir(DIR); + +open(OUT, ">tracepaths.cephtrace") or die "cannot_open_file: $!"; +flock(OUT, 2); + +for $file_handle(@files) { + if($file_handle =~ /IOR/ and $file_handle !~ /cephtrace/) { + open(FILE, $file_handle) or die "cannot_open_file: $!"; + flock(FILE, 2); + + @file_data = ; + + my $line; + my @args; + foreach $line (@file_data) { + my $op; + + @args = split(/\s/, $line); + $op = $args[1]; + + if($op =~ /open\(/) { + + my $before; + my $path; + my $after; + ($before, $path, $after) = split(/\"/, $op); + + my $handle; + my @rest; + ($handle, @rest) = reverse split(/\//, $path); + + my $subdir; + my $dirpath; + foreach $subdir (reverse @rest) { + if ($dirpath) { + $dirpath = "$dirpath/$subdir"; + } + else { + $dirpath = "$subdir"; + } + + if (! $seen_paths{$dirpath}) { + $seen_paths{$dirpath} = 1; + print OUT "mkdir\n\/$dirpath\n493\n"; + } + } + + #if (! $seen_paths{$dirpath}) { + # $seen_paths{$dirpath} = 1; + # print "mkdir\n\/$dirpath\n493\n"; + #} + + } + } + + } +} +close(OUT); -- 2.39.5