Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
36625c28
Commit
36625c28
authored
May 01, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
56b8309c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
121 deletions
+23
-121
wcfs/t/t.go
wcfs/t/t.go
+0
-117
wcfs/testdata/zblk_test_gen.py
wcfs/testdata/zblk_test_gen.py
+2
-0
wcfs/wcfs_test.py
wcfs/wcfs_test.py
+19
-4
wcfs/zblk.go
wcfs/zblk.go
+2
-0
No files found.
wcfs/t/t.go
deleted
100644 → 0
View file @
56b8309c
package
main
import
(
"flag"
"fmt"
"log"
"os"
"time"
"github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/fuse/nodefs"
)
// dir represents a directory in the filesystem.
type
dir
struct
{
nodefs
.
Node
}
// file represents a file in the filesystem.
type
file
struct
{
nodefs
.
Node
}
// fileHandle represents opened file.
type
fileHandle
struct
{
nodefs
.
File
content
[]
byte
}
/*
// XXX recheck whether Lookup is needed
func (d *dir) Lookup(out *fuse.Attr, name string, _ *fuse.Context) (*nodefs.Inode, fuse.Status) {
ientry := d.Inode().GetChild(name)
if ientry == nil {
return nil, fuse.ENOENT
}
// XXX fill out
return ientry, fuse.OK
}
*/
var
nopen
=
0
func
(
f
*
file
)
Open
(
flags
uint32
,
_
*
fuse
.
Context
)
(
nodefs
.
File
,
fuse
.
Status
)
{
_
,
name
:=
f
.
Inode
()
.
Parent
()
nopen
++
// XXX -> atomic
data
:=
fmt
.
Sprintf
(
"%04d %s
\n
"
,
nopen
,
name
)
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
,
},
fuse
.
OK
}
func
(
fh
*
fileHandle
)
Read
(
dest
[]
byte
,
off
int64
)
(
fuse
.
ReadResult
,
fuse
.
Status
)
{
l
:=
int64
(
len
(
dest
))
// XXX demonstrate we can indeed serve different content to different openings.
if
l
>=
1
{
l
=
1
time
.
Sleep
(
1
*
time
.
Second
)
}
end
:=
off
+
l
if
ldata
:=
int64
(
len
(
fh
.
content
));
end
>
ldata
{
end
=
ldata
}
res
:=
fh
.
content
[
off
:
end
]
fmt
.
Printf
(
"read [%d:%d] -> %q
\n
"
,
off
,
end
,
res
)
return
fuse
.
ReadResultData
(
res
),
fuse
.
OK
}
func
(
d
*
dir
)
mkdir
(
name
string
)
*
dir
{
child
:=
&
dir
{
Node
:
nodefs
.
NewDefaultNode
()}
d
.
Inode
()
.
NewChild
(
name
,
true
,
child
)
return
child
}
func
(
d
*
dir
)
mkfile
(
name
string
)
*
file
{
child
:=
&
file
{
Node
:
nodefs
.
NewDefaultNode
()}
d
.
Inode
()
.
NewChild
(
name
,
false
,
child
)
return
child
}
func
main
()
{
debug
:=
flag
.
Bool
(
"d"
,
true
,
"debug"
)
flag
.
Parse
()
if
len
(
flag
.
Args
())
!=
1
{
log
.
Fatalf
(
"Usage: %s mntpt"
,
os
.
Args
[
0
])
}
mntpt
:=
flag
.
Args
()[
0
]
root
:=
&
dir
{
Node
:
nodefs
.
NewDefaultNode
()}
opts
:=
nodefs
.
NewOptions
()
if
*
debug
{
opts
.
Debug
=
true
}
server
,
_
,
err
:=
nodefs
.
MountRoot
(
mntpt
,
root
,
opts
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
// XXX err ctx?
}
// NOTE cannot make entries before mount because Inode.AddChild does
// not work before that (panics on nil deref to mountRootXXX)
aaa
:=
root
.
mkdir
(
"aaa"
)
root
.
mkfile
(
"hello.txt"
)
aaa
.
mkfile
(
"world.txt"
)
server
.
Serve
()
// XXX error?
}
wcfs/testdata/zblk_test_gen.py
View file @
36625c28
...
...
@@ -44,6 +44,8 @@ def main():
root
=
conn
.
root
()
# 0, 1, 2, ... as u32
#
# XXX also include hole inside and at tail.
data
=
arange
(
0
,
blksize32
,
dtype
=
'>u4'
).
tobytes
()
root
[
'zblk0'
]
=
z0
=
ZBlk0
()
...
...
wcfs/wcfs_test.py
View file @
36625c28
...
...
@@ -118,8 +118,8 @@ def test_join_autostart():
# --- test access to data ----
# DF
corresponds to ΔF in wcfs
.
# it
represents a change in files space
.
# DF
represents a change in files space
.
# it
corresponds to ΔF in wcfs.go
.
class
DF
:
# .rev tid
# .byfile {} ZBigFile -> DFile
...
...
@@ -127,8 +127,8 @@ class DF:
# rev set from outside
dF
.
byfile
=
{}
# DFile
is similar to ΔFile in wcfs
.
#
represents a change to one file
.
# DFile
represents a change to one file
.
#
it is is similar to ΔFile in wcfs.go
.
class
DFile
:
# .rev tid
# .ddata {} blk -> data XXX name
...
...
@@ -646,6 +646,21 @@ def test_wcfs():
done
.
recv
()
print
(
'
\
n
CCC
\
n
'
)
# checkSetupWatch verifies setting up new watch for zf@at.
def
checkSetupWatch
(
zf
,
at
):
# all changes to zf
vdf
=
[
_
.
byfile
[
zf
]
for
_
in
t
.
dFtail
if
zf
in
t
.
dFtail
.
byfile
]
# changes to zf after at
vdfpost
=
[
_
for
_
in
vdf
if
_
.
rev
>
at
]
# open watch and check that we receive pins for blocks changed > at
w
=
t
.
openwatch
()
for
i
in
range
(
len
(
t
.
dFtail
)):
return
# XXX test watch with all at variants
...
...
wcfs/zblk.go
View file @
36625c28
...
...
@@ -70,6 +70,7 @@ type zBlk interface {
// inΔFtail returns pointer to struct zblkInΔFtail embedded into this ZBlk.
inΔFtail
()
*
zblkInΔFtail
// XXX kill - in favour of inΔFtail
/*
// bindFile associates ZBlk as being used by file to store block #blk.
//
...
...
@@ -100,6 +101,7 @@ type zBlk interface {
var
_
zBlk
=
(
*
ZBlk0
)(
nil
)
var
_
zBlk
=
(
*
ZBlk1
)(
nil
)
// XXX kill
/*
// ---- zBlkBase ----
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment