puterfs

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

* Copyright (C) 2024 Puter Technologies Inc. * * This file is part of puter-fuse. * * puter-fuse is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>.

* Copyright (C) 2024 Puter Technologies Inc. * * This file is part of puter-fuse. * * puter-fuse is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>.

* Copyright (C) 2024 Puter Technologies Inc. * * This file is part of puter-fuse. * * puter-fuse is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>.

* Copyright (C) 2024 Puter Technologies Inc. * * This file is part of puter-fuse. * * puter-fuse is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>.

* Copyright (C) 2024 Puter Technologies Inc. * * This file is part of puter-fuse. * * puter-fuse is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>.

* Copyright (C) 2024 Puter Technologies Inc. * * This file is part of puter-fuse. * * puter-fuse is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CloudItemNode

type CloudItemNode struct {
	*Filesystem
	CloudItem fao.NodeInfo
}

func (*CloudItemNode) GetIno

func (n *CloudItemNode) GetIno() uint64

func (*CloudItemNode) GetStableAttrMode

func (n *CloudItemNode) GetStableAttrMode() uint32

func (*CloudItemNode) Init

func (n *CloudItemNode) Init()

func (*CloudItemNode) SetCloudItem

func (n *CloudItemNode) SetCloudItem(cloudItem fao.NodeInfo)

type DirectoryNode

type DirectoryNode struct {
	fs.Inode
	CloudItemNode
	Items        []fao.NodeInfo
	PollDuration time.Duration
	Logger       debug.ILogger
	PathLockMap  *kvdotgo.KVMap[string, struct{}]
}

func (*DirectoryNode) Create

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

func (*DirectoryNode) Getattr

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

func (*DirectoryNode) Init

func (n *DirectoryNode) Init()

func (*DirectoryNode) Lookup

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

func (*DirectoryNode) Mkdir

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

func (*DirectoryNode) Readdir

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

func (*DirectoryNode) Rename

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

func (*DirectoryNode) Rmdir

func (n *DirectoryNode) Rmdir(ctx context.Context, name string) syscall.Errno
func (n *DirectoryNode) Symlink(
	ctx context.Context,
	target string,
	name string,
	out *fuse.EntryOut,
) (*fs.Inode, syscall.Errno)
func (n *DirectoryNode) Unlink(ctx context.Context, name string) syscall.Errno

type FileHandler

type FileHandler struct {
	Node *FileNode
}

type FileNode

type FileNode struct {
	fs.Inode
	CloudItemNode
	Logger debug.ILogger
}

func (*FileNode) Fsync

func (n *FileNode) Fsync(ctx context.Context, f fs.FileHandle, flags uint32) syscall.Errno

func (*FileNode) Getattr

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

func (*FileNode) Init

func (n *FileNode) Init()

func (*FileNode) Open

func (n *FileNode) Open(ctx context.Context, flags uint32) (fs.FileHandle, uint32, syscall.Errno)

func (*FileNode) Read

func (n *FileNode) Read(
	ctx context.Context,
	f fs.FileHandle,
	dest []byte, off int64,
) (fuse.ReadResult, syscall.Errno)
func (n *FileNode) Readlink(ctx context.Context) ([]byte, syscall.Errno)

func (*FileNode) Setattr

func (n *FileNode) Setattr(ctx context.Context, f fs.FileHandle, in *fuse.SetAttrIn, out *fuse.AttrOut) syscall.Errno

func (*FileNode) Write

func (n *FileNode) Write(
	ctx context.Context,
	f fs.FileHandle,
	data []byte, off int64,
) (uint32, syscall.Errno)

type Filesystem

type Filesystem struct {
	// map Puter UIDs to inode numbers
	UidInoMap  map[string]uint64
	InoCounter uint64

	Nodes map[uint64]fs.InodeEmbedder

	SDK *putersdk.PuterSDK
	fao.FAO
	Services *services.ServicesContainer

	NodesMutex     sync.RWMutex
	UidInoMapMutex sync.RWMutex
}

func (*Filesystem) CreateDirNodeFromCloudItem

func (pfs *Filesystem) CreateDirNodeFromCloudItem(cloudItem fao.NodeInfo) fs.InodeEmbedder

func (*Filesystem) CreateFileNodeFromCloudItem

func (pfs *Filesystem) CreateFileNodeFromCloudItem(cloudItem fao.NodeInfo) fs.InodeEmbedder

func (*Filesystem) CreateNodeFromCloudItem

func (fs *Filesystem) CreateNodeFromCloudItem(cloudItem fao.NodeInfo) fs.InodeEmbedder

func (*Filesystem) GetInoFromUID

func (fs *Filesystem) GetInoFromUID(uid string) uint64

func (*Filesystem) GetNodeFromCloudItem

func (fs *Filesystem) GetNodeFromCloudItem(cloudItem fao.NodeInfo) fs.InodeEmbedder

func (*Filesystem) Init

func (pfs *Filesystem) Init()

type HasPuterNodeCapabilities

type HasPuterNodeCapabilities interface {
	GetStableAttrMode() uint32
	GetIno() uint64
	SetCloudItem(cloudItem fao.NodeInfo)
}

type RootNode

type RootNode struct {
	fs.Inode
	// TODO: Path -> UID
	*Filesystem
	Items        []fao.NodeInfo
	PollDuration time.Duration
	LastPoll     time.Time
	Logger       debug.ILogger
}

func (*RootNode) Init

func (n *RootNode) Init()

func (*RootNode) Lookup

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

func (*RootNode) Readdir

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

Jump to

Keyboard shortcuts

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