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
524a7603
Commit
524a7603
authored
Sep 05, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix fsInode.TestDoubleOpen()
parent
efb4ad35
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
31 deletions
+46
-31
fuse/fsinode.go
fuse/fsinode.go
+32
-22
fuse/pathfilesystem.go
fuse/pathfilesystem.go
+3
-3
fuse/pathops.go
fuse/pathops.go
+10
-5
unionfs/unionfs_test.go
unionfs/unionfs_test.go
+1
-1
No files found.
fuse/fsinode.go
View file @
524a7603
...
...
@@ -170,15 +170,16 @@ func (me *fsInode) GetAttr(file File, context *Context) (fi *os.FileInfo, code S
}
func
(
me
*
fsInode
)
Chmod
(
file
File
,
perms
uint32
,
context
*
Context
)
(
code
Status
)
{
if
file
==
nil
{
file
=
me
.
inode
.
getWritableFile
()
}
if
file
!=
nil
{
files
:=
me
.
inode
.
getWritableFiles
()
for
_
,
f
:=
range
files
{
// TODO - pass context
code
=
file
.
Chmod
(
perms
)
}
code
=
f
.
Chmod
(
perms
)
if
!
code
.
Ok
()
{
break
}
}
if
file
==
nil
||
code
==
ENOSYS
{
if
len
(
files
)
==
0
||
code
==
ENOSYS
{
code
=
me
.
inode
.
mount
.
fs
.
Chmod
(
me
.
GetPath
(),
perms
,
context
)
}
return
code
...
...
@@ -186,11 +187,15 @@ func (me *fsInode) Chmod(file File, perms uint32, context *Context) (code Status
func
(
me
*
fsInode
)
Chown
(
file
File
,
uid
uint32
,
gid
uint32
,
context
*
Context
)
(
code
Status
)
{
if
file
!=
nil
{
files
:=
me
.
inode
.
getWritableFiles
()
for
_
,
f
:=
range
files
{
// TODO - pass context
code
=
file
.
Chown
(
uid
,
gid
)
code
=
f
.
Chown
(
uid
,
gid
)
if
!
code
.
Ok
()
{
break
}
}
if
file
==
nil
||
code
==
ENOSYS
{
if
len
(
files
)
==
0
||
code
==
ENOSYS
{
// TODO - can we get just FATTR_GID but not FATTR_UID ?
code
=
me
.
inode
.
mount
.
fs
.
Chown
(
me
.
GetPath
(),
uid
,
gid
,
context
)
}
...
...
@@ -198,26 +203,31 @@ func (me *fsInode) Chown(file File, uid uint32, gid uint32, context *Context) (c
}
func
(
me
*
fsInode
)
Truncate
(
file
File
,
size
uint64
,
context
*
Context
)
(
code
Status
)
{
if
file
==
nil
{
file
=
me
.
inode
.
getWritableFile
()
}
if
file
!=
nil
{
code
=
file
.
Truncate
(
size
)
files
:=
me
.
inode
.
getWritableFiles
()
for
_
,
f
:=
range
files
{
// TODO - pass context
log
.
Println
(
"truncating file"
,
f
)
code
=
f
.
Truncate
(
size
)
if
!
code
.
Ok
()
{
break
}
}
if
file
==
nil
||
code
==
ENOSYS
{
if
len
(
files
)
==
0
||
code
==
ENOSYS
{
code
=
me
.
inode
.
mount
.
fs
.
Truncate
(
me
.
GetPath
(),
size
,
context
)
}
return
code
}
func
(
me
*
fsInode
)
Utimens
(
file
File
,
atime
uint64
,
mtime
uint64
,
context
*
Context
)
(
code
Status
)
{
if
file
==
nil
{
file
=
me
.
inode
.
getWritableFile
()
}
if
file
!=
nil
{
code
=
file
.
Utimens
(
atime
,
mtime
)
files
:=
me
.
inode
.
getWritableFiles
()
for
_
,
f
:=
range
files
{
// TODO - pass context
code
=
f
.
Utimens
(
atime
,
mtime
)
if
!
code
.
Ok
()
{
break
}
}
if
file
==
nil
||
code
==
ENOSYS
{
if
len
(
files
)
==
0
||
code
==
ENOSYS
{
code
=
me
.
inode
.
mount
.
fs
.
Utimens
(
me
.
GetPath
(),
atime
,
mtime
,
context
)
}
return
code
...
...
fuse/pathfilesystem.go
View file @
524a7603
...
...
@@ -260,16 +260,16 @@ func (me *inode) getAnyFile() (file File) {
}
// Returns an open writable file for the given inode.
func
(
me
*
inode
)
getWritableFile
()
(
file
File
)
{
func
(
me
*
inode
)
getWritableFile
s
()
(
files
[]
File
)
{
me
.
OpenFilesMutex
.
Lock
()
defer
me
.
OpenFilesMutex
.
Unlock
()
for
_
,
f
:=
range
me
.
OpenFiles
{
if
f
.
OpenFlags
&
O_ANYWRITE
!=
0
{
return
f
.
file
files
=
append
(
files
,
f
.
file
)
}
}
return
nil
return
files
}
const
initDirSize
=
20
...
...
fuse/pathops.go
View file @
524a7603
...
...
@@ -159,15 +159,21 @@ 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
)
...
...
@@ -182,18 +188,17 @@ 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
}
fi
,
code
:=
node
.
fsInode
.
GetAttr
(
f
,
&
header
.
Context
)
out
=
&
AttrOut
{}
if
fi
!=
nil
{
out
.
Attr
.
Ino
=
header
.
NodeId
node
.
mount
.
fileInfoToAttr
(
fi
,
out
)
}
out
.
Attr
.
Ino
=
header
.
NodeId
node
.
mount
.
fileInfoToAttr
(
fi
,
out
)
return
out
,
code
}
...
...
unionfs/unionfs_test.go
View file @
524a7603
...
...
@@ -892,7 +892,7 @@ func TestDoubleOpen(t *testing.T) {
output
,
err
:=
ioutil
.
ReadAll
(
roFile
)
CheckSuccess
(
err
)
if
len
(
output
)
!=
0
{
t
.
Errorf
(
"After r/w truncation, r/o file should be empty too:
"
,
output
)
t
.
Errorf
(
"After r/w truncation, r/o file should be empty too:
%q"
,
string
(
output
)
)
}
disabled
:=
true
...
...
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