Commit dfb82ecc authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 4ce4b808
......@@ -54,11 +54,16 @@ func (f *StaticFile) Read(_ nodefs.File, dest []byte, off int64, _ *fuse.Context
// mkdir adds child to parent as directory.
//
// Note: parent must to be already in the filesystem tree - i.e. associated
// with inode. if not - nodefs will panic in Inode.NewChild on nil dereference.
func mkdir(parent nodefs.Node, name string, child nodefs.Node) {
parent.Inode().NewChild(name, true, child)
}
// mkfile adds child to parent as file.
//
// Note: parent must be already in the filesystem tree (see mkdir for details).
func mkfile(parent nodefs.Node, name string, child nodefs.Node) {
parent.Inode().NewChild(name, false, child)
}
......@@ -262,17 +262,76 @@ type BigFileRoot struct {
zstor zodb.IStorage
mu sync.Mutex
tab map[zodb.Oid]*BigFile
tab map[zodb.Oid]*BigFileX
}
// BigFileX represents "/bigfile/<bigfileX>"
type BigFileX struct {
nodefs.Node
oid zodb.Oid
root *BigFileRoot
}
// BigFile represents "/bigfile/<bigfileX>/head"
type BigFile struct {
nodefs.Node
x *BigFileX
data *BigFileData
//at *BigFileAt
//inv *BigFileInvalidations
}
// BigFileData represents "/bigfile/<bigfileX>/head/data"
type BigFileData struct {
nodefs.Node
head *BigFile
}
// ---- ctors ---- XXX to down?
func NewBigFileRoot(zstor zodb.IStorage) *BigFileRoot {
return &BigFileRoot{
Node: nodefs.NewDefaultNode(),
zstor: zstor,
tab: make(map[zodb.Oid]*BigFile),
tab: make(map[zodb.Oid]*BigFileX),
}
}
func NewBigFileX(oid zodb.Oid, root *BigFileRoot) *BigFileX {
bx := &BigFileX{
Node: nodefs.NewDefaultNode(),
oid: oid,
root: root,
}
return bx
}
func NewBigFile(x *BigFileX) *BigFile {
f := &BigFile{Node: nodefs.NewDefaultNode(), x: x}
f.data = NewBigFileData(f)
// XXX + .at
return f
}
func NewBigFileData(head *BigFile) *BigFileData {
return &BigFileData{Node: nodefs.NewDefaultNode(), head: head}
}
// 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)
......@@ -290,29 +349,20 @@ func (br *BigFileRoot) Mkdir(name string, mode uint32, _ *fuse.Context) (*nodefs
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
}
bx := NewBigFileX(oid, br)
br.tab[oid] = bx
// XXX do we need to support rmdir? (probably no)
bf := NewBigFile(bx)
mkdir(br, name, bx) // XXX takes treeLock - ok under br.mu ?
mkdir(bx, "head", bf)
mkfile(bf, "data", bf.data)
// BigFile represents "/bigfile/<bigfileX>"
type BigFile struct {
nodefs.Node
oid zodb.Oid
root *BigFileRoot
return bx.Inode(), fuse.OK
}
func NewBigFile(oid zodb.Oid, root *BigFileRoot) *BigFile {
return &BigFile{
Node: nodefs.NewDefaultNode(),
oid: oid,
root: root,
}
}
// XXX do we need to support rmdir? (probably no)
......
......@@ -112,7 +112,12 @@ def test_bigfile_empty():
transaction.commit()
wc = wcfs.join(testzurl, autostart=True)
os.mkdir("%s/bigfile/%s" % (wc.mountpoint, f._p_oid.encode('hex')))
# path to f under wcfs
fpath = "%s/bigfile/%s" % (wc.mountpoint, f._p_oid.encode('hex'))
os.mkdir(fpath)
os.stat(fpath + "/head/data")
# XXX size(head/data) = 0
# XXX mtime(head/data) ~= last txn that changed bigdile
......
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