Geschreven door studenten die geslaagd zijn Direct beschikbaar na je betaling Online lezen of als PDF Verkeerd document? Gratis ruilen 4,6 TrustPilot
logo-home
College aantekeningen

UNIX File System and Kernel Support for Files

Beoordeling
-
Verkocht
-
Pagina's
13
Geüpload op
06-06-2017
Geschreven in
2016/2017

These notes provide an in-depth understanding of the types of files and directories present in the UNIX systems, and how they are programmed. Some information of the POSIX standards followed are included. A comprehensive guide to the UNIX kernel support for files, and the significance of inode tables are also included. Reader gets an idea of how to manipulate UNIX files, and how to generate hard links or symbolic links.

Meer zien Lees minder
Instelling
Vak

Voorbeeld van de inhoud

Unix programming : File Handling


Files are the building blocks of any operating system. When you execute a
command in UNIX, the UNIX kernel fetches the corresponding executable
file from a file system, loads its instruction text to memory, and creates a
process to execute the command on your behalf. In the course of execution,
a process may read from or write to files. All these operations involve files.
Thus, the design of an operating system always begins with an efficient file
management system.


 File Types
A file in a UNIX or POSIX system may be one of the following types:
 regular file
 directory file
 FIFO file
 Character device file
 Block device file


1. Regular file
A regular file may be either a text file or a binary file. These files may
be read or written to by users with the appropriate access permission
.Regular files may be created, browsed through and modified by various
means such as text editors or compilers, and they can be removed by
specific system commands.
2. Directory file
It is like a folder that contains other files, including sub-directory
files.It provides a means for users to organize their files into some
hierarchical structure based on file relationship or uses. Example:

,/bin directory contains all system executable programs, such as cat, rm,
sort,etc.
A directory may be created in UNIX by the mkdir command.
Ex: mkdir/usr/foo/xyz
A directory may be removed via the rmdir command
Ex: rmdir /usr/foo/xyz.
The content of directory may be displayed by the ls command.


3. Device file
Device files can be of two types:
Block device file
It represents a physical device that transmits data a block at a time.
Ex: hard disk drives and floppy disk drives
Character device file
It represents a physical device that transmits data in a character-based
manner.
Ex: line printers, modems, and consoles


A physical device may have both block and character device files
representing it for different access methods. An application program may
perform read and write operations on a device file and the OS will
automatically invoke an appropriate device driver function to perform the
actual data transfer between the physical device and the application.
An application program in turn may choose to transfer data by either a
character-based(via character device file) or block-based(via block device
file).
A device file is created in UNIX via the mknod command.

, Ex: mknod /dev/cdsk c 115 5
Here ,
c character device file
115 major device number
5 minor device number
For block device file, use argument ‘b’ instead of ‘c’.
 Major device number: an index to a kernel table that contains the
addresses of all device driver functions known to the system. Whenever a
process reads data from or writes data to a device file, the kernel uses the
device file’s major number to select and invoke a device driver function
to carry out actual data transfer with a physical device.
 Minor device number : an integer value to be passed as an argument to a
device driver function when it is called. It tells the device driver function
what actual physical device is talking to and the I/O buffering scheme to
be used for data transfer.


4. FIFO file
It is a special pipe device file which provides a temporary buffer for two or
more processes to communicate by writing data to and reading data from the
buffer.
 The size of the buffer is fixed to PIPE_BUF.
 Data in the buffer is accessed in a first-in-first-out manner.
 The buffer is allocated when the first process opens the FIFO file for
read or write.
 The buffer is discarded when all processes close their references
(stream pointers) to the FIFO file.
 Data stored in a FIFO buffer is temporary.
 A FIFO file may be created via the mkfifo command.

Gekoppeld boek

Geschreven voor

Instelling
Vak

Documentinformatie

Geüpload op
6 juni 2017
Aantal pagina's
13
Geschreven in
2016/2017
Type
College aantekeningen
Docent(en)
Onbekend
Bevat
Alle colleges

Onderwerpen

$3.99
Krijg toegang tot het volledige document:

Verkeerd document? Gratis ruilen Binnen 14 dagen na aankoop en voor het downloaden kun je een ander document kiezen. Je kunt het bedrag gewoon opnieuw besteden.
Geschreven door studenten die geslaagd zijn
Direct beschikbaar na je betaling
Online lezen of als PDF

Maak kennis met de verkoper
Seller avatar
Srija123

Maak kennis met de verkoper

Seller avatar
Srija123 Dayananda Sagar College of Engineering
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
-
Lid sinds
8 jaar
Aantal volgers
0
Documenten
2
Laatst verkocht
-

0.0

0 beoordelingen

5
0
4
0
3
0
2
0
1
0

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Bezig met je bronvermelding?

Maak nauwkeurige citaten in APA, MLA en Harvard met onze gratis bronnengenerator.

Bezig met je bronvermelding?

Veelgestelde vragen