Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have read that each directories store their content (files and subdirectories) by using a list of filename and inode pairs. But none of the reference I got said something about how they are stored.

Are they stored on inode of their parent directory, using data blocks like a normal file, or maybe using other ways that I don't aware of?

Thanks for the clarification.

share|improve this question
    
There is no single way how Unix stores files. Similar to there is no single way to how windows stores files. In both cases it depends on the filesystem used. (FAT, NTFS, ext2, UFS, ...) –  Hennes Dec 16 '12 at 16:45
    
For filesystems the directory structure on disk is defined in dirent.h, and you are supposed to use the libcalls opendir/readdir/closedir etc to access the content. –  ott-- Dec 16 '12 at 17:05

1 Answer 1

up vote 3 down vote accepted

See file system internals which outlines in a rather simple way the internals of a typical Unix filesystem.

enter image description here

Most Unix filesystems contain

  • A boot block
  • A superblock (disk geometry, partition layout, inode count, etc)
  • Inode blocks
  • Data blocks

Modern filesystems contain additional structures.

One of the things in the superblock is the location of the inodes for the root directory.

A directory is a specially formatted file. As with all ordinary files, it has data blocks.

You can see this in The Linux Documentation Project: Filesystem

enter image description here

You can use debugfs to explore these structures.

share|improve this answer
    
"A directory is a specially formatted file. As with all ordinary files, it has data blocks." So are directories stored their filename-inode pairs (leftmost table on the 1st picture, or the row in the 2nd picture) in their data blocks? –  Oka Dec 17 '12 at 0:49
    
@Oka: That is correct. –  RedGrittyBrick Dec 17 '12 at 10:42
    
Okay, thanks for the help, sir. –  Oka Dec 17 '12 at 12:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.