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

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

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
			}
		}
	}
}