Version
main
Platform
Subsystem
vfs
What steps will reproduce the bug?
import fs from 'node:fs';
import path from 'node:path';
import vfs from 'node:vfs';
const mountPoint = path.resolve(`/tmp/vfs-lchown-${process.pid}`);
const virtualFs = vfs.create({ emitExperimentalWarning: false });
virtualFs.writeFileSync('/target.txt', 'target');
virtualFs.symlinkSync('/target.txt', '/link.txt');
virtualFs.mount(mountPoint);
fs.lchownSync(path.join(mountPoint, 'link.txt'), 123, 456);
virtualFs.unmount();
const targetStats = virtualFs.lstatSync('/target.txt');
const linkStats = virtualFs.lstatSync('/link.txt');
console.log({
target: { uid: targetStats.uid, gid: targetStats.gid },
link: { uid: linkStats.uid, gid: linkStats.gid },
});
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
{
target: { uid: 0, gid: 0 },
link: { uid: 123, gid: 456 }
}
lchown should not follow the symlink; it should update the symlink’s own metadata and leave the target unchanged.
What do you see instead?
{
target: { uid: 123, gid: 456 },
link: { uid: 0, gid: 0 }
}
fs.lchownSync() updates the symlink target’s uid/gid while the symlink itself remains unchanged.
Additional information
No response
Version
main
Platform
Subsystem
vfs
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
lchownshould not follow the symlink; it should update the symlink’s own metadata and leave the target unchanged.What do you see instead?
fs.lchownSync()updates the symlink target’s uid/gid while the symlink itself remains unchanged.Additional information
No response