Current location - Training Enrollment Network - Mathematics courses - Directory tree mathematics
Directory tree mathematics
From the user's point of view, the hard disk presents a directory tree structure whose depth and width can be widely expanded.

Unix divides the disk block into three super blocks, i- node table and data area.

I- node table, which stores all i- node information, each i- node information has an i- node number, an array for storing disk block numbers (disk block numbers for storing file contents referenced by this i- node number), and a stat structure (where file attributes are placed).

In fact, the contents of directories and ordinary files are placed on disk blocks (data is divided into several disk blocks, and each disk block has a number).

So how to distinguish between ordinary files and directories?

There are flags in the stat structure to distinguish whether the files referenced by i- nodes are ordinary files, directories, block files, character files, pipeline files or socket files.

Only the file name and I-node number are stored in the directory. In this way, through the file name -> I node number-> disk block number-> read;

You can read the contents of the corresponding file.

For details, please refer to Chapter 4. 14 of Advanced Programming in unix environment.

About learning linux or unix, it is not recommended to soak in forums. It is recommended to read books, read more and write more, and post if you have any questions. Both csdn and chinaunix are good.