Andys Unix FAQ

Unix Device Files - generic explanation

In this FAQ Understanding.. Major numbers Minor numbers Block/Character
Disk devices Serial Devices Removable media Tapes  
Related FAQs Solaris Devices Linux devices    


Unix FAQ Menu
Contents
Basic commands
Cron
Creating CDs
Device Files
DHCP server (Solaris)
Filesystem explained
Fsck
grub/lilo vanished!
Linux applications?
Linux databases?
Linux distributions
Serial Console
Solaris devices
Solaris disks - Intro
Solaris disks - Adding
Solaris x86 install
SQL/Shell script
Syslog/Monitoring
Time Synchronisation.
Virtual Memory
Web Multi-Language
Web Server Errors
Humour
Unix a Prank



 

A generic, platform independent explanation of Unix device handling follows, if you are looking for specific details check out the companion FAQ's for either Solaris of Linux.

Note: This FAQ assumes you are familar with the concepts and terms outlined in The Unix filesystem explained

Devices under Unix

Within Unix devices and files all handled it in much the same way. There are not distinct device and file management systems. Under Unix whenever a process opens a file or device the system creates a new entry for that file in the process'es open file table.

If you do an "ls -l" of a device file you'll notice that where you would normally see the size of the file there is instead two comma separated numbers.;

    sun (ksh) % ls -l /dev/fb
    crw------- 1 root other 63, 0 Mar 11 1999 /dev/fb 

These numbers are known as the major and minor device numbers.

The major device number is simply index into the kernel "Device Switch Table" and identifies the driver which handles that device.

The minor device number is a argument passed to the device driver whenever the kernel calls that driver. It interpreted in a device dependent fashion. Often it is the index of the device handled by that driver so the first terminal would have a minor number of zero the second of a minor number of one, etc.

Block & Character devices: There are two device switch tables within the kernel, one for character based devices ("cdevsw") such as terminal's or printers, and the second is the block devices ("bdevsw") such as disk or CD-ROM drives. The first character in the ls -l output indicates which table a device belongs to; 'c' - character, or 'b' - block.

Character devices are often refered to as Raw devices.

 

More about Solaris Devices

 

This page is under construction, please revisit soon...

 



Home Thai Guide   Great Circle Calculator WorldClock AMS Services Contact us