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
bad4ee66
Commit
bad4ee66
authored
Sep 05, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Kludge up setattr/getattr handling for UnionFs.
parent
524a7603
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
43 additions
and
19 deletions
+43
-19
fuse/fsinode.go
fuse/fsinode.go
+1
-1
fuse/pathfilesystem.go
fuse/pathfilesystem.go
+5
-2
fuse/pathops.go
fuse/pathops.go
+3
-8
unionfs/unionfs.go
unionfs/unionfs.go
+19
-1
unionfs/unionfs_test.go
unionfs/unionfs_test.go
+15
-7
No files found.
fuse/fsinode.go
View file @
bad4ee66
...
...
@@ -150,7 +150,7 @@ func (me *fsInode) Lookup(name string) (fi *os.FileInfo, code Status) {
}
func
(
me
*
fsInode
)
GetAttr
(
file
File
,
context
*
Context
)
(
fi
*
os
.
FileInfo
,
code
Status
)
{
if
file
==
nil
&&
me
.
Parent
==
nil
&&
me
.
inode
.
mountPoint
==
nil
{
if
file
==
nil
{
// called on a deleted files.
file
=
me
.
inode
.
getAnyFile
()
}
...
...
fuse/pathfilesystem.go
View file @
bad4ee66
...
...
@@ -249,14 +249,17 @@ func (me *inode) getMountDirEntries() (out []DirEntry) {
return
out
}
// Returns any open file, preferably a r/w one.
func
(
me
*
inode
)
getAnyFile
()
(
file
File
)
{
me
.
OpenFilesMutex
.
Lock
()
defer
me
.
OpenFilesMutex
.
Unlock
()
for
_
,
f
:=
range
me
.
OpenFiles
{
return
f
.
file
if
file
==
nil
||
f
.
OpenFlags
&
O_ANYWRITE
!=
0
{
file
=
f
.
file
}
}
return
nil
return
file
}
// Returns an open writable file for the given inode.
...
...
fuse/pathops.go
View file @
bad4ee66
...
...
@@ -159,21 +159,15 @@ func (me *FileSystemConnector) SetAttr(header *InHeader, input *SetAttrIn) (out
}
node
:=
me
.
getInodeData
(
header
.
NodeId
)
fi
,
code
:=
node
.
fsInode
.
GetAttr
(
f
,
&
header
.
Context
)
if
code
.
Ok
()
&&
input
.
Valid
&
FATTR_MODE
!=
0
{
permissions
:=
uint32
(
07777
)
&
input
.
Mode
code
=
node
.
fsInode
.
Chmod
(
f
,
permissions
,
&
header
.
Context
)
fi
.
Mode
=
(
fi
.
Mode
&^
07777
)
|
permissions
}
if
code
.
Ok
()
&&
(
input
.
Valid
&
(
FATTR_UID
|
FATTR_GID
)
!=
0
)
{
code
=
node
.
fsInode
.
Chown
(
f
,
uint32
(
input
.
Uid
),
uint32
(
input
.
Gid
),
&
header
.
Context
)
fi
.
Uid
=
int
(
input
.
Uid
)
fi
.
Gid
=
int
(
input
.
Gid
)
}
if
code
.
Ok
()
&&
input
.
Valid
&
FATTR_SIZE
!=
0
{
code
=
node
.
fsInode
.
Truncate
(
f
,
input
.
Size
,
&
header
.
Context
)
fi
.
Size
=
int64
(
input
.
Size
)
}
if
code
.
Ok
()
&&
(
input
.
Valid
&
(
FATTR_ATIME
|
FATTR_MTIME
|
FATTR_ATIME_NOW
|
FATTR_MTIME_NOW
)
!=
0
)
{
atime
:=
uint64
(
input
.
Atime
*
1e9
)
+
uint64
(
input
.
Atimensec
)
...
...
@@ -188,14 +182,15 @@ func (me *FileSystemConnector) SetAttr(header *InHeader, input *SetAttrIn) (out
// TODO - if using NOW, mtime and atime may differ.
code
=
node
.
fsInode
.
Utimens
(
f
,
atime
,
mtime
,
&
header
.
Context
)
fi
.
Atime_ns
=
int64
(
atime
)
fi
.
Mtime_ns
=
int64
(
mtime
)
}
if
!
code
.
Ok
()
{
return
nil
,
code
}
// Must call GetAttr(); the filesystem may override some of
// the changes we effect here.
fi
,
code
:=
node
.
fsInode
.
GetAttr
(
f
,
&
header
.
Context
)
out
=
&
AttrOut
{}
out
.
Attr
.
Ino
=
header
.
NodeId
node
.
mount
.
fileInfoToAttr
(
fi
,
out
)
...
...
unionfs/unionfs.go
View file @
bad4ee66
...
...
@@ -863,7 +863,11 @@ func (me *UnionFs) Open(name string, flags uint32, context *fuse.Context) (fuseF
r
.
attr
.
Mtime_ns
=
time
.
Nanoseconds
()
me
.
branchCache
.
Set
(
name
,
r
)
}
return
me
.
fileSystems
[
r
.
branch
]
.
Open
(
name
,
uint32
(
flags
),
context
)
fuseFile
,
status
=
me
.
fileSystems
[
r
.
branch
]
.
Open
(
name
,
uint32
(
flags
),
context
)
if
fuseFile
!=
nil
{
fuseFile
=
&
UnionFsFile
{
fuseFile
}
}
return
fuseFile
,
status
}
func
(
me
*
UnionFs
)
Flush
(
name
string
)
fuse
.
Status
{
...
...
@@ -879,3 +883,17 @@ func (me *UnionFs) Name() string {
}
return
fmt
.
Sprintf
(
"%v"
,
names
)
}
type
UnionFsFile
struct
{
fuse
.
File
}
func
(
me
*
UnionFsFile
)
GetAttr
()
(
*
os
.
FileInfo
,
fuse
.
Status
)
{
fi
,
code
:=
me
.
File
.
GetAttr
()
if
fi
!=
nil
{
f
:=
*
fi
fi
=
&
f
fi
.
Mode
|=
0222
}
return
fi
,
code
}
unionfs/unionfs_test.go
View file @
bad4ee66
...
...
@@ -193,12 +193,6 @@ func TestChmod(t *testing.T) {
err
:=
os
.
Chmod
(
m_fn
,
07070
)
CheckSuccess
(
err
)
err
=
os
.
Chown
(
m_fn
,
0
,
0
)
code
:=
fuse
.
OsErrorToErrno
(
err
)
if
code
!=
fuse
.
EPERM
{
t
.
Error
(
"Unexpected error code"
,
code
,
err
)
}
fi
,
err
:=
os
.
Lstat
(
m_fn
)
CheckSuccess
(
err
)
if
fi
.
Mode
&
07777
!=
07272
{
...
...
@@ -210,6 +204,21 @@ func TestChmod(t *testing.T) {
}
}
func
TestChown
(
t
*
testing
.
T
)
{
wd
,
clean
:=
setupUfs
(
t
)
defer
clean
()
ro_fn
:=
wd
+
"/ro/file"
m_fn
:=
wd
+
"/mount/file"
writeToFile
(
ro_fn
,
"a"
)
err
:=
os
.
Chown
(
m_fn
,
0
,
0
)
code
:=
fuse
.
OsErrorToErrno
(
err
)
if
code
!=
fuse
.
EPERM
{
t
.
Error
(
"Unexpected error code"
,
code
,
err
)
}
}
func
TestDelete
(
t
*
testing
.
T
)
{
wd
,
clean
:=
setupUfs
(
t
)
defer
clean
()
...
...
@@ -857,7 +866,6 @@ func TestDisappearing(t *testing.T) {
}
func
TestDeletedGetAttr
(
t
*
testing
.
T
)
{
t
.
Log
(
"TestDeletedGetAttr"
)
wd
,
clean
:=
setupUfs
(
t
)
defer
clean
()
...
...
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