Merge pull request #5641 from thaJeztah/move_sys_fmountat
move sys.FMountat() into mount package and un-export
This commit is contained in:
commit
c8c6eed932
@ -14,7 +14,7 @@
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package sys
|
||||
package mount
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
@ -26,8 +26,8 @@ import (
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
// FMountat performs mount from the provided directory.
|
||||
func FMountat(dirfd uintptr, source, target, fstype string, flags uintptr, data string) error {
|
||||
// fMountat performs mount from the provided directory.
|
||||
func fMountat(dirfd uintptr, source, target, fstype string, flags uintptr, data string) error {
|
||||
var (
|
||||
sourceP, targetP, fstypeP, dataP *byte
|
||||
pid uintptr
|
@ -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
|
||||
}
|
||||
@ -88,7 +88,7 @@ func testFMountatNormal(t *testing.T, root string) {
|
||||
defer f.Close()
|
||||
|
||||
// mount work to fs
|
||||
if err = FMountat(f.Fd(), workdir, "fs", "bind", unix.MS_BIND|unix.MS_RDONLY, ""); err != nil {
|
||||
if err = fMountat(f.Fd(), workdir, "fs", "bind", unix.MS_BIND|unix.MS_RDONLY, ""); err != nil {
|
||||
t.Fatalf("expected no error here, but got error: %+v", err)
|
||||
}
|
||||
defer umount(t, fsdir)
|
||||
@ -124,7 +124,7 @@ func testFMountatWithFileFd(t *testing.T, root string) {
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
err = FMountat(f.Fd(), filepath.Join(root, "empty"), filepath.Join(root, "work"), "", 0, "")
|
||||
err = fMountat(f.Fd(), filepath.Join(root, "empty"), filepath.Join(root, "work"), "", 0, "")
|
||||
if !errors.Is(err, expectedErr) {
|
||||
t.Fatalf("expected error %v, but got %v", expectedErr, errors.Cause(err))
|
||||
}
|
||||
@ -145,7 +145,7 @@ func testFMountatWithInvalidSource(t *testing.T, root string) {
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
err = FMountat(f.Fd(), filepath.Join(root, "oops"), "at", "bind", unix.MS_BIND, "")
|
||||
err = fMountat(f.Fd(), filepath.Join(root, "oops"), "at", "bind", unix.MS_BIND, "")
|
||||
if !errors.Is(err, expectedErr) {
|
||||
t.Fatalf("expected error %v, but got %v", expectedErr, err)
|
||||
}
|
@ -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 {
|
||||
|
@ -14,7 +14,7 @@
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package sys
|
||||
package mount
|
||||
|
||||
import (
|
||||
_ "unsafe" // required for go:linkname.
|
Loading…
Reference in New Issue
Block a user