Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jacobsa-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
jacobsa-fuse
Commits
c3601bff
Commit
c3601bff
authored
Aug 04, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
errorFS.GetInodeAttributes
parent
978399a2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
0 deletions
+51
-0
samples/errorfs/error_fs.go
samples/errorfs/error_fs.go
+51
-0
No files found.
samples/errorfs/error_fs.go
View file @
c3601bff
...
@@ -15,15 +15,22 @@
...
@@ -15,15 +15,22 @@
package
errorfs
package
errorfs
import
(
import
(
"fmt"
"os"
"reflect"
"reflect"
"sync"
"sync"
"syscall"
"syscall"
"golang.org/x/net/context"
"github.com/jacobsa/fuse/fuseops"
"github.com/jacobsa/fuse/fuseutil"
"github.com/jacobsa/fuse/fuseutil"
)
)
const
FooContents
=
"xxxx"
const
FooContents
=
"xxxx"
const
fooInodeID
=
fuseops
.
RootInodeID
+
1
// A file system whose sole contents are a file named "foo" containing the
// A file system whose sole contents are a file named "foo" containing the
// string defined by FooContents.
// string defined by FooContents.
//
//
...
@@ -63,3 +70,47 @@ func (fs *errorFS) SetError(t reflect.Type, err syscall.Errno) {
...
@@ -63,3 +70,47 @@ func (fs *errorFS) SetError(t reflect.Type, err syscall.Errno) {
fs
.
errors
[
t
.
Name
()]
=
err
fs
.
errors
[
t
.
Name
()]
=
err
}
}
// LOCKS_EXCLUDED(fs.mu)
func
(
fs
*
errorFS
)
transformError
(
op
interface
{},
err
*
error
)
bool
{
fs
.
mu
.
Lock
()
defer
fs
.
mu
.
Unlock
()
var
ok
bool
*
err
,
ok
=
fs
.
errors
[
reflect
.
TypeOf
(
op
)
.
Name
()]
return
ok
}
////////////////////////////////////////////////////////////////////////
// File system methods
////////////////////////////////////////////////////////////////////////
// LOCKS_EXCLUDED(fs.mu)
func
(
fs
*
errorFS
)
GetInodeAttributes
(
ctx
context
.
Context
,
op
*
fuseops
.
GetInodeAttributesOp
)
(
err
error
)
{
if
fs
.
transformError
(
op
,
&
err
)
{
return
}
// Figure out which inode the request is for.
switch
{
case
op
.
Inode
==
fuseops
.
RootInodeID
:
op
.
Attributes
=
fuseops
.
InodeAttributes
{
Mode
:
os
.
ModeDir
|
0777
,
}
case
op
.
Inode
==
fooInodeID
:
op
.
Attributes
=
fuseops
.
InodeAttributes
{
Nlink
:
1
,
Size
:
uint64
(
len
(
FooContents
)),
Mode
:
0444
,
}
default
:
err
=
fmt
.
Errorf
(
"Unknown inode: %d"
,
op
.
Inode
)
return
}
return
}
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