Initial commit
This commit is contained in:
67
ffs/fs.go
Normal file
67
ffs/fs.go
Normal file
@@ -0,0 +1,67 @@
|
||||
package ffs
|
||||
|
||||
import (
|
||||
"fusetest/furcadia"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"bazil.org/fuse"
|
||||
"bazil.org/fuse/fs"
|
||||
)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// VAR ////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
var (
|
||||
// Filesystem context (there should only be one)
|
||||
G_FS *FurcFS = nil
|
||||
)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// TYPE: FS ///////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
type FurcFS struct {
|
||||
RootDir *RootDir
|
||||
_pounce *furcadia.PounceList
|
||||
}
|
||||
|
||||
func InitFS(rootUID, rootGID uint32) *FurcFS {
|
||||
if G_FS != nil {
|
||||
panic("G_FS already initialized - wtf?")
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
fs := &FurcFS{
|
||||
RootDir: &RootDir{
|
||||
_nodes: make(map[string]TopLevelDir),
|
||||
_attr: fuse.Attr{
|
||||
Inode: ROOT_INODE,
|
||||
Nlink: 1,
|
||||
Mode: os.ModeDir | 0500,
|
||||
Uid: rootUID,
|
||||
Gid: rootGID,
|
||||
Atime: now,
|
||||
Ctime: now,
|
||||
Mtime: now,
|
||||
},
|
||||
},
|
||||
_pounce: furcadia.NewPounceList(),
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// register root-level items
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
fs.RootDir._nodes["furres"] = NewFurresDir(FURRES_DIR_INODE_BASE, rootUID, rootGID)
|
||||
fs.RootDir._nodes["dreams"] = NewDreamsDir(DREAMS_DIR_INODE_BASE, rootUID, rootGID)
|
||||
|
||||
// FS context is now ready
|
||||
G_FS = fs
|
||||
return fs
|
||||
}
|
||||
|
||||
func (fs *FurcFS) Root() (fs.Node, error) {
|
||||
return fs.RootDir, nil
|
||||
}
|
||||
Reference in New Issue
Block a user