Commit dcd3fed8 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent e1c6b5c5
......@@ -246,28 +246,75 @@ import (
"flag"
"log"
"os"
"github.com/hanwen/go-fuse/fuse/nodefs"
"sync"
"syscall"
"lab.nexedi.com/kirr/neo/go/zodb"
_ "lab.nexedi.com/kirr/neo/go/zodb/wks"
"github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/fuse/nodefs"
)
// BigFileRoot represents "/bigfile"
type BigFileRoot struct {
nodefs.Node
zstor zodb.IStorage
}
mu sync.Mutex
tab map[zodb.Oid]*BigFile
}
func NewBigFileRoot(zstor zodb.IStorage) *BigFileRoot {
return &BigFileRoot{
Node: nodefs.NewDefaultNode(),
zstor: zstor,
tab: make(map[zodb.Oid]*BigFile),
}
}
// Mkdir receives client request to create /bigfile/<bigfileX>.
func (br *BigFileRoot) Mkdir(name string, mode uint32, _ *fuse.Context) (*nodefs.Inode, fuse.Status) {
oid, err := zodb.ParseOid(name)
if err != nil {
log.Printf("/bigfile: mkdir: non-oid: %q", name)
return nil, fuse.EINVAL
}
// XXX ok to ignore mode?
br.mu.Lock()
defer br.mu.Unlock()
if _, already := br.tab[oid]; already {
return nil, fuse.Status(syscall.EEXIST)
}
bf := NewBigFile(oid, br)
br.tab[oid] = bf
mkdir(br, name, bf) // XXX takes treeLock - ok under br.mu ?
return bf.Inode(), fuse.OK
}
// XXX do we need to support rmdir? (probably no)
// BigFile represents "/bigfile/<bigfileX>"
type BigFile struct {
nodefs.Node
oid zodb.Oid
root *BigFileRoot
}
func NewBigFile(oid zodb.Oid, root *BigFileRoot) *BigFile {
return &BigFile{
Node: nodefs.NewDefaultNode(),
oid: oid,
root: root,
}
}
// XXX option to prevent starting if wcfs was already started ?
// XXX option to automatically exit/unmount if there are no requests for some t
......@@ -301,7 +348,7 @@ func main() {
server, _, err := nodefs.MountRoot(mntpt, root, opts)
if err != nil {
log.Fatal(err) // XXX err ctx?
log.Fatal(err)
}
// add entries to /
......
......@@ -103,7 +103,7 @@ def test_join_autostart():
# XXX parametrize zblk0, zblk1
# XXX select !wcfs mode so that we prepare data through !wcfs path.
def _test_bigfile_empty():
def test_bigfile_empty():
root = testdb.dbopen()
root['zfile'] = f = ZBigFile(blksize)
transaction.commit()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment