/dev 下的 MAKEDEV

13175發表於2012-04-06
# man MAKEDEV
MAKEDEV(8) Linux Programmer’s Manual MAKEDEV(8)

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.

CUSTOMIZATION
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 // tty(1-7)本機登入
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 //偽終端 ssh登入使用
ssh登入後;
[root@a ~]# tty
/dev/pts/0

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] // IDE並行 原盤
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 parti-
tion, 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 sec-
ondary controller. These devices can also be used to
acess IDE CDROMs if using the new IDE driver.

xd[a-d] // XT 介面硬碟 這是IBM電腦時代的東西
XT hard disks. Partitions are the same as IDE disks.

sd[a-z], sd[a-c][a-z], sdd[a-x] // 串列埠硬碟 SCSI,SATA,SAS 都是。
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 (rewind-
ing) and nrftx (non-rewinding) are created. For compata-
bility, 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 sup-
porting 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 net-
work 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, skip-
ping over subdirectories, symbolic links, and device nodes, pro-
cessing lines in the files like so:

[root@a ~]# ls /etc/makedev.d/
00macros 01console 01ia64 01ipfilter 01mouse 01s390 01v4l
01alsa 01dac960 01ibcs 01isdn 01qic 01sound
01cciss 01ftape 01ida 01linux1394 01raid 01std
01cdrom 01generic 01ide 01linux-2.6.x 01redhat 01undocumented
[root@a ~]# cat /etc/makedev.d/00macros // cat 自己檢視。
=ALLREAD 644 root root
=ALLWRITE 666 root root
=FLOPPY 660 root floppy
=KMEM 640 root kmem
=PRINTER 660 root lp
=PTY 666 root tty
=ROOT 600 root root
=SERIAL 660 root uucp
=STORAGE 640 root disk
=TTY 620 root tty
=VCSA 620 vcsa tty

# Define "console" as an alias for root for specifying input devices and such.
=CONSOLE $ROOT


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 for-
matting 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.

macros
=macro expansion
Indicates a macro which can be referenced as $macro in
subsequent configuration statements.

CONFIGURATION CONFLICTS
In the event that the set of configuration files contains multi-
ple rules for a given device name, MAKEDEV will use all of them.
The end result is typically that the last rule given (either by
virtue of being listed below all other matching rules in the
same file, or by being listed in a file which is read after all
others which contain alternate rules) will apply. MAKEDEV reads
the set of configuration files in sorted order, so this misfea-
ture can be exploited dependably.

SEE ALSO
Linux Allocated Devices, maintained by Torben Mathiasen
.

BUGS
Let’s hope not. If we’re lucky, any problems we’ll find will be
confined to the configuration files, which were written by exam-
ining the devices.txt file. If your system uses udev, conflicts
between devices.txt and the in-kernel data which udev uses for
naming devices may crop up. If you find any bugs, please file
them in the bug database at against
the "MAKEDEV" component.

AUTHOR
Nalin Dahyabhai, based largely on work done by Nick Holloway and
Michael K. Johnson.

Linux 26 June 2001 MAKEDEV(8)
(END)

[root@a ~]# ls /dev
agpgart fd0u800 loop7 ram0 rtc tty17 tty35 tty53 vcs
autofs fd0u820 lp0 ram1 sda tty18 tty36 tty54 vcs1
cdrom fd0u830 MAKEDEV ram10 sda1 tty19 tty37 tty55 vcs2
cdrom-hdc floppy mapper ram11 sda2 tty2 tty38 tty56 vcs3
console floppy-fd0 md0 ram12 sg0 tty20 tty39 tty57 vcs4
core full mem ram13 shm tty21 tty4 tty58 vcs5
disk gpmctl net ram14 stderr tty22 tty40 tty59 vcs6
fd hdc null ram15 stdin tty23 tty41 tty6 vcsa
fd0 hpet nvram ram2 stdout tty24 tty42 tty60 vcsa1
fd0u1040 initctl oldmem ram3 systty tty25 tty43 tty61 vcsa2
fd0u1120 input par0 ram4 tty tty26 tty44 tty62 vcsa3
fd0u1440 kmsg parport0 ram5 tty0 tty27 tty45 tty63 vcsa4
fd0u1680 log parport1 ram6 tty1 tty28 tty46 tty7 vcsa5
fd0u1722 loop0 parport2 ram7 tty10 tty29 tty47 tty8 vcsa6
fd0u1743 loop1 parport3 ram8 tty11 tty3 tty48 tty9 vg
fd0u1760 loop2 port ram9 tty12 tty30 tty49 ttyS0 X0R
fd0u1840 loop3 ppp ramdisk tty13 tty31 tty5 ttyS1 xen
fd0u1920 loop4 ptmx random tty14 tty32 tty50 ttyS2 zero
fd0u360 loop5 pts rawctl tty15 tty33 tty51 ttyS3
fd0u720 loop6 ram root tty16 tty34 tty52 urandom[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/14181270/viewspace-1057838/,如需轉載,請註明出處,否則將追究法律責任。

相關文章