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
ab18be23
Commit
ab18be23
authored
Mar 06, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored inode time tracking.
parent
62bda89c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
11 deletions
+26
-11
samples/memfs/fs.go
samples/memfs/fs.go
+5
-10
samples/memfs/inode.go
samples/memfs/inode.go
+21
-1
No files found.
samples/memfs/fs.go
View file @
ab18be23
...
...
@@ -74,7 +74,7 @@ func NewMemFS(
Mode
:
0700
|
os
.
ModeDir
,
}
fs
.
inodes
[
fuse
.
RootInodeID
]
=
newInode
(
rootAttrs
)
fs
.
inodes
[
fuse
.
RootInodeID
]
=
newInode
(
clock
,
rootAttrs
)
// Set up invariant checking.
fs
.
mu
=
syncutil
.
NewInvariantMutex
(
fs
.
checkInvariants
)
...
...
@@ -163,7 +163,7 @@ func (fs *memFS) getInodeForReadingOrDie(id fuse.InodeID) (inode *inode) {
func
(
fs
*
memFS
)
allocateInode
(
attrs
fuse
.
InodeAttributes
)
(
id
fuse
.
InodeID
,
inode
*
inode
)
{
// Create and lock the inode.
inode
=
newInode
(
attrs
)
inode
=
newInode
(
fs
.
clock
,
attrs
)
inode
.
mu
.
Lock
()
// Re-use a free ID if possible. Otherwise mint a new one.
...
...
@@ -281,13 +281,8 @@ func (fs *memFS) MkDir(
// Set up attributes from the child, using the credentials of the calling
// process as owner (matching inode_init_owner, cf. http://goo.gl/5qavg8).
now
:=
fs
.
clock
.
Now
()
childAttrs
:=
fuse
.
InodeAttributes
{
Mode
:
req
.
Mode
,
Atime
:
now
,
Mtime
:
now
,
Ctime
:
now
,
Crtime
:
now
,
Uid
:
req
.
Header
.
Uid
,
Gid
:
req
.
Header
.
Gid
,
}
...
...
samples/memfs/inode.go
View file @
ab18be23
...
...
@@ -22,6 +22,7 @@ import (
"github.com/jacobsa/fuse"
"github.com/jacobsa/fuse/fuseutil"
"github.com/jacobsa/gcloud/syncutil"
"github.com/jacobsa/gcsfuse/timeutil"
)
// Common attributes for files and directories.
...
...
@@ -30,6 +31,12 @@ import (
// been unlinked, including creating a new file. Make sure we don't screw up
// and reuse an inode ID while it is still in use.
type
inode
struct
{
/////////////////////////
// Dependencies
/////////////////////////
clock
timeutil
.
Clock
/////////////////////////
// Constant data
/////////////////////////
...
...
@@ -84,9 +91,22 @@ type inode struct {
// Helpers
////////////////////////////////////////////////////////////////////////
// Create a new inode with the supplied attributes, which need not contain
// time-related information (the inode object will take care of that).
// Initially the link count is one.
func
newInode
(
attrs
fuse
.
InodeAttributes
)
(
in
*
inode
)
{
func
newInode
(
clock
timeutil
.
Clock
,
attrs
fuse
.
InodeAttributes
)
(
in
*
inode
)
{
// Update time info.
now
:=
clock
.
Now
()
attrs
.
Atime
=
now
attrs
.
Mtime
=
now
attrs
.
Ctime
=
now
attrs
.
Crtime
=
now
// Create the object.
in
=
&
inode
{
clock
:
clock
,
linkCount
:
1
,
dir
:
(
attrs
.
Mode
&
os
.
ModeDir
!=
0
),
attributes
:
attrs
,
...
...
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