(chdir string, source, target, fstype string, flags uintptr, data string)
| 511 | } |
| 512 | |
| 513 | func 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 | |
| 550 | func (m *Mount) mountWithHelper(helperBinary, typePrefix, target string) error { |
| 551 | // helperBinary: "mount.fuse3" |
searching dependent graphs…