litfs

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

Github stars Tracking Chart

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 系统编程课程下建立的。


Main metrics

Overview
Name With Owneranaskhan96/litfs
Primary LanguageGo
Program languageGo (Language Count: 1)
PlatformBSD, Linux
License:MIT License
所有者活动
Created At2018-01-18 19:50:40
Pushed At2020-11-03 14:04:34
Last Commit At2020-11-03 19:34:33
Release Count0
用户参与
Stargazers Count124
Watchers Count7
Fork Count11
Commits Count45
Has Issues Enabled
Issues Count1
Issue Open Count0
Pull Requests Count0
Pull Requests Open Count0
Pull Requests Close Count0
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private

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.