際際滷

際際滷Share a Scribd company logo
UNIX SYSTEM
PROGRAMING
SEMINAR-1
 NAME- SWETA LEENA
 USN- 1NH19CS750
 SEC-3E
Topic :Device file API
Unix system programing device file api
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.
Unix system programing device file api
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.
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
 <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.
Unix system programing device file api
Unix system programing device file api
Unix system programing device file api
THANK
YOU

More Related Content

Unix system programing device file api

  • 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.