FILE SYSTEM OF UNIX
• When we create a file in Unix, the kernel
does the following:
1.Kernel allots, storage for the file,
somewhere in the disk.
2.Kernel creates inode entry on a special
section on the disk. Inode contains all
attributes of the file, Inode contents are
listed below
Inode-contents
A. The starting location of disk from where the file
starts.
B. The size of the file.
C. When the file was last used and modified.
D. The owner of the file.
E. Various permissions(read, write and execution) the
file has got.
F. The number of links the file has got.
G. And various other administrative information of file.
• That means Inode consists of everything about the file except
the contents and name of file
1. Kernel creates a directory entry for the file. Infact Unix treats
a directory as a file. In directory file Unix stores just two
items: The inode number of the file and the name of the file.
Directory entries are shown below:
f ILE NAME INODE NUMBER
X.C 12199
Y.C 22224
PAD 12345
When we type “vi X.C or cat X.C then in order to display the file
contents the system uses the directory entry to find what inode
number corresponds to X.C.
Then the system uses that inode number to locate the file and
displays the file.
Inode-number
Staring address of file AB19H
File size
File creation time
Last modification time
Number of links
I-node information -table
NOTE:: The command “ls –l “ displays all the files of Present
Working Directory and their corresponding inode entries(shown
above as directory entries).
Unix keeps regular files on a block devices such as disks or
tapes. An installation can have several disk units. Each disk
unit may contain one or more file systems.
Partitioning a disk into several file systems makes it easier for
administrator to manage. The kernel deals with file systems
rather than with disks. Kernel treats each file system as a
logical device by providing a device number.
A file system is divided into blocks of size 512, 1024, 2048…
etc. Block size depends upon the system.
If the block size is more then disk operations are faster but
effective storage capacity will be dropped due to internal
fragmentation.
.
• A file system is divided into 3 groups. The first group
consists of the block one which is called as super block. It
contains information about the particular file system.
Super
block
I N O D E B L
O C K S
FILE ST O RA GE BL O C
KS
FILE
SYSTEM1
FILE
SYSTEM2
A FILE SYSTEM
SUPER BLOCK
• Super block consists of the following information:
1. The size of the file system.
2. The number of blocks in the file system.
3. The number of free blocks.
4. The index of the next free block.
5. The size of the inode list.
6. The index of the next free inode.
Inode -& other blocks
• The second group consists of inode blocks.
Third and final portion of the file
• file System consists of blocks for storing
files themselves.
• Changing a file name or moving a file
doesnot change the inode number.
•
• A copy command creates another file.
Replicated or duplicated files can be created
by ‘ln’ - link command.
• $ln V.C newV.C
•
• $ls -l
• 3977 V.C
• 3977 newV.C
• ln command allows several different
names to indicate the same file. By giving
ln V.C newV.c the following things will
happen:
• 1. The kernel names a new file “newV.C in
the directory entry with the inode number of
V.C.
• 2. In the inode table entry of “V.C” it makes
the number of links as 1(Note: an inode table
consists of one entry(column) that indicates
the number of links)
• When we say “rm newV.C”
• 1) it only deletes the file entry in the
directory.
• 2) It decrements the link field entry.
LINK COMMAND-INODES

files-inodes in Unix programming in computer science and engineering.ppt

  • 1.
    FILE SYSTEM OFUNIX • When we create a file in Unix, the kernel does the following: 1.Kernel allots, storage for the file, somewhere in the disk. 2.Kernel creates inode entry on a special section on the disk. Inode contains all attributes of the file, Inode contents are listed below
  • 2.
    Inode-contents A. The startinglocation of disk from where the file starts. B. The size of the file. C. When the file was last used and modified. D. The owner of the file. E. Various permissions(read, write and execution) the file has got. F. The number of links the file has got. G. And various other administrative information of file.
  • 3.
    • That meansInode consists of everything about the file except the contents and name of file 1. Kernel creates a directory entry for the file. Infact Unix treats a directory as a file. In directory file Unix stores just two items: The inode number of the file and the name of the file. Directory entries are shown below: f ILE NAME INODE NUMBER X.C 12199 Y.C 22224 PAD 12345 When we type “vi X.C or cat X.C then in order to display the file contents the system uses the directory entry to find what inode number corresponds to X.C. Then the system uses that inode number to locate the file and displays the file.
  • 4.
    Inode-number Staring address offile AB19H File size File creation time Last modification time Number of links I-node information -table NOTE:: The command “ls –l “ displays all the files of Present Working Directory and their corresponding inode entries(shown above as directory entries).
  • 5.
    Unix keeps regularfiles on a block devices such as disks or tapes. An installation can have several disk units. Each disk unit may contain one or more file systems. Partitioning a disk into several file systems makes it easier for administrator to manage. The kernel deals with file systems rather than with disks. Kernel treats each file system as a logical device by providing a device number. A file system is divided into blocks of size 512, 1024, 2048… etc. Block size depends upon the system. If the block size is more then disk operations are faster but effective storage capacity will be dropped due to internal fragmentation. .
  • 6.
    • A filesystem is divided into 3 groups. The first group consists of the block one which is called as super block. It contains information about the particular file system. Super block I N O D E B L O C K S FILE ST O RA GE BL O C KS FILE SYSTEM1 FILE SYSTEM2 A FILE SYSTEM
  • 7.
    SUPER BLOCK • Superblock consists of the following information: 1. The size of the file system. 2. The number of blocks in the file system. 3. The number of free blocks. 4. The index of the next free block. 5. The size of the inode list. 6. The index of the next free inode.
  • 8.
    Inode -& otherblocks • The second group consists of inode blocks. Third and final portion of the file • file System consists of blocks for storing files themselves. • Changing a file name or moving a file doesnot change the inode number. •
  • 9.
    • A copycommand creates another file. Replicated or duplicated files can be created by ‘ln’ - link command. • $ln V.C newV.C • • $ls -l • 3977 V.C • 3977 newV.C • ln command allows several different names to indicate the same file. By giving ln V.C newV.c the following things will happen:
  • 10.
    • 1. Thekernel names a new file “newV.C in the directory entry with the inode number of V.C. • 2. In the inode table entry of “V.C” it makes the number of links as 1(Note: an inode table consists of one entry(column) that indicates the number of links) • When we say “rm newV.C” • 1) it only deletes the file entry in the directory. • 2) It decrements the link field entry. LINK COMMAND-INODES