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
Levin Zimmermann
go-fuse
Commits
e8e94fea
Commit
e8e94fea
authored
May 01, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Run gofmt.
parent
49cf5940
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
49 additions
and
46 deletions
+49
-46
fuse/default.go
fuse/default.go
+2
-2
fuse/fsetattr_test.go
fuse/fsetattr_test.go
+14
-14
fuse/fuse.go
fuse/fuse.go
+1
-1
fuse/opcode.go
fuse/opcode.go
+5
-5
fuse/pathfilesystem.go
fuse/pathfilesystem.go
+4
-4
fuse/pathops.go
fuse/pathops.go
+10
-10
fuse/request.go
fuse/request.go
+2
-2
fuse/types.go
fuse/types.go
+8
-5
unionfs/unionfs.go
unionfs/unionfs.go
+1
-1
unionfs/unionfs_test.go
unionfs/unionfs_test.go
+2
-2
No files found.
fuse/default.go
View file @
e8e94fea
...
...
@@ -163,7 +163,7 @@ func (me *DefaultFile) Fsync(*FsyncIn) (code Status) {
func
(
me
*
DefaultFile
)
Utimens
(
atimeNs
uint64
,
mtimeNs
uint64
)
Status
{
return
ENOSYS
}
func
(
me
*
DefaultFile
)
Truncate
(
size
uint64
)
Status
{
return
ENOSYS
}
...
...
@@ -171,7 +171,7 @@ func (me *DefaultFile) Truncate(size uint64) Status {
func
(
me
*
DefaultFile
)
Chown
(
uid
uint32
,
gid
uint32
)
Status
{
return
ENOSYS
}
func
(
me
*
DefaultFile
)
Chmod
(
perms
uint32
)
Status
{
return
ENOSYS
}
...
...
fuse/fsetattr_test.go
View file @
e8e94fea
...
...
@@ -16,7 +16,7 @@ type MutableDataFile struct {
}
func
(
me
*
MutableDataFile
)
Read
(
r
*
ReadIn
,
bp
*
BufferPool
)
([]
byte
,
Status
)
{
return
me
.
data
[
r
.
Offset
:
r
.
Offset
+
uint64
(
r
.
Size
)],
OK
return
me
.
data
[
r
.
Offset
:
r
.
Offset
+
uint64
(
r
.
Size
)],
OK
}
func
(
me
*
MutableDataFile
)
Write
(
w
*
WriteIn
,
d
[]
byte
)
(
uint32
,
Status
)
{
...
...
@@ -24,7 +24,7 @@ func (me *MutableDataFile) Write(w *WriteIn, d []byte) (uint32, Status) {
if
int
(
end
)
>
len
(
me
.
data
)
{
data
:=
make
([]
byte
,
len
(
me
.
data
),
end
)
copy
(
data
,
me
.
data
)
me
.
data
=
data
me
.
data
=
data
}
copy
(
me
.
data
[
w
.
Offset
:
end
],
d
)
return
w
.
Size
,
OK
...
...
@@ -42,12 +42,12 @@ func (me *MutableDataFile) getAttr() *Attr {
a
:=
&
Attr
{}
CopyFileInfo
(
&
me
.
FileInfo
,
a
)
a
.
Size
=
uint64
(
len
(
me
.
data
))
return
a
}
func
(
me
*
MutableDataFile
)
GetAttr
()
*
Attr
{
me
.
GetAttrCalled
=
true
me
.
GetAttrCalled
=
true
return
me
.
getAttr
()
}
...
...
@@ -60,7 +60,7 @@ func (me *MutableDataFile) Utimens(atimeNs uint64, mtimeNs uint64) Status {
me
.
FileInfo
.
Mtime_ns
=
int64
(
mtimeNs
)
return
OK
}
func
(
me
*
MutableDataFile
)
Truncate
(
size
uint64
)
Status
{
me
.
data
=
me
.
data
[
:
size
]
return
OK
...
...
@@ -71,7 +71,7 @@ func (me *MutableDataFile) Chown(uid uint32, gid uint32) Status {
me
.
FileInfo
.
Gid
=
int
(
uid
)
return
OK
}
func
(
me
*
MutableDataFile
)
Chmod
(
perms
uint32
)
Status
{
me
.
FileInfo
.
Mode
=
(
me
.
FileInfo
.
Mode
&^
07777
)
|
perms
return
OK
...
...
@@ -93,7 +93,7 @@ func (me *FSetAttrFs) GetAttr(name string) (*Attr, Status) {
return
&
Attr
{
Mode
:
S_IFDIR
|
0700
},
OK
}
if
name
==
"file"
&&
me
.
file
!=
nil
{
a
:=
me
.
file
.
getAttr
()
a
:=
me
.
file
.
getAttr
()
a
.
Mode
|=
S_IFREG
return
a
,
OK
}
...
...
@@ -131,17 +131,17 @@ func TestFSetAttr(t *testing.T) {
state
.
Mount
(
dir
)
state
.
Debug
=
true
defer
state
.
Unmount
()
go
state
.
Loop
(
false
)
fn
:=
dir
+
"/file"
f
,
err
:=
os
.
OpenFile
(
fn
,
os
.
O_CREATE
|
os
.
O_WRONLY
,
0755
)
f
,
err
:=
os
.
OpenFile
(
fn
,
os
.
O_CREATE
|
os
.
O_WRONLY
,
0755
)
CheckSuccess
(
err
)
defer
f
.
Close
()
_
,
err
=
f
.
WriteString
(
"hello"
)
CheckSuccess
(
err
)
fmt
.
Println
(
"Ftruncate"
)
code
:=
syscall
.
Ftruncate
(
f
.
Fd
(),
3
)
if
code
!=
0
{
...
...
@@ -151,13 +151,13 @@ func TestFSetAttr(t *testing.T) {
t
.
Error
(
"truncate"
)
}
if
state
.
KernelSettings
()
.
Flags
&
CAP_FILE_OPS
==
0
{
if
state
.
KernelSettings
()
.
Flags
&
CAP_FILE_OPS
==
0
{
log
.
Println
(
"Mount does not support file operations"
)
m
,
_
:=
json
.
Marshal
(
state
.
KernelSettings
())
log
.
Println
(
"Kernel settings: "
,
string
(
m
))
return
}
_
,
err
=
os
.
Lstat
(
fn
)
CheckSuccess
(
err
)
...
...
@@ -167,13 +167,13 @@ func TestFSetAttr(t *testing.T) {
err
=
os
.
Chmod
(
fn
,
024
)
CheckSuccess
(
err
)
if
fs
.
file
.
FileInfo
.
Mode
&
07777
!=
024
{
if
fs
.
file
.
FileInfo
.
Mode
&
07777
!=
024
{
t
.
Error
(
"chmod"
)
}
err
=
os
.
Chtimes
(
fn
,
100
,
101
)
CheckSuccess
(
err
)
if
fs
.
file
.
FileInfo
.
Atime_ns
!=
100
||
fs
.
file
.
FileInfo
.
Atime_ns
!=
101
{
if
fs
.
file
.
FileInfo
.
Atime_ns
!=
100
||
fs
.
file
.
FileInfo
.
Atime_ns
!=
101
{
t
.
Error
(
"Utimens"
)
}
...
...
fuse/fuse.go
View file @
e8e94fea
...
...
@@ -32,7 +32,7 @@ type MountState struct {
buffers
*
BufferPool
*
LatencyMap
kernelSettings
InitIn
}
...
...
fuse/opcode.go
View file @
e8e94fea
...
...
@@ -60,10 +60,10 @@ const (
func
doInit
(
state
*
MountState
,
req
*
request
)
{
const
(
FUSE_KERNEL_VERSION
=
7
FUSE_KERNEL_VERSION
=
7
FUSE_KERNEL_MINOR_VERSION
=
13
)
input
:=
(
*
InitIn
)(
req
.
inData
)
if
input
.
Major
!=
FUSE_KERNEL_VERSION
{
log
.
Printf
(
"Major versions does not match. Given %d, want %d
\n
"
,
input
.
Major
,
FUSE_KERNEL_VERSION
)
...
...
@@ -82,7 +82,7 @@ func doInit(state *MountState, req *request) {
Major
:
FUSE_KERNEL_VERSION
,
Minor
:
FUSE_KERNEL_MINOR_VERSION
,
MaxReadAhead
:
input
.
MaxReadAhead
,
Flags
:
state
.
kernelSettings
.
Flags
,
Flags
:
state
.
kernelSettings
.
Flags
,
MaxWrite
:
maxRead
,
CongestionThreshold
:
_BACKGROUND_TASKS
*
3
/
4
,
MaxBackground
:
_BACKGROUND_TASKS
,
...
...
@@ -467,14 +467,14 @@ func init() {
_OP_LOOKUP
:
func
(
ptr
unsafe
.
Pointer
)
interface
{}
{
return
(
*
EntryOut
)(
ptr
)
},
_OP_OPEN
:
func
(
ptr
unsafe
.
Pointer
)
interface
{}
{
return
(
*
EntryOut
)(
ptr
)
},
_OP_GETATTR
:
func
(
ptr
unsafe
.
Pointer
)
interface
{}
{
return
(
*
AttrOut
)(
ptr
)
},
_OP_CREATE
:
func
(
ptr
unsafe
.
Pointer
)
interface
{}
{
return
(
*
CreateOut
)(
ptr
)
},
_OP_CREATE
:
func
(
ptr
unsafe
.
Pointer
)
interface
{}
{
return
(
*
CreateOut
)(
ptr
)
},
}
{
operationHandlers
[
op
]
.
DecodeOut
=
f
}
for
op
,
f
:=
range
map
[
opcode
]
castPointerFunc
{
_OP_GETATTR
:
func
(
ptr
unsafe
.
Pointer
)
interface
{}
{
return
(
*
GetAttrIn
)(
ptr
)
},
_OP_SETATTR
:
func
(
ptr
unsafe
.
Pointer
)
interface
{}
{
return
(
*
SetAttrIn
)(
ptr
)
},
_OP_INIT
:
func
(
ptr
unsafe
.
Pointer
)
interface
{}
{
return
(
*
InitIn
)(
ptr
)
},
_OP_INIT
:
func
(
ptr
unsafe
.
Pointer
)
interface
{}
{
return
(
*
InitIn
)(
ptr
)
},
}
{
operationHandlers
[
op
]
.
DecodeIn
=
f
}
...
...
fuse/pathfilesystem.go
View file @
e8e94fea
...
...
@@ -15,8 +15,8 @@ package fuse
- We are doing lookups (incurring GetAttr() costs) for internal
lookups (eg. after doing a symlink). We could probably do without
the GetAttr calls.
*/
*/
import
(
"fmt"
...
...
@@ -230,7 +230,7 @@ func (me *FileSystemConnector) registerFile(node *inode, mount *mountData, f int
defer
me
.
fileLock
.
Unlock
()
b
:=
&
interfaceBridge
{
Iface
:
f
,
Iface
:
f
,
mountData
:
mount
,
}
h
:=
uint64
(
uintptr
(
unsafe
.
Pointer
(
b
)))
...
...
@@ -525,6 +525,6 @@ func (me *FileSystemConnector) getOpenFileData(nodeid uint64, fh uint64) (f File
p
,
m
=
node
.
GetPath
()
}
return
return
}
fuse/pathops.go
View file @
e8e94fea
...
...
@@ -74,13 +74,13 @@ func (me *FileSystemConnector) Forget(h *InHeader, input *ForgetIn) {
}
func
(
me
*
FileSystemConnector
)
GetAttr
(
header
*
InHeader
,
input
*
GetAttrIn
)
(
out
*
AttrOut
,
code
Status
)
{
if
input
.
Flags
&
FUSE_GETATTR_FH
!=
0
{
if
input
.
Flags
&
FUSE_GETATTR_FH
!=
0
{
f
,
mount
:=
me
.
getFile
(
input
.
Fh
)
attr
:=
f
.
GetAttr
()
if
attr
!=
nil
{
out
=
&
AttrOut
{
Attr
:
*
attr
,
Attr
:
*
attr
,
}
out
.
Attr
.
Ino
=
header
.
NodeId
SplitNs
(
mount
.
options
.
AttrTimeout
,
&
out
.
AttrValid
,
&
out
.
AttrValidNsec
)
...
...
@@ -88,7 +88,7 @@ func (me *FileSystemConnector) GetAttr(header *InHeader, input *GetAttrIn) (out
return
out
,
OK
}
}
fullPath
,
mount
,
_
:=
me
.
GetPath
(
header
.
NodeId
)
if
mount
==
nil
{
return
nil
,
ENOENT
...
...
@@ -205,17 +205,17 @@ func (me *FileSystemConnector) SetAttr(header *InHeader, input *SetAttrIn) (out
fileResult
=
ENOSYS
}
}
if
err
==
OK
&&
(
input
.
Valid
&
(
FATTR_ATIME
|
FATTR_MTIME
|
FATTR_ATIME_NOW
|
FATTR_MTIME_NOW
)
!=
0
)
{
atime
:=
uint64
(
input
.
Atime
*
1e9
)
+
uint64
(
input
.
Atimensec
)
if
input
.
Valid
&
FATTR_ATIME_NOW
!=
0
{
if
err
==
OK
&&
(
input
.
Valid
&
(
FATTR_ATIME
|
FATTR_MTIME
|
FATTR_ATIME_NOW
|
FATTR_MTIME_NOW
)
!=
0
)
{
atime
:=
uint64
(
input
.
Atime
*
1e9
)
+
uint64
(
input
.
Atimensec
)
if
input
.
Valid
&
FATTR_ATIME_NOW
!=
0
{
atime
=
uint64
(
time
.
Nanoseconds
())
}
mtime
:=
uint64
(
input
.
Mtime
*
1e9
)
+
uint64
(
input
.
Mtimensec
)
if
input
.
Valid
&
FATTR_MTIME_NOW
!=
0
{
mtime
:=
uint64
(
input
.
Mtime
*
1e9
)
+
uint64
(
input
.
Mtimensec
)
if
input
.
Valid
&
FATTR_MTIME_NOW
!=
0
{
mtime
=
uint64
(
time
.
Nanoseconds
())
}
if
f
!=
nil
{
fileResult
=
f
.
Utimens
(
atime
,
mtime
)
}
...
...
fuse/request.go
View file @
e8e94fea
...
...
@@ -54,7 +54,7 @@ func (me *request) InputDebug() string {
names
:=
""
if
me
.
handler
.
FileNames
>
0
{
names
=
fmt
.
Sprintf
(
"names: %v"
,
me
.
filenames
(
me
.
handler
.
FileNames
))
}
}
return
fmt
.
Sprintf
(
"Dispatch: %v, NodeId: %v.%v%v"
,
me
.
inHeader
.
opcode
,
me
.
inHeader
.
NodeId
,
val
,
names
)
...
...
@@ -89,7 +89,7 @@ func (req *request) parse() {
inHSize
:=
unsafe
.
Sizeof
(
InHeader
{})
if
len
(
req
.
inputBuf
)
<
inHSize
{
log
.
Printf
(
"Short read for input header: %v"
,
req
.
inputBuf
)
return
return
}
req
.
inHeader
=
(
*
InHeader
)(
unsafe
.
Pointer
(
&
req
.
inputBuf
[
0
]))
...
...
fuse/types.go
View file @
e8e94fea
...
...
@@ -20,7 +20,7 @@ const (
FUSE_POLL_SCHEDULE_NOTIFY
=
(
1
<<
0
)
CUSE_INIT_INFO_MAX
=
4096
CUSE_INIT_INFO_MAX
=
4096
S_IFDIR
=
syscall
.
S_IFDIR
S_IFREG
=
syscall
.
S_IFREG
...
...
@@ -132,9 +132,9 @@ const (
)
type
GetAttrIn
struct
{
Flags
uint32
Dummy
uint32
Fh
uint64
Flags
uint32
Dummy
uint32
Fh
uint64
}
type
AttrOut
struct
{
...
...
@@ -165,7 +165,7 @@ type LinkIn struct {
}
const
(
// SetAttrIn.Valid
const
(
// SetAttrIn.Valid
FATTR_MODE
=
(
1
<<
0
)
FATTR_UID
=
(
1
<<
1
)
FATTR_GID
=
(
1
<<
2
)
...
...
@@ -243,6 +243,7 @@ type FlushIn struct {
const
(
FUSE_READ_LOCKOWNER
=
(
1
<<
1
)
)
type
ReadIn
struct
{
Fh
uint64
Offset
uint64
...
...
@@ -258,6 +259,7 @@ const (
FUSE_WRITE_CACHE
=
(
1
<<
0
)
FUSE_WRITE_LOCKOWNER
=
(
1
<<
1
)
)
type
WriteIn
struct
{
Fh
uint64
Offset
uint64
...
...
@@ -384,6 +386,7 @@ const (
FUSE_IOCTL_UNRESTRICTED
=
(
1
<<
1
)
FUSE_IOCTL_RETRY
=
(
1
<<
2
)
)
type
IoctlIn
struct
{
Fh
uint64
Flags
uint32
...
...
unionfs/unionfs.go
View file @
e8e94fea
...
...
@@ -329,7 +329,7 @@ func (me *UnionFs) Truncate(path string, offset uint64) (code fuse.Status) {
return
code
}
}
return
me
.
fileSystems
[
0
]
.
Truncate
(
path
,
offset
)
}
...
...
unionfs/unionfs_test.go
View file @
e8e94fea
...
...
@@ -330,11 +330,11 @@ func TestTruncate(t *testing.T) {
writeToFile
(
wd
+
"/ro/file"
,
"hello"
)
os
.
Truncate
(
wd
+
"/mount/file"
,
2
)
content
:=
readFromFile
(
wd
+
"/mount/file"
)
content
:=
readFromFile
(
wd
+
"/mount/file"
)
if
content
!=
"he"
{
t
.
Errorf
(
"unexpected content %v"
,
content
)
}
content2
:=
readFromFile
(
wd
+
"/rw/file"
)
content2
:=
readFromFile
(
wd
+
"/rw/file"
)
if
content2
!=
content
{
t
.
Errorf
(
"unexpected rw content %v"
,
content2
)
}
...
...
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