All Projects → elliotxx → Os_filesystem

elliotxx / Os_filesystem

Licence: gpl-2.0
A linux-like virtual file system by C++

Programming Languages

cpp
1120 projects

Labels

Projects that are alternatives of or similar to Os filesystem

Nemesis
💾 x86 operation system writen on fasm
Stars: ✭ 29 (-63.29%)
Mutual labels:  os
Ready For Tech Interview
💻 신입 개발자로서 준비를 하기 위해 지식을 정리하는 공간 👨‍💻
Stars: ✭ 1,035 (+1210.13%)
Mutual labels:  os
Cross Platform Node Guide
📗 How to write cross-platform Node.js code
Stars: ✭ 1,161 (+1369.62%)
Mutual labels:  os
Illumos Gate
An open-source Unix operating system
Stars: ✭ 952 (+1105.06%)
Mutual labels:  os
Lakka Libreelec
Lakka is a lightweight Linux distribution that transforms a small computer into a full blown game console.
Stars: ✭ 1,007 (+1174.68%)
Mutual labels:  os
Greentea
🍵 Userspace of the @GreenteaOS
Stars: ✭ 56 (-29.11%)
Mutual labels:  os
Bugz
🐛 Composable User Agent Detection using Ramda
Stars: ✭ 15 (-81.01%)
Mutual labels:  os
Harmonyos
鸿蒙系统资料。Docs about HarmonyOS.
Stars: ✭ 1,191 (+1407.59%)
Mutual labels:  os
Atomos
JS-based Linux desktop environment.
Stars: ✭ 42 (-46.84%)
Mutual labels:  os
Toaru Nih
NOTICE: The ToaruOS-NIH Project has been MERGED UPSTREAM. This repository is now archived.
Stars: ✭ 66 (-16.46%)
Mutual labels:  os
Limbobyexample
Examples for the Limbo Programming Language
Stars: ✭ 34 (-56.96%)
Mutual labels:  os
Fiwix
A UNIX-like kernel for the i386 architecture
Stars: ✭ 38 (-51.9%)
Mutual labels:  os
Sos
Home-made almost operating system
Stars: ✭ 57 (-27.85%)
Mutual labels:  os
Blog
本仓库存放个人博客的 markdown 源文件
Stars: ✭ 951 (+1103.8%)
Mutual labels:  os
Sparrow
My Operating System.
Stars: ✭ 71 (-10.13%)
Mutual labels:  os
Ansible Role Munin
Ansible Role - Munin
Stars: ✭ 27 (-65.82%)
Mutual labels:  os
Dennix
Dennix is a unix-like hobbyist operating system written from scratch.
Stars: ✭ 53 (-32.91%)
Mutual labels:  os
Chrysalisp
Parallel OS, with GUI, Terminal, OO Assembler, Class libraries, C-Script compiler, Lisp interpreter and more...
Stars: ✭ 1,205 (+1425.32%)
Mutual labels:  os
Jlivecd
Live cd/dvd customization tool
Stars: ✭ 72 (-8.86%)
Mutual labels:  os
Oneos
oneOS
Stars: ✭ 60 (-24.05%)
Mutual labels:  os

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
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].