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
77ffd1bf
Commit
77ffd1bf
authored
Apr 05, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
c18237fe
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
10 deletions
+17
-10
wcfs/misc.go
wcfs/misc.go
+14
-8
wcfs/wcfs.go
wcfs/wcfs.go
+3
-2
No files found.
wcfs/misc.go
View file @
77ffd1bf
...
...
@@ -144,7 +144,7 @@ type fsOptions struct {
Sticky
bool
}
var
fSticky
=
&
fsOptions
{
Sticky
:
true
}
// frequently used shortcut
XXX -> newFSticky?
var
fSticky
=
&
fsOptions
{
Sticky
:
true
}
// frequently used shortcut
func
(
n
*
fsNode
)
Deletable
()
bool
{
return
!
n
.
opt
.
Sticky
...
...
@@ -186,8 +186,8 @@ func (n *fsNode) path() string {
//
// Created file is sticky.
func
NewStaticFile
(
data
[]
byte
)
*
SmallFile
{
return
newSmallFile
(
func
(
)
[]
byte
{
return
data
return
newSmallFile
(
func
(
_
*
fuse
.
Context
)
([]
byte
,
error
)
{
return
data
,
nil
},
fuse
.
FOPEN_KEEP_CACHE
/*see ^^^*/
)
}
...
...
@@ -197,10 +197,10 @@ type SmallFile struct {
fuseFlags
uint32
// fuse.FOPEN_*
// readData gives whole file data
readData
func
(
)
[]
byte
readData
func
(
fctx
*
fuse
.
Context
)
([]
byte
,
error
)
}
func
newSmallFile
(
readData
func
(
)
[]
byte
,
fuseFlags
uint32
)
*
SmallFile
{
func
newSmallFile
(
readData
func
(
*
fuse
.
Context
)
([]
byte
,
error
)
,
fuseFlags
uint32
)
*
SmallFile
{
return
&
SmallFile
{
fsNode
:
newFSNode
(
&
fsOptions
{
Sticky
:
true
}),
fuseFlags
:
fuseFlags
,
...
...
@@ -211,7 +211,7 @@ func newSmallFile(readData func() []byte, fuseFlags uint32) *SmallFile {
// NewSmallFile creates nodefs.Node for file with dynamic, but always small, data.
//
// Created file is sticky.
func
NewSmallFile
(
readData
func
(
)
[]
byte
)
*
SmallFile
{
func
NewSmallFile
(
readData
func
(
*
fuse
.
Context
)
([]
byte
,
error
)
)
*
SmallFile
{
return
newSmallFile
(
readData
,
fuse
.
FOPEN_DIRECT_IO
)
}
...
...
@@ -223,14 +223,20 @@ func (f *SmallFile) Open(flags uint32, _ *fuse.Context) (nodefs.File, fuse.Statu
}
func
(
f
*
SmallFile
)
GetAttr
(
out
*
fuse
.
Attr
,
_
nodefs
.
File
,
fctx
*
fuse
.
Context
)
fuse
.
Status
{
data
:=
f
.
readData
()
// XXX pass in fctx, so that the call could be canceled
data
,
err
:=
f
.
readData
(
fctx
)
if
err
!=
nil
{
return
err2LogStatus
(
err
)
}
out
.
Size
=
uint64
(
len
(
data
))
out
.
Mode
=
fuse
.
S_IFREG
|
0644
return
fuse
.
OK
}
func
(
f
*
SmallFile
)
Read
(
_
nodefs
.
File
,
dest
[]
byte
,
off
int64
,
fctx
*
fuse
.
Context
)
(
fuse
.
ReadResult
,
fuse
.
Status
)
{
data
:=
f
.
readData
()
// XXX +fctx -> cancel
data
,
err
:=
f
.
readData
(
fctx
)
if
err
!=
nil
{
return
nil
,
err2LogStatus
(
err
)
}
l
:=
int64
(
len
(
data
))
end
:=
off
+
l
if
end
>
l
{
...
...
wcfs/wcfs.go
View file @
77ffd1bf
...
...
@@ -2176,11 +2176,12 @@ func (f *BigFile) Close() error {
// ---- misc ---
// /(head|<rev>)/at -> readAt serves read.
func
(
h
*
Head
)
readAt
()
[]
byte
{
func
(
h
*
Head
)
readAt
(
fctx
*
fuse
.
Context
)
([]
byte
,
error
)
{
// XXX cancel on fctx cancel
h
.
zheadMu
.
RLock
()
defer
h
.
zheadMu
.
RUnlock
()
return
[]
byte
(
h
.
zconn
.
At
()
.
String
())
return
[]
byte
(
h
.
zconn
.
At
()
.
String
())
,
nil
}
// /(head|<rev>)/ -> Getattr serves stat.
...
...
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