Commit 77a32bd3 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Make go-fuse compile (not work) on Darwin, partially.

parent 1a6d9d93
......@@ -86,24 +86,6 @@ func (a *Attr) SetTimes(access *time.Time, mod *time.Time, chstatus *time.Time)
}
}
func (a *Attr) FromStat(s *syscall.Stat_t) {
a.Ino = uint64(s.Ino)
a.Size = uint64(s.Size)
a.Blocks = uint64(s.Blocks)
a.Atime = uint64(s.Atim.Sec)
a.Atimensec = uint32(s.Atim.Nsec)
a.Mtime = uint64(s.Mtim.Sec)
a.Mtimensec = uint32(s.Mtim.Nsec)
a.Ctime = uint64(s.Ctim.Sec)
a.Ctimensec = uint32(s.Ctim.Nsec)
a.Mode = s.Mode
a.Nlink = uint32(s.Nlink)
a.Uid = uint32(s.Uid)
a.Gid = uint32(s.Gid)
a.Rdev = uint32(s.Rdev)
a.Blksize = uint32(s.Blksize)
}
func (a *Attr) ChangeTime() time.Time {
return time.Unix(int64(a.Ctime), int64(a.Ctimensec))
}
......
package fuse
import (
"syscall"
)
func (a *Attr) FromStat(s *syscall.Stat_t) {
a.Ino = uint64(s.Ino)
a.Size = uint64(s.Size)
a.Blocks = uint64(s.Blocks)
a.Atime = uint64(s.Atimespec.Sec)
a.Atimensec = uint32(s.Atimespec.Nsec)
a.Mtime = uint64(s.Mtimespec.Sec)
a.Mtimensec = uint32(s.Mtimespec.Nsec)
a.Ctime = uint64(s.Ctimespec.Sec)
a.Ctimensec = uint32(s.Ctimespec.Nsec)
a.Mode = uint32(s.Mode)
a.Nlink = uint32(s.Nlink)
a.Uid = uint32(s.Uid)
a.Gid = uint32(s.Gid)
a.Rdev = uint32(s.Rdev)
a.Blksize = uint32(s.Blksize)
}
package fuse
func (a *Attr) FromStat(s *syscall.Stat_t) {
a.Ino = uint64(s.Ino)
a.Size = uint64(s.Size)
a.Blocks = uint64(s.Blocks)
a.Atime = uint64(s.Atim.Sec)
a.Atimensec = uint32(s.Atim.Nsec)
a.Mtime = uint64(s.Mtim.Sec)
a.Mtimensec = uint32(s.Mtim.Nsec)
a.Ctime = uint64(s.Ctim.Sec)
a.Ctimensec = uint32(s.Ctim.Nsec)
a.Mode = s.Mode
a.Nlink = uint32(s.Nlink)
a.Uid = uint32(s.Uid)
a.Gid = uint32(s.Gid)
a.Rdev = uint32(s.Rdev)
a.Blksize = uint32(s.Blksize)
}
......@@ -71,7 +71,7 @@ func (fs *LoopbackFileSystem) OpenDir(name string, context *Context) (stream []D
Name: n,
}
if s := ToStatT(infos[i]); s != nil {
d.Mode = s.Mode
d.Mode = uint32(s.Mode)
} else {
log.Printf("ReadDir entry %q for %q has no stat info", n, name)
}
......@@ -166,42 +166,3 @@ func (fs *LoopbackFileSystem) Create(path string, flags uint32, mode uint32, con
f, err := os.OpenFile(fs.GetPath(path), int(flags)|os.O_CREATE, os.FileMode(mode))
return &LoopbackFile{File: f}, ToStatus(err)
}
func (fs *LoopbackFileSystem) GetXAttr(name string, attr string, context *Context) ([]byte, Status) {
data := make([]byte, 1024)
data, errNo := GetXAttr(fs.GetPath(name), attr, data)
return data, Status(errNo)
}
func (fs *LoopbackFileSystem) ListXAttr(name string, context *Context) ([]string, Status) {
data, errNo := ListXAttr(fs.GetPath(name))
return data, Status(errNo)
}
func (fs *LoopbackFileSystem) RemoveXAttr(name string, attr string, context *Context) Status {
return Status(Removexattr(fs.GetPath(name), attr))
}
func (fs *LoopbackFileSystem) String() string {
return fmt.Sprintf("LoopbackFs(%s)", fs.Root)
}
func (fs *LoopbackFileSystem) StatFs(name string) *StatfsOut {
s := syscall.Statfs_t{}
err := syscall.Statfs(fs.GetPath(name), &s)
if err == nil {
return &StatfsOut{
Blocks: s.Blocks,
Bsize: uint32(s.Bsize),
Bfree: s.Bfree,
Bavail: s.Bavail,
Files: s.Files,
Ffree: s.Ffree,
Frsize: uint32(s.Frsize),
NameLen: uint32(s.Namelen),
}
}
return nil
}
package fuse
import (
"syscall"
)
func (fs *LoopbackFileSystem) StatFs(name string) *StatfsOut {
s := syscall.Statfs_t{}
err := syscall.Statfs(fs.GetPath(name), &s)
if err == nil {
return &StatfsOut{
Blocks: s.Blocks,
Bsize: uint32(s.Bsize),
Bfree: s.Bfree,
Bavail: s.Bavail,
Files: s.Files,
Ffree: s.Ffree,
Frsize: uint32(s.Frsize),
NameLen: uint32(s.Namelen),
}
}
return nil
}
func (fs *LoopbackFileSystem) ListXAttr(name string, context *Context) ([]string, Status) {
data, errNo := ListXAttr(fs.GetPath(name))
return data, Status(errNo)
}
func (fs *LoopbackFileSystem) RemoveXAttr(name string, attr string, context *Context) Status {
return Status(Removexattr(fs.GetPath(name), attr))
}
func (fs *LoopbackFileSystem) String() string {
return fmt.Sprintf("LoopbackFs(%s)", fs.Root)
}
func (fs *LoopbackFileSystem) GetXAttr(name string, attr string, context *Context) ([]byte, Status) {
data := make([]byte, 1024)
data, errNo := GetXAttr(fs.GetPath(name), attr, data)
return data, Status(errNo)
}
package fuse
import (
"fmt"
)
func (s *MountState) setSplice() {
panic("darwin has no splice.")
}
func (ms *MountState) trySplice(header []byte, req *request, fdData *ReadResultFd) error {
return fmt.Errorf("unimplemented")
}
......@@ -53,10 +53,7 @@ func init() {
os.O_TRUNC: "TRUNC",
syscall.O_CLOEXEC: "CLOEXEC",
syscall.O_DIRECT: "DIRECT",
syscall.O_DIRECTORY: "DIRECTORY",
syscall_O_LARGEFILE: "LARGEFILE",
syscall_O_NOATIME: "NOATIME",
}
FuseOpenFlagNames = map[int]string{
FOPEN_DIRECT_IO: "DIRECT",
......
package raw
init() {
OpenFlagNames[syscall.O_DIRECT] = "DIRECT"
OpenFlagNames[syscall.O_LARGEFILE] = "LARGEFILE"
OpenFlagNames[syscall_O_NOATIME] = "NOATIME"
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment