Commit 1cb9bb8
Roy Lin
fix(box): single-file bind mount no longer clobbers parent dir
A '-v /host/file:/etc/app.conf' mount destroyed the entire target parent
directory (/etc lost hostname/passwd/etc.). The shim correctly converts a
file mount to a temp-dir virtio-fs share, but the guest mounted that share
*over the parent dir* (/etc), and the two sides decided file-vs-dir with
disagreeing heuristics (shim: host_path.is_file(); guest: dot-in-name).
- Host (spec.rs) is now authoritative: emits an explicit ':file' flag on
BOX_VOL_<i> when the source path stats as a file.
- Guest (init) obeys the flag: mounts the share at a private mountpoint,
then bind-mounts only the file onto guest_path, preserving the parent.
Honors :ro via an MS_REMOUNT pass. Dir mounts unchanged.
- Shim: per-mount temp dir keyed by tag so two file mounts sharing a
basename don't collide.
Verified on KVM: file content present at target; /etc intact (37 entries,
hostname present) vs clobbered (1 entry) before; :ro rejects writes and
leaves host file unchanged; dir mounts still read+write-back. Known limit:
rw single-file writes are guest-isolated (share is a copy), not written
back to the host file.1 parent 493bb07 commit 1cb9bb8
3 files changed
Lines changed: 81 additions & 52 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
692 | 692 | | |
693 | 693 | | |
694 | 694 | | |
695 | | - | |
696 | | - | |
697 | | - | |
698 | | - | |
699 | | - | |
700 | | - | |
701 | | - | |
702 | | - | |
703 | | - | |
704 | | - | |
705 | | - | |
706 | | - | |
707 | | - | |
708 | | - | |
709 | | - | |
710 | | - | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
711 | 730 | | |
712 | | - | |
713 | | - | |
714 | | - | |
715 | | - | |
716 | | - | |
717 | | - | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
718 | 757 | | |
719 | 758 | | |
720 | 759 | | |
721 | 760 | | |
722 | | - | |
723 | | - | |
724 | 761 | | |
725 | | - | |
| 762 | + | |
726 | 763 | | |
727 | 764 | | |
728 | | - | |
729 | | - | |
730 | | - | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
731 | 768 | | |
732 | 769 | | |
733 | 770 | | |
734 | 771 | | |
735 | | - | |
| 772 | + | |
736 | 773 | | |
737 | 774 | | |
738 | 775 | | |
739 | | - | |
740 | | - | |
741 | | - | |
742 | | - | |
743 | | - | |
744 | | - | |
745 | | - | |
746 | | - | |
747 | | - | |
748 | | - | |
749 | | - | |
750 | | - | |
751 | | - | |
752 | | - | |
753 | | - | |
754 | | - | |
755 | | - | |
756 | | - | |
757 | | - | |
758 | | - | |
759 | | - | |
760 | 776 | | |
761 | 777 | | |
762 | 778 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
164 | 174 | | |
165 | 175 | | |
166 | | - | |
| 176 | + | |
167 | 177 | | |
168 | 178 | | |
169 | 179 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
455 | 455 | | |
456 | 456 | | |
457 | 457 | | |
458 | | - | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
459 | 462 | | |
460 | 463 | | |
461 | 464 | | |
| |||
0 commit comments