NAME
MAKEDEV - 建立设备
总览 (SYNOPSIS)
cd dev; ./MAKEDEV -V
cd dev; ./MAKEDEV [ -n ] [ -v ] update
cd dev; ./MAKEDEV [ -n ] [ -v ] [ -d ] device ...
描述 (DESCRIPTION)
MAKEDEV 是 一个 脚本程序, 用于 在 /dev 目录下 建立 设备, 通过 这些 设备文件可以 访问 位于 内核 的 驱动程序.
注意, 如果 应用程序 显示 出错信息 ``ENOENT: No such file or directory'', 一般指 设备文件 不存在, 而 ``ENODEV: No such device'' 则 表明 内核 没有配置 或 装载 相应的 驱动程序.
选项 (OPTIONS)
- -V
- 显示 版本信息 (实际上 是 RCS 版本信息) 然后 退出.
- -n
- 并不做 真正的 更新, 只是 显示 一下 它的 执行 效果.
- -d
- 删除 设备文件. 主要 供 MAKEDEV 自己 用.
- -v
- 繁琐模式. 显示出 执行的 每一个 动作. 它的 输出内容 和 -n 选项 的 输出内容 一样.
自定义 (CUSTOMISATION)
由于 目前 还没有 系统 用户 和 用户组 的 标准名称, 你 可能 需要 修改 MAKEDEV 以 配合 你的 系统设置. 在 这个 程序 的 开始位置, 定义了 从 设备类型 到 用户, 用户组 和 访问权限的 映射关系 (例如, 所有的 CD-ROM 设备 通过 $cdrom 变量 设置). 如果 你 打算 改变 缺省定义, 就需要 编辑 这个 部分.
设备 (DEVICES)
- 基本选项 (General Option)
- update
- 该选项 只用于 实现了 /proc/interrupts 的 内核(从 1.1.x 开始). MAKEDEV 扫描 这个文件, 检查 目前 内核 配置了 什么设备, 它 和 上次配置 的 设备 做 比较 (记录在 文件 DEVICES 中), 创建 新设备 或主设备号 不相同 的 设备, 删除 没有 配置的 设备.
- generic
- 创建 通用设备 子集. 包括 标准设备, 软驱, 各种硬驱, 伪终端, 控制台设备, 基本串行设备, 总线鼠标 和 打印口.
- std
- 标准设备. 它们有:
- mem - 访问 物理内存;
- kmem - 访问 内核虚拟内存;
- null - 空设备 (无限写入 infinite sink);
- port - 访问 I/O 端口;
- zero - 空(0)字节 来源 (无限读出 infinite source);
- core - /proc/kcore 的 符号连接 (用于 内核除错);
- full - 写访问 这个设备 一定 返回 ENOSPACE;
- ram - 虚拟磁盘 (ramdisk);
- tty - 访问 进程 的 控制终端.
- local
- 运行 MAKEDEV.local. 它是个 脚本程序, 用来 创建 各种 本地设备 (local devices).
- 虚拟终端 (Virtual Terminal)
- console
- 用于 建立 关联(associate) 控制台 的 设备. 就是 虚拟终端 ttyx, x 从 0 到 63. 设备 tty0 是 当前的 活动 虚拟终端, 也就是 console. 每个 虚拟终端 有 两个 设备, vcsx 和 vcsax, 用做 虚拟终端 的 屏幕转储(screen-dump), vcsx 只有 文本, vcsax 还包括 属性.
- 串行设备 (Serial Device)
- ttyS{0..63}
- 串行口 和 对应的 拨出设备(dial-out). 对于 ttySx 设备, 有 同样的 设备 cuax 用于 拨出. 在 一些 简单 的 应用环境, 这种 形式 可以 避免 使用 协作锁.
- cyclades
- 用于 cyclades 智能 I/O 串行卡 的 拨入和拨出 设备. 拨入设备 是 ttyCx, 对应的 拨出设备 是 cubx. 缺省情况是 创建 7线 设备, 但是 去掉 注释 可以 改成 15线.
- 伪终端 (Pseudo Terminal)
- pty[p-s]
- 参数中的 每个字符 可以 创建 一组 共 16 个 主从伪终端对. 1.2 版本的 内核 支持 64 对. 主伪终端 是 pty[p-s][0-9a-f], 从伪终端是 tty[p-s][0-9a-f].
- 并行口 (Parallel Port)
- lp
- 标准并行口. 创建的 设备 是 lp0, lp1 和 lp2. 它们 对应的 端口 是 0x3bc, 0x378 和 0x278. 因此, 有些 机器 上 的 ***个 打印口 是 lp1.
- par
- lp 的替换. 端口 由 parx 命名, 代替了 lpx.
- 总线鼠标 (Bus Mice)
- busmice
- 各种 总线鼠标 设备. 有 logimouse (Logitech bus mouse), psmouse (PS/2-style mouse), msmouse (Microsoft Inport bus mouse) 和 atimouse (ATI XL bus mouse) 和 jmouse (J-mouse).
- 游戏杆设备 (Joystick Device)
- js
- 游戏操纵杆. 创建 js0 和 js1.
- Disk Devices
- fd[0-7]
- 软驱设备. fdx 设备 能够 自动检测 (盘面)格式, 其他设备 采用 固定格式, 在 名字中 指定 容量. 命名格式 是 fdxLn, 字母 L 表明 软盘 规格 (d = 5.25" DD, h = 5.25" HD, D = 3.5" DD, H = 3.5" HD, E = 3.5" ED). 数字 n 代表 这种规格下 的 盘面 容量 (单位是K). 因此 标准的容量 是 fdxd360, fdxh1200, fdxD720, fdxH1440, 和 fdxE2880.
- 更多的 内容 请参看 Alain Knaff 的 fdutils 发行包.
- 从 fd0* 到 fd3* 的 设备 是 ***个 控制器 上的 软驱, 而 fd4* 到 fd7* 则 位于 第二个 控制器 上.
- hd[a-d]
- AT 硬盘. 设备 hdx 提供 对 整个 硬盘 的 访问, 访问 分区 用 hdx[0-20]. 四个 主分区 从 hdx1 到 hdx4, 它们的 逻辑分区 从 hdx5 开始 到 hdx20. (主分区 可以 配置为 扩展分区, 扩展分区 可以 容纳 4个 逻辑分区). 缺省情况下, 一个 设备 只创建 4个 逻辑分区. 如果 要求 更多的 逻辑分区, 可以 在 MAKEDEV 中 去掉 相应的 注释.
- 驱动器 hda 和 hdb 位于 ***个 控制器 上. 如果 使用 新型的 IDE 驱动器 (而非 老式的 HD 驱动器), 还会有 hdc 和 hdd, 在 第二个 磁盘控制器上. 这些设备 同样可以 访问 IDE CDROM 驱动器.
- xd[a-d]
- XT 硬盘. 分区结构 和 IDE 硬盘 一样.
- sd[a-z], sd[a-c][a-z], sdd[a-x]
- SCSI 硬盘. 分区结构 和 IDE 硬盘 类似, 但是 逻辑分区 限制在 11 个 以内, (sdx5 到 sdx15). 允许 有 128个 SCSI 硬盘.
- loop
- 自环(loopback) 磁盘设备. 允许 你 把 普通文件 当做 块设备 使用. 这 意味着 可以 挂载(mount) 各种 文件系统 的 映像(文件), 用起来和 普通 的 文件系统 一样. 一般 创建 8个 设备, loop0 到 loop7.
- 磁带设备 (Tape Device)
- st[0-7]
- SCSI 磁带. 有 可回卷(rewinding)的 磁带设备 stx 和 不可回卷(non-rewinding) 的 nstx.
- qic
- QIC-80 磁带. 创建 的 设备 有 rmt8, rmt16, tape-d 和 tape-reset.
- ftape
- 软驱磁带 (QIC-117). 根据 不同的 驱动方法, 有 四种 存取 方法 0, 1, 2 和 3, 对应 各自的 设备 rftx (可回卷) 和 nrftx (不可回卷). 另外 还提供了 兼容设备 ftape 和 nftape , 它们是 rft0 和 nrft0 的 符号连接.
- CDROM 设备
- scd[0-7]
- SCSI CD 播放器.
- sonycd
- Sony CDU-31A CD 播放器.
- mcd
- Mitsumi CD 播放器.
- cdu535
- Sony CDU-535 CD 播放器.
- lmscd
- LMS/Philips CD 播放器.
- sbpcd{,1,2,3}
- Sound Blaster CD 播放器. 内核 能够 支持 16个 CDROM, 通过 sbpcd[0-9a-f] 访问. 它们 每四个 一组 分配 在 各个 控制器 上. sbpcd 是 sbpcd0 的 符号连接.
- 扫描仪 (Scanner)
- logiscan
- Logitech ScanMan32 & ScanMan 256.
- m105scan
- Mustek M105 手持式.
- ac4096
- A4Tek 彩色手持式.
- 音频 (Audio)
- audio
- 建立 供 声音驱动程序 使用的 音频设备. 包括 mixer, sequencer, dsp 和 audio.
- pcaudio
- PC 扬声器 声音驱动程序 的 设备. 有 pcmixer. pxsp, 和 pcaudio.
- 杂项 (Miscellaneous)
- sg
- 通用 SCSI 设备. 从 sga 到 sgh , sg0 到 sg7. 它们 允许 对 任何 SCSI 设备 发出 任意指令. 可以 查询 设备信息, 或者 控制不是 磁盘, 磁带 或 CDROM 的 SCSI 设备 (例如 扫描仪, 可擦写CDROM).
- fd
- 允许 任何程序 从 文件描述符 x 中 获取 输入, 文件名 是 /dev/fd/x. 而且 还创建了 /dev/stdin, /dev/stdout, 和 /dev/stderr. (注意, 这些 只是 到 /proc/self/fd 的 符号连接).
- ibcs2
- IBCS2 模拟器 所需的 设备(和符号连接).
- apm
- 电源管理设备.
- dcf
- DCF-77 radio clock 驱动程序 用的 设备.
- helloworld
- 内核模块 的 演示设备. 见 模块 源程序.
- 网络设备
- Linux 曾经在 /dev 下面 放了一些 设备文件, 用于 控制 网络设备, 现在 取消了. 想知道 内核 支持 什么 网络设备, 请 查看 /proc/net/dev.
另见 (SEE ALSO)
Linux Allocated Devices, H. Peter Anvin 维护, <Peter.Anvin@linux.org>.
#p#
NAME
MAKEDEV - create devices
SYNOPSIS
/sbin/MAKEDEV -V
/sbin/MAKEDEV [ -d directory ] [ -D directory ] [ -c configdir ] [ -m maxdevices ] [-a] [-n] [-v] [-i] [-M] [-S] [-u] [-x] device ...
DESCRIPTION
MAKEDEV is a program that will create the devices in /dev used to interface with drivers in the kernel.
Note that programs giving the error ``ENOENT: No such file or directory'' normally means that the device file is missing, whereas ``ENODEV: No such device'' normally means the kernel does not have the driver configured or loaded.
OPTIONS
- -V
- Print out version and exit.
- -a
- Always create devices, even if they already exist and have the proper permissions and file context. The default behavior is to only (re-)create device nodes which appear to be missing or whose permissions differ from the configured values.
- -m maxdevices
- Create no more than the specified number of devices for any specification in a configuration file.
- -n
- Do not actually update the devices, just print the actions that would be performed.
- -M
- Create symlinks, directories, and sockets belonging to the current user, and print out the list of devices which would be created in a format which is understood by RPM.
- -S
- Do not actually update the devices, just print the actions that would be performed in a format which can be fed to a shell.
- -d directory
- Create the devices under directory instead of the default (usually /dev).
- -D directory
- Compute file contexts for device creation as if the directory specified for the -d flag were the specified directory. This is useful if the -d flag is being used to populate a chrooted device directory.
- -u
- Print the ownership and permissions for devices instead of creating them. The information is formatted for use by udev.
- -x
- Create exactly the named device. By default, device names which have the specified device name as the initial portion of their name are also created. For example, specifying "tty" will also trigger the creation of "tty1", "tty2", and so on.
- -v
- Be verbose. Print out the actions as they are performed. This is the same output as produced by the -n option.
- -i
- Ignore errors parsing configuration files. .SHCUSTOMIZATION Since there is currently no standardization in what names are used for system users and groups, it is possible that you may need to modify MAKEDEV's configuration files to reflect your site's settings.
DEVICES
- Certain devices are required for minimal functionality. These are:
- mem - access to physical memory; null - null device (infinite sink); port - access to I/O ports; zero - null byte source (infinite source); core - symlink to /proc/kcore (for kernel debugging); full - always returns ENOSPACE on write; ram - ramdisk; tty - to access the controlling tty of a process.
- Virtual Terminals
- console
- This creates the devices associated with the console. These are the virtual terminals ttyx, where x can be from 0 though 63. The device tty0 is the currently active VT, and is also known as console. For each VT, there are two devices: vcsx and vcsax, which can be used to generate screen-dumps of the VT (vcsx is just the text, and vcsax includes the attributes).
- Serial Devices
- ttyS{0..63}
- Serial ports.
- Pseudo Terminals
- pty[p-s]
- Each possible argument will create a bank of 16 master and slave pairs. The current kernel (1.2) is limited to 64 such pairs. The master pseudo-terminals are pty[p-s][0-9a-f], and the slaves are tty[p-s][0-9a-f].
- Parallel Ports
- lp
- Standard parallel ports. The devices are created lp0, lp1, and lp2.
- Bus Mice
- busmice
- The various bus mice devices. This creates the following devices: logimouse (Logitech bus mouse), psmouse (PS/2-style mouse), msmouse (Microsoft Inport bus mouse) and atimouse (ATI XL bus mouse) and jmouse (J-mouse).
- Joystick Devices
- js
- Joystick. Creates js0 and js1.
- Disk Devices
- fd[0-7]
- Floppy disk devices. The device fdx is the device which autodetects the format, and the additional devices are fixed format (whose size is indicated in the name). The other devices are named as fdxLn. The single letter L identifies the type of floppy disk (d = 5.25" DD, h = 5.25" HD, D = 3.5" DD, H = 3.5" HD, E = 3.5" ED). The number n represents the capacity of that format in K. Thus the standard formats are fdxd360, fdxh1200, fdxD720, fdxH1440, and fdxE2880.
- For more information see Alain Knaff's fdutils package.
- Devices fd0* through fd3* are floppy disks on the first controller, and devices fd4* through fd7* are floppy disks on the second controller.
- hd[a-d]
- AT hard disks. The device hdx provides access to the whole disk, with the partitions being hdx[0-20]. The four primary partitions are hdx1 through hdx4, with the logical partitions being numbered from hdx5 though hdx20. (A primary partition can be made into an extended partition, which can hold 4 logical partitions). By default, only the devices for 4 logical partitions are made. The others can be made by uncommenting them.
- Drives hda and hdb are the two on the first controller. If using the new IDE driver (rather than the old HD driver), then hdc and hdd are the two drives on the secondary controller. These devices can also be used to acess IDE CDROMs if using the new IDE driver.
- xd[a-d]
- XT hard disks. Partitions are the same as IDE disks.
- sd[a-z], sd[a-c][a-z], sdd[a-x]
- SCSI hard disks. The partitions are similar to the IDE disks, but there is a limit of 11 logical partitions (sdx5 through sdx15). This is to allow there to be 128 SCSI disks.
- loop
- Loopback disk devices. These allow you to use a regular file as a block device. This means that images of filesystems can be mounted, and used as normal. This creates 16 devices loop0 through loop15.
- Tape Devices
- st[0-7]
- SCSI tapes. This creates the rewinding tape device stx and the non-rewinding tape device nstx.
- qic
- QIC-80 tapes. The devices created are rmt8, rmt16, tape-d, and tape-reset.
- ftape
- Floppy driver tapes (QIC-117). There are 4 methods of access depending on the floppy tape drive. For each of access methods 0, 1, 2 and 3, the devices rftx (rewinding) and nrftx (non-rewinding) are created. For compatability, devices ftape and nftape are symlinks to rft0 and nrft0 respectively.
- CDROM Devices
- scd[0-7]
- SCSI CD players.
- sonycd
- Sony CDU-31A CD player.
- mcd
- Mitsumi CD player.
- cdu535
- Sony CDU-535 CD player.
- lmscd
- LMS/Philips CD player.
- sbpcd{,1,2,3}
- Sound Blaster CD player. The kernel is capable of supporting 16 CDROMs, each of which is accessed as sbpcd[0-9a-f]. These are assigned in groups of 4 to each controller. sbpcd is a symlink to sbpcd0.
- Scanner
- logiscan
- Logitech ScanMan32 & ScanMan 256.
- m105scan
- Mustek M105 Handscanner.
- ac4096
- A4Tek Color Handscanner.
- Audio
- sound
- This creates the audio devices used by the sound driver. These include mixer, sequencer, dsp, and audio.
- Miscellaneous
- sg
- Generic SCSI devices. The devices created are sga through sgh and sg0 through sg7. These allow arbitary commands to be sent to any SCSI device. This allows for querying information about the device, or controlling SCSI devices that are not one of disk, tape or CDROM (e.g. scanner, CD-R, CD-RW).
- fd
- To allow an arbitary program to be fed input from file descriptor x, use /dev/fd/x as the file name. This also creates /dev/stdin, /dev/stdout, and /dev/stderr. (Note, these are just symlinks into /proc/self/fd).
- ibcs2
- Devices (and symlinks) needed by the IBCS2 emulation.
- apm
- Devices for power management.
- Network Devices
- Linux used to have devices in /dev for controlling network devices, but that is no longer the case. To see what network devices are known by the kernel, look in /proc/net/dev.
- Other Devices
- Note that the list of devices above is not exhaustive. MAKEDEV can create more devices nodes. Its aim is to be able to create everything listed in the devices.txt file distributed with Linux 2.4.
CONFIGURATION
MAKEDEV doesn't actually know anything about devices. It reads all of the information from files stored in /etc/makedev.d. MAKEDEV will read any and all files in the subdirectory, processing lines in them like so:
- devices
- [b|c] mode owner group major minor inc count fmt [base]
count devices will be created, with permissions set to mode and owned by owner and group. The first device will be named fmt, and additional devices will be created if count is larger than 1. If fmt contains a C-style formatting string, it will be filled with the sum of base and zero. Subsequent devices will be filled with the sum of base and n * inc, where n is the order this device is being created in. If the format string did not already include a format specifier, a "%d" will automatically be appended to it to make this work. - symbolic links
- l linkname target
A symbolic link pointing to target named linkname will be created. - aliases
- a alias value
Any commands that create devices for alias will also include devices that would be crated for value.
SEE ALSO
Linux Allocated Devices, maintained by Torben Mathiasen <device@lanana.org>.