Linux File System

Example: cat

          cat does this (not showing alot of stuff, like error checking, etc).

            main(argc, argv) {

                while (1) {

                    s = read(stdin, buf, 1);

                    s = write(stdout, buf, 1);

            }

'cat < /dev/console >/dev/console' is equivalent to 'cat'

both will simply echo what you type. /dev/console is special file in the file system that has a "device driver" associated with it. When you write to this device, you are really calling a function in the device driver package. In this case, the device driver, running in kernel space, can send characters to the user's display and get them from the keyboard.

Example

cat < dog > eat

Example

cat < dog | cat | cat | cat

Device Drivers

Example

    With the proper device driver, you should be able to send music to your 466 format player by using the following command:
    'cat song.466 > /dev/player466'

In class activity

write psuedo-code for a sonar device driver: The sonar device has one input, INIT and one output ECHO. The device performs a single measurement when INIT is asserted by the user. The time between the user's assertion of INIT and the devices assertion of ECHO corresponds distance. The challenge:

    Define the functions: open, read, write, close so that the device will look like a device.

You must

Example