summaryrefslogtreecommitdiff
path: root/test/raidfile/make-darwin-intercepts.pl
diff options
context:
space:
mode:
authorBen Summers <ben@fluffy.co.uk>2005-10-14 08:50:54 +0000
committerBen Summers <ben@fluffy.co.uk>2005-10-14 08:50:54 +0000
commit99f8ce096bc5569adbfea1911dbcda24c28d8d8b (patch)
tree049c302161fea1f2f6223e1e8f3c40d9e8aadc8b /test/raidfile/make-darwin-intercepts.pl
Box Backup 0.09 with a few tweeks
Diffstat (limited to 'test/raidfile/make-darwin-intercepts.pl')
-rwxr-xr-xtest/raidfile/make-darwin-intercepts.pl46
1 files changed, 46 insertions, 0 deletions
diff --git a/test/raidfile/make-darwin-intercepts.pl b/test/raidfile/make-darwin-intercepts.pl
new file mode 100755
index 00000000..2f19e090
--- /dev/null
+++ b/test/raidfile/make-darwin-intercepts.pl
@@ -0,0 +1,46 @@
+#!/usr/bin/perl
+use strict;
+
+my $out = $ARGV[0];
+die "No out directory specified" unless $out ne '';
+
+my @calls = split /[\r\n]+/,<<__E;
+lseek SYSCALL_TEST(lseek, 3)
+open SYSCALL_TEST(open, 3)
+close SYSCALL_TEST(close, 1)
+write SYSCALL_TEST(write, 3)
+read SYSCALL_TEST(read, 3)
+readv SYSCALL_TEST(readv, 3)
+__E
+
+for(@calls)
+{
+ my ($name,$line) = split / /,$_,2;
+
+ open FL,">$out/intercept-$name.s" or die "Can't open out file";
+ print FL <<'__S';
+#include "../../../test/raidfile/Darwin-SYS.h"
+
+#define SYSCALL_TEST(name, nargs) \
+ .globl cerror @\
+LEAF(_TEST_##name) @\
+ kernel_trap_args_##nargs @\
+ li r0,SYS_##name @\
+ sc @\
+ b 1f @\
+ b 2f @\
+1: BRANCH_EXTERN(cerror) @\
+.text \
+2: nop
+
+__S
+ print FL $line,"\n\tblr\n\n";
+
+ close FL;
+
+ if(system("gcc -c $out/intercept-$name.s -o $out/intercept-$name.o") != 0)
+ {
+ die "Assembly failed\n";
+ }
+}
+