litfs

Go中的FUSE文件系统,扩展了持久性文件存储功能。「A FUSE file system in Go extended with persistent file storage」

Github星跟踪图

litfs

这个 FUSE 文件系统,除了提供正常的文件 I/O 操作外,还通过将单个二进制 Unix 文件模拟为磁盘并对其执行读写来实现持久性。

构建和运行

go get github.com/anaskhan96/litfs
cd $GOPATH/src/github.com/anaskhan96/litfs
go run main.go data # data/ 是挂载文件系统的目录

运行 umount <path-to-directory> 来卸载文件系统。

文件系统特性

  • 创建、删除目录
  • 在一个目录中创建、删除、读取和写入文件。
  • 复制,将一个文件的内容移动到另一个文件,跨目录

持久性实施

  • disklib/sda 是创建的模拟磁盘的二进制文件。保持 4096 字节的块大小。
  • 文件系统树的序列化表示形式被存储在第一个块中。
  • 一个包含两个组件的结构 -- 一个表示文件系统中空闲和分配的块的位图和一个包含当前最低空闲块的整数 -- 被序列化并存储在第二个块中。
  • 文件数据从第三个块开始存储,将一个块作为一个整体分配给从文件中释放的对象

这个项目是在 PES 大学的 Unix 系统编程课程下建立的。


主要指标

概览
名称与所有者anaskhan96/litfs
主编程语言Go
编程语言Go (语言数: 1)
平台BSD, Linux
许可证MIT License
所有者活动
创建于2018-01-18 19:50:40
推送于2020-11-03 14:04:34
最后一次提交2020-11-03 19:34:33
发布数0
用户参与
星数125
关注者数7
派生数11
提交数45
已启用问题?
问题数1
打开的问题数0
拉请求数0
打开的拉请求数0
关闭的拉请求数0
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?

litfs

Image of litfs at work

This FUSE filesystem, apart from providing the normal file I/O operations, implements persistence by emulating a single binary Unix file as disk and performing read/writes on it.

Build and Run

go get github.com/anaskhan96/litfs
cd $GOPATH/src/github.com/anaskhan96/litfs
go run main.go data # data/ is the directory on which to mount the filesystem on

Run umount <path-to-directory> to unmount the filesystem.

File System Characteristics

  • Create, remove a directory
  • Create, remove, read from, and write to files inside a directory
  • Copy, move the contents of a file to another, across directories

Persistence Implementation

disklib/sda is the created binary file emulating a disk. Keeping a block size of 4096 bytes:

  • A serialized form of the tree representation of the filesystem is stored in the first block
  • A structure containing two components - a bitmap indicating free and allocated blocks in the filesystem and an integer containing the lowest free block at the moment - is serialized and stored in the second block
  • File data is stored from the third block onwards, with a block as a whole being allocated to/deallocated from the file

This project was built under the course Unix Systems Programming in PES University.