Commit 00947164 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Use syscall directly rather than os functions.

parent 3ab227cc
...@@ -131,12 +131,13 @@ func (me *LoopbackFile) Chown(uid uint32, gid uint32) Status { ...@@ -131,12 +131,13 @@ func (me *LoopbackFile) Chown(uid uint32, gid uint32) Status {
} }
func (me *LoopbackFile) GetAttr() (*Attr, Status) { func (me *LoopbackFile) GetAttr() (*Attr, Status) {
fi, err := me.File.Stat() st := syscall.Stat_t{}
err := syscall.Fstat(me.File.Fd(), &st)
if err != nil { if err != nil {
return nil, ToStatus(err) return nil, ToStatus(err)
} }
a := &Attr{} a := &Attr{}
a.FromFileInfo(fi) a.FromStat(&st)
return a, OK return a, OK
} }
......
...@@ -37,19 +37,19 @@ func (me *LoopbackFileSystem) GetPath(relPath string) string { ...@@ -37,19 +37,19 @@ func (me *LoopbackFileSystem) GetPath(relPath string) string {
func (me *LoopbackFileSystem) GetAttr(name string, context *Context) (a *Attr, code Status) { func (me *LoopbackFileSystem) GetAttr(name string, context *Context) (a *Attr, code Status) {
fullPath := me.GetPath(name) fullPath := me.GetPath(name)
var err error = nil var err error = nil
var fi os.FileInfo st := syscall.Stat_t{}
if name == "" { if name == "" {
// When GetAttr is called for the toplevel directory, we always want // When GetAttr is called for the toplevel directory, we always want
// to look through symlinks. // to look through symlinks.
fi, err = os.Stat(fullPath) err = syscall.Stat(fullPath, &st)
} else { } else {
fi, err = os.Lstat(fullPath) err = syscall.Lstat(fullPath, &st)
} }
if err != nil { if err != nil {
return nil, ToStatus(err) return nil, ToStatus(err)
} }
a = &Attr{} a = &Attr{}
a.FromFileInfo(fi) a.FromStat(&st)
return a, OK return a, OK
} }
......
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