3 # Make VNODE structure from INODE structure
5 # Created By: Derek Atkins <warlord@MIT.EDU>
9 $linux_header_dir="/usr/src/linux";
10 $outdir="./src/afs/LINUX";
11 $tmpldir="./src/afs/LINUX";
13 $sepline="/* LINUX VNODE INCLUDED BELOW -- DO NOT MODIFY */\n";
15 # makeVfs (fs.h, vfs.hin, vfs.out)
17 my ($in,$base,$out) = @_;
20 open (IN, "$in") || die "Cannot open $in for reading";
21 open (BASE, "$base" ) || die "Cannot open base file $base";
22 open (OUT, ">$out") || die "Cannot open tempfile $out";
32 print OUT $sepline if !$seplinefound;
37 # Look for 'struct inode' definition
39 next unless m/^struct\s+inode\s*\{/;
45 # Look for 'union {' -- print otherwise
47 if (m/^\s*union\s*\{/) {
49 print OUT "#ifdef notdef\n";
55 # Look for the end of the union -- ignore otherwise
58 next unless (m/^\s+\}\s*u;/);
60 print OUT "#endif /* notdef */\n";
64 # Look for end brace -- print until we find it
67 if (m/^\s*\};/) { $state++ }
71 while (<BASE>) { print OUT; }
79 print "usage: $0 [-i linux_header_dir] [-o output_dir] [-h]\n";
85 return $arg if ($arg && $arg ne "");
89 while ($_ = shift @ARGV) {
90 if (m/^-i/) { $linux_header_dir = testArg(shift @ARGV); next; }
91 if (m/^-o/) { $outdir = testArg(shift @ARGV); next; }
92 if (m/^-t/) { $tmpldir = testArg(shift @ARGV); next; }
96 $linux_fs_h="$linux_header_dir/include/linux/fs.h";
97 $vfs_h="$outdir/osi_vfs.h";
98 $vfs_hin="$tmpldir/osi_vfs.hin";
100 # we're running prior to configure finishing, so outdir might not exist yet
101 mkpath([$outdir], 0, 0755);
103 makeVfs ($linux_fs_h, $vfs_hin, "$vfs_h.new");
105 system ("cmp", "-s", $vfs_h, "$vfs_h.new");
106 $exit_value = $? >> 8;
107 $signal_num = $? & 127;
108 $core_dump = $? & 128;
110 if ($exit_value == 0 || $signal_num > 0) {
112 print "nothing to do... $vfs_h not changed.\n"
115 rename ("$vfs_h.new", $vfs_h);
116 print "wrote $vfs_h\n";