Skip to content

Commit

Permalink
sandbox: Bind mount on top of symlink if possible
Browse files Browse the repository at this point in the history
Instead of mounting on top of the resolved symlink, let's just mount
directly on top of the symlink if we can.
  • Loading branch information
DaanDeMeyer committed Nov 29, 2024
1 parent 07ef37c commit 7128427
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion mkosi/sandbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,11 +459,16 @@ def __eq__(self, other: object) -> bool:

def execute(self, oldroot: str, newroot: str) -> None:
src = chase(oldroot, self.src)
dst = chase(newroot, self.dst)

if not os.path.exists(src) and not self.required:
return

# If we're mounting a file on top of a symlink, mount directly on top of the symlink instead of
# resolving it.
if not os.path.isdir(src) and os.path.islink(self.dst):
return mount_rbind(src, self.dst, attrs=MOUNT_ATTR_RDONLY if self.readonly else 0)

dst = chase(newroot, self.dst)
if not os.path.exists(dst):
isfile = os.path.isfile(src)

Expand Down

0 comments on commit 7128427

Please sign in to comment.