Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fs/stat: add FreeBSD, and cleanup some nolint-comments #184

Merged
merged 2 commits into from Jun 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 2 additions & 4 deletions fs/du_unix.go
Expand Up @@ -41,10 +41,8 @@ type inode struct {

func newInode(stat *syscall.Stat_t) inode {
return inode{
// Dev is uint32 on darwin/bsd, uint64 on linux/solaris/freebsd
dev: uint64(stat.Dev), // nolint: unconvert
// Ino is uint32 on bsd, uint64 on darwin/linux/solaris/freebsd
ino: uint64(stat.Ino), // nolint: unconvert
dev: uint64(stat.Dev), //nolint: unconvert // dev is uint32 on darwin/bsd, uint64 on linux/solaris/freebsd
ino: uint64(stat.Ino), //nolint: unconvert // ino is uint32 on bsd, uint64 on darwin/linux/solaris/freebsd
}
}

Expand Down
4 changes: 2 additions & 2 deletions fs/du_unix_test.go
Expand Up @@ -34,7 +34,7 @@ func getBsize(root string) (int64, error) {
return 0, err
}

return int64(s.Bsize), nil // nolint: unconvert
return int64(s.Bsize), nil //nolint: unconvert
}

// getTmpAlign returns filesystem specific size alignment functions
Expand Down Expand Up @@ -92,6 +92,6 @@ func duCheck(root string) (usage int64, err error) {
if err != nil {
return 0, err
}
return blocks * blocksUnitSize, nil

return blocks * blocksUnitSize, nil
}
3 changes: 1 addition & 2 deletions fs/hardlink_unix.go
Expand Up @@ -29,6 +29,5 @@ func getLinkInfo(fi os.FileInfo) (uint64, bool) {
return 0, false
}

// Ino is uint32 on bsd, uint64 on darwin/linux/solaris
return uint64(s.Ino), !fi.IsDir() && s.Nlink > 1 // nolint: unconvert
return uint64(s.Ino), !fi.IsDir() && s.Nlink > 1 //nolint: unconvert // ino is uint32 on bsd, uint64 on darwin/linux/solaris
}
4 changes: 2 additions & 2 deletions fs/stat_darwinfreebsd.go → fs/stat_darwinbsd.go
@@ -1,4 +1,4 @@
// +build darwin freebsd
// +build darwin freebsd netbsd

/*
Copyright The containerd Authors.
Expand Down Expand Up @@ -40,5 +40,5 @@ func StatMtime(st *syscall.Stat_t) syscall.Timespec {

// StatATimeAsTime returns the access time as a time.Time
func StatATimeAsTime(st *syscall.Stat_t) time.Time {
return time.Unix(int64(st.Atimespec.Sec), int64(st.Atimespec.Nsec)) // nolint: unconvert
return time.Unix(int64(st.Atimespec.Sec), int64(st.Atimespec.Nsec)) //nolint: unconvert // int64 conversions ensure the line compiles for 32-bit systems as well.
}
3 changes: 1 addition & 2 deletions fs/stat_linuxopenbsd.go
Expand Up @@ -40,6 +40,5 @@ func StatMtime(st *syscall.Stat_t) syscall.Timespec {

// StatATimeAsTime returns st.Atim as a time.Time
func StatATimeAsTime(st *syscall.Stat_t) time.Time {
// The int64 conversions ensure the line compiles for 32-bit systems as well.
return time.Unix(int64(st.Atim.Sec), int64(st.Atim.Nsec)) // nolint: unconvert
return time.Unix(int64(st.Atim.Sec), int64(st.Atim.Nsec)) //nolint: unconvert // int64 conversions ensure the line compiles for 32-bit systems as well.
}
10 changes: 4 additions & 6 deletions manifest.go
Expand Up @@ -75,7 +75,7 @@ func MarshalText(w io.Writer, m *Manifest) error {
// BuildManifest creates the manifest for the given context
func BuildManifest(ctx Context) (*Manifest, error) {
resourcesByPath := map[string]Resource{}
hardlinks := newHardlinkManager()
hardLinks := newHardlinkManager()

if err := ctx.Walk(func(p string, fi os.FileInfo, err error) error {
if err != nil {
Expand All @@ -97,7 +97,7 @@ func BuildManifest(ctx Context) (*Manifest, error) {
}

// add to the hardlink manager
if err := hardlinks.Add(fi, resource); err == nil {
if err := hardLinks.Add(fi, resource); err == nil {
// Resource has been accepted by hardlink manager so we don't add
// it to the resourcesByPath until we merge at the end.
return nil
Expand All @@ -114,14 +114,12 @@ func BuildManifest(ctx Context) (*Manifest, error) {
}

// merge and post-process the hardlinks.
// nolint:misspell
hardlinked, err := hardlinks.Merge()
hardLinked, err := hardLinks.Merge()
if err != nil {
return nil, err
}

// nolint:misspell
for _, resource := range hardlinked {
for _, resource := range hardLinked {
resourcesByPath[resource.Path()] = resource
}

Expand Down