Original Blog -> here
Minor differences means that would be Major similarities(and vice versa).
In UNIX, Linux, every I/O operation is done through files (at least conceptually). Files on disks are files but even the peripherals attached to your computer are logically mapped(converted) to files in order to communicate data between them and the user.
Our computer stores the data in two forms
- Physical(which the machine understands or in binary form).
- Logical(which the user understands or in easy form).
So, here mapping is necessary. To find these files explore the /dev directory.
With each such device file, there are two numbers associated. These are the major number and the minor number.
A device driver is a program that controls a particular type of device that is attached to your computer. There are device drivers for printers, displays. When you buy an operating system, many device drivers are built into the product. It interface hardware of extreme variety with your operating system.
A peripheral(terminal) can be classified by the kind of driver it uses to interface with the operating system.
Need of Major Number?
There is a reason behind each small thing stored in a computer.
Device files(also known as character special files) a device file that provides serial access (as opposed to a block special device such as a disk drive). For example terminals and serial devices are interfaced through character special files.
Now since there are many drivers residing concurrently inside of your OS kernel, each driver must (can) be uniquely identified with a number. These are your major numbers. Every device file is given the major number of the driver which the device needs (uses). Two files can have the same major number.
In order to differentiate with devices having the same major number, we assign them another number which is essentially serves as a serial number for all the devices of the same major. These are your minor numbers.
So, a file representing a device, has with it, two numbers, major and minor. Major represents the driver that device belongs to and Minor represents that device’s unique identity among all the devices with the same major. It is absolutely possible for devices to have the same major and majors to have devices of many minors.
As an example, all USB drives(say 3 files having different minor number) can be thought as devices represented by a USB driver(same major number).
ls -l /dev
crw-rw-rw- 1 root root 1, 3 Apr 11 2002 null crw------- 1 root root 10, 1 Apr 11 2002 psaux crw------- 1 root root 4, 1 Oct 28 03:04 tty1 crw-rw-rw- 1 root tty 4, 64 Apr 11 2002 ttys0 crw-rw---- 1 root uucp 4, 65 Apr 11 2002 ttyS1 crw--w---- 1 vcsa tty 7, 1 Apr 11 2002 vcs1 crw--w---- 1 vcsa tty 7, 129 Apr 11 2002 vcsa1
Here c means character special files(device files). The 5th and 6th column show the major and minor numbers (of the files) respectively.