The document discusses the device file API in Unix systems. It defines device files as interfaces between physical devices like modems and application programs. It explains that mknod is the API used to create device files, which can be block or character special files. Mknod allows programs to interact with devices via device drivers and simplifies programming tasks related to system resources without physical connections. The document provides the prototype and an example of using mknod, specifying the path, permissions, and device ID with major and minor numbers.
2. NAME- SWETA LEENA
USN- 1NH19CS750
SEC-3E
Topic :Device file API
4. DEVICE FILE API
Definition
Device files are used to interface physical
device(ex:console, modem) with application
programs. Modem
Device file support is implementation
dependent. Unix system provides mknod
API to create the Device files.
mknod makes block or character special
files.
6. Why device file
It allows application program to
interact with a device by device driver.
Simplifies many programming tasks.
Device files are useful for accessing
system resource which have no
connections with device.
7. The prototype of mknod
#include<stdio.h>
#include<sys/stat.h>
#include<unistd.h>
int mknod(const char* path_name,
mode_t mode, int device_id);
Example:
mknod(SCSI5,S_IFBLK | S_IRWXU |
S_IRWXG | S_IRWXO,(15<<8) | 3);
On success mknod API returns 0 , else it
returns -1
8. <sys/stat. h> header defines the
structure of the data returned by the
functions like stat(),fstat().
The mode specifies the access
permission of the files
Device id contains the major and
minor numbers.
The lowest byte of the device_id is set
to be minor device number and the
next byte is set to be major device
number.