aferofuse

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2022 License: GPL-3.0 Imports: 8 Imported by: 1

README

aferofuse

Coverage GoDocs Have you ever thought: I really like X file system Go implementation but I sure wish I could expose it to the whole operating system. Well, you are in luck!

This is exactly what aferofuse is. Taken from the two libraries: afero and fuse - aferofuse aims to expose internal Go abstract filesystems to the linux operating system by using the fuse library.

why?

My original reason to implement this was to faciliate a tool that could limit a directory's size. I searched all over the web for about 3.5 seconds, found nothing(or most likely didn't read through anything) and decided to implement this library.

how?

Start by getting the library:

go get github.com/lemondevxyz/aferofuse

Afterwards, just borrow the code from example/osfs/main.go and modify it to your liking! Too lazy to go there? Lucky for you I have a code snippet ready:

package main

import (
    "flag"
    "log"

    "github.com/hanwen/go-fuse/v2/fs"
    "github.com/hanwen/go-fuse/v2/fuse/nodefs"
    "github.com/hanwen/go-fuse/v2/fuse/pathfs"
    "github.com/lemondevxyz/aferofuse"
    "github.com/spf13/afero"
)

type embeddedINode struct {
    inode *fs.Inode
}

func (e *embeddedINode) EmbeddedInode() *fs.Inode {
    return e.inode
}

func main() {
    base := flag.String("base", "", "the base path to 'contain' the os filesystem")
    debug := flag.Bool("debug", false, "print debug data")
    flag.Parse()
    if len(flag.Args()) < 1 {
        log.Fatal("Usage:\n  osfs MOUNTPOINT")
    }

    afs := afero.NewBasePathFs(afero.NewOsFs(), *base)
    fusefs := aferofuse.NewFuseFileSystem(afs)

    opts := &nodefs.Options{}
    opts.Debug = *debug

    mynodefs := pathfs.NewPathNodeFs(fusefs, &pathfs.PathNodeFsOptions{
        ClientInodes: true,
    })
    server, _, err := nodefs.MountRoot(flag.Arg(0), mynodefs.Root(), opts)
    if err != nil {
        log.Fatalf("Mount fail: %v\n", err)
    }
    log.Println("Mounted!")
    server.Serve()
}

what's left?

  • Internal unit testing
  • GitHub actions code coverage
  • Testing through a stressor like iozone
  • Release v0.1.0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFuseFileSystem

func NewFuseFileSystem(afs afero.Fs) pathfs.FileSystem

Types

This section is empty.

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL