wanyuzha / fat_file_system Goto Github PK
View Code? Open in Web Editor NEWFAT文件系统
FAT文件系统
操作系统代码本质上是函数,为了方便模块的验证,设置一个主入口函数调用这些函数来进行验证。后期如果添加GUI则需要循环调用这些函数。
以下开始讨论函数设计:
虚拟一个文件缓冲区,一个文件缓冲区大小和一个扇区相同,都为512B。写入文件时,先写入文件缓冲区,写满一个就把这个扇区写入磁盘,如果没有写满就强制写入。读取时,按照一个扇区大小来取数据。
在构建FAT文件系统时,首先构造MBR扇区、DBR扇区,按照格式写在vdisk文件的开头
1.用Tab缩进
2.函数的左右括号单独一行,控制语句的左括号在同一行
3.在关键字“if,switch,case,for,do,while”之后需要加上空格;大多数的二元和三元运算符两边需要加空格,“= + - < > * / % | & ^ <= >= == != ? :”;
4.函数的代码程度不超过两屏,局部变量不超过10个。一个很大的函数尽量分成一些更短小的函数的组合,每个函数应该功能单一并且实现精准。如果担心函数调用带来开销,可以把小函数声明为inline。如果函数的名称是一种动作或者命令式的语句,应该以错误代码的形式返回(一般0表示成功,-Exxx形式的负数表示错误),如:do_something()。如果函数的名称是判断语句,则返回值应该类似于布尔值(1表示成功,0表示失败),如:something_is_exist()
5.注释使用C89风格/.../,描述代码要做什么和为什么这么做
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.