Simple file system implementation
Xushua xiasihua00001@hotmail.com
introduction:
File management is an important one in the four major resource management in the operating system. Deepen the understanding of the principles by realizing a simple file system. Due to the large and considers of the file system, add a simpler file system to the limitations of our own time and capabilities.
Overview:
The mainstream of the file system has Windows FAT, FAT32, NTFS, and Linux. I can't achieve a complexity for a variety of reasons. Here, the following:
Document storage Space Management: Opening a space in memory as a file memory, using the FAT table combined with the bit diagram to achieve allocation and recycling of storage space. The field of the file system is implemented by the real deposit file.
Directory structure: The original intention tree structure is more complicated, you want to use the secondary directory structure (main file directory, user file directory), structure contains: file name, physical address, length, etc. However, in the actual development, a smart approach is used, so it uses a Linux system tree type directory structure.
Physical structure: Link file structure.
Logical structure: Flow file (collection of character sequence, non-structured recording file ").
Access mode: sequentially access. (Have a read-write pointer).
Experimental content:
Algorithm and data structure
FCB file, directory control information
Struct FCB {
Char szname [256]; // file, directory name
INT IIndex; // Index
INT ifatherindex; // The index root directory of the superior directory is -1
// int ishared; // shared count
INT TYPE; // catalog, one of both
// Bool isroot; // is the root directory
INT INEXTBLOCK; // The first memory address block is the first address of the directory is 0
INT ILENGTH; // File length directory is 0
int State; // Usage
INT isopend; // is open state (only if State is 1, Type is only valid) open to 1
} FCB [FATLENGTH]; // Control information for files or directories
INT FAT [FATLENGTH]; // FAT table and bit diagram combined with the recycling of physical blocks and idle blocks
Implementation
The file system is provided:
Format: Format the file memory, that is, the storage space is layout according to the structure of the file system, and the root directory is created and its data structure for managing file storage. Format
Create a subdirectory MKDir
Delete subdirectory RMDir
Display directory PWD
Change the current directory (return to the previous bid) CD..
Create a file mk
Open file open
Close file close
Write file VI
Read file cat
Delete file RM
Program introduction:
This document system has developed VC 6.0 (MFC). The static library has been placed (so the executable FileSystem_static is larger), which enters the execution of the machine promulgation (including the MFC class mfc42d.dll) to perform the executable filesystem_share.
The screenshot of the interface is as follows:
The interface style is a bit like Linux command line. The above has been explained. Execute the executable, enter the interface, as shown above. Displays the current directory name / root with a command line prompt>. You can enter the command to enter the car. Which commands can I support HELP or? Enter the details.
Let's try a multi-section management:
Establish the following structure
Just enter the following commands.
Want to write to write content in file F2, then display; there are other features to be reader to try!
Insufficient and improvement:
Due to various reasons, there is no resolution of the file directory.
The file content modification function has not increased.
references:
Operating system teacher
Online information