Check-in [3b9488fc72]
Overview
SHA1:3b9488fc72ff9ccac8fb257c7981253a8882bd9e
Date: 2014-10-29 16:07:37
User: rkeene
Comment:Added working modprobe
Timelines: family | ancestors | descendants | both | trunk
Downloads: Tarball | ZIP archive
Other Links: files | file ages | folders | manifest
Tags And Properties
Context
2014-10-29
16:17
[50eb7273e9] Added support for device name loading (user: rkeene, tags: trunk)
16:07
[3b9488fc72] Added working modprobe (user: rkeene, tags: trunk)
15:52
[da57283f3e] Fixed linking order (user: rkeene, tags: trunk)
Changes

Modified tuapi.tcl from [fd3cc0d95d] to [395d853f2a].

   251    251   				::tuapi::syscall::ifconfig $interface flags $flags
   252    252   			}
   253    253   
   254    254   		}
   255    255   	}
   256    256   }
   257    257   
   258         -proc ::tuapi::internal::foreach_line {fd {sep ""} code} {
          258  +proc ::tuapi::internal::foreach_line {fd sep code} {
   259    259   	while {![eof $fd]} {
   260    260   		gets $fd line
   261    261   
   262    262   		regsub { *#.*$} $line {} line
   263    263   
   264    264   		if {$line == ""} {
   265    265   			continue
   266    266   		}
   267    267   
   268         -		if {$sep == ""} {
   269         -			set line [split $line]
   270         -		} else {
   271         -			set line [split $line $sep]
   272         -		}
          268  +		set line [split $line $sep]
   273    269   
   274    270   		uplevel 1 [list set line $line]
   275    271   		uplevel 1 $code
   276    272   	}
   277    273   	uplevel 1 [list unset -nocomplain line]
   278    274   }
   279    275   
   280    276   proc ::tuapi::modprobe args {
   281    277   	# Load aliases
   282    278   	set modules_dir [file join /lib/modules $::tcl_platform(osVersion)]
   283    279   	set aliases_file [file join $modules_dir modules.alias]
   284    280   	set fd [open $aliases_file]
   285         -	::tuapi::internal::foreach_line $fd {
          281  +	::tuapi::internal::foreach_line $fd " " {
   286    282   		set alias [lindex $line 1]
   287    283   		set module [lindex $line 2]
   288    284   
   289    285   		set alias2module($alias) $module
   290    286   	}
   291         -
   292    287   	close $fd
   293    288   
   294    289   	# Load dependencies
   295    290   	set deps_file [file join $modules_dir modules.dep]
          291  +	set fd [open $deps_file]
   296    292   	::tuapi::internal::foreach_line $fd ":" {
   297    293   		set module [string trim [lindex $line 0]]
   298         -		set deps [split [string trim [lrange $line 1 end]]]
   299         -		puts "$module -> $deps"
          294  +		set deps [split [string trim [join [lrange $line 1 end]]]]
          295  +
          296  +		set module_basename [file rootname [file tail $module]]
          297  +		set module_basename_alt1 [string map [list "_" "-"] $module_basename]
          298  +		set module_basename_alt2 [string map [list "-" "_"] $module_basename]
          299  +
          300  +		set alias2module($module_basename) $module
          301  +		set alias2module($module_basename_alt1) $module
          302  +		set alias2module($module_basename_alt2) $module
          303  +
          304  +		if {[llength $deps] != 0} {
          305  +			set module2deps($module) $deps
          306  +		}
   300    307   	}
          308  +	close $fd
   301    309   
   302    310   	# Load modules
   303    311   	foreach modules $args {
   304    312   		foreach module $modules {
          313  +			for {set try 0} {$try < 100} {incr try} {
          314  +				if {![info exists alias2module($module)]} {
          315  +					break
          316  +				}
          317  +
          318  +				set module $alias2module($module)
          319  +			}
          320  +
          321  +			if {[info exists module2deps($module)]} {
          322  +				set load $module2deps($module)
          323  +			} else {
          324  +				set load [list]
          325  +			}
          326  +
          327  +			lappend load $module
          328  +
          329  +			foreach module $load {
          330  +				set module [file join $modules_dir $module]
          331  +
          332  +				::tuapi::syscall::insmod $module
          333  +			}
   305    334   		}
   306    335   	}
   307    336   }