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
9c05c7ba
Commit
9c05c7ba
authored
May 14, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Run GoFmt.
parent
d89692e2
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
28 additions
and
28 deletions
+28
-28
fuse/copy.go
fuse/copy.go
+6
-5
fuse/copy_test.go
fuse/copy_test.go
+4
-6
fuse/files.go
fuse/files.go
+1
-0
unionfs/autounion.go
unionfs/autounion.go
+1
-1
unionfs/dircache.go
unionfs/dircache.go
+1
-1
unionfs/unionfs.go
unionfs/unionfs.go
+15
-15
No files found.
fuse/copy.go
View file @
9c05c7ba
package
fuse
import
(
"os"
)
...
...
@@ -15,9 +16,9 @@ func CopyFile(srcFs, destFs FileSystem, srcFile, destFile string) Status {
if
!
code
.
Ok
()
{
return
code
}
w
:=
WriteIn
{
Flags
:
uint32
(
os
.
O_WRONLY
|
os
.
O_CREATE
|
os
.
O_TRUNC
),
Flags
:
uint32
(
os
.
O_WRONLY
|
os
.
O_CREATE
|
os
.
O_TRUNC
),
}
dst
,
code
:=
destFs
.
Create
(
destFile
,
w
.
Flags
,
attr
.
Mode
)
if
!
code
.
Ok
()
{
...
...
@@ -28,7 +29,7 @@ func CopyFile(srcFs, destFs FileSystem, srcFile, destFile string) Status {
bp
:=
NewBufferPool
()
r
:=
ReadIn
{
Size
:
128
*
(
1
<<
10
),
Size
:
128
*
(
1
<<
10
),
}
for
{
data
,
code
:=
src
.
Read
(
&
r
,
bp
)
...
...
@@ -36,7 +37,7 @@ func CopyFile(srcFs, destFs FileSystem, srcFile, destFile string) Status {
return
code
}
if
len
(
data
)
==
0
{
break
;
break
}
n
,
code
:=
dst
.
Write
(
&
w
,
data
)
if
!
code
.
Ok
()
{
...
...
@@ -46,7 +47,7 @@ func CopyFile(srcFs, destFs FileSystem, srcFile, destFile string) Status {
return
EIO
}
if
len
(
data
)
<
int
(
r
.
Size
)
{
break
;
break
}
r
.
Offset
+=
uint64
(
len
(
data
))
w
.
Offset
+=
uint64
(
len
(
data
))
...
...
fuse/copy_test.go
View file @
9c05c7ba
...
...
@@ -14,7 +14,7 @@ func TestCopyFile(t *testing.T) {
content1
:=
"blabla"
err
:=
ioutil
.
WriteFile
(
d1
+
"/file"
,
[]
byte
(
content1
),
0644
)
err
:=
ioutil
.
WriteFile
(
d1
+
"/file"
,
[]
byte
(
content1
),
0644
)
CheckSuccess
(
err
)
code
:=
CopyFile
(
fs1
,
fs2
,
"file"
,
"file"
)
...
...
@@ -26,10 +26,10 @@ func TestCopyFile(t *testing.T) {
if
content1
!=
string
(
data
)
{
t
.
Fatal
(
"Unexpected content"
,
string
(
data
))
}
content2
:=
"foobar"
err
=
ioutil
.
WriteFile
(
d2
+
"/file"
,
[]
byte
(
content2
),
0644
)
err
=
ioutil
.
WriteFile
(
d2
+
"/file"
,
[]
byte
(
content2
),
0644
)
CheckSuccess
(
err
)
// Copy back: should overwrite.
...
...
@@ -42,7 +42,5 @@ func TestCopyFile(t *testing.T) {
if
content2
!=
string
(
data
)
{
t
.
Fatal
(
"Unexpected content"
,
string
(
data
))
}
}
}
fuse/files.go
View file @
9c05c7ba
...
...
@@ -5,6 +5,7 @@ import (
"os"
"syscall"
)
var
_
=
fmt
.
Println
// ReadOnlyFile is for implementing read-only filesystems. This
...
...
unionfs/autounion.go
View file @
9c05c7ba
...
...
@@ -103,7 +103,7 @@ func (me *AutoUnionFs) createFs(name string, roots []string) (*UnionFs, fuse.Sta
me
.
knownFileSystems
[
name
]
=
gofs
me
.
nameRootMap
[
name
]
=
roots
[
0
]
return
gofs
,
fuse
.
OK
}
...
...
unionfs/dircache.go
View file @
9c05c7ba
...
...
@@ -21,7 +21,7 @@ func newDirnameMap(fs fuse.FileSystem, dir string) map[string]bool {
return
result
}
for
e
:=
range
stream
{
if
e
.
Mode
&
fuse
.
S_IFREG
!=
0
{
if
e
.
Mode
&
fuse
.
S_IFREG
!=
0
{
result
[
e
.
Name
]
=
true
}
}
...
...
unionfs/unionfs.go
View file @
9c05c7ba
...
...
@@ -60,7 +60,7 @@ func filePathHash(path string) string {
type
UnionFs
struct
{
fuse
.
DefaultFileSystem
name
string
name
string
// The same, but as interfaces.
fileSystems
[]
fuse
.
FileSystem
...
...
@@ -105,7 +105,7 @@ func NewUnionFs(name string, fileSystems []fuse.FileSystem, options UnionFsOptio
if
code
==
fuse
.
ENOENT
{
code
=
writable
.
Mkdir
(
options
.
DeletionDirName
,
0755
)
fi
,
code
=
writable
.
GetAttr
(
options
.
DeletionDirName
)
}
}
if
!
code
.
Ok
()
||
!
fi
.
IsDirectory
()
{
panic
(
fmt
.
Sprintf
(
"could not create deletion path %v: %v"
,
options
.
DeletionDirName
,
code
))
...
...
@@ -137,7 +137,7 @@ func (me *UnionFs) isDeleted(name string) bool {
if
code
==
fuse
.
ENOENT
{
return
false
}
panic
(
fmt
.
Sprintf
(
"Unexpected GetAttr return code %v %v"
,
code
,
marker
))
return
false
}
...
...
@@ -201,7 +201,7 @@ func (me *UnionFs) removeDeletion(name string) {
// os.Remove tries to be smart and issues a Remove() and
// Rmdir() sequentially. We want to skip the 2nd system call,
// so use syscall.Unlink() directly.
code
:=
me
.
fileSystems
[
0
]
.
Unlink
(
marker
)
if
!
code
.
Ok
()
&&
code
!=
fuse
.
ENOENT
{
log
.
Printf
(
"error unlinking %s: %v"
,
marker
,
code
)
...
...
@@ -226,7 +226,7 @@ func (me *UnionFs) putDeletion(name string) fuse.Status {
if
int
(
n
)
!=
len
(
name
)
||
!
code
.
Ok
()
{
panic
(
fmt
.
Sprintf
(
"Error for writing %v: %v, %v (exp %v) %v"
,
name
,
marker
,
n
,
len
(
name
),
code
))
}
return
fuse
.
OK
}
...
...
@@ -239,7 +239,7 @@ func (me *UnionFs) Promote(name string, srcResult branchResult) fuse.Status {
// Promote directories.
me
.
promoteDirsTo
(
name
)
code
:=
fuse
.
CopyFile
(
sourceFs
,
writable
,
name
,
name
)
if
!
code
.
Ok
()
{
me
.
branchCache
.
GetFresh
(
name
)
...
...
@@ -396,7 +396,7 @@ func (me *UnionFs) Chmod(name string, mode uint32) (code fuse.Status) {
if
r
.
code
!=
fuse
.
OK
{
return
r
.
code
}
permMask
:=
uint32
(
07777
)
// Always be writable.
...
...
@@ -532,7 +532,7 @@ func (me *UnionFs) GetAttr(name string) (a *os.FileInfo, s fuse.Status) {
if
name
==
_DROP_CACHE
{
return
&
os
.
FileInfo
{
Mode
:
fuse
.
S_IFREG
|
0777
,
},
fuse
.
OK
},
fuse
.
OK
}
if
name
==
me
.
options
.
DeletionDirName
{
return
nil
,
fuse
.
ENOENT
...
...
@@ -674,17 +674,17 @@ func (me *UnionFs) Rename(src string, dst string) (code fuse.Status) {
}
func
(
me
*
UnionFs
)
DropCaches
()
{
log
.
Println
(
"Forced cache drop on"
,
me
.
name
)
me
.
branchCache
.
DropAll
()
me
.
deletionCache
.
DropCache
()
for
_
,
fs
:=
range
me
.
cachingFileSystems
{
fs
.
DropCache
()
}
log
.
Println
(
"Forced cache drop on"
,
me
.
name
)
me
.
branchCache
.
DropAll
()
me
.
deletionCache
.
DropCache
()
for
_
,
fs
:=
range
me
.
cachingFileSystems
{
fs
.
DropCache
()
}
}
func
(
me
*
UnionFs
)
Open
(
name
string
,
flags
uint32
)
(
fuseFile
fuse
.
File
,
status
fuse
.
Status
)
{
if
name
==
_DROP_CACHE
{
if
flags
&
fuse
.
O_ANYWRITE
!=
0
{
if
flags
&
fuse
.
O_ANYWRITE
!=
0
{
me
.
DropCaches
()
}
return
fuse
.
NewDevNullFile
(),
fuse
.
OK
...
...
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