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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Joshua
wendelin.core
Commits
6d86fb8e
Commit
6d86fb8e
authored
Jun 27, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
ac8296b6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
2 deletions
+67
-2
wcfs/t/t.go
wcfs/t/t.go
+4
-1
wcfs/wcfs.go
wcfs/wcfs.go
+63
-1
No files found.
wcfs/t/t.go
View file @
6d86fb8e
...
...
@@ -29,6 +29,7 @@ type fileHandle struct {
}
/*
// 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)
...
...
@@ -38,6 +39,7 @@ func (d *dir) Lookup(out *fuse.Attr, name string, _ *fuse.Context) (*nodefs.Inod
// XXX fill out
return ientry, fuse.OK
}
*/
var
nopen
=
0
...
...
@@ -106,8 +108,9 @@ func main() {
// NOTE cannot make entries before mount because Inode.AddChild does
// not work before that (panics on nil deref to mountRootXXX)
root
.
mkdir
(
"aaa"
)
aaa
:=
root
.
mkdir
(
"aaa"
)
root
.
mkfile
(
"hello.txt"
)
aaa
.
mkfile
(
"world.txt"
)
server
.
Serve
()
// XXX error?
}
wcfs/wcfs.go
View file @
6d86fb8e
...
...
@@ -241,9 +241,71 @@ package main
// link above), but better we have proper FUSE flag for filesystem server to
// tell the kernel it is fully responsible for invalidating pagecache.
// usage: wcfs zurl mountpoint
import
(
"flag"
"log"
"os"
"github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/fuse/nodefs"
)
// /.wcfs + option to prevent starting if wcfs was already started ?
// /zurl ?
type
StaticFile
struct
{
nodefs
.
Node
data
[]
byte
}
func
NewStaticFile
(
data
[]
byte
)
*
StaticFile
{
return
&
StaticFile
{
Node
:
nodefs
.
NewDefaultNode
(),
data
:
data
}
}
func
(
f
*
StaticFile
)
Read
(
_
nodefs
.
File
,
dest
[]
byte
,
off
int64
,
_
*
fuse
.
Context
)
(
fuse
.
ReadResult
,
fuse
.
Status
)
{
l
:=
int64
(
len
(
f
.
data
))
end
:=
off
+
l
if
end
>
l
{
end
=
l
}
return
fuse
.
ReadResultData
(
f
.
data
[
off
:
end
]),
fuse
.
OK
}
// mkdir adds child to parent as directory.
func
mkdir
(
parent
nodefs
.
Node
,
name
string
,
child
nodefs
.
Node
)
{
parent
.
Inode
()
.
NewChild
(
name
,
true
,
child
)
}
// mkfile adds child to parent as file.
func
mkfile
(
parent
nodefs
.
Node
,
name
string
,
child
nodefs
.
Node
)
{
parent
.
Inode
()
.
NewChild
(
name
,
false
,
child
)
}
func
main
()
{
log
.
SetPrefix
(
"wcfs: "
)
debug
:=
flag
.
Bool
(
"d"
,
false
,
"debug"
)
flag
.
Parse
()
if
len
(
flag
.
Args
())
!=
2
{
log
.
Fatalf
(
"Usage: %s zurl mntpt"
,
os
.
Args
[
0
])
}
zurl
:=
flag
.
Args
()[
0
]
mntpt
:=
flag
.
Args
()[
1
]
opts
:=
nodefs
.
NewOptions
()
opts
.
Debug
=
*
debug
root
:=
nodefs
.
NewDefaultNode
()
server
,
_
,
err
:=
nodefs
.
MountRoot
(
mntpt
,
root
,
opts
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
// XXX err ctx?
}
// add entries to /
mkfile
(
root
,
".wcfs"
,
NewStaticFile
([]
byte
(
zurl
)))
server
.
Serve
()
// XXX Serve returns no eror
}
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