Giter Club home page Giter Club logo

Comments (10)

rfjakob avatar rfjakob commented on August 24, 2024 1

from go-fuse.

marius-enlock avatar marius-enlock commented on August 24, 2024 1

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.

rfjakob avatar rfjakob commented on August 24, 2024 1

from go-fuse.

marius-enlock avatar marius-enlock commented on August 24, 2024

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.

kingfly629 avatar kingfly629 commented on August 24, 2024

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.

rfjakob avatar rfjakob commented on August 24, 2024

from go-fuse.

marius-enlock avatar marius-enlock commented on August 24, 2024

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.

kingfly629 avatar kingfly629 commented on August 24, 2024

from go-fuse.

kingfly629 avatar kingfly629 commented on August 24, 2024

@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.

hanwen avatar hanwen commented on August 24, 2024

not a go-fuse question.

from go-fuse.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.