From 21f532d51891087f850ef3a7ed7e737c8c95b88a Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 23 Jun 2021 09:59:46 +0200 Subject: [PATCH] move sys.FMountat() into mount package It's the only location this is used, so might as well move it into that package. I could not find external users of this utility, so not adding an alias / deprecation. Signed-off-by: Sebastiaan van Stijn --- sys/mount_linux.go => mount/fmountat_linux.go | 2 +- sys/mount_linux_test.go => mount/fmountat_linux_test.go | 4 ++-- mount/mount_linux.go | 3 +-- {sys => mount}/subprocess_unsafe_linux.go | 2 +- {sys => mount}/subprocess_unsafe_linux.s | 0 5 files changed, 5 insertions(+), 6 deletions(-) rename sys/mount_linux.go => mount/fmountat_linux.go (99%) rename sys/mount_linux_test.go => mount/fmountat_linux_test.go (99%) rename {sys => mount}/subprocess_unsafe_linux.go (98%) rename {sys => mount}/subprocess_unsafe_linux.s (100%) diff --git a/sys/mount_linux.go b/mount/fmountat_linux.go similarity index 99% rename from sys/mount_linux.go rename to mount/fmountat_linux.go index a21045529..45732488d 100644 --- a/sys/mount_linux.go +++ b/mount/fmountat_linux.go @@ -14,7 +14,7 @@ limitations under the License. */ -package sys +package mount import ( "runtime" diff --git a/sys/mount_linux_test.go b/mount/fmountat_linux_test.go similarity index 99% rename from sys/mount_linux_test.go rename to mount/fmountat_linux_test.go index 38745f497..4f25acf9b 100644 --- a/sys/mount_linux_test.go +++ b/mount/fmountat_linux_test.go @@ -14,7 +14,7 @@ limitations under the License. */ -package sys +package mount import ( "io/ioutil" @@ -32,7 +32,7 @@ import ( type fMountatCaseFunc func(t *testing.T, root string) func TestFMountat(t *testing.T) { - if !runningPrivileged() { + if unix.Geteuid() != 0 { t.Skip("Needs to be run as root") return } diff --git a/mount/mount_linux.go b/mount/mount_linux.go index 3f05ebc89..e0e066b31 100644 --- a/mount/mount_linux.go +++ b/mount/mount_linux.go @@ -24,7 +24,6 @@ import ( "strings" "time" - "github.com/containerd/containerd/sys" "github.com/pkg/errors" "golang.org/x/sys/unix" ) @@ -378,7 +377,7 @@ func mountAt(chdir string, source, target, fstype string, flags uintptr, data st if !fs.IsDir() { return errors.Wrap(errors.Errorf("%s is not dir", chdir), "failed to mountat") } - return errors.Wrap(sys.FMountat(f.Fd(), source, target, fstype, flags, data), "failed to mountat") + return errors.Wrap(FMountat(f.Fd(), source, target, fstype, flags, data), "failed to mountat") } func (m *Mount) mountWithHelper(helperBinary, typePrefix, target string) error { diff --git a/sys/subprocess_unsafe_linux.go b/mount/subprocess_unsafe_linux.go similarity index 98% rename from sys/subprocess_unsafe_linux.go rename to mount/subprocess_unsafe_linux.go index 6e40a9c7d..c7cb0c034 100644 --- a/sys/subprocess_unsafe_linux.go +++ b/mount/subprocess_unsafe_linux.go @@ -14,7 +14,7 @@ limitations under the License. */ -package sys +package mount import ( _ "unsafe" // required for go:linkname. diff --git a/sys/subprocess_unsafe_linux.s b/mount/subprocess_unsafe_linux.s similarity index 100% rename from sys/subprocess_unsafe_linux.s rename to mount/subprocess_unsafe_linux.s