Commit da48cbaf authored by Kirill Smelkov's avatar Kirill Smelkov

.

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