• Stars
    star
    139
  • Rank 261,464 (Top 6 %)
  • Language
    C++
  • License
    GNU General Publi...
  • Created over 7 years ago
  • Updated almost 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A linux-like virtual file system by C++

os_filesystem - 一个虚拟文件系统(C++)

简介

这是一个仿linux的虚拟文件系统,系统由一个虚拟磁盘文件承载,以文件读写模拟磁盘读写,不涉及底层驱动。

写一个简单的仿linux文件系统,首先需要设计好包含inode、block、superblock、虚拟磁盘布局,空间分配等信息的基本框架。文件系统的开头是一个superblock,包含系统的重要信息,包括inode和block的数量和大小。对于inode,一般来说需要占磁盘空间的百分之一,不过这是个小系统,总大小才5M多一点,所以分配给inode区的空间很少,剩下的空间大部分是block区。

该文件系统的总体规划如下:

由于写程序的时候时间比较紧张,只写了4天就去验收,所以代码没来得及优化,有的地方会显得冗余,大家不要见怪。

虽然时间有限,不过也额外实现了一个vi编辑器的功能,写的比较简陋,代码也很乱,有时间改进一下。

总的来说,代码还有待优化,欢迎多提意见,多挑毛病。

如何使用

step 1:下载项目

git clone https://github.com/windcode/os_filesystem.git

step 2:用VC++6.0打开项目

双击目录中的 MingOS.dsw 文件,或者将该文件拖到VC++6.0界面中。

step 3:编译,链接,运行

或者

step 1:直接运行 /Debug 文件夹下 MingOS.exe 文件

特性

  • 初次运行,创建虚拟磁盘文件

  • 登录系统

默认用户为root,密码为root

  • 帮助命令(help)

  • 用户添加、删除、登录、注销(useradd、userdel、logout)

  • 修改文件或目录权限(chmod)

  • 写入、读取受权限限制

  • 文件/文件夹添加、删除(touch、rm、mkdir、rmdir)

  • 查看系统信息(super、inode、block)

  • 仿写一个vi文本编辑器(vi)

  • 索引节点inode管理文件和目录信息

  • 使用 成组链接法 管理空闲block的分配

    • block分配过程: 当需要分配一个block的时候,空闲块堆栈顶拿出一个空闲块地址作为新分配的block。 当栈空的时候,将栈底地址代表的空闲块中堆栈作为新的空闲块堆栈。
    • block回收过程: 当回收一个block的时候,检查堆栈是否已满,如果不满,当前堆栈指针上移,将要回收的block地址放在新的栈顶。 如果堆栈已满,则将要回收的block作为新的空闲块堆栈,将这个空闲块堆栈栈底元素地址置为刚才的空闲块堆栈。
    • 分配和回收的同时需要更新block位图,以及超级块。
  • inode的分配/回收

    • inode的分配和回收较为简单,采用顺序分配和回收。
    • 需要分配时,从inode位图中顺序查找一个空闲的inode,查找成功返回inode的编号。
    • 回收的时候,更新inode位图即可。
    • 分配和回收都需要更新inode位图。

注意

  • 运行环境为VC++6.0

More Repositories

1

zhihu-crawler-people

A simple distributed crawler for zhihu && data analysis
Python
191
star
2

watchman

📆 更夫(watchman)是一款可视化的定时任务配置 Web 工具,麻麻不用担心我漏掉任何更新啦!
JavaScript
51
star
3

MingBlog

A personal blog based on Django
JavaScript
27
star
4

mdfmt

💡 A Markdown formatter that follow the CommonMark. Like gofmt, but for Markdown.
Go
24
star
5

paper_autotranslation

An automatic translation tool for paper ( PDF => TXT, English => Chinese )
Python
17
star
6

EventExtractByNovel

【NLP】基于SVM的网络小说事件类型识别
Python
13
star
7

py2exe

python程序 ==> exe可执行文件 纯净版转换器(自动删除多余文件,只保留最后转换好的exe文件)
Python
12
star
8

RenewRemind

一个 小说/番剧/漫画 更新 email 提醒脚本
Python
8
star
9

heatbox

《绝地求生》的直播热度监控(暂停服务)
Python
8
star
10

es-handle

A simple CRUD of ElasticSearch python client
Python
5
star
11

FileCarry

我是局域网文件搬运工 _(:з」∠)_
Python
5
star
12

go-web-template

Template application of Domain Driven Design(DDD) in go and gin.
Go
4
star
13

readNewspaper

自动获取电子版报纸,方便每天阅读
Python
4
star
14

douyin_front

the front-end of Douyin-Sprite
Vue
3
star
15

errors

An errors package for web development in Golang.
Go
3
star
16

gulu

A Golang util (轱辘)
Go
3
star
17

go-badges

⭐ Add pretty badges (build passing, coverage, etc) to your readme/markdown file for Go project!
3
star
18

login_form

一个登陆框 HTML 模板
CSS
2
star
19

kusion-action

Kusion Github Action
Shell
2
star
20

lunarvim-config

My LunarVim Configuartion.
Lua
2
star
21

windcode.github.io

A blog based on Hexo.
HTML
2
star
22

go-makefile

A Go project general Makefile, encapsulated some common Targets
Makefile
2
star
23

alacritty-config

my alacritty config
2
star
24

kstatus

Low Dependency/Scalable Kubernetes Resource Status Check Library
Go
2
star
25

healthcheck

Low-dependency, High-efficiency, Kubernetes-style healthcheck for Gin.
Go
1
star
26

go-cli-prototype

This is a cli application with go and cobra.
Shell
1
star
27

argparse

A 200-line command-line parsing library
Go
1
star
28

go-pkg-template

Go Package Template
Makefile
1
star
29

safe

A library for safely using go-routine.
Go
1
star
30

outliers

An outliers detection cmd tool by Isolation Forest
Python
1
star
31

gocmt

Read Go code, better comment. Power by AI.
Go
1
star
32

gvimrc-for-windows

我的windows下gvim的配置文件
Vim Script
1
star
33

login_libs

模拟登陆各网站的代码 - 持续更新,欢迎PR
Python
1
star
34

webhooks

golang webhooks 库,支持阿里云容器镜像服务
Go
1
star
35

videos

一个电影回收站 && 可以保存电影记录
Python
1
star
36

go-cli-action-prototype

A github action prototype based on docker and https://github.com/elliotxx/go-cli-prototype
Dockerfile
1
star
37

TouchBar-Presets-for-MTMR

🍎 Cool TouchBar Presets for MTMR
1
star
38

oss-watchman

Cron Statistics, Persistent, Update Report for Open Source Software(OSS), All in Git.
Python
1
star