strload 命令
用途
装入和配置可移植流环境(PSE)。
语法
描述
strload 命令使系统管理员能够装入和卸装驱动程序和模块,并且查询 PSE 和它的从属的装入状态。
缺省情况下,strload 命令根据 /etc/pse.conf 文件装入 PSE。 -f 标志允许管理员使用备用的配置文件。 -d 和 -m 标志是用来指定不在配置文件中(比如正在开发新的驱动程序时)的驱动程序和模块。 -q 标志报告引用的驱动程序和模块的系统装入状态(内核的存在)。
配置文件
配置文件是一个平面 ASCII、面向行的数据库。 注释由 #(镑符号)引入,并继续到行尾。 空行将被忽略。 每个记录的格式为:
attributes filename [argument [node [minor ...] ] ]字段由空格、制表符或空格和制表符分隔。 破折号(-)可以用来指定字段值,表示使用缺省值。 字段定义如下:
| 项 | 描述 |
|---|---|
| attributes | 描述要装入的扩展名。 可接受的值有:
|
| 项 | 描述 |
|---|---|
| filename | 指定包含该扩展名的对象文件。 如果发出的命令在要装入、卸装或查询的驱动程序或模块的文件名中有“/”(斜杠),那么 strload 命令在文件名字段中显式地使用该值。 如果文件名条目中没有“/”,那么 strload 命令首先会在当前目录中查找该驱动程序或模块的副本。 如果该驱动程序或模块不在当前目录中,那么 strload 将在 /usr/lib/drivers/pse 目录中查找该驱动程序或模块。 |
注: 建议从根目录 (/) 发出 strload 命令。 必须始终从同一目录发出用于装入,卸载和查询的 strload 命令。
内核扩展装入程序“要求”在装入、卸载和查询时使用的路径名完全相同。 这个要求,加上文件名是由 strload 确定,可能会带来问题。 strload 命令所使用的路径名中的每个字节,必须与内核扩展装入程序所使用的路径名中的每个对应位置的字节完全匹配,这是因为内核在查找匹配项时将对文件名执行 strcmp()。 如果从另一个目录发出了 strload 命令以卸装该模块或驱动程序,那么将发生下列其中一个事件:
- 如果 strload 命令在新的当前目录中找不到驱动程序或模块的副本, strload 尝试卸载 /usr/lib/drivers/pse 目录中的驱动程序或模块。 但是,此路径名可能与装入器为该驱动程序或模块记录的路径名不相同。 如果这两个路径名不相同,那么 strload 命令将失败。
- 如果 strload 命令在新的当前目录中找到模块或驱动程序的另一个副本,那么路径名相同,并且装入程序正确卸载装入的驱动程序或模块。 这样,strload 命令会成功运行,但结果未必是用户所期望的。
例如:
以下方案(不推荐使用)将导致卸载“spx”(也称为“A”)。 这可能并不是用户期望的效果。
mkdir /tmp/foo /tmp/bar
cp /usr/lib/drivers/pse/spx /tmp/foo/A
cp /bin/ls /tmp/bar/A
cd /tmp/foo
strload -d A # The loader knows the path and filename as
# "A" because "A" is found in the current
# directory
cd /tmp/bar
strload -q -d A # Reports "yes" because there is "A" in the
# current directory. Note that the file "A"
# in /tmp/bar is NOT the same file "A" in
# /tmp/foo, but the loader does not care
# because it identifies the file by
# pathname.
strload -u -d A # Unloads spx (also known as "A")!以下内容是一个错误方案:
mkdir /tmp/foo2 /tmp/bar2
cp /usr/lib/drivers/pse/spx /tmp/foo2/A
cd /tmp/foo2
strload -d A # The loader knows the path and filename as
# "A"because "A" is found in the current
# directory.
cd /tmp/bar2
strload -q -d A # Answers "no". There is no filename
# in /tmp/bar2 that matches "A", so strload
# prepends pathname "/usr/lib/drivers/pse" to
# "A". "/usr/lib/drivers/pse/A" is not found,
# so strload answers "no".
strload -u -d A # Fails - "A" does not exist.以下内容是一个错误方案:
cd /usr/lib/drivers/pse
strload -d spx # The loader knows the path and filename as
# "spx" because "spx" is found in the
# current directory.
cd /
strload -q -d spx # Answers "no". There is no filename in /
# that matches "spx", so strload prepends
# the pathname "/usr/lib/drivers/pse" to
# "spx". "/usr/lib/drivers/pse/spx" is found
# since it exists, so strload gives
# "/usr/lib/drivers/pse/spx" to the loader.
# The strcmp() fails since
# "/usr/lib/drivers/pse/spx" and "spx" do
# not match exactly.
strload -u -d spx # Fails - "spx" does not exist.
| 项 | 描述 |
|---|---|
| argument | 对于 strload 命令,该参数没有含义。 这个字段是可选的。 在调用它的配置例程时,将它传递到扩展名。 其解释是特定于该扩展名的。 缺省参数是filename。 |
| node | 指定要创建的节点名称。 这个字段是可选的。 它只适用于驱动程序,并且只在装入驱动程序时作为创建的节点名使用。 缺省情况下,创建的节点为 /dev/filename. |
| minor | 指定要为此驱动程序另外创建的非克隆节点。 这个字段是可选的。 通过将次要数字附加到克隆的驱动程序节点名上,创建该节点名。 给出的次要数字不超过 5(从 0 至 4),并且对每个数字都创建一个节点。 |
如果命令行中显式地给出了配置文件的名称,那么 -d 和 -m 标志不会使配置文件被忽略,情况如下:
strload -f /tmp/my.conf -d newdriver注: -d 和 -m 标志不会覆盖配置文件。 即如果使用该配置文件装入驱动程序 dgb,-d 标志将试图重新装入它,但会失败。 在 -d 和 -m 标志前处理该配置文件。
-d 和 -m 标志的 List 变量是一个以逗号分隔的文件名列表,每个文件名都包含单个 PSE 驱动程序或模块。 就像在该配置文件中找到以下表单之一中的某行,进行配置处理:
d filename m filename标志
| 项 | 描述 |
|---|---|
| -d 列表 | 列出要装入或卸装的 PSE 设备驱动程序。 List 变量指定一个以逗号分隔的驱动程序对象名的列表。 |
| -f 文件 | 根据 File 变量指示的文件中包含的配置信息来配置 PSE 。 缺省的配置文件是 /etc/pse.conf。 |
| -m 列表 | 列出要装入或卸装的 PSE 模块。 List 变量指定一个以逗号分隔的模块对象名的列表。 |
| -q | 报告扩展名的装入状态。 |
| -U | 卸装扩展名。 |
安全性
示例
- 输入以下命令将装入 PSE (如果尚未装入) ,dgb和ssb来自 /usr/lib/drivers/pse/ 目录的驱动程序,以及aoot当前目录中的模块,但不使用配置文件:
root# strload -d dgb,ssb -m ./aoot - 要卸载aoot仅模块,请输入:
root# strload -u -m ./aoot - 输入以下命令将询问spx驱动程序存在:
如果不存在,将产生以下输出:root# strload -q -d spxspx : no - 以下是示例配置文件:
行 1 装入dgb作为已克隆设备的驱动程序扩展/dev/dgb. 传递给dgb配置例程是dgb.#example configuration file d dgb #line 1 d mux - - 0 #line 2 ds foo #line 3 d+ xtiso tcp /dev/xti/tcp #line 4 d+ xtiso udp /dev/xti/udp #line 5 m aoot #line 6行 2 装入mux作为已克隆设备的驱动程序扩展/dev/mux并创建标准设备名/dev/mux0具有次数 0 (零)。 (用次要数字 0 至 4 创建的设备名不超过 5 个。)
行 3 装入foo作为标准设备 (未克隆) 指定的驱动程序扩展/dev/foo. 次数字为 0。
行 4 和 5 装入xtiso驱动程序扩展,并将其配置两次: 一次作为tcp一次作为udp. 创建的克隆节点是/dev/xti/tcp和/dev/xti/udp. 配置例程xtiso被调用两次: 一次与自变量一起调用tcp和一次udp.
行 6 装入aoot模块扩展。 未创建任何节点,将向配置例程传递值aoot.
- 要装入流 dlpi 驱动程序,请输入以下命令:
strload -f /etc/dlpi.conf
文件
| 项 | 描述 |
|---|---|
| /usr/lib/drivers/pse/* | 包含 PSE 内核扩展名。 |
| /etc/pse.conf | 缺省的 PSE 配置文件。 |
| / usr / sbin / strload | 包含 strload 命令。 |