MCPcopy
hub / github.com/containerd/containerd / mountAt

Function mountAt

core/mount/mount_linux.go:513–548  ·  view source on GitHub ↗
(chdir string, source, target, fstype string, flags uintptr, data string)

Source from the content-addressed store, hash-verified

511}
512
513func mountAt(chdir string, source, target, fstype string, flags uintptr, data string) error {
514 if chdir == "" {
515 err := unix.Mount(source, target, fstype, flags, data)
516 if err != nil {
517 return fmt.Errorf("mount source: %q, target: %q, fstype: %s, flags: %d, data: %q, err: %w", source, target, fstype, flags, data, err)
518 }
519 return nil
520 }
521
522 ch := make(chan error, 1)
523 go func() {
524 runtime.LockOSThread()
525
526 // Do not unlock this thread.
527 // If the thread is unlocked go will try to use it for other goroutines.
528 // However it is not possible to restore the thread state after CLONE_FS.
529 //
530 // Once the goroutine exits the thread should eventually be terminated by go.
531
532 if err := unix.Unshare(unix.CLONE_FS); err != nil {
533 ch <- err
534 return
535 }
536
537 if err := unix.Chdir(chdir); err != nil {
538 ch <- err
539 return
540 }
541 err := unix.Mount(source, target, fstype, flags, data)
542 if err != nil {
543 err = fmt.Errorf("mount source: %q, target: %q, fstype: %s, flags: %d, data: %q, err: %w", source, target, fstype, flags, data, err)
544 }
545 ch <- err
546 }()
547 return <-ch
548}
549
550func (m *Mount) mountWithHelper(helperBinary, typePrefix, target string) error {
551 // helperBinary: "mount.fuse3"

Callers 2

TestMountAtFunction · 0.85
mountMethod · 0.85

Calls 1

MountMethod · 0.65

Tested by 1

TestMountAtFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…