Commit da48cbaf authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent f29e5dbc
......@@ -42,7 +42,7 @@ from ZODB.FileStorage import FileStorage
# Conn represents connection to wcfs server.
class Conn(object):
# .mountpoint path to mountpoint
# ._fwcfs /.wcfs opened to keep the server from going away (at least cleanly)
# ._fwcfs /.wcfs/zurl opened to keep the server from going away (at least cleanly)
def __init__(self, mountpoint, fwcfs):
self.mountpoint = mountpoint
......@@ -68,7 +68,7 @@ def serve(zurl, exec_=False):
# try opening .wcfs - it is an error if we can do it.
# XXX -> option to wcfs itself?
try:
f = open(mntpt + "/.wcfs")
f = open(mntpt + "/.wcfs/zurl")
except IOError as e:
if e.errno != ENOENT:
raise
......@@ -108,7 +108,7 @@ def join(zurl, autostart=_default_autostart()):
# try opening .wcfs - if we succeed - it is already mounted.
# XXX -> wcfs itself?
try:
f = open(mntpt + "/.wcfs")
f = open(mntpt + "/.wcfs/zurl")
except IOError as e:
if e.errno != ENOENT:
raise
......@@ -179,7 +179,7 @@ def _start(zurl, *optv):
try:
while 1:
try:
f = open("%s/.wcfs" % mntpt)
f = open("%s/.wcfs/zurl" % mntpt)
except IOError as e:
if e.errno != ENOENT:
raise
......@@ -188,7 +188,7 @@ def _start(zurl, *optv):
res = f
dotwcfs = f.read()
if dotwcfs != zurl:
raise RuntimeError(".wcfs != zurl (%s != %s)" % (qq(dotwcfs), qq(zurl)))
raise RuntimeError(".wcfs/zurl != zurl (%s != %s)" % (qq(dotwcfs), qq(zurl)))
break
......
......@@ -50,6 +50,7 @@ func (f *file) Open(flags uint32, _ *fuse.Context) (nodefs.File, fuse.Status) {
h := &fileHandle{File: nodefs.NewDefaultFile(), content: []byte(data)}
// force direct-io to disable pagecache: we alway return different data
// and st_size=0 (like in /proc).
// XXX + FOPEN_NONSEEKABLE - then it will be like socket
return &nodefs.WithFlags{
File: h,
FuseFlags: fuse.FOPEN_DIRECT_IO,
......
......@@ -1229,10 +1229,16 @@ func main() {
}
// add entries to /
mkfile(root, ".wcfs", NewStaticFile([]byte(zurl)))
mkdir(root, "head", head)
mkdir(head, "bigfile", bfdir)
mkfile(head, "at", NewSmallFile(head.readAt)) // TODO mtime(at) = tidtime(at)
// XXX ^^^ invalidate cache or direct io
// for debugging/testing
dotwcfs := nodefs.NewDefaultNode()
mkdir(root, ".wcfs", dotwcfs)
mkfile(dotwcfs, "zurl", NewStaticFile([]byte(zurl)))
// XXX zhead
// TODO handle autoexit
_ = autoexit
......
......@@ -99,7 +99,7 @@ def test_join():
wc = wcfs._start(zurl)
defer(wc.close)
assert wc.mountpoint == testmntpt
assert readfile(wc.mountpoint + "/.wcfs") == zurl
assert readfile(wc.mountpoint + "/.wcfs/zurl") == zurl
assert os.path.isdir(wc.mountpoint + "/head")
assert os.path.isdir(wc.mountpoint + "/head/bigfile")
......@@ -116,7 +116,7 @@ def test_join_autostart():
wc = wcfs.join(zurl, autostart=True)
defer(wc.close)
assert wc.mountpoint == testmntpt
assert readfile(wc.mountpoint + "/.wcfs") == zurl
assert readfile(wc.mountpoint + "/.wcfs/zurl") == zurl
assert os.path.isdir(wc.mountpoint + "/head")
assert os.path.isdir(wc.mountpoint + "/head/bigfile")
......@@ -126,7 +126,7 @@ def test_join_autostart():
@method(wcfs.Conn)
def _sync(self):
print >>sys.stderr, "\n# >>> wcfs.Conn.sync"
zurl = readfile(self.mountpoint + "/.wcfs")
zurl = readfile(self.mountpoint + "/.wcfs/zurl")
bigfilev = os.listdir(self.mountpoint + "/head/bigfile")
self.close()
......
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