Fixed a bunch of build errors.
parent
32dc0dc4da
commit
e226901fc6
|
@ -18,6 +18,8 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
|
@ -415,39 +417,55 @@ func Convert(
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func convertTime(t time.Time) (secs uint64, nsec uint32)
|
||||||
|
|
||||||
func convertAttributes(
|
func convertAttributes(
|
||||||
inode InodeID,
|
inodeID InodeID,
|
||||||
attr InodeAttributes,
|
in *InodeAttributes,
|
||||||
expiration time.Time) fuseshim.Attr {
|
out *fusekernel.Attr) {
|
||||||
return fuseshim.Attr{
|
out.Ino = uint64(inodeID)
|
||||||
Inode: uint64(inode),
|
out.Size = in.Size
|
||||||
Size: attr.Size,
|
out.Atime, out.AtimeNsec = convertTime(in.Atime)
|
||||||
Mode: attr.Mode,
|
out.Mtime, out.MtimeNsec = convertTime(in.Mtime)
|
||||||
Nlink: uint32(attr.Nlink),
|
out.Ctime, out.CtimeNsec = convertTime(in.Ctime)
|
||||||
Atime: attr.Atime,
|
out.SetCrtime(convertTime(in.Crtime))
|
||||||
Mtime: attr.Mtime,
|
out.Nlink = uint32(in.Nlink) // TODO(jacobsa): Make the public field uint32?
|
||||||
Ctime: attr.Ctime,
|
out.Uid = in.Uid
|
||||||
Crtime: attr.Crtime,
|
out.Gid = in.Gid
|
||||||
Uid: attr.Uid,
|
|
||||||
Gid: attr.Gid,
|
// Set the mode.
|
||||||
Valid: convertExpirationTime(expiration),
|
out.Mode = uint32(in.Mode) & 077
|
||||||
|
switch {
|
||||||
|
default:
|
||||||
|
out.Mode |= syscall.S_IFREG
|
||||||
|
case in.Mode&os.ModeDir != 0:
|
||||||
|
out.Mode |= syscall.S_IFDIR
|
||||||
|
case in.Mode&os.ModeDevice != 0:
|
||||||
|
if in.Mode&os.ModeCharDevice != 0 {
|
||||||
|
out.Mode |= syscall.S_IFCHR
|
||||||
|
} else {
|
||||||
|
out.Mode |= syscall.S_IFBLK
|
||||||
|
}
|
||||||
|
case in.Mode&os.ModeNamedPipe != 0:
|
||||||
|
out.Mode |= syscall.S_IFIFO
|
||||||
|
case in.Mode&os.ModeSymlink != 0:
|
||||||
|
out.Mode |= syscall.S_IFLNK
|
||||||
|
case in.Mode&os.ModeSocket != 0:
|
||||||
|
out.Mode |= syscall.S_IFSOCK
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert an absolute cache expiration time to a relative time from now for
|
// Convert an absolute cache expiration time to a relative time from now for
|
||||||
// consumption by fuse.
|
// consumption by the fuse kernel module.
|
||||||
func convertExpirationTime(t time.Time) (d time.Duration) {
|
func convertExpirationTime(t time.Time) (secs uint64, nsecs uint32) {
|
||||||
// Fuse represents durations as unsigned 64-bit counts of seconds and 32-bit
|
// Fuse represents durations as unsigned 64-bit counts of seconds and 32-bit
|
||||||
// counts of nanoseconds (cf. http://goo.gl/EJupJV). The bazil.org/fuse
|
// counts of nanoseconds (cf. http://goo.gl/EJupJV). So negative durations
|
||||||
// package converts time.Duration values to this form in a straightforward
|
// are right out. There is no need to cap the positive magnitude, because
|
||||||
// way (cf. http://goo.gl/FJhV8j).
|
// 2^64 seconds is well longer than the 2^63 ns range of time.Duration.
|
||||||
//
|
d := t.Sub(time.Now())
|
||||||
// So negative durations are right out. There is no need to cap the positive
|
if d > 0 {
|
||||||
// magnitude, because 2^64 seconds is well longer than the 2^63 ns range of
|
secs = uint64(d / time.Second)
|
||||||
// time.Duration.
|
nsecs = uint32((d % time.Second) / time.Nanosecond)
|
||||||
d = t.Sub(time.Now())
|
|
||||||
if d < 0 {
|
|
||||||
d = 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
|
@ -456,9 +474,10 @@ func convertExpirationTime(t time.Time) (d time.Duration) {
|
||||||
func convertChildInodeEntry(
|
func convertChildInodeEntry(
|
||||||
in *ChildInodeEntry,
|
in *ChildInodeEntry,
|
||||||
out *fusekernel.EntryOut) {
|
out *fusekernel.EntryOut) {
|
||||||
out.Nodeid = in.Child
|
out.Nodeid = uint64(in.Child)
|
||||||
out.Generation = in.Generation
|
out.Generation = uint64(in.Generation)
|
||||||
convertAttributes(in.Attributes, &out.Attr)
|
out.EntryValid, out.EntryValidNsec = convertExpirationTime(in.EntryExpiration)
|
||||||
out.Attr = convertAttributes(in.Child, in.Attributes, in.AttributesExpiration)
|
out.AttrValid, out.AttrValidNsec = convertExpirationTime(in.AttributesExpiration)
|
||||||
out.EntryValid = convertExpirationTime(in.EntryExpiration)
|
|
||||||
|
convertAttributes(in.Child, &in.Attributes, &out.Attr)
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,7 @@ func (o *LookUpInodeOp) kernelResponse() (msg []byte) {
|
||||||
size := fusekernel.EntryOutSize(fusekernel.Protocol{0, 0})
|
size := fusekernel.EntryOutSize(fusekernel.Protocol{0, 0})
|
||||||
buf := NewBuffer(size)
|
buf := NewBuffer(size)
|
||||||
out := (*fusekernel.EntryOut)(buf.Alloc(size))
|
out := (*fusekernel.EntryOut)(buf.Alloc(size))
|
||||||
out.Nodeid = uint64(resp.Node)
|
out.Nodeid = uint64(o.Entry.InodeID)
|
||||||
out.Generation = resp.Generation
|
out.Generation = resp.Generation
|
||||||
out.EntryValid = uint64(resp.EntryValid / time.Second)
|
out.EntryValid = uint64(resp.EntryValid / time.Second)
|
||||||
out.EntryValidNsec = uint32(resp.EntryValid % time.Second / time.Nanosecond)
|
out.EntryValidNsec = uint32(resp.EntryValid % time.Second / time.Nanosecond)
|
||||||
|
|
Loading…
Reference in New Issue