linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Why does d_splice_alias need to check IS_ROOT?
@ 2018-05-26 16:33 Lei Chen
  2018-05-26 17:12 ` Al Viro
  0 siblings, 1 reply; 3+ messages in thread
From: Lei Chen @ 2018-05-26 16:33 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, viro

Hello list,

I'm insteresting in how hard link and denry lookup work and their
implementation.

I know that this interface tries to connect an inode to a dentry, but
why does it need
to check whether the inode alias IS_ROOT if the inode represents a directory?
And the code process in different way according to check result.  What
occasions
are they used for?

struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry)
{
    if (S_ISDIR(inode->i_mode)) {
        struct dentry *new = __d_find_any_alias(inode);
        if (unlikely(new)) {
            if (unlikely(d_ancestor(new, dentry))) {
                /*the code here is to forbidden ancestor hard link*/
            } else if (!IS_ROOT(new)) {
                __d_unalias(inode, dentry, new);
            } else {
                __d_move(new, dentry, false);
            }

        }


    }
}

Thanks in advance.

Regards,
Larry

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-05-27 11:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-26 16:33 Why does d_splice_alias need to check IS_ROOT? Lei Chen
2018-05-26 17:12 ` Al Viro
2018-05-27 11:09   ` Lei Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).