Comments (10)
from go-fuse.
I think you need to go to the kernel space to achieve this - I do not think it is recommended. I have 0 experience with this programming space. Maybe you can find some insight in a forum dedicated to linux kernel programming.
from go-fuse.
from go-fuse.
To answer in short: you can get inspiration from this project that uses go-fuse and encrypts/decrypts the original files when you write/ read them: https://github.com/rfjakob/gocryptfs/
The long answer: Building a filesystem is hard - you first need to understand how filesystems work, after you need to implement the interfaces from this docs page: https://pkg.go.dev/github.com/hanwen/go-fuse/[email protected]/fs
That get called on each system call on your mounted folder.
You can structure your code in terms of two data structures: Directories and Files
Both of them need to implement Getattr
Your root node that gets mounted can be modeled as just a Directory.
For directories you need the: Statfs, Lookup (makes your filesystem discoverable), Readdir, Mkdir, Create (creates files), Unlink (removes files), Rmdir, Rename (to perform renames, and moves)
For files you need the: Open, Release, Write, Read, Flush, Fsync
Depending on your platform you can read on how they should behave by accessing the man page - as they are system calls on your mounted folder.
About the encryption/ decryption part. I suggest you start with the passthrough example, then you can venture into using a stream cipher in your Write method to perform the encryption and the same stream cipher in the Read method to perform the decryption.
If you want to take it a step further and use authenticated encryption you will need to work with data blocks when writing to the underlying folder and in your Getattr method for the file, you need to convert the total file size from the cipher text (stored on disk) to the plain text that is readable.
I hope this helps, and good luck!
from go-fuse.
hey, marius-enlock!
thank you for your reply.
as i know, libfuse only support decrypt/encrypt files in original dir when read/write the files in mountpoint dir.
On the contrary, I just want to decrypt/encrypt the files in original dir when i directly read/write them. i don't want to operate the files in mountpoint dir anyway.
from go-fuse.
from go-fuse.
I just want to decrypt/encrypt the files in original dir when i directly read/write them.
Silly question, how are you going to access them?
If you access them from only your program that reads/writes data to them, then you can do the encryption/ decryption on your application. You do not need go-fuse.
If you want them to be accesible by any generic application, you can achieve this using FUSE and having a virtual mountpoint.
from go-fuse.
from go-fuse.
@rfjakob @marius-enlock
You are right, fuse may not meet my needs.
I want to implement transparent encryption and decryption for file read/write on Linux, which automatically decrypts/encrypts files when I read/write them. Is there any other good solution?
from go-fuse.
not a go-fuse question.
from go-fuse.
Related Issues (20)
- opcode POLL HOT 8
- panic: LARGEFILE (8000) overlaps with LARGEFILE (8000) HOT 2
- Loopback fs could no be used inside a tree HOT 1
- Race in Inode.Forgotten() HOT 8
- Error message when using `DirectMount: true`: writer: Write/Writev failed, err: 2=no such file or directory. opcode: RELEASE HOT 4
- Concurrent mount/unmount results in hanging HOT 15
- Support for linux FUSE_SETXATTR_EXT HOT 1
- FUSE Passthrough Support HOT 1
- Support for fuse_custom_io feature HOT 2
- Implementing Loopback FS - memory access error in path() function HOT 3
- Issues when unmounting on linux/ darwin HOT 15
- Changing filesize in Getattr Loopback HOT 2
- conflicting values on mipsel64 HOT 4
- macFUSE + LoopbackFS copying files through Finder not working HOT 7
- darwin: go-fuse/fuse.CAP_RENAME_SWAP has value 1<<25 while VFS_RENAME_SWAP has value 0x00000002
- Get PID of requesting process HOT 1
- Feature request: Server.Stop in order to allow resuming in a new process HOT 3
- How to disable RENAME_SWAP HOT 1
- How to exit go-fuse process gracefully? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-fuse.