Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go-fuse
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
Kirill Smelkov
go-fuse
Commits
4df83d57
Commit
4df83d57
authored
Aug 28, 2024
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fs: reorganize code
Change-Id: I91a375cc2956b2ead0ad3a4a5b2a0c66a4c327e2
parent
e0a0b09a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
65 deletions
+63
-65
fs/bridge.go
fs/bridge.go
+63
-65
No files found.
fs/bridge.go
View file @
4df83d57
...
...
@@ -422,13 +422,12 @@ func (b *rawBridge) Unlink(cancel <-chan struct{}, header *fuse.InHeader, name s
func
(
b
*
rawBridge
)
Mkdir
(
cancel
<-
chan
struct
{},
input
*
fuse
.
MkdirIn
,
name
string
,
out
*
fuse
.
EntryOut
)
fuse
.
Status
{
parent
,
_
:=
b
.
inode
(
input
.
NodeId
,
0
)
var
child
*
Inode
var
errno
syscall
.
Errno
if
mops
,
ok
:=
parent
.
ops
.
(
NodeMkdirer
);
ok
{
child
,
errno
=
mops
.
Mkdir
(
&
fuse
.
Context
{
Caller
:
input
.
Caller
,
Cancel
:
cancel
},
name
,
input
.
Mode
,
out
)
}
else
{
ctx
:=
&
fuse
.
Context
{
Caller
:
input
.
Caller
,
Cancel
:
cancel
}
mops
,
ok
:=
parent
.
ops
.
(
NodeMkdirer
)
if
!
ok
{
return
fuse
.
ENOTSUP
}
child
,
errno
:=
mops
.
Mkdir
(
ctx
,
name
,
input
.
Mode
,
out
)
if
errno
!=
0
{
return
errnoToStatus
(
errno
)
...
...
@@ -451,14 +450,12 @@ func (b *rawBridge) Mkdir(cancel <-chan struct{}, input *fuse.MkdirIn, name stri
func
(
b
*
rawBridge
)
Mknod
(
cancel
<-
chan
struct
{},
input
*
fuse
.
MknodIn
,
name
string
,
out
*
fuse
.
EntryOut
)
fuse
.
Status
{
parent
,
_
:=
b
.
inode
(
input
.
NodeId
,
0
)
var
child
*
Inode
var
errno
syscall
.
Errno
if
mops
,
ok
:=
parent
.
ops
.
(
NodeMknoder
);
ok
{
child
,
errno
=
mops
.
Mknod
(
&
fuse
.
Context
{
Caller
:
input
.
Caller
,
Cancel
:
cancel
},
name
,
input
.
Mode
,
input
.
Rdev
,
out
)
}
else
{
mops
,
ok
:=
parent
.
ops
.
(
NodeMknoder
)
if
!
ok
{
return
fuse
.
ENOTSUP
}
ctx
:=
&
fuse
.
Context
{
Caller
:
input
.
Caller
,
Cancel
:
cancel
}
child
,
errno
:=
mops
.
Mknod
(
ctx
,
name
,
input
.
Mode
,
input
.
Rdev
,
out
)
if
errno
!=
0
{
return
errnoToStatus
(
errno
)
}
...
...
@@ -470,18 +467,14 @@ func (b *rawBridge) Mknod(cancel <-chan struct{}, input *fuse.MknodIn, name stri
}
func
(
b
*
rawBridge
)
Create
(
cancel
<-
chan
struct
{},
input
*
fuse
.
CreateIn
,
name
string
,
out
*
fuse
.
CreateOut
)
fuse
.
Status
{
ctx
:=
&
fuse
.
Context
{
Caller
:
input
.
Caller
,
Cancel
:
cancel
}
parent
,
_
:=
b
.
inode
(
input
.
NodeId
,
0
)
var
child
*
Inode
var
errno
syscall
.
Errno
var
f
FileHandle
var
flags
uint32
if
mops
,
ok
:=
parent
.
ops
.
(
NodeCreater
);
ok
{
child
,
f
,
flags
,
errno
=
mops
.
Create
(
ctx
,
name
,
input
.
Flags
,
input
.
Mode
,
&
out
.
EntryOut
)
}
else
{
mops
,
ok
:=
parent
.
ops
.
(
NodeCreater
)
if
!
ok
{
return
fuse
.
EROFS
}
ctx
:=
&
fuse
.
Context
{
Caller
:
input
.
Caller
,
Cancel
:
cancel
}
child
,
f
,
flags
,
errno
:=
mops
.
Create
(
ctx
,
name
,
input
.
Flags
,
input
.
Mode
,
&
out
.
EntryOut
)
if
errno
!=
0
{
if
b
.
options
.
NegativeTimeout
!=
nil
{
...
...
@@ -632,51 +625,56 @@ func (b *rawBridge) Link(cancel <-chan struct{}, input *fuse.LinkIn, name string
parent
,
_
:=
b
.
inode
(
input
.
NodeId
,
0
)
target
,
_
:=
b
.
inode
(
input
.
Oldnodeid
,
0
)
if
mops
,
ok
:=
parent
.
ops
.
(
NodeLinker
);
ok
{
child
,
errno
:=
mops
.
Link
(
&
fuse
.
Context
{
Caller
:
input
.
Caller
,
Cancel
:
cancel
},
target
.
ops
,
name
,
out
)
if
errno
!=
0
{
return
errnoToStatus
(
errno
)
}
mops
,
ok
:=
parent
.
ops
.
(
NodeLinker
)
if
!
ok
{
return
fuse
.
ENOTSUP
}
child
,
_
=
b
.
addNewChild
(
parent
,
name
,
child
,
nil
,
0
,
out
)
child
.
setEntryOut
(
out
)
b
.
setEntryOutTimeout
(
out
)
return
fuse
.
OK
ctx
:=
&
fuse
.
Context
{
Caller
:
input
.
Caller
,
Cancel
:
cancel
}
child
,
errno
:=
mops
.
Link
(
ctx
,
target
.
ops
,
name
,
out
)
if
errno
!=
0
{
return
errnoToStatus
(
errno
)
}
return
fuse
.
ENOTSUP
child
,
_
=
b
.
addNewChild
(
parent
,
name
,
child
,
nil
,
0
,
out
)
child
.
setEntryOut
(
out
)
b
.
setEntryOutTimeout
(
out
)
return
fuse
.
OK
}
func
(
b
*
rawBridge
)
Symlink
(
cancel
<-
chan
struct
{},
header
*
fuse
.
InHeader
,
target
string
,
name
string
,
out
*
fuse
.
EntryOut
)
fuse
.
Status
{
parent
,
_
:=
b
.
inode
(
header
.
NodeId
,
0
)
if
mops
,
ok
:=
parent
.
ops
.
(
NodeSymlinker
);
ok
{
child
,
status
:=
mops
.
Symlink
(
&
fuse
.
Context
{
Caller
:
header
.
Caller
,
Cancel
:
cancel
},
target
,
name
,
out
)
if
status
!=
0
{
return
errnoToStatus
(
status
)
}
child
,
_
=
b
.
addNewChild
(
parent
,
name
,
child
,
nil
,
syscall
.
O_EXCL
,
out
)
child
.
setEntryOut
(
out
)
b
.
setEntryOutTimeout
(
out
)
return
fuse
.
OK
mops
,
ok
:=
parent
.
ops
.
(
NodeSymlinker
)
if
!
ok
{
return
fuse
.
ENOTSUP
}
return
fuse
.
ENOTSUP
ctx
:=
&
fuse
.
Context
{
Caller
:
header
.
Caller
,
Cancel
:
cancel
}
child
,
status
:=
mops
.
Symlink
(
ctx
,
target
,
name
,
out
)
if
status
!=
0
{
return
errnoToStatus
(
status
)
}
child
,
_
=
b
.
addNewChild
(
parent
,
name
,
child
,
nil
,
syscall
.
O_EXCL
,
out
)
child
.
setEntryOut
(
out
)
b
.
setEntryOutTimeout
(
out
)
return
fuse
.
OK
}
func
(
b
*
rawBridge
)
Readlink
(
cancel
<-
chan
struct
{},
header
*
fuse
.
InHeader
)
(
out
[]
byte
,
status
fuse
.
Status
)
{
n
,
_
:=
b
.
inode
(
header
.
NodeId
,
0
)
if
linker
,
ok
:=
n
.
ops
.
(
NodeReadlinker
);
ok
{
result
,
errno
:=
linker
.
Readlink
(
&
fuse
.
Context
{
Caller
:
header
.
Caller
,
Cancel
:
cancel
})
if
errno
!=
0
{
return
nil
,
errnoToStatus
(
errno
)
}
return
result
,
fuse
.
OK
linker
,
ok
:=
n
.
ops
.
(
NodeReadlinker
)
if
!
ok
{
return
nil
,
fuse
.
ENOTSUP
}
ctx
:=
&
fuse
.
Context
{
Caller
:
header
.
Caller
,
Cancel
:
cancel
}
result
,
errno
:=
linker
.
Readlink
(
ctx
)
if
errno
!=
0
{
return
nil
,
errnoToStatus
(
errno
)
}
return
nil
,
fuse
.
ENOTSUP
return
result
,
fuse
.
OK
}
func
(
b
*
rawBridge
)
Access
(
cancel
<-
chan
struct
{},
input
*
fuse
.
AccessIn
)
fuse
.
Status
{
...
...
@@ -742,25 +740,25 @@ func (b *rawBridge) RemoveXAttr(cancel <-chan struct{}, header *fuse.InHeader, a
func
(
b
*
rawBridge
)
Open
(
cancel
<-
chan
struct
{},
input
*
fuse
.
OpenIn
,
out
*
fuse
.
OpenOut
)
fuse
.
Status
{
n
,
_
:=
b
.
inode
(
input
.
NodeId
,
0
)
if
op
,
ok
:=
n
.
ops
.
(
NodeOpener
);
ok
{
f
,
flags
,
errno
:=
op
.
Open
(
&
fuse
.
Context
{
Caller
:
input
.
Caller
,
Cancel
:
cancel
},
input
.
Flags
)
if
errno
!=
0
{
return
errnoToStatus
(
errno
)
}
out
.
OpenFlags
=
flags
op
,
ok
:=
n
.
ops
.
(
NodeOpener
)
if
!
ok
{
return
fuse
.
ENOTSUP
}
f
,
flags
,
errno
:=
op
.
Open
(
&
fuse
.
Context
{
Caller
:
input
.
Caller
,
Cancel
:
cancel
},
input
.
Flags
)
if
errno
!=
0
{
return
errnoToStatus
(
errno
)
}
out
.
OpenFlags
=
flags
if
f
!=
nil
{
b
.
mu
.
Lock
()
defer
b
.
mu
.
Unlock
()
fe
:=
b
.
registerFile
(
n
,
f
,
input
.
Flags
)
out
.
Fh
=
uint64
(
fe
.
fh
)
if
f
!=
nil
{
b
.
mu
.
Lock
()
defer
b
.
mu
.
Unlock
()
fe
:=
b
.
registerFile
(
n
,
f
,
input
.
Flags
)
out
.
Fh
=
uint64
(
fe
.
fh
)
b
.
addBackingID
(
n
,
f
,
out
)
}
return
fuse
.
OK
b
.
addBackingID
(
n
,
f
,
out
)
}
return
fuse
.
ENOTSUP
return
fuse
.
OK
}
// must hold bridge.mu
...
...
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