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