1#!/usr/local/bin/tclsh8.3 2# $FreeBSD$ 3 4set fo [open _.html w] 5 6proc do_file {file} { 7 global names ops op 8 set f [open $file] 9 10 set s 0 11 12 while {[gets $f a] >= 0} { 13 if {$s == 0} { 14 if {[regexp {struct[ ]*vnodeopv_entry_desc} "$a"]} { 15 regsub {.*vnodeopv_entry_desc[ ]*} $a {} a 16 regsub {\[.*} $a {} a 17 regsub {_entries} $a {} a 18 set name $a 19 set names($a) 0 20 set s 1 21 } 22 continue 23 } 24 if {$s == 1} { 25 if {[regexp {NULL} "$a"]} { 26 set s 0 27 continue 28 } 29 if {![regexp {vop.*_desc} "$a"]} continue 30 regsub -all {[,&]} $a " " a 31 regsub -all {\(vop_t \*\)} $a " " a 32 set b [lindex $a 0] 33 if {"$b" == "/*"} { 34 set s 0 35 continue 36 } 37 #puts "$name>> [lindex $b 0] >> [lindex $b 3]" 38 set o [lindex $b 0] 39 regsub {_desc} $o "" o 40 set ops($o) 0 41 set op([list $name $o]) [lindex $b 1] 42 continue 43 } 44 puts "$s>> $a" 45 } 46 close $f 47} 48 49set fi [open "|find /usr/src/sys -type f -name *.c -print | xargs grep VNODEOP_SET" ] 50while {[gets $fi a] >= 0} { 51 puts stderr $a 52 if {[regexp {#define} $a]} continue 53 if {[regexp {mallocfs} $a]} continue 54 do_file [lindex [split $a :] 0] 55} 56close $fi 57 58puts $fo {<HTML> 59<HEAD></HEAD><BODY> 60<TABLE BORDER WIDTH="100%" NOSAVE> 61} 62 63set opn [lsort [array names ops]] 64set a [lsort [array names names]] 65 66set tbn default_vnodeop 67foreach i $a { 68 if {$i == "default_vnodeop"} continue 69 lappend tbn $i 70} 71 72foreach i $opn { 73 if {$i == "vop_default"} continue 74 regsub "vop_" $i "" i 75 lappend fl [format "%12s" $i] 76} 77 78lappend fl [format "%12s" default] 79 80puts $fo {<TR>} 81puts $fo {<TD>} 82puts $fo {</TD>} 83puts $fo "<TR>" 84 puts $fo "<TD></TD>" 85 foreach j $fl { 86 puts $fo "<TD>" 87 88 for {set i 0} {$i < 12} {incr i} { 89 puts $fo "[string index $j $i]<BR>" 90 } 91 puts $fo "</TD>" 92 } 93puts $fo "</TR>" 94 95set fnames(vop_defaultop) * 96 97set fnames(vop_null) - 98set fnames(vop_ebadf) b 99set fnames(vop_einval) i 100set fnames(vop_enotty) t 101set fnames(vop_panic) ! 102set fnames(vfs_cache_lookup) C 103set fnames(vop_eopnotsupp) * 104 105set fn 0 106set nop(aa) 0 107unset nop(aa) 108foreach i $tbn { 109 puts $fo {<TR>} 110 puts $fo "<TD>$i</TD>" 111 set pfx [lindex [split $i _] 0] 112 foreach j $opn { 113 if {$j == "vop_default"} continue 114 set sfx [lindex [split $j _] 1] 115 if {![info exists op([list $i $j])]} { 116 puts $fo "<TD BGCOLOR=\"#d0d0d0\"></TD>" 117 continue 118 } 119 set t $op([list $i $j]) 120 121 set c "#00ddd0" 122 if {[info exists fnames($t)]} { 123 set t $fnames($t) 124 } elseif { $t == "${pfx}_${sfx}" } { 125 set t "F" 126 } elseif { $t == "vop_${sfx}" } { 127 set t "V" 128 } elseif { $t == "vop_no${sfx}" } { 129 set t "N" 130 } elseif { $t == "vop_std${sfx}" } { 131 set t "S" 132 } elseif { $sfx == "cachedlookup" && $t == "${pfx}_lookup" } { 133 set t "L" 134 } else { 135 if {![info exists nop($t)]} { 136 incr fn 137 set nop($t) $fn 138 set nfn($fn) $t 139 set use($fn) 0 140 } 141 incr use($nop($t)) 142 set t "<FONT SIZE=-1>$nop($t)</FONT>" 143 set c "#ffff00" 144 } 145 puts $fo "<TD BGCOLOR=\"$c\">$t</TD>" 146 } 147 set j vop_default 148 if {![info exists op([list $i $j])]} { 149 puts $fo "<TD></TD>" 150 continue 151 } 152 puts $fo "<TD>$op([list $i $j])</TD>" 153 154 puts $fo "</TR>" 155} 156puts $fo "</TABLE>" 157puts $fo "<HR>" 158puts $fo {<PRE>} 159foreach i [lsort [array names fnames]] { 160 puts $fo [format "%-2s %s" $fnames($i) $i] 161} 162puts $fo [format "%-2s %s" "F" "<fs>_<vop>"] 163puts $fo [format "%-2s %s" "V" "vop_<vop>"] 164puts $fo [format "%-2s %s" "N" "vop_no<vop>"] 165puts $fo [format "%-2s %s" "S" "vop_std<vop>"] 166puts $fo [format "%-2s %s" "L" "<fs>_lookup"] 167puts $fo { 168</PRE> 169} 170puts $fo "<HR>" 171puts $fo {<TABLE BORDER NOSAVE>} 172set m 8 173for {set i 1} {$i <= $fn} {incr i $m} { 174 puts $fo "<TR>" 175 for {set j 0} {$j < $m} {incr j} { 176 set k [expr $i + $j] 177 if {$k <= $fn} { 178 #puts $fo "<TD>$k</TD><TD><FONT SIZE=-1>$nfn($k)/$use($k)</FONT></TD>" 179 puts $fo "<TD>$k</TD><TD><FONT SIZE=-1>$nfn($k)</FONT></TD>" 180 } 181 } 182 puts $fo "</TR>" 183} 184puts $fo "</TABLE>" 185 186puts $fo "</TABLE>" 187puts $fo "</BODY>" 188puts $fo "</HTML>" 189foreach i $tbn { 190 if {$i == "default_vnodeop"} { 191 continue 192 } 193 foreach j $opn { 194 set sfx [lindex [split $j _] 1] 195 if {![info exists op([list $i $j])]} { 196 continue 197 } 198 set v $op([list $i $j]) 199 if {$v != "vop_std$sfx"} { 200 continue 201 } 202 if {![info exists op([list default_vnodeop $j])]} { 203 continue 204 } 205 if {$op([list default_vnodeop $j]) != $v} { 206 continue 207 } 208 if {$op([list $i vop_default]) != "vop_defaultop"} { 209 continue 210 } 211 puts "Suspect: uses explicit default, $i $j $v $op([list $i vop_default])" 212 } 213} 214