Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f0ce367

Browse files
committed
pkg/system: deprecate types and functions that are only used internally
These types and functions are only used internally (through pkg/archive). Deprecate them, and mark them for removal. This deprecates the `Lstat()`, `Mkdev()`, `Mknod()`, `FromStatT()` and `Stat()` functions, and related `StatT` type. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 577a795 commit f0ce367

File tree

9 files changed

+29
-3
lines changed

9 files changed

+29
-3
lines changed

.golangci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,12 @@ issues:
151151
linters:
152152
- staticcheck
153153

154+
# FIXME temporarily suppress these until https://github.com/moby/moby/pull/49072 is merged, which removes their use.
155+
- text: "SA1019: system\\.(FromStatT|Mkdev|Mknod|StatT)"
156+
path: "pkg/archive/"
157+
linters:
158+
- staticcheck
159+
154160
- text: "ineffectual assignment to ctx"
155161
source: "ctx[, ].*=.*\\(ctx[,)]"
156162
linters:

pkg/system/lstat_unix.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import (
1010
// Lstat takes a path to a file and returns
1111
// a system.StatT type pertaining to that file.
1212
//
13-
// Throws an error if the file does not exist
13+
// Throws an error if the file does not exist.
14+
//
15+
// Deprecated: this function is only used internally, and will be removed in the next release.
1416
func Lstat(path string) (*StatT, error) {
1517
s := &syscall.Stat_t{}
1618
if err := syscall.Lstat(path, s); err != nil {

pkg/system/lstat_windows.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import "os"
44

55
// Lstat calls os.Lstat to get a fileinfo interface back.
66
// This is then copied into our own locally defined structure.
7+
//
8+
// Deprecated: this function is only used internally, and will be removed in the next release.
79
func Lstat(path string) (*StatT, error) {
810
fi, err := os.Lstat(path)
911
if err != nil {

pkg/system/mknod.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import (
1111
// Linux device nodes are a bit weird due to backwards compat with 16 bit device nodes.
1212
// They are, from low to high: the lower 8 bits of the minor, then 12 bits of the major,
1313
// then the top 12 bits of the minor.
14+
//
15+
// Deprecated: this function is only used internally, and will be removed in the next release.
1416
func Mkdev(major int64, minor int64) uint32 {
1517
return uint32(unix.Mkdev(uint32(major), uint32(minor)))
1618
}

pkg/system/mknod_freebsd.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88

99
// Mknod creates a filesystem node (file, device special file or named pipe) named path
1010
// with attributes specified by mode and dev.
11+
//
12+
// Deprecated: this function is only used internally, and will be removed in the next release.
1113
func Mknod(path string, mode uint32, dev int) error {
1214
return unix.Mknod(path, mode, uint64(dev))
1315
}

pkg/system/mknod_unix.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88

99
// Mknod creates a filesystem node (file, device special file or named pipe) named path
1010
// with attributes specified by mode and dev.
11+
//
12+
// Deprecated: this function is only used internally, and will be removed in the next release.
1113
func Mknod(path string, mode uint32, dev int) error {
1214
return unix.Mknod(path, mode, dev)
1315
}

pkg/system/stat_linux.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ func fromStatT(s *syscall.Stat_t) (*StatT, error) {
1717

1818
// FromStatT converts a syscall.Stat_t type to a system.Stat_t type
1919
// This is exposed on Linux as pkg/archive/changes uses it.
20+
//
21+
// Deprecated: this function is only used internally, and will be removed in the next release.
2022
func FromStatT(s *syscall.Stat_t) (*StatT, error) {
2123
return fromStatT(s)
2224
}

pkg/system/stat_unix.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99

1010
// StatT type contains status of a file. It contains metadata
1111
// like permission, owner, group, size, etc about a file.
12+
//
13+
// Deprecated: this type is only used internally, and will be removed in the next release.
1214
type StatT struct {
1315
mode uint32
1416
uid uint32
@@ -56,7 +58,9 @@ func (s StatT) IsDir() bool {
5658
// Stat takes a path to a file and returns
5759
// a system.StatT type pertaining to that file.
5860
//
59-
// Throws an error if the file does not exist
61+
// Throws an error if the file does not exist.
62+
//
63+
// Deprecated: this function is only used internally, and will be removed in the next release.
6064
func Stat(path string) (*StatT, error) {
6165
s := &syscall.Stat_t{}
6266
if err := syscall.Stat(path, s); err != nil {

pkg/system/stat_windows.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import (
77

88
// StatT type contains status of a file. It contains metadata
99
// like permission, size, etc about a file.
10+
//
11+
// Deprecated: this type is only used internally, and will be removed in the next release.
1012
type StatT struct {
1113
mode os.FileMode
1214
size int64
@@ -31,7 +33,9 @@ func (s StatT) Mtim() time.Time {
3133
// Stat takes a path to a file and returns
3234
// a system.StatT type pertaining to that file.
3335
//
34-
// Throws an error if the file does not exist
36+
// Throws an error if the file does not exist.
37+
//
38+
// Deprecated: this function is only used internally, and will be removed in the next release.
3539
func Stat(path string) (*StatT, error) {
3640
fi, err := os.Stat(path)
3741
if err != nil {

0 commit comments

Comments
 (0)