Skip to content

Commit

Permalink
Merge pull request #49100 from thaJeztah/27.x_backport_deprecate_pkg_…
Browse files Browse the repository at this point in the history
…system

[27.x backport] pkg/system: deprecate types and functions that are only used internally
  • Loading branch information
thaJeztah authored Dec 16, 2024
2 parents 24f2f4f + 1df9e89 commit 2a62319
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ issues:
linters:
- staticcheck

# FIXME temporarily suppress these until /~https://github.com/moby/moby/pull/49072 is merged, which removes their use.
- text: "SA1019: system\\.(FromStatT|Mkdev|Mknod|StatT)"
path: "pkg/archive/"
linters:
- staticcheck

- text: "ineffectual assignment to ctx"
source: "ctx[, ].*=.*\\(ctx[,)]"
linters:
Expand Down
4 changes: 3 additions & 1 deletion pkg/system/lstat_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import (
// Lstat takes a path to a file and returns
// a system.StatT type pertaining to that file.
//
// Throws an error if the file does not exist
// Throws an error if the file does not exist.
//
// Deprecated: this function is only used internally, and will be removed in the next release.
func Lstat(path string) (*StatT, error) {
s := &syscall.Stat_t{}
if err := syscall.Lstat(path, s); err != nil {
Expand Down
2 changes: 2 additions & 0 deletions pkg/system/lstat_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import "os"

// Lstat calls os.Lstat to get a fileinfo interface back.
// This is then copied into our own locally defined structure.
//
// Deprecated: this function is only used internally, and will be removed in the next release.
func Lstat(path string) (*StatT, error) {
fi, err := os.Lstat(path)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions pkg/system/mknod.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
// Linux device nodes are a bit weird due to backwards compat with 16 bit device nodes.
// They are, from low to high: the lower 8 bits of the minor, then 12 bits of the major,
// then the top 12 bits of the minor.
//
// Deprecated: this function is only used internally, and will be removed in the next release.
func Mkdev(major int64, minor int64) uint32 {
return uint32(unix.Mkdev(uint32(major), uint32(minor)))
}
2 changes: 2 additions & 0 deletions pkg/system/mknod_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (

// Mknod creates a filesystem node (file, device special file or named pipe) named path
// with attributes specified by mode and dev.
//
// Deprecated: this function is only used internally, and will be removed in the next release.
func Mknod(path string, mode uint32, dev int) error {
return unix.Mknod(path, mode, uint64(dev))
}
2 changes: 2 additions & 0 deletions pkg/system/mknod_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (

// Mknod creates a filesystem node (file, device special file or named pipe) named path
// with attributes specified by mode and dev.
//
// Deprecated: this function is only used internally, and will be removed in the next release.
func Mknod(path string, mode uint32, dev int) error {
return unix.Mknod(path, mode, dev)
}
2 changes: 2 additions & 0 deletions pkg/system/stat_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ func fromStatT(s *syscall.Stat_t) (*StatT, error) {

// FromStatT converts a syscall.Stat_t type to a system.Stat_t type
// This is exposed on Linux as pkg/archive/changes uses it.
//
// Deprecated: this function is only used internally, and will be removed in the next release.
func FromStatT(s *syscall.Stat_t) (*StatT, error) {
return fromStatT(s)
}
6 changes: 5 additions & 1 deletion pkg/system/stat_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (

// StatT type contains status of a file. It contains metadata
// like permission, owner, group, size, etc about a file.
//
// Deprecated: this type is only used internally, and will be removed in the next release.
type StatT struct {
mode uint32
uid uint32
Expand Down Expand Up @@ -56,7 +58,9 @@ func (s StatT) IsDir() bool {
// Stat takes a path to a file and returns
// a system.StatT type pertaining to that file.
//
// Throws an error if the file does not exist
// Throws an error if the file does not exist.
//
// Deprecated: this function is only used internally, and will be removed in the next release.
func Stat(path string) (*StatT, error) {
s := &syscall.Stat_t{}
if err := syscall.Stat(path, s); err != nil {
Expand Down
6 changes: 5 additions & 1 deletion pkg/system/stat_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (

// StatT type contains status of a file. It contains metadata
// like permission, size, etc about a file.
//
// Deprecated: this type is only used internally, and will be removed in the next release.
type StatT struct {
mode os.FileMode
size int64
Expand All @@ -31,7 +33,9 @@ func (s StatT) Mtim() time.Time {
// Stat takes a path to a file and returns
// a system.StatT type pertaining to that file.
//
// Throws an error if the file does not exist
// Throws an error if the file does not exist.
//
// Deprecated: this function is only used internally, and will be removed in the next release.
func Stat(path string) (*StatT, error) {
fi, err := os.Stat(path)
if err != nil {
Expand Down

0 comments on commit 2a62319

Please sign in to comment.