Check-in [50eb7273e9]
Overview
SHA1:50eb7273e9c59d28049a7e3ec0d7967509d9ed08
Date: 2014-10-29 16:17:30
User: rkeene
Comment:Added support for device name loading
Timelines: family | ancestors | descendants | both | trunk
Downloads: Tarball | ZIP archive
Other Links: files | file ages | folders | manifest
Tags And Properties
Context
2014-10-29
18:09
[a7c3ea759b] Added basic support for "stty" (user: rkeene, tags: trunk)
16:17
[50eb7273e9] Added support for device name loading (user: rkeene, tags: trunk)
16:07
[3b9488fc72] Added working modprobe (user: rkeene, tags: trunk)
Changes

Modified test.tcl from [0a5644d7e0] to [6bb651550d].

     1      1   #! /usr/bin/env tclsh
     2      2   
     3      3   puts [exec ./build-dyn.sh]
     4      4   
     5      5   load ./tuapi.so
     6      6   
     7         -::tuapi::modprobe fuse
            7  +::tuapi::modprobe /dev/fuse
     8      8   
     9      9   ::tuapi::syscall::tsmf_start_svc blah /bin/true /tmp/logfile [list PATH=/bin] / 022 0 0 10
    10     10   
    11     11   foreach iface [tuapi::syscall::ifconfig] {
    12     12   #lo0:2: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
    13     13   #        inet 127.0.0.1 netmask ff000000 
    14     14   #aggr100003:1: flags=201000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4,CoS> mtu 1500 index 2

Modified tuapi.tcl from [395d853f2a] to [741721e332].

   270    270   		uplevel 1 [list set line $line]
   271    271   		uplevel 1 $code
   272    272   	}
   273    273   	uplevel 1 [list unset -nocomplain line]
   274    274   }
   275    275   
   276    276   proc ::tuapi::modprobe args {
   277         -	# Load aliases
          277  +	# Set module base directory
   278    278   	set modules_dir [file join /lib/modules $::tcl_platform(osVersion)]
          279  +
          280  +	# Load device names
          281  +	set devnames_file [file join $modules_dir modules.devname]
          282  +	set fd [open $devnames_file]
          283  +	::tuapi::internal::foreach_line $fd " " {
          284  +		set module [lindex $line 0]
          285  +		set device [lindex $line 1]
          286  +		set id [lindex $line 2]
          287  +
          288  +		set id_type [string index $id 0]
          289  +		set id_type [string map [list "c" "char" "b" "block"] $id_type]
          290  +		set id [split [string range $id 1 end] :]
          291  +		set id_alias "${id_type}-major-[lindex $id 0]-[lindex $id 1]"
          292  +
          293  +		set "alias2module(/dev/${device})" $module
          294  +		set alias2module($id_alias) $module
          295  +	}
          296  +	close $fd
          297  +
          298  +	# Load aliases
   279    299   	set aliases_file [file join $modules_dir modules.alias]
   280    300   	set fd [open $aliases_file]
   281    301   	::tuapi::internal::foreach_line $fd " " {
   282    302   		set alias [lindex $line 1]
   283    303   		set module [lindex $line 2]
   284    304   
   285    305   		set alias2module($alias) $module
................................................................................
   323    343   			} else {
   324    344   				set load [list]
   325    345   			}
   326    346   
   327    347   			lappend load $module
   328    348   
   329    349   			foreach module $load {
          350  +				if {[string match "/dev/*" $module]} {
          351  +					return -code error "Unable to lookup device node module for $module"
          352  +				}
          353  +
   330    354   				set module [file join $modules_dir $module]
   331    355   
   332    356   				::tuapi::syscall::insmod $module
   333    357   			}
   334    358   		}
   335    359   	}
   336    360   }