1833875 Members
1877 Online
110063 Solutions
New Discussion

Re: Device file

 
johnreid
Contributor

Device file

Hi Team ,

I have a doubt in device file ,

What is the purpose of having character and block files for a device , if we are using modem character device it self enough what is the need of block file.


Thanks in Advance

john
4 REPLIES 4
Pete Randall
Outstanding Contributor

Re: Device file

With disk devices, for example, the character or raw device file bypasses the operating system's buffer cache, which is what some data base products require. Other than that, most times you would want to use the block device.


Pete

Pete
Bill Hassell
Honored Contributor

Re: Device file

Block device files refer to a specific driver (the major number) and this number points to a driver that uses the buffer cache. There is no block driver for any device that is not a disk (ie, printer, tty/modem, LAN, etc). All filesystems access data via block files for performance unless extra options are used in fstab to bypass the cache.


Bill Hassell, sysadmin
A. Clay Stephenson
Acclaimed Contributor

Re: Device file

In general, only disk devices will have block device nodes but all devices will have character device nodes. In the kernel there are two device switch tables (character and block) and these tables tell the system how to do basic operations (open, close, read, write, seek, ...) for a given device. These tables are actually implemented as arrays of pointers to the various functions. In any event, if there are no entries for these functions this is signaled as a null entry in the device switch tables and if there are no functions at all defined for a given device (such as block devices for a modem) then a -1 or NULL is inserted in the device switch table.
If it ain't broke, I can fix that.
Sandman!
Honored Contributor

Re: Device file