X01. OS. 13: file system, x01. OS. 13 File System
After two days of power stop, I suddenly had to be idle. Finding a broken guitar is no longer a string.
Ding ding Dangdang knocked on the power. To pick up time, stay up late for three or four o'clock.
From my top postsX01.Lab. DownloadDownloadX01. OS .12.tar.gz, Decompress the package and enter the OS directory on the terminal. Enter the bochs command to see the following interface:
Note that the following four lines are open, write, read, and unlink files. The call code is as follows:
1 void TestA () {2 int fd, n; 3 char path [] = "/test"; 4 char bufw [] = "hello"; 5 const int Len = 3; 6 char bufr [Len]; 7 8 fd = open (path, O_CREAT | O_RDWR); 9 Print ("fd: % d \ n", fd ); 10 11 n = write (fd, bufw, StrLength (bufw); 12 Print ("write OK! \ N "); 13 14 close (fd); 15 16 fd = open (path, O_RDWR); 17 n = read (fd, bufr, Len ); 18 bufr [n] = 0; 19 Print ("read: % s \ n", bufr); 20 21 close (fd); 22 23 if (unlink (path) = 0) 24 Print ("unlink file: % s", path); 25 26 // Spin ("TestA"); 27 while (1) {28 milllidelay (2000); 29} 30}TestA
After pressing F2, you can switch to tty2 and enter "hello" and "this is a test" respectively. The following page is displayed:
The call code is as follows:
1 void TestB () {2 char ttyName [] = "/dev_tty1"; 3 int stdin = open (ttyName, O_RDWR); 4 Assert (stdin = 0 ); 5 int stdout = open (ttyName, O_RDWR); 6 Assert (stdout = 1); 7 char buf [128]; 8 9 while (1) {10 write (stdout, "$", 2); 11 // Spin ("write"); 12 int r = read (stdin, buf, 70); 13 buf [r] = 0; 14 if (StrCompare (buf, "hello") = 0) {15 write (stdout, "hello world! \ N ", 13); 16} else {17 if (buf [0]) {18 write (stdout," {", 1); 19 write (stdout, buf, r); 20 write (stdout, "} \ n", 2); 21} 22} 23} 24 25 Assert (0); 26 while (1) {27 MilliDelay (2000); 28} 29}TestB
The two-way comparison shows that functions such as opening, reading, writing, and deleting a file are available, and tty is also successfully incorporated into the file system.
The file system itself is not complicated, but the structure of the super block and the index node is two. However, the implementation of the file system is quite complicated. It involves not only hard disk operations, but also tty and inter-process communication. In a sense, the file system is at the core of the entire operating system. Because the user program itself is just a file. To find out the file system, read books and read code.
It takes several days to finally run the file system successfully.
What is the format of Mac OS X's file system? Is FAT32 compatible?
The most common mac OS X file system is HFS +.
This is a LINUX file format.
In addition, WINDOWS is completely incompatible with this file format.
When formatting an apple machine, select a mac OS X extension file system with log records.
Very stable, very efficient
The HPFS you mentioned should be called a high-performance file system"
Not the same thing
FAT32 is compatible
If you want to use a mobile storage device that can be used by both MAC and PC, the FAT32 format is generally used.
But you need to know
FAT32 manages hard drives very poorly.
What are the main objectives of the file system in the operating system?
A solution for data stream management and storage. Otherwise, it will be difficult to read, search, run, and save data from data streams without rules.