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
f9bfdb9c
Commit
f9bfdb9c
authored
Nov 30, 2012
by
Adam Goode
Committed by
Han-Wen Nienhuys
Dec 07, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Standardize on time.Time for all times in the API
parent
44c3ce73
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
75 additions
and
75 deletions
+75
-75
fuse/api.go
fuse/api.go
+3
-3
fuse/attr.go
fuse/attr.go
+6
-36
fuse/default.go
fuse/default.go
+4
-2
fuse/defaultfile.go
fuse/defaultfile.go
+2
-1
fuse/defaultnode.go
fuse/defaultnode.go
+2
-1
fuse/fsetattr_test.go
fuse/fsetattr_test.go
+2
-2
fuse/fsops.go
fuse/fsops.go
+18
-11
fuse/lockingfs.go
fuse/lockingfs.go
+3
-2
fuse/loopback.go
fuse/loopback.go
+10
-2
fuse/memnode.go
fuse/memnode.go
+11
-7
fuse/pathfs.go
fuse/pathfs.go
+2
-1
fuse/prefixfs.go
fuse/prefixfs.go
+3
-2
unionfs/unionfs.go
unionfs/unionfs.go
+9
-5
No files found.
fuse/api.go
View file @
f9bfdb9c
...
...
@@ -78,7 +78,7 @@ type FsNode interface {
Chmod
(
file
File
,
perms
uint32
,
context
*
Context
)
(
code
Status
)
Chown
(
file
File
,
uid
uint32
,
gid
uint32
,
context
*
Context
)
(
code
Status
)
Truncate
(
file
File
,
size
uint64
,
context
*
Context
)
(
code
Status
)
Utimens
(
file
File
,
atime
int64
,
mtime
int64
,
context
*
Context
)
(
code
Status
)
Utimens
(
file
File
,
atime
*
time
.
Time
,
mtime
*
time
.
Time
,
context
*
Context
)
(
code
Status
)
StatFs
()
*
StatfsOut
}
...
...
@@ -105,7 +105,7 @@ type FileSystem interface {
// These should update the file's ctime too.
Chmod
(
name
string
,
mode
uint32
,
context
*
Context
)
(
code
Status
)
Chown
(
name
string
,
uid
uint32
,
gid
uint32
,
context
*
Context
)
(
code
Status
)
Utimens
(
name
string
,
Atime
Ns
int64
,
MtimeNs
int64
,
context
*
Context
)
(
code
Status
)
Utimens
(
name
string
,
Atime
*
time
.
Time
,
Mtime
*
time
.
Time
,
context
*
Context
)
(
code
Status
)
Truncate
(
name
string
,
size
uint64
,
context
*
Context
)
(
code
Status
)
...
...
@@ -179,7 +179,7 @@ type File interface {
GetAttr
(
out
*
Attr
)
Status
Chown
(
uid
uint32
,
gid
uint32
)
Status
Chmod
(
perms
uint32
)
Status
Utimens
(
atime
Ns
int64
,
mtimeNs
int64
)
Status
Utimens
(
atime
*
time
.
Time
,
mtime
*
time
.
Time
)
Status
}
// The result of Read is an array of bytes, but for performance
...
...
fuse/attr.go
View file @
f9bfdb9c
...
...
@@ -71,48 +71,18 @@ func (a *Attr) IsSymlink() bool { return (uint32(a.Mode) & syscall.S_IFMT) == sy
// IsSocket reports whether the FileInfo describes a socket.
func
(
a
*
Attr
)
IsSocket
()
bool
{
return
(
uint32
(
a
.
Mode
)
&
syscall
.
S_IFMT
)
==
syscall
.
S_IFSOCK
}
func
(
a
*
Attr
)
Atimens
()
int64
{
return
int64
(
1e9
*
a
.
Atime
)
+
int64
(
a
.
Atimensec
)
}
func
(
a
*
Attr
)
Mtimens
()
int64
{
return
int64
(
1e9
*
a
.
Mtime
)
+
int64
(
a
.
Mtimensec
)
}
func
(
a
*
Attr
)
Ctimens
()
int64
{
return
int64
(
1e9
*
a
.
Ctime
)
+
int64
(
a
.
Ctimensec
)
}
func
(
a
*
Attr
)
SetNs
(
atimens
int64
,
mtimens
int64
,
ctimens
int64
)
{
if
atimens
>=
0
{
a
.
Atime
=
uint64
(
atimens
/
1e9
)
a
.
Atimensec
=
uint32
(
atimens
%
1e9
)
}
if
mtimens
>=
0
{
a
.
Mtime
=
uint64
(
mtimens
/
1e9
)
a
.
Mtimensec
=
uint32
(
mtimens
%
1e9
)
}
if
atimens
>=
0
{
a
.
Ctime
=
uint64
(
ctimens
/
1e9
)
a
.
Ctimensec
=
uint32
(
ctimens
%
1e9
)
}
}
func
(
a
*
Attr
)
SetTimes
(
access
*
time
.
Time
,
mod
*
time
.
Time
,
chstatus
*
time
.
Time
)
{
if
access
!=
nil
{
atimens
:=
access
.
UnixNano
()
a
.
Atime
=
uint64
(
atimens
/
1e9
)
a
.
Atimensec
=
uint32
(
atimens
%
1e9
)
a
.
Atime
=
uint64
(
access
.
Unix
())
a
.
Atimensec
=
uint32
(
access
.
Nanosecond
())
}
if
mod
!=
nil
{
mtimens
:=
mod
.
UnixNano
()
a
.
Mtime
=
uint64
(
mtimens
/
1e9
)
a
.
Mtimensec
=
uint32
(
mtimens
%
1e9
)
a
.
Mtime
=
uint64
(
mod
.
Unix
())
a
.
Mtimensec
=
uint32
(
mod
.
Nanosecond
())
}
if
chstatus
!=
nil
{
ctimens
:=
chstatus
.
UnixNano
()
a
.
Ctime
=
uint64
(
ctimens
/
1e9
)
a
.
Ctimensec
=
uint32
(
ctimens
%
1e9
)
a
.
Ctime
=
uint64
(
chstatus
.
Unix
())
a
.
Ctimensec
=
uint32
(
chstatus
.
Nanosecond
())
}
}
...
...
fuse/default.go
View file @
f9bfdb9c
package
fuse
import
()
import
(
"time"
)
// DefaultFileSystem
func
(
fs
*
DefaultFileSystem
)
GetAttr
(
name
string
,
context
*
Context
)
(
*
Attr
,
Status
)
{
...
...
@@ -89,7 +91,7 @@ func (fs *DefaultFileSystem) Create(name string, flags uint32, mode uint32, cont
return
nil
,
ENOSYS
}
func
(
fs
*
DefaultFileSystem
)
Utimens
(
name
string
,
Atime
Ns
int64
,
CtimeNs
int64
,
context
*
Context
)
(
code
Status
)
{
func
(
fs
*
DefaultFileSystem
)
Utimens
(
name
string
,
Atime
*
time
.
Time
,
Mtime
*
time
.
Time
,
context
*
Context
)
(
code
Status
)
{
return
ENOSYS
}
...
...
fuse/defaultfile.go
View file @
f9bfdb9c
...
...
@@ -2,6 +2,7 @@ package fuse
import
(
"log"
"time"
"github.com/hanwen/go-fuse/raw"
)
...
...
@@ -45,7 +46,7 @@ func (f *DefaultFile) Fsync(flags int) (code Status) {
return
ENOSYS
}
func
(
f
*
DefaultFile
)
Utimens
(
atime
Ns
int64
,
mtimeNs
int64
)
Status
{
func
(
f
*
DefaultFile
)
Utimens
(
atime
*
time
.
Time
,
mtime
*
time
.
Time
)
Status
{
return
ENOSYS
}
...
...
fuse/defaultnode.go
View file @
f9bfdb9c
...
...
@@ -2,6 +2,7 @@ package fuse
import
(
"log"
"time"
)
var
_
=
log
.
Println
...
...
@@ -150,6 +151,6 @@ func (n *DefaultFsNode) Truncate(file File, size uint64, context *Context) (code
return
ENOSYS
}
func
(
n
*
DefaultFsNode
)
Utimens
(
file
File
,
atime
int64
,
mtime
int64
,
context
*
Context
)
(
code
Status
)
{
func
(
n
*
DefaultFsNode
)
Utimens
(
file
File
,
atime
*
time
.
Time
,
mtime
*
time
.
Time
,
context
*
Context
)
(
code
Status
)
{
return
ENOSYS
}
fuse/fsetattr_test.go
View file @
f9bfdb9c
...
...
@@ -63,8 +63,8 @@ func (f *MutableDataFile) GetAttr(out *Attr) Status {
return
OK
}
func
(
f
*
MutableDataFile
)
Utimens
(
atime
Ns
int64
,
mtimeNs
int64
)
Status
{
f
.
Attr
.
Set
Ns
(
atimeNs
,
mtimeNs
,
-
1
)
func
(
f
*
MutableDataFile
)
Utimens
(
atime
*
time
.
Time
,
mtime
*
time
.
Time
)
Status
{
f
.
Attr
.
Set
Times
(
atime
,
mtime
,
nil
)
return
OK
}
...
...
fuse/fsops.go
View file @
f9bfdb9c
...
...
@@ -176,19 +176,26 @@ func (c *FileSystemConnector) SetAttr(out *raw.AttrOut, header *raw.InHeader, in
code
=
node
.
fsInode
.
Truncate
(
f
,
input
.
Size
,
(
*
Context
)(
&
header
.
Context
))
}
if
code
.
Ok
()
&&
(
input
.
Valid
&
(
raw
.
FATTR_ATIME
|
raw
.
FATTR_MTIME
|
raw
.
FATTR_ATIME_NOW
|
raw
.
FATTR_MTIME_NOW
)
!=
0
)
{
now
:=
int64
(
0
)
if
input
.
Valid
&
raw
.
FATTR_ATIME_NOW
!=
0
||
input
.
Valid
&
raw
.
FATTR_MTIME_NOW
!=
0
{
now
=
time
.
Now
()
.
UnixNano
()
now
:=
time
.
Now
()
var
atime
*
time
.
Time
var
mtime
*
time
.
Time
if
input
.
Valid
&
raw
.
FATTR_ATIME
!=
0
{
if
input
.
Valid
&
raw
.
FATTR_ATIME_NOW
!=
0
{
atime
=
&
now
}
else
{
t
:=
time
.
Unix
(
int64
(
input
.
Atime
),
int64
(
input
.
Atimensec
))
atime
=
&
t
}
}
atime
:=
int64
(
input
.
Atime
*
1e9
)
+
int64
(
input
.
Atimensec
)
if
input
.
Valid
&
raw
.
FATTR_ATIME_NOW
!=
0
{
atime
=
now
}
mtime
:=
int64
(
input
.
Mtime
*
1e9
)
+
int64
(
input
.
Mtimensec
)
if
input
.
Valid
&
raw
.
FATTR_MTIME_NOW
!=
0
{
mtime
=
now
if
input
.
Valid
&
raw
.
FATTR_MTIME
!=
0
{
if
input
.
Valid
&
raw
.
FATTR_MTIME_NOW
!=
0
{
mtime
=
&
now
}
else
{
t
:=
time
.
Unix
(
int64
(
input
.
Mtime
),
int64
(
input
.
Mtimensec
))
mtime
=
&
t
}
}
code
=
node
.
fsInode
.
Utimens
(
f
,
atime
,
mtime
,
(
*
Context
)(
&
header
.
Context
))
...
...
fuse/lockingfs.go
View file @
f9bfdb9c
...
...
@@ -2,6 +2,7 @@ package fuse
import
(
"sync"
"time"
"github.com/hanwen/go-fuse/raw"
)
...
...
@@ -118,9 +119,9 @@ func (fs *LockingFileSystem) Create(name string, flags uint32, mode uint32, cont
return
fs
.
FileSystem
.
Create
(
name
,
flags
,
mode
,
context
)
}
func
(
fs
*
LockingFileSystem
)
Utimens
(
name
string
,
Atime
Ns
int64
,
CtimeNs
int64
,
context
*
Context
)
(
code
Status
)
{
func
(
fs
*
LockingFileSystem
)
Utimens
(
name
string
,
Atime
*
time
.
Time
,
Mtime
*
time
.
Time
,
context
*
Context
)
(
code
Status
)
{
defer
fs
.
locked
()()
return
fs
.
FileSystem
.
Utimens
(
name
,
Atime
Ns
,
CtimeNs
,
context
)
return
fs
.
FileSystem
.
Utimens
(
name
,
Atime
,
Mtime
,
context
)
}
func
(
fs
*
LockingFileSystem
)
GetXAttr
(
name
string
,
attr
string
,
context
*
Context
)
([]
byte
,
Status
)
{
...
...
fuse/loopback.go
View file @
f9bfdb9c
...
...
@@ -111,8 +111,16 @@ func (fs *LoopbackFileSystem) Truncate(path string, offset uint64, context *Cont
return
ToStatus
(
os
.
Truncate
(
fs
.
GetPath
(
path
),
int64
(
offset
)))
}
func
(
fs
*
LoopbackFileSystem
)
Utimens
(
path
string
,
AtimeNs
int64
,
MtimeNs
int64
,
context
*
Context
)
(
code
Status
)
{
return
ToStatus
(
os
.
Chtimes
(
fs
.
GetPath
(
path
),
time
.
Unix
(
0
,
AtimeNs
),
time
.
Unix
(
0
,
MtimeNs
)))
func
(
fs
*
LoopbackFileSystem
)
Utimens
(
path
string
,
Atime
*
time
.
Time
,
Mtime
*
time
.
Time
,
context
*
Context
)
(
code
Status
)
{
var
a
time
.
Time
if
Atime
!=
nil
{
a
=
*
Atime
}
var
m
time
.
Time
if
Mtime
!=
nil
{
m
=
*
Mtime
}
return
ToStatus
(
os
.
Chtimes
(
fs
.
GetPath
(
path
),
a
,
m
))
}
func
(
fs
*
LoopbackFileSystem
)
Readlink
(
name
string
,
context
*
Context
)
(
out
string
,
code
Status
)
{
...
...
fuse/memnode.go
View file @
f9bfdb9c
...
...
@@ -34,8 +34,8 @@ func (fs *MemNodeFs) newNode() *memNode {
fs
:
fs
,
id
:
fs
.
nextFree
,
}
now
:=
time
.
Now
()
.
UnixNano
()
n
.
info
.
Set
Ns
(
now
,
now
,
now
)
now
:=
time
.
Now
()
n
.
info
.
Set
Times
(
&
now
,
&
now
,
&
now
)
n
.
info
.
Mode
=
S_IFDIR
|
0777
fs
.
nextFree
++
fs
.
mutex
.
Unlock
()
...
...
@@ -189,27 +189,31 @@ func (n *memNode) Truncate(file File, size uint64, context *Context) (code Statu
code
=
ToStatus
(
err
)
}
if
code
.
Ok
()
{
n
.
info
.
SetNs
(
-
1
,
-
1
,
time
.
Now
()
.
UnixNano
())
now
:=
time
.
Now
()
n
.
info
.
SetTimes
(
nil
,
nil
,
&
now
)
// TODO - should update mtime too?
n
.
info
.
Size
=
size
}
return
code
}
func
(
n
*
memNode
)
Utimens
(
file
File
,
atime
int64
,
mtime
int64
,
context
*
Context
)
(
code
Status
)
{
n
.
info
.
SetNs
(
int64
(
atime
),
int64
(
mtime
),
time
.
Now
()
.
UnixNano
())
func
(
n
*
memNode
)
Utimens
(
file
File
,
atime
*
time
.
Time
,
mtime
*
time
.
Time
,
context
*
Context
)
(
code
Status
)
{
c
:=
time
.
Now
()
n
.
info
.
SetTimes
(
atime
,
mtime
,
&
c
)
return
OK
}
func
(
n
*
memNode
)
Chmod
(
file
File
,
perms
uint32
,
context
*
Context
)
(
code
Status
)
{
n
.
info
.
Mode
=
(
n
.
info
.
Mode
^
07777
)
|
perms
n
.
info
.
SetNs
(
-
1
,
-
1
,
time
.
Now
()
.
UnixNano
())
now
:=
time
.
Now
()
n
.
info
.
SetTimes
(
nil
,
nil
,
&
now
)
return
OK
}
func
(
n
*
memNode
)
Chown
(
file
File
,
uid
uint32
,
gid
uint32
,
context
*
Context
)
(
code
Status
)
{
n
.
info
.
Uid
=
uid
n
.
info
.
Gid
=
gid
n
.
info
.
SetNs
(
-
1
,
-
1
,
time
.
Now
()
.
UnixNano
())
now
:=
time
.
Now
()
n
.
info
.
SetTimes
(
nil
,
nil
,
&
now
)
return
OK
}
fuse/pathfs.go
View file @
f9bfdb9c
...
...
@@ -6,6 +6,7 @@ import (
"path/filepath"
"strings"
"sync"
"time"
)
var
_
=
log
.
Println
...
...
@@ -625,7 +626,7 @@ func (n *pathInode) Truncate(file File, size uint64, context *Context) (code Sta
return
code
}
func
(
n
*
pathInode
)
Utimens
(
file
File
,
atime
int64
,
mtime
int64
,
context
*
Context
)
(
code
Status
)
{
func
(
n
*
pathInode
)
Utimens
(
file
File
,
atime
*
time
.
Time
,
mtime
*
time
.
Time
,
context
*
Context
)
(
code
Status
)
{
files
:=
n
.
inode
.
Files
(
O_ANYWRITE
)
for
_
,
f
:=
range
files
{
// TODO - pass context
...
...
fuse/prefixfs.go
View file @
f9bfdb9c
...
...
@@ -3,6 +3,7 @@ package fuse
import
(
"fmt"
"path/filepath"
"time"
)
// PrefixFileSystem adds a path prefix to incoming calls.
...
...
@@ -87,8 +88,8 @@ func (fs *PrefixFileSystem) Create(name string, flags uint32, mode uint32, conte
return
fs
.
FileSystem
.
Create
(
fs
.
prefixed
(
name
),
flags
,
mode
,
context
)
}
func
(
fs
*
PrefixFileSystem
)
Utimens
(
name
string
,
Atime
Ns
int64
,
CtimeNs
int64
,
context
*
Context
)
(
code
Status
)
{
return
fs
.
FileSystem
.
Utimens
(
fs
.
prefixed
(
name
),
Atime
Ns
,
CtimeNs
,
context
)
func
(
fs
*
PrefixFileSystem
)
Utimens
(
name
string
,
Atime
*
time
.
Time
,
Mtime
*
time
.
Time
,
context
*
Context
)
(
code
Status
)
{
return
fs
.
FileSystem
.
Utimens
(
fs
.
prefixed
(
name
),
Atime
,
Mtime
,
context
)
}
func
(
fs
*
PrefixFileSystem
)
GetXAttr
(
name
string
,
attr
string
,
context
*
Context
)
([]
byte
,
Status
)
{
...
...
unionfs/unionfs.go
View file @
f9bfdb9c
...
...
@@ -281,8 +281,9 @@ func (fs *UnionFs) Promote(name string, srcResult branchResult, context *fuse.Co
code
=
writable
.
Chmod
(
name
,
srcResult
.
attr
.
Mode
&
07777
|
0200
,
context
)
}
if
code
.
Ok
()
{
code
=
writable
.
Utimens
(
name
,
srcResult
.
attr
.
Atimens
(),
srcResult
.
attr
.
Mtimens
(),
context
)
aTime
:=
srcResult
.
attr
.
AccessTime
()
mTime
:=
srcResult
.
attr
.
ModTime
()
code
=
writable
.
Utimens
(
name
,
&
aTime
,
&
mTime
,
context
)
}
files
:=
fs
.
nodeFs
.
AllFiles
(
name
,
0
)
...
...
@@ -478,7 +479,7 @@ func (fs *UnionFs) Truncate(path string, size uint64, context *fuse.Context) (co
return
code
}
func
(
fs
*
UnionFs
)
Utimens
(
name
string
,
atime
int64
,
mtime
int64
,
context
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
func
(
fs
*
UnionFs
)
Utimens
(
name
string
,
atime
*
time
.
Time
,
mtime
*
time
.
Time
,
context
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
name
=
stripSlash
(
name
)
r
:=
fs
.
getBranch
(
name
)
...
...
@@ -491,7 +492,8 @@ func (fs *UnionFs) Utimens(name string, atime int64, mtime int64, context *fuse.
code
=
fs
.
fileSystems
[
0
]
.
Utimens
(
name
,
atime
,
mtime
,
context
)
}
if
code
.
Ok
()
{
r
.
attr
.
SetNs
(
atime
,
mtime
,
time
.
Now
()
.
UnixNano
())
now
:=
time
.
Now
()
r
.
attr
.
SetTimes
(
atime
,
mtime
,
&
now
)
fs
.
branchCache
.
Set
(
name
,
r
)
}
return
code
...
...
@@ -640,7 +642,9 @@ func (fs *UnionFs) promoteDirsTo(filename string) fuse.Status {
return
fuse
.
EPERM
}
fs
.
fileSystems
[
0
]
.
Utimens
(
d
,
r
.
attr
.
Atimens
(),
r
.
attr
.
Mtimens
(),
nil
)
aTime
:=
r
.
attr
.
AccessTime
()
mTime
:=
r
.
attr
.
ModTime
()
fs
.
fileSystems
[
0
]
.
Utimens
(
d
,
&
aTime
,
&
mTime
,
nil
)
r
.
branch
=
0
fs
.
branchCache
.
Set
(
d
,
r
)
}
...
...
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