Unix /dev and kernel extensions

socheesome

Registered
I am trying to understand logical interaction between Unix devices and OSX kernel Extensions (KEXT).

May someone help me ?

I have a powerbook and my simple question is:
when OSX uses the modem which is the driver is using ?

answer 1: /dev/cu.modem
answer 2: /System/Library/Extensions/AppleSCCSerial.kext
answer 3: both of them ???

I know quite well UNIX and Mac but really don't understand where in OSX end UNIX and begins OSX.

Tnaks a lot
 
The serial kext provides the driver and /dev/cu.modem (and /dev/tty.modem) represent the filesystem mapping of the modem device according to the POSIX standard.
 
So the files /dev/*.modem are just simbolic links to the real driver ?

I have seen the descriptors for the files

the descriptors are crw-rw-rw

the rw descriptors are well known but what does it mean "c" ??

Thanks a lot
 
Nope, they aren't the same as symbolic links - not by a longshot. They are "filesystem entities" that "abstract" the device (in this case a physical modem) so that it "maps" into the filesystem. However these are not "real" disk-based files, hence the letter 'c' in the flags field, which indicates a "character-based" device. (The letter 'b' indicates a "block" device.)

A device such as a modem is mapped into the filesystem so that you can use standard File I/O instructions from any language to communicate with the device. This mapping is totally "abstract," in the sense that the filesystem presents these devices "as if" they were files or directories, but reading and writing to them doesn't cause disk I/O to take place. Instead it causes some other I/O to take place.

This is consistent with the true nature of the filesystem, which appears to us as if it was a seamless window to our hard drives and removable disks. In fact every part of the filesystem is just an abstraction of a device by means of a driver. Once you understand that there is no distinction between disks and other devices (from the POSIX point of view) then you'll gain a better understanding of I/O in-general.

A cursory Google search turns up a few interesting discussions of the whole idea:

http://www.oreilly.com/catalog/linuxdrive2/sample/ch03.html
http://www.ece.umd.edu/class/enee642.S2000/handout8.shtml
http://jan.netcomp.monash.edu.au/OS/l15_1.html
 
The files in /dev usually fall into two categories: character special files and block special files. If the first character in a long ls is a c, it is a character special, whereas if the first character is a b, it's a block special. Most devices are character special, since most devices need to be byte-by-byte accessed (ie, modems). Disk devices can also be accessed in a 'cooked' fashion, where some of the work is done in the driver/kernel; this is the block special. Note disks have both character and block; character is used by low-level items like fsck, but usually mount is used against the block special.

As far as how they work, if you look at a long ls you'll see these files don't have sizes, but instead something like 8, 0. This is the major and minor numbers of that particular device. It tells the kernel how to handle the device; when you try to access it, the kernel sees the major number (8 in this example), and knows which driver handles 8. The driver then uses the minor however it needs to, like differentiating different partitions for a disk driver.
 
One other interesting note about MacOS X:

Most of the files in /dev are created dynamically. For example, when you plug in a USB device, a /dev file may be created, and it will be removed when the device is removed.

Wade
 
Ok , now is clear, ummmm, I think is better to me recover and refresh my old UNIX books.

Thanks a lot to all community.
 
Back
Top