From 85b2145aa529230b45c8308b6b41b87baa939e88 Mon Sep 17 00:00:00 2001 From: Yannick Ulrich Date: Sun, 19 Feb 2023 19:39:26 +0000 Subject: [PATCH] Implemented Create --- fuse/main.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/fuse/main.go b/fuse/main.go index 6f24473..ac1347d 100644 --- a/fuse/main.go +++ b/fuse/main.go @@ -317,6 +317,35 @@ func (f *ITNode) Open(ctx context.Context, openFlags uint32) (fh fs.FileHandle, return nil, 0, syscall.EROFS } +var _ = (fs.NodeCreater)((*ITNode)(nil)) +func (f *ITNode) Create(ctx context.Context, name string, flags uint32, mode uint32, out *fuse.EntryOut) (node *fs.Inode, fh fs.FileHandle, fuseFlags uint32, errno syscall.Errno) { + if f.kind != 2 { + return nil, nil, 0, syscall.EROFS + } + + path := f.path + "/" + name + ino := uint64(len(inodemap)) + 11 + inodemap[path] = ino + + stable := fs.StableAttr{ + Mode: fuse.S_IFREG, + Ino: ino, + } + operations := &ITNode{ + kind: 2, Ino: ino, + path : path, + } + node = f.NewInode(ctx, operations, stable) + + fh = &bytesFileWriteHandle{ + path : path, + content : make([]byte, 0), + } + + errno = 0 + return node, fh, fuseFlags, 0 +} + func main() { // This is where we'll mount the FS mntDir := "/tmp/x"