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
800e5338
Commit
800e5338
authored
Apr 11, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
os.Open API changes.
parent
bc5d4287
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
21 deletions
+21
-21
example/bulkstat/bulkstat.go
example/bulkstat/bulkstat.go
+1
-1
fuse/loopback.go
fuse/loopback.go
+3
-3
fuse/loopback_test.go
fuse/loopback_test.go
+15
-15
fuse/misc.go
fuse/misc.go
+1
-1
fuse/pathfilesystem.go
fuse/pathfilesystem.go
+1
-1
No files found.
example/bulkstat/bulkstat.go
View file @
800e5338
...
...
@@ -19,7 +19,7 @@ func main() {
flag
.
Parse
()
filename
:=
flag
.
Args
()[
0
]
f
,
err
:=
os
.
Open
(
filename
,
os
.
O_RDONLY
,
0
)
f
,
err
:=
os
.
Open
(
filename
)
if
err
!=
nil
{
panic
(
"err"
+
err
.
String
())
}
...
...
fuse/loopback.go
View file @
800e5338
...
...
@@ -47,7 +47,7 @@ func (me *LoopbackFileSystem) GetAttr(name string) (*Attr, Status) {
func
(
me
*
LoopbackFileSystem
)
OpenDir
(
name
string
)
(
stream
chan
DirEntry
,
status
Status
)
{
// What other ways beyond O_RDONLY are there to open
// directories?
f
,
err
:=
os
.
Open
(
me
.
GetPath
(
name
)
,
os
.
O_RDONLY
,
0
)
f
,
err
:=
os
.
Open
(
me
.
GetPath
(
name
))
if
err
!=
nil
{
return
nil
,
OsErrorToFuseError
(
err
)
}
...
...
@@ -78,7 +78,7 @@ func (me *LoopbackFileSystem) OpenDir(name string) (stream chan DirEntry, status
}
func
(
me
*
LoopbackFileSystem
)
Open
(
name
string
,
flags
uint32
)
(
fuseFile
RawFuseFile
,
status
Status
)
{
f
,
err
:=
os
.
Open
(
me
.
GetPath
(
name
),
int
(
flags
),
0
)
f
,
err
:=
os
.
Open
File
(
me
.
GetPath
(
name
),
int
(
flags
),
0
)
if
err
!=
nil
{
return
nil
,
OsErrorToFuseError
(
err
)
}
...
...
@@ -142,7 +142,7 @@ func (me *LoopbackFileSystem) Access(name string, mode uint32) (code Status) {
}
func
(
me
*
LoopbackFileSystem
)
Create
(
path
string
,
flags
uint32
,
mode
uint32
)
(
fuseFile
RawFuseFile
,
code
Status
)
{
f
,
err
:=
os
.
Open
(
me
.
GetPath
(
path
),
int
(
flags
)
|
os
.
O_CREAT
,
mode
)
f
,
err
:=
os
.
Open
File
(
me
.
GetPath
(
path
),
int
(
flags
)
|
os
.
O_CREATE
,
mode
)
return
&
LoopbackFile
{
file
:
f
},
OsErrorToFuseError
(
err
)
}
...
...
fuse/loopback_test.go
View file @
800e5338
...
...
@@ -98,7 +98,7 @@ func (me *testCase) removeMountFile() {
}
func
(
me
*
testCase
)
writeOrigFile
()
{
f
,
err
:=
os
.
Open
(
me
.
origFile
,
os
.
O_WRONLY
|
os
.
O_CREAT
,
0700
)
f
,
err
:=
os
.
Open
File
(
me
.
origFile
,
os
.
O_WRONLY
|
os
.
O_CREATE
,
0700
)
CheckSuccess
(
err
)
_
,
err
=
f
.
Write
([]
byte
(
contents
))
CheckSuccess
(
err
)
...
...
@@ -109,7 +109,7 @@ func (me *testCase) writeOrigFile() {
// Tests.
func
(
me
*
testCase
)
testOpenUnreadable
()
{
_
,
err
:=
os
.
Open
(
filepath
.
Join
(
me
.
mountPoint
,
"doesnotexist"
)
,
os
.
O_RDONLY
,
0
)
_
,
err
:=
os
.
Open
(
filepath
.
Join
(
me
.
mountPoint
,
"doesnotexist"
))
if
err
==
nil
{
me
.
tester
.
Errorf
(
"open non-existent should raise error"
)
}
...
...
@@ -131,7 +131,7 @@ func (me *testCase) testReadThroughFuse() {
// Open (for read), read.
fmt
.
Println
(
"Testing open."
)
f
,
err
:=
os
.
Open
(
me
.
mountFile
,
os
.
O_RDONLY
,
0
)
f
,
err
:=
os
.
Open
(
me
.
mountFile
)
CheckSuccess
(
err
)
fmt
.
Println
(
"Testing read."
)
...
...
@@ -163,7 +163,7 @@ func (me *testCase) testRemove() {
func
(
me
*
testCase
)
testWriteThroughFuse
()
{
// Create (for write), write.
me
.
tester
.
Log
(
"Testing create."
)
f
,
err
:=
os
.
Open
(
me
.
mountFile
,
os
.
O_WRONLY
|
os
.
O_CREATE
,
0644
)
f
,
err
:=
os
.
Open
File
(
me
.
mountFile
,
os
.
O_WRONLY
|
os
.
O_CREATE
,
0644
)
CheckSuccess
(
err
)
me
.
tester
.
Log
(
"Testing write."
)
...
...
@@ -178,7 +178,7 @@ func (me *testCase) testWriteThroughFuse() {
me
.
tester
.
Errorf
(
"create mode error %o"
,
fi
.
Mode
&
0777
)
}
f
,
err
=
os
.
Open
(
me
.
origFile
,
os
.
O_RDONLY
,
0
)
f
,
err
=
os
.
Open
(
me
.
origFile
)
CheckSuccess
(
err
)
var
buf
[
1024
]
byte
slice
:=
buf
[
:
]
...
...
@@ -221,7 +221,7 @@ func (me *testCase) testLink() {
me
.
tester
.
Errorf
(
"Expect 2 links: %v"
,
fi
)
}
f
,
err
:=
os
.
Open
(
me
.
mountSubfile
,
os
.
O_RDONLY
,
0
)
f
,
err
:=
os
.
Open
(
me
.
mountSubfile
)
var
buf
[
1024
]
byte
slice
:=
buf
[
:
]
...
...
@@ -325,7 +325,7 @@ func (me *testCase) testReaddir() {
me
.
writeOrigFile
()
me
.
makeOrigSubdir
()
dir
,
err
:=
os
.
Open
(
me
.
mountPoint
,
os
.
O_RDONLY
,
0
)
dir
,
err
:=
os
.
Open
(
me
.
mountPoint
)
CheckSuccess
(
err
)
infos
,
err
:=
dir
.
Readdir
(
10
)
CheckSuccess
(
err
)
...
...
@@ -355,7 +355,7 @@ func (me *testCase) testFSync() {
me
.
tester
.
Log
(
"Testing fsync."
)
me
.
writeOrigFile
()
f
,
err
:=
os
.
Open
(
me
.
mountFile
,
os
.
O_WRONLY
,
0
)
f
,
err
:=
os
.
Open
File
(
me
.
mountFile
,
os
.
O_WRONLY
,
0
)
_
,
err
=
f
.
WriteString
(
"hello there"
)
CheckSuccess
(
err
)
...
...
@@ -370,7 +370,7 @@ func (me *testCase) testFSync() {
func
(
me
*
testCase
)
testLargeRead
()
{
me
.
tester
.
Log
(
"Testing large read."
)
name
:=
filepath
.
Join
(
me
.
origDir
,
"large"
)
f
,
err
:=
os
.
Open
(
name
,
os
.
O_WRONLY
|
os
.
O_CREATE
,
0777
)
f
,
err
:=
os
.
Open
File
(
name
,
os
.
O_WRONLY
|
os
.
O_CREATE
,
0777
)
CheckSuccess
(
err
)
b
:=
bytes
.
NewBuffer
(
nil
)
...
...
@@ -388,7 +388,7 @@ func (me *testCase) testLargeRead() {
CheckSuccess
(
err
)
// Read in one go.
g
,
err
:=
os
.
Open
(
filepath
.
Join
(
me
.
mountPoint
,
"large"
)
,
os
.
O_RDONLY
,
0
)
g
,
err
:=
os
.
Open
(
filepath
.
Join
(
me
.
mountPoint
,
"large"
))
CheckSuccess
(
err
)
readSlice
:=
make
([]
byte
,
len
(
slice
))
m
,
err
:=
g
.
Read
(
readSlice
)
...
...
@@ -406,7 +406,7 @@ func (me *testCase) testLargeRead() {
g
.
Close
()
// Read in chunks
g
,
err
=
os
.
Open
(
filepath
.
Join
(
me
.
mountPoint
,
"large"
)
,
os
.
O_RDONLY
,
0
)
g
,
err
=
os
.
Open
(
filepath
.
Join
(
me
.
mountPoint
,
"large"
))
CheckSuccess
(
err
)
readSlice
=
make
([]
byte
,
4096
)
total
:=
0
...
...
@@ -458,7 +458,7 @@ func (me *testCase) testLargeDirRead() {
nameSet
[
base
]
=
true
f
,
err
:=
os
.
Open
(
name
,
os
.
O_WRONLY
|
os
.
O_CREATE
,
0777
)
f
,
err
:=
os
.
Open
File
(
name
,
os
.
O_WRONLY
|
os
.
O_CREATE
,
0777
)
CheckSuccess
(
err
)
f
.
WriteString
(
"bla"
)
f
.
Close
()
...
...
@@ -466,7 +466,7 @@ func (me *testCase) testLargeDirRead() {
names
[
i
]
=
name
}
dir
,
err
:=
os
.
Open
(
filepath
.
Join
(
me
.
mountPoint
,
"readdirSubdir"
)
,
os
.
O_RDONLY
,
0
)
dir
,
err
:=
os
.
Open
(
filepath
.
Join
(
me
.
mountPoint
,
"readdirSubdir"
))
CheckSuccess
(
err
)
// Chunked read.
total
:=
0
...
...
@@ -525,7 +525,7 @@ func TestRecursiveMount(t *testing.T) {
ts
:=
new
(
testCase
)
ts
.
Setup
(
t
)
f
,
err
:=
os
.
Open
(
filepath
.
Join
(
ts
.
mountPoint
,
"hello.txt"
),
f
,
err
:=
os
.
Open
File
(
filepath
.
Join
(
ts
.
mountPoint
,
"hello.txt"
),
os
.
O_WRONLY
|
os
.
O_CREATE
,
0777
)
CheckSuccess
(
err
)
...
...
@@ -551,7 +551,7 @@ func TestRecursiveMount(t *testing.T) {
_
,
err
=
os
.
Lstat
(
filepath
.
Join
(
submnt
,
"hello.txt"
))
CheckSuccess
(
err
)
f
,
err
=
os
.
Open
(
filepath
.
Join
(
submnt
,
"hello.txt"
)
,
os
.
O_RDONLY
,
0
)
f
,
err
=
os
.
Open
(
filepath
.
Join
(
submnt
,
"hello.txt"
))
CheckSuccess
(
err
)
code
=
ts
.
connector
.
Unmount
(
"/mnt"
)
if
code
!=
EBUSY
{
...
...
fuse/misc.go
View file @
800e5338
...
...
@@ -213,7 +213,7 @@ func Writev(fd int, packet [][]byte) (n int, err os.Error) {
func
CountCpus
()
int
{
var
contents
[
10240
]
byte
f
,
err
:=
os
.
Open
(
"/proc/stat"
,
os
.
O_RDONLY
,
0
)
f
,
err
:=
os
.
Open
(
"/proc/stat"
)
defer
f
.
Close
()
if
err
!=
nil
{
return
1
...
...
fuse/pathfilesystem.go
View file @
800e5338
...
...
@@ -356,7 +356,7 @@ func (me *PathFileSystemConnector) Unmount(path string) Status {
mount
.
mutex
.
Lock
()
defer
mount
.
mutex
.
Unlock
()
if
mount
.
openCount
>
0
{
log
.
Println
(
"busy: "
,
mount
)
log
.
Println
(
"
Umount -
busy: "
,
mount
)
return
EBUSY
}
...
...
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