elementary d_move question
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....
--b.
Jan Kara
reviewerQuoted 14 lines · J. Bruce Fields
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.
Quoted 7 lines
But
d_move()doesswitch_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
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR