guestfused

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Guest FUSE daemon using go-fuse library Connects to host VFS server over vsock and mounts at configurable workspace

Index

Constants

View Source
const (
	AF_VSOCK        = 40
	VMADDR_CID_HOST = 2
	VsockPortVFS    = 5001
)

Variables

View Source
var (
	ErrSocket  = errors.New("socket")
	ErrConnect = errors.New("connect")
	ErrEOF     = errors.New("EOF")
)

Functions

func Run

func Run()

Types

type OpCode

type OpCode uint8

VFS protocol (must match pkg/vfs/server.go)

const (
	OpLookup OpCode = iota
	OpGetattr
	OpSetattr
	OpRead
	OpWrite
	OpCreate
	OpMkdir
	OpUnlink
	OpRmdir
	OpRename
	OpOpen
	OpRelease
	OpReaddir
	OpFsync
	OpMkdirAll
	OpTruncate
	OpSymlink
	OpReadlink
	OpLink
)

type VFSClient

type VFSClient struct {
	// contains filtered or unexported fields
}

VFSClient communicates with host VFS server over vsock

func NewVFSClient

func NewVFSClient() (*VFSClient, error)

func (*VFSClient) Close

func (c *VFSClient) Close() error

func (*VFSClient) Request

func (c *VFSClient) Request(req *VFSRequest) (*VFSResponse, error)

func (*VFSClient) RequestCtx

func (c *VFSClient) RequestCtx(ctx context.Context, req *VFSRequest) (*VFSResponse, error)

type VFSDirEntry

type VFSDirEntry struct {
	Name  string `cbor:"name"`
	IsDir bool   `cbor:"is_dir"`
	Mode  uint32 `cbor:"mode"`
	Size  int64  `cbor:"size"`
	Ino   uint64 `cbor:"ino,omitempty"`
}

type VFSFileHandle

type VFSFileHandle struct {
	// contains filtered or unexported fields
}

VFSFileHandle handles read/write operations on open files

func (*VFSFileHandle) Fsync

func (h *VFSFileHandle) Fsync(ctx context.Context, flags uint32) syscall.Errno

func (*VFSFileHandle) Getattr

func (h *VFSFileHandle) Getattr(ctx context.Context, out *fuse.AttrOut) syscall.Errno

func (*VFSFileHandle) Read

func (h *VFSFileHandle) Read(ctx context.Context, dest []byte, off int64) (fuse.ReadResult, syscall.Errno)

func (*VFSFileHandle) Release

func (h *VFSFileHandle) Release(ctx context.Context) syscall.Errno

func (*VFSFileHandle) Write

func (h *VFSFileHandle) Write(ctx context.Context, data []byte, off int64) (uint32, syscall.Errno)

type VFSNode

type VFSNode struct {
	fs.Inode
	// contains filtered or unexported fields
}

VFSNode represents a file or directory in the VFS

func (*VFSNode) Create

func (n *VFSNode) Create(ctx context.Context, name string, flags uint32, mode uint32, out *fuse.EntryOut) (inode *fs.Inode, fh fs.FileHandle, fuseFlags uint32, errno syscall.Errno)

func (*VFSNode) Getattr

func (n *VFSNode) Getattr(ctx context.Context, fh fs.FileHandle, out *fuse.AttrOut) syscall.Errno

func (*VFSNode) Lookup

func (n *VFSNode) Lookup(ctx context.Context, name string, out *fuse.EntryOut) (*fs.Inode, syscall.Errno)

func (*VFSNode) Mkdir

func (n *VFSNode) Mkdir(ctx context.Context, name string, mode uint32, out *fuse.EntryOut) (*fs.Inode, syscall.Errno)

func (*VFSNode) Open

func (n *VFSNode) Open(ctx context.Context, flags uint32) (fh fs.FileHandle, fuseFlags uint32, errno syscall.Errno)

func (*VFSNode) Readdir

func (n *VFSNode) Readdir(ctx context.Context) (fs.DirStream, syscall.Errno)

func (*VFSNode) Rename

func (n *VFSNode) Rename(ctx context.Context, name string, newParent fs.InodeEmbedder, newName string, flags uint32) syscall.Errno

func (*VFSNode) Rmdir

func (n *VFSNode) Rmdir(ctx context.Context, name string) syscall.Errno

func (*VFSNode) Setattr

func (n *VFSNode) Setattr(ctx context.Context, fh fs.FileHandle, in *fuse.SetAttrIn, out *fuse.AttrOut) syscall.Errno
func (n *VFSNode) Unlink(ctx context.Context, name string) syscall.Errno

type VFSRequest

type VFSRequest struct {
	Op      OpCode `cbor:"op"`
	Path    string `cbor:"path,omitempty"`
	NewPath string `cbor:"new_path,omitempty"`
	Handle  uint64 `cbor:"fh,omitempty"`
	Offset  int64  `cbor:"off,omitempty"`
	Size    uint32 `cbor:"sz,omitempty"`
	Data    []byte `cbor:"data,omitempty"`
	Flags   uint32 `cbor:"flags,omitempty"`
	Mode    uint32 `cbor:"mode,omitempty"`
	UID     uint32 `cbor:"uid,omitempty"`
	GID     uint32 `cbor:"gid,omitempty"`
}

type VFSResponse

type VFSResponse struct {
	Err     int32         `cbor:"err"`
	Stat    *VFSStat      `cbor:"stat,omitempty"`
	Data    []byte        `cbor:"data,omitempty"`
	Written uint32        `cbor:"written,omitempty"`
	Handle  uint64        `cbor:"fh,omitempty"`
	Entries []VFSDirEntry `cbor:"entries,omitempty"`
}

type VFSRoot

type VFSRoot struct {
	fs.Inode
	// contains filtered or unexported fields
}

VFSRoot is the root node of the FUSE filesystem

func (*VFSRoot) Create

func (r *VFSRoot) Create(ctx context.Context, name string, flags uint32, mode uint32, out *fuse.EntryOut) (inode *fs.Inode, fh fs.FileHandle, fuseFlags uint32, errno syscall.Errno)

func (*VFSRoot) Getattr

func (r *VFSRoot) Getattr(ctx context.Context, fh fs.FileHandle, out *fuse.AttrOut) syscall.Errno

func (*VFSRoot) Lookup

func (r *VFSRoot) Lookup(ctx context.Context, name string, out *fuse.EntryOut) (*fs.Inode, syscall.Errno)

func (*VFSRoot) Mkdir

func (r *VFSRoot) Mkdir(ctx context.Context, name string, mode uint32, out *fuse.EntryOut) (*fs.Inode, syscall.Errno)

func (*VFSRoot) Readdir

func (r *VFSRoot) Readdir(ctx context.Context) (fs.DirStream, syscall.Errno)

func (*VFSRoot) Rename

func (r *VFSRoot) Rename(ctx context.Context, name string, newParent fs.InodeEmbedder, newName string, flags uint32) syscall.Errno

func (*VFSRoot) Rmdir

func (r *VFSRoot) Rmdir(ctx context.Context, name string) syscall.Errno
func (r *VFSRoot) Unlink(ctx context.Context, name string) syscall.Errno

type VFSStat

type VFSStat struct {
	Size    int64  `cbor:"size"`
	Mode    uint32 `cbor:"mode"`
	ModTime int64  `cbor:"mtime"`
	IsDir   bool   `cbor:"is_dir"`
	Ino     uint64 `cbor:"ino,omitempty"`
}

Jump to

Keyboard shortcuts

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