{"id":18412075,"url":"https://github.com/elliotxx/os_filesystem","last_synced_at":"2026-03-11T19:33:09.722Z","repository":{"id":86319244,"uuid":"77918911","full_name":"elliotxx/os_filesystem","owner":"elliotxx","description":"A linux-like virtual file system by C++","archived":false,"fork":false,"pushed_at":"2019-11-11T08:05:25.000Z","size":2436,"stargazers_count":144,"open_issues_count":3,"forks_count":38,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-07T11:37:17.262Z","etag":null,"topics":["cpp","inode","os","os-filesystem"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elliotxx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-03T13:21:07.000Z","updated_at":"2025-03-19T03:13:05.000Z","dependencies_parsed_at":"2023-07-07T06:45:27.619Z","dependency_job_id":null,"html_url":"https://github.com/elliotxx/os_filesystem","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/elliotxx/os_filesystem","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elliotxx%2Fos_filesystem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elliotxx%2Fos_filesystem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elliotxx%2Fos_filesystem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elliotxx%2Fos_filesystem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elliotxx","download_url":"https://codeload.github.com/elliotxx/os_filesystem/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elliotxx%2Fos_filesystem/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30395635,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-11T18:46:22.935Z","status":"ssl_error","status_checked_at":"2026-03-11T18:46:17.045Z","response_time":84,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","inode","os","os-filesystem"],"created_at":"2024-11-06T03:39:38.117Z","updated_at":"2026-03-11T19:33:09.696Z","avatar_url":"https://github.com/elliotxx.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"﻿# os_filesystem - 一个虚拟文件系统（C++）\n\n## 简介\n这是一个仿linux的虚拟文件系统，系统由一个虚拟磁盘文件承载，以文件读写模拟磁盘读写，不涉及底层驱动。\n\n写一个简单的仿linux文件系统，首先需要设计好包含inode、block、superblock、虚拟磁盘布局，空间分配等信息的基本框架。文件系统的开头是一个superblock，包含系统的重要信息，包括inode和block的数量和大小。对于inode，一般来说需要占磁盘空间的百分之一，不过这是个小系统，总大小才5M多一点，所以分配给inode区的空间很少，剩下的空间大部分是block区。\n\n该文件系统的总体规划如下：  \n![](./screenshots/00.png)\n\n由于写程序的时候时间比较紧张，只写了4天就去验收，所以代码没来得及优化，有的地方会显得冗余，大家不要见怪。\n\n虽然时间有限，不过也额外实现了一个vi编辑器的功能，写的比较简陋，代码也很乱，有时间改进一下。\n\n总的来说，代码还有待优化，欢迎多提意见，多挑毛病。\n\n## 如何使用\n### step 1：下载项目\n`git clone https://github.com/windcode/os_filesystem.git`\n\n### step 2：用VC++6.0打开项目\n双击目录中的 **MingOS.dsw** 文件，或者将该文件拖到VC++6.0界面中。\n\n### step 3：编译，链接，运行\n![](./screenshots/0.png)\n\n### 或者\n### step 1：直接运行 **/Debug** 文件夹下 **MingOS.exe** 文件\n\n## 特性\n* 初次运行，创建虚拟磁盘文件\n\n![](./screenshots/1.png)\n\n* 登录系统\n\n默认用户为root，密码为root\n\n![](./screenshots/2.gif)\n\n* 帮助命令（help）\n\n![](./screenshots/3.gif)\n\n* 用户添加、删除、登录、注销（useradd、userdel、logout）\n\n![](./screenshots/5.gif)\n\n* 修改文件或目录权限（chmod）\n\n![](./screenshots/6.gif)\n\n* 写入、读取受权限限制\n\n![](./screenshots/7.gif)\n\n* 文件/文件夹添加、删除（touch、rm、mkdir、rmdir）\n\n![](./screenshots/8.gif)\n\n* 查看系统信息（super、inode、block）\n\n![](./screenshots/9.gif)\n\n* 仿写一个vi文本编辑器（vi）\n\n![](./screenshots/4.gif)\n\n* 索引节点inode管理文件和目录信息\n\n* 使用 **成组链接法** 管理空闲block的分配  \n\t* **block分配过程：**\n当需要分配一个block的时候，空闲块堆栈顶拿出一个空闲块地址作为新分配的block。\n当栈空的时候，将栈底地址代表的空闲块中堆栈作为新的空闲块堆栈。  \n\t* **block回收过程：**\n当回收一个block的时候，检查堆栈是否已满，如果不满，当前堆栈指针上移，将要回收的block地址放在新的栈顶。\n如果堆栈已满，则将要回收的block作为新的空闲块堆栈，将这个空闲块堆栈栈底元素地址置为刚才的空闲块堆栈。  \n\t* 分配和回收的同时需要更新block位图，以及超级块。\n\n* inode的分配/回收  \n\t* inode的分配和回收较为简单，采用顺序分配和回收。  \n\t* 需要分配时，从inode位图中顺序查找一个空闲的inode，查找成功返回inode的编号。\n\t* 回收的时候，更新inode位图即可。  \n\t* 分配和回收都需要更新inode位图。\n\n## 注意\n* 运行环境为VC++6.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felliotxx%2Fos_filesystem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felliotxx%2Fos_filesystem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felliotxx%2Fos_filesystem/lists"}