3 # Attempt to generate a similar HTML file akin to vop_table.tcl output.
4 # This is all fairly poor perl code... but whatever, will be cleaned up
7 # (c) 2004 Andrew R. Reiter <arr@watson.org>
12 # XXX todo: Make $src_dir modificationable
14 $src_dir = "/usr/src";
15 $srcsys_dir = $src_dir."/sys";
16 $vnode_if_awk = $srcsys_dir."/tools/vnode_if.awk";
17 $vnode_if_src = $srcsys_dir."/kern/vnode_if.src";
19 # Temporary input file... generated by a find(1) based command.
20 $infile = "/tmp/vt.$$";
23 $outfile = "vop_vectors.html";
25 # Get a bunch of the vop_ routines out of this file.
26 `awk -f $vnode_if_awk $vnode_if_src -q`;
28 print "Incapable of writing out the typedef file.\n";
32 # Eat the typedefs file into memory
33 open TD, "vnode_if_typedef.h" || die "Unable to open typedef file: $!\n";
36 `rm -f vnode_if_typedef.h`;
38 # List of available vnode operations
39 @available_vn_ops = ();
40 push @available_vn_ops, "default";
41 foreach $vt (@vop_tdefs) {
42 if ($vt =~ m/typedef\s+(\S+)\s+vop_(\S+)_t\(/) {
43 push @available_vn_ops, $2;
47 @available_vn_ops = sort(@available_vn_ops);
49 # Array of { file , fs }
53 # Array of available vops for a given fs
59 print OF "<HTML><HEAD><TITLE>File system vnode Operations</TITLE>";
60 print OF "</HEAD><BODY>\n";
61 print OF "<TABLE BORDER WIDTH=\"100%\" HEIGHT=\"100%\" >\n";
62 print OF "<TR><TH><font size=-1>F<br>i<br>l<br>e<br><br>S<br>y<br>s<br>t<br>e<br>m<br></font>\n";
63 print OF "<TH><font size=-1>V<br>e<br>c<br>t<br>o<br>r<br><br>V<br>a<br>r<br>i<br>a<br>b<br>l<br>e<br></font>\n";
64 foreach $avops (@available_vn_ops) {
65 @ao = split //,$avops;
66 print OF "<TH><font size=-1> ";
68 print OF "$aoz<br>\n";
72 print OF "</TR></font>\n";
74 #Generate $infile; sketchy
75 `find /usr/src/sys -type f -iname *.c -print | xargs grep 'vnodeops =' > $infile`;
77 # Read in the file we find(1) generated.
82 # Attempt to find all the files holding vop_vector declarations
85 # Need to sort based on $fs[]->{fs}
86 if ($l =~ m/^(\S+):.*vop_vector ((\S+)_vnodeops) =/) {
87 # Eh, I suck at perl; forgot some syntax, so hack.
90 $fs[$sz]->{file} = $1;
91 $fs[$sz]->{fs} = $3; # file system
92 $fs[$sz]->{fsvar} = $2; # fs vop vector variable
101 foreach $fss (@fs_s) {
102 for ($l = 0; $l < $#fs; $l++) {
103 if ($fs_s[$m] eq $fs[$l]->{fs}) {
113 $ret = "<TD BGCOLOR=\"#00ddd0\"> ";
115 if ($vfn eq "VOP_EBADF") {
119 if ($vfn eq "VOP_PANIC") {
123 if ($vfn eq "VOP_NULL") {
127 if ($vfn =~ m/vop_std/) {
131 if ($vfn eq "vop_cache_lookup") {
135 if ($vfn =~ m/vop_no/) {
139 if ($vfn =~ m/vop_/) {
143 if ($vfn eq "VOP_EINVAL") {
147 if ($vfn eq "VOP_ENOTTY") {
151 if ($vfn eq "VOP_ENOTOPSUPP") {
155 if ($vfn =~ m/_lookup/) {
163 # Loop through files that define vop_vectors.
164 for ($j = 0; $j < $#fs; $j++) {
166 # Open the file containing the vop_vector decl.
167 open V, $fs[$j]->{file};
171 # Zero out array; is there an easier way to do this in perl?
172 for ($z = 0; $z < $#fsvnops; $z++) {
173 $fsvnops[$z] = "<td bgcolor=\"d0d0d0\">";
180 if ($v =~ m/vop_vector (\S+_vnodeops) =/) {
193 # ... Generate a vop_vector under each @fs entry?
195 if ($v =~ m/\.vop_(\S+)\s+=\s+(\S+),/) {
196 $iz = get_vop_fn_index($1);
198 print "Unknown vnop routine: $1:$2 \n";
201 $fsvnops[$iz] = vop_fn_val($2);
205 $fs[$j]->{out} = " <TD> $fs[$j]->{fsvar}";
207 # Print out based on fsvnops
208 foreach $z (@fsvnops) {
209 $fs[$j]->{out} .= $z;
211 $fs[$j]->{out} .= "</TR>\n";
215 for ($b = 0; $b < $#fs; $b++) {
216 if ($s eq $fs[$b]->{fs}) {
217 print OF "<TD> $s ".$fs[$b]->{out};
223 print OF "</TR></TABLE>\n";
240 print OF "</BODY></HTML>\n";
244 sub get_vop_fn_index {
248 foreach $y (@available_vn_ops) {