Skip to content

Commit

Permalink
Update to canonical Rio path and fix windows syscall reference
Browse files Browse the repository at this point in the history
fix #8
fix #9
  • Loading branch information
willscott committed Nov 22, 2020
1 parent e93b1ca commit dcbd379
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 17 deletions.
10 changes: 5 additions & 5 deletions file.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"io"
"log"
"os"
"syscall"
"time"

"github.com/go-git/go-billy/v5"
"github.com/willscott/go-nfs-client/nfs/xdr"
"github.com/willscott/go-nfs/file"
)

// FileAttribute holds metadata about a filesystem object
Expand Down Expand Up @@ -111,10 +111,10 @@ func ToFileAttribute(info os.FileInfo) *FileAttribute {
// The number of hard links to the file.
f.Nlink = 1

if s, ok := info.Sys().(*syscall.Stat_t); ok {
f.Nlink = uint32(s.Nlink)
f.UID = s.Uid
f.GID = s.Gid
if a := file.GetInfo(info); a != nil {
f.Nlink = a.Nlink
f.UID = a.UID
f.GID = a.GID
}

f.Filesize = uint64(info.Size())
Expand Down
14 changes: 14 additions & 0 deletions file/file.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package file

import "os"

type FileInfo struct {
Nlink uint32
UID uint32
GID uint32
}

// GetInfo extracts some non-standardized items from the result of a Stat call.
func GetInfo(fi os.FileInfo) *FileInfo {
return getInfo(fi)
}
19 changes: 19 additions & 0 deletions file/file_unix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris

package file

import (
"os"
"syscall"
)

func getInfo(info os.FileInfo) *FileInfo {
fi := &FileInfo{}
if s, ok := info.Sys().(*syscall.Stat_t); ok {
fi.Nlink = uint32(s.Nlink)
fi.UID = s.Uid
fi.GID = s.Gid
return fi
}
return nil
}
12 changes: 12 additions & 0 deletions file/file_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// +build windows

package file

import "os"

func getInfo(info os.FileInfo) *FileInfo {
// https://godoc.org/golang.org/x/sys/windows#GetFileInformationByHandle
// can be potentially used to populate Nlink

return nil
}
7 changes: 1 addition & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ require (
github.com/google/uuid v1.1.1
github.com/hashicorp/golang-lru v0.5.4
github.com/rasky/go-xdr v0.0.0-20170124162913-1a41d1a06c93
github.com/warpfork/go-wish v0.0.0-20200122115046-b9ea61034e4a // indirect
github.com/willscott/go-nfs-client v0.0.0-20200605172546-271fa9065b33
github.com/willscott/memphis v0.0.0-20200912205913-768fef98189f
github.com/willscott/memphis v0.0.0-20201122065000-f2beb41b6be3
)

replace go.polydawn.net/go-timeless-api => github.com/polydawn/go-timeless-api v0.0.0-20190707220600-0ece408663ed

replace go.polydawn.net/rio => github.com/polydawn/rio v0.0.0-20200325050149-e97d9995e350
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/polydawn/go-timeless-api v0.0.0-20190707220600-0ece408663ed h1:WzzCCfq6k2m5d+FT2JRoeH+knLiA1aNWDuqTy6CZnDs=
github.com/polydawn/go-timeless-api v0.0.0-20190707220600-0ece408663ed/go.mod h1:z2fMUifgtqrZiNLgzF4ZR8pX+YFLCmAp1jJTSTvyDMM=
github.com/polydawn/go-timeless-api v0.0.0-20201121022836-7399661094a6 h1:0aujMYTWlf0+fgE4W6NKMwcNVFWBYrk7ozFtUXj/GkM=
github.com/polydawn/go-timeless-api v0.0.0-20201121022836-7399661094a6/go.mod h1:z2fMUifgtqrZiNLgzF4ZR8pX+YFLCmAp1jJTSTvyDMM=
github.com/polydawn/refmt v0.0.0-20190807091052-3d65705ee9f1 h1:CskT+S6Ay54OwxBGB0R3Rsx4Muto6UnEYTyKJbyRIAI=
github.com/polydawn/refmt v0.0.0-20190807091052-3d65705ee9f1/go.mod h1:uIp+gprXxxrWSjjklXD+mN4wed/tMfjMMmN/9+JsA9o=
github.com/polydawn/rio v0.0.0-20200325050149-e97d9995e350 h1:4fkF5MLSMdVPu+Or1+CUJGP1YGftS42tJVdXoL+/7BQ=
github.com/polydawn/rio v0.0.0-20200325050149-e97d9995e350/go.mod h1:mwZtAu36D3fSNzVLN1we6PFdRU4VeE+RXLTZiOiQlJ0=
github.com/polydawn/rio v0.0.0-20201122020833-6192319df581 h1:oWJ+IohuFAcwV3cwK/ExI7tJddHB1VERduwtpPiiStY=
github.com/polydawn/rio v0.0.0-20201122020833-6192319df581/go.mod h1:mwZtAu36D3fSNzVLN1we6PFdRU4VeE+RXLTZiOiQlJ0=
github.com/rasky/go-xdr v0.0.0-20170124162913-1a41d1a06c93 h1:UVArwN/wkKjMVhh2EQGC0tEc1+FqiLlvYXY5mQ2f8Wg=
github.com/rasky/go-xdr v0.0.0-20170124162913-1a41d1a06c93/go.mod h1:Nfe4efndBz4TibWycNE+lqyJZiMX4ycx+QKV8Ta0f/o=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
Expand All @@ -33,8 +33,8 @@ github.com/warpfork/go-wish v0.0.0-20200122115046-b9ea61034e4a h1:G++j5e0OC488te
github.com/warpfork/go-wish v0.0.0-20200122115046-b9ea61034e4a/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw=
github.com/willscott/go-nfs-client v0.0.0-20200605172546-271fa9065b33 h1:Wd8wdpRzPXskyHvZLyw7Wc1fp5oCE2mhBCj7bAiibUs=
github.com/willscott/go-nfs-client v0.0.0-20200605172546-271fa9065b33/go.mod h1:cOUKSNty+RabZqKhm5yTJT5Vq/Fe83ZRWAJ5Kj8nRes=
github.com/willscott/memphis v0.0.0-20200912205913-768fef98189f h1:b+G0cnCRLaSCGLPV/mXpDaqVrPdOIKx0y59wENVFUBI=
github.com/willscott/memphis v0.0.0-20200912205913-768fef98189f/go.mod h1:wQ73uP8H2umTsqMbo021y58pWHnrS9BZEkdoS0gDnHg=
github.com/willscott/memphis v0.0.0-20201122065000-f2beb41b6be3 h1:AdLOEjtapvxtb6S26lamqFSjFrlMBReLjFggJwDx9Z8=
github.com/willscott/memphis v0.0.0-20201122065000-f2beb41b6be3/go.mod h1:59vHBW4EpjiL5oiqgCrBp1Tc9JXRzKCNMEOaGmNfSHo=
github.com/zema1/go-nfs-client v0.0.0-20200604081958-0cf942f0e0fe/go.mod h1:im3CVJ32XM3+E+2RhY0sa5IVJVQehUrX0oE1wX4xOwU=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
Expand Down

0 comments on commit dcbd379

Please sign in to comment.