On Wed 23-10-13 11:46:54, J. Bruce Fields wrote: > If I rename foo over bar, while holding bar open, then > /proc/<pid>/fd/<fd> still shows me bar's old path: > > $ touch foo bar > $ tail -f bar & > [1] 23492 > $ mv foo bar > $ readlink /proc/23492/fd/3 > /home/bfields/bar (deleted) > > The rename does a d_move(dentry, target) where I assume dentry is for > "foo" and target for "bar", with target the same dentry that the file > descriptor holds a reference on. > > But d_move() does > > switch_names(dentry, target); > > giving target name "foo". So how does readlink still get "bar"? > > I've clearly missed something obvious.... You didn't read switch_names() carefully enough :) (and I didn't either on the first reading). There is one (the common) case when the switching doesn't happen and the name is only copied from 'target' to 'dentry' so target's name remains intact... Honza -- Jan Kara <jack@xxxxxxx> SUSE Labs, CR -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html