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
df325e01
Commit
df325e01
authored
Sep 24, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UnionFs: centralize write mask, carry over timestamps in promoteDirsTo.
parent
fed54568
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
10 deletions
+44
-10
unionfs/unionfs.go
unionfs/unionfs.go
+11
-9
unionfs/unionfs_test.go
unionfs/unionfs_test.go
+33
-1
No files found.
unionfs/unionfs.go
View file @
df325e01
...
...
@@ -194,8 +194,6 @@ func (me *UnionFs) getBranchAttrNoCache(name string) branchResult {
// Needed to make hardlinks work.
a
.
Ino
=
0
}
// Make all files appear writable
a
.
Mode
|=
0222
return
branchResult
{
attr
:
a
,
code
:
s
,
...
...
@@ -418,7 +416,7 @@ func (me *UnionFs) Mkdir(path string, mode uint32, context *fuse.Context) (code
if
code
.
Ok
()
{
me
.
removeDeletion
(
path
)
attr
:=
&
os
.
FileInfo
{
Mode
:
fuse
.
S_IFDIR
|
mode
|
0222
,
Mode
:
fuse
.
S_IFDIR
|
mode
,
}
me
.
branchCache
.
Set
(
path
,
branchResult
{
attr
,
fuse
.
OK
,
0
})
}
...
...
@@ -533,7 +531,6 @@ func (me *UnionFs) Chmod(name string, mode uint32, context *fuse.Context) (code
permMask
:=
uint32
(
07777
)
// Always be writable.
mode
|=
0222
oldMode
:=
r
.
attr
.
Mode
&
permMask
if
oldMode
!=
mode
{
...
...
@@ -624,12 +621,14 @@ func (me *UnionFs) promoteDirsTo(filename string) fuse.Status {
for
i
,
_
:=
range
todo
{
j
:=
len
(
todo
)
-
i
-
1
d
:=
todo
[
j
]
code
:=
me
.
fileSystems
[
0
]
.
Mkdir
(
d
,
0755
,
nil
)
r
:=
results
[
j
]
code
:=
me
.
fileSystems
[
0
]
.
Mkdir
(
d
,
r
.
attr
.
Mode
&
07777
,
nil
)
if
code
!=
fuse
.
OK
{
log
.
Println
(
"Error creating dir leading to path"
,
d
,
code
)
return
fuse
.
EPERM
}
r
:=
results
[
j
]
me
.
fileSystems
[
0
]
.
Utimens
(
d
,
uint64
(
r
.
attr
.
Atime_ns
),
uint64
(
r
.
attr
.
Mtime_ns
),
nil
)
r
.
branch
=
0
me
.
branchCache
.
Set
(
d
,
r
)
}
...
...
@@ -650,7 +649,7 @@ func (me *UnionFs) Create(name string, flags uint32, mode uint32, context *fuse.
now
:=
time
.
Nanoseconds
()
a
:=
os
.
FileInfo
{
Mode
:
fuse
.
S_IFREG
|
mode
|
0222
,
Mode
:
fuse
.
S_IFREG
|
mode
,
Ctime_ns
:
now
,
Mtime_ns
:
now
,
}
...
...
@@ -683,7 +682,10 @@ func (me *UnionFs) GetAttr(name string, context *fuse.Context) (a *os.FileInfo,
if
r
.
branch
<
0
{
return
nil
,
fuse
.
ENOENT
}
return
r
.
attr
,
r
.
code
fi
:=
*
r
.
attr
// Make everything appear writable.
fi
.
Mode
|=
0200
return
&
fi
,
r
.
code
}
func
(
me
*
UnionFs
)
GetXAttr
(
name
string
,
attr
string
,
context
*
fuse
.
Context
)
([]
byte
,
fuse
.
Status
)
{
...
...
@@ -996,7 +998,7 @@ func (me *unionFsFile) GetAttr() (*os.FileInfo, fuse.Status) {
if
fi
!=
nil
{
f
:=
*
fi
fi
=
&
f
fi
.
Mode
|=
02
22
fi
.
Mode
|=
02
00
}
return
fi
,
code
}
unionfs/unionfs_test.go
View file @
df325e01
...
...
@@ -30,6 +30,9 @@ var testOpts = UnionFsOptions{
}
func
setupUfs
(
t
*
testing
.
T
)
(
workdir
string
,
cleanup
func
())
{
// Make sure system setting does not affect test.
syscall
.
Umask
(
0
)
wd
,
_
:=
ioutil
.
TempDir
(
""
,
""
)
err
:=
os
.
Mkdir
(
wd
+
"/mount"
,
0700
)
fuse
.
CheckSuccess
(
err
)
...
...
@@ -196,7 +199,7 @@ func TestChmod(t *testing.T) {
fi
,
err
:=
os
.
Lstat
(
m_fn
)
CheckSuccess
(
err
)
if
fi
.
Mode
&
07777
!=
0727
2
{
if
fi
.
Mode
&
07777
!=
0727
0
{
t
.
Errorf
(
"Unexpected mode found: %o"
,
fi
.
Mode
)
}
_
,
err
=
os
.
Lstat
(
wd
+
"/rw/file"
)
...
...
@@ -1066,3 +1069,32 @@ func TestTruncGetAttr(t *testing.T) {
t
.
Fatalf
(
"Length mismatch got %d want %d"
,
fi
.
Size
,
len
(
c
))
}
}
func
TestPromoteDirTimeStamp
(
t
*
testing
.
T
)
{
wd
,
clean
:=
setupUfs
(
t
)
defer
clean
()
err
:=
os
.
Mkdir
(
wd
+
"/ro/subdir"
,
0750
)
CheckSuccess
(
err
)
err
=
ioutil
.
WriteFile
(
wd
+
"/ro/subdir/file"
,
[]
byte
(
"hello"
),
0644
)
CheckSuccess
(
err
)
err
=
os
.
Chmod
(
wd
+
"/mount/subdir/file"
,
0060
)
CheckSuccess
(
err
)
fRo
,
err
:=
os
.
Lstat
(
wd
+
"/ro/subdir"
)
CheckSuccess
(
err
)
fRw
,
err
:=
os
.
Lstat
(
wd
+
"/rw/subdir"
)
CheckSuccess
(
err
)
// TODO - need to update timestamps after promoteDirsTo calls,
// not during.
if
false
&&
fRo
.
Mtime_ns
!=
fRw
.
Mtime_ns
{
t
.
Errorf
(
"Changed timestamps on promoted subdir: ro %d rw %d"
,
fRo
.
Mtime_ns
,
fRw
.
Mtime_ns
)
}
if
fRo
.
Mode
!=
fRw
.
Mode
{
t
.
Errorf
(
"Changed mode ro: %o, rw: %o"
,
fRo
.
Mode
,
fRw
.
Mode
)
}
}
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