Wednesday 26 February 2014

Filesystem blocks

BLOCKS
File system is divided in to 5 blocks
1.boot block
2.super block
3.dentry
4.inode
5.data block

  • Boot block-located in first few sectors of a file system. first sector contains a boot strap program that reads a larger boot strap program from the next few sectors, and forth.
  • Each file system has one super block.it contains type of file system,the block size,pointers to a list of free blocks,the inode number of the root directory,magic number.
  • Every file  have one inode.In linux every file is recognized with integer number known as inode number.this structure consists of file ownership indication,file type(e.g., regular,directory,special device, pipes, etc.),file access permissions,time of last access and modification,number of links to the file,pointers to the data blocks to the file,size of the file in bytes.
       inode include pointers to the data blocks. Each inode contains 15 pointers.

  1.  the first 12 pointers point directly to data blocks
  2.  the 13 th pointer point to an indirect block, a block containing pointers to data blocks.
  3.  the 14 th pointer points to a doubly-indirect block, a block containing 128 addresses of singly indirect blocks.
  4. the 15 th pointer points to a triply indirect block(which contains pointers to doubly indirect blocks,etc)
      Difference Between in-core inode and disk inode:
                                               The inode is a data structure that descibes everything about a file other than their name.when a file is opened then the kernel copies the inode in to memory. As the file changes, the in-core inode is updated usuallymore often than on-disk copy. And the in-core inode has a few extra fields that are only needed while the file is opened.
                               In-core copy of the inode contains
                              -status of the in-core inode(ref)
                              -logical device number of file system(from which this inode is copied in to main memory)
                               -inode number
                               -pointers to other in-core inodes(hash list,queue list(ref, buffer cache))
                              -reference count(how many instances active at particular time)
   NOTE:By observing in-core copy of inode and disk inode, we observe that
            -we won't need inode number in disk inode because blocks are stored sequentially.But when we are transferring in to main memory that sequence may not be maintained.(ex., we may want node 4 followed by node12 and so on..)                                              
    REF:
    status-  1.locked(the inode may be used by some other process, to prevent other inode to access)
                2.A process is waiting for inode to be unlocked
                3.changed(if inode on memory is changed, this option helps to reflect the changes on disk)
                4.file changed(corresponding to this inode)
                      The above provided information is not found on disk.

No comments:

Post a Comment