bunpen: fix edge-case where we wouldnt deref (and bind the underlying path of) a symlink under an already-mounted directory

This commit is contained in:
2024-09-03 16:05:28 +00:00
parent 8a61ad704a
commit 181bc57a8a

View File

@@ -255,10 +255,13 @@ fn bind_component(ctx: *ns_ctx, strpath: str, remaining: str) (void | fs::error
let st = fs::stat(ctx.old_fs, strpath)?; let st = fs::stat(ctx.old_fs, strpath)?;
if (fs::islink(st.mode)) { if (fs::islink(st.mode)) {
if (new_exists) return; // we already made the link
let linktext = fs::readlink(ctx.old_fs, strpath)?; let linktext = fs::readlink(ctx.old_fs, strpath)?;
log::printfln("[namespace/bind] ln new/{} -> {}", strpath, linktext); if (!new_exists) {
fs::symlink(ctx.new_fs, linktext, strpath)?; // we already made the link (but not necessarily what's *behind* it: maybe
// we bind-mounted its directory, and still need to mount the underlying)
log::printfln("[namespace/bind] ln new/{} -> {}", strpath, linktext);
fs::symlink(ctx.new_fs, linktext, strpath)?;
};
// bind the real path (or, the "more real" path, in case there are // bind the real path (or, the "more real" path, in case there are
// multiple layers of symlink). // multiple layers of symlink).