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
a529f8d9
Commit
a529f8d9
authored
May 15, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add hello example.
parent
3ad26b23
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
0 deletions
+67
-0
example/hello/Makefile
example/hello/Makefile
+8
-0
example/hello/hello.go
example/hello/hello.go
+59
-0
No files found.
example/hello/Makefile
0 → 100644
View file @
a529f8d9
include
$(GOROOT)/src/Make.inc
TARG
=
hello
GOFILES
=
hello.go
DEPS
=
../../fuse
include
$(GOROOT)/src/Make.cmd
example/hello/hello.go
0 → 100644
View file @
a529f8d9
// A Go mirror of libfuse's hello.c
package
main
import
(
"flag"
"log"
"github.com/hanwen/go-fuse/fuse"
"os"
)
type
HelloFs
struct
{
fuse
.
DefaultFileSystem
}
func
(
me
*
HelloFs
)
GetAttr
(
name
string
)
(
*
os
.
FileInfo
,
fuse
.
Status
)
{
switch
name
{
case
"file.txt"
:
return
&
os
.
FileInfo
{
Mode
:
fuse
.
S_IFREG
|
0644
,
Size
:
int64
(
len
(
name
)),
},
fuse
.
OK
case
""
:
return
&
os
.
FileInfo
{
Mode
:
fuse
.
S_IFDIR
|
0755
,
},
fuse
.
OK
}
return
nil
,
fuse
.
ENOENT
}
func
(
me
*
HelloFs
)
OpenDir
(
name
string
)
(
c
chan
fuse
.
DirEntry
,
code
fuse
.
Status
)
{
if
name
==
""
{
c
=
make
(
chan
fuse
.
DirEntry
,
1
)
c
<-
fuse
.
DirEntry
{
Name
:
"file.txt"
,
Mode
:
fuse
.
S_IFREG
}
close
(
c
)
return
c
,
fuse
.
OK
}
return
nil
,
fuse
.
ENOENT
}
func
(
me
*
HelloFs
)
Open
(
name
string
,
flags
uint32
)
(
file
fuse
.
File
,
code
fuse
.
Status
)
{
if
name
!=
"file.txt"
{
return
nil
,
fuse
.
ENOENT
}
if
flags
&
fuse
.
O_ANYWRITE
!=
0
{
return
nil
,
fuse
.
EPERM
}
return
fuse
.
NewReadOnlyFile
([]
byte
(
name
)),
fuse
.
OK
}
func
main
()
{
if
len
(
flag
.
Args
())
<
1
{
log
.
Fatal
(
"Usage:
\n
hello MOUNTPOINT"
)
}
state
,
conn
,
err
:=
fuse
.
MountFileSystem
(
flag
.
Arg
(
0
),
&
HelloFs
{},
nil
)
if
err
!=
nil
{
log
.
Fatal
(
"Mount fail: %v
\n
"
,
err
)
}
state
.
Loop
(
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