linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lei Chen <losemyheaven@gmail.com>
To: linux-fsdevel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, viro@zeniv.linux.org.uk
Subject: Why does d_splice_alias need to check IS_ROOT?
Date: Sun, 27 May 2018 00:33:40 +0800	[thread overview]
Message-ID: <CAKEZqKJhZNoF-29ymEmAjiYfVn64q5mHrMY9sC2NZ=EDqTHjeA@mail.gmail.com> (raw)

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

             reply	other threads:[~2018-05-26 16:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-26 16:33 Lei Chen [this message]
2018-05-26 17:12 ` Why does d_splice_alias need to check IS_ROOT? Al Viro
2018-05-27 11:09   ` Lei Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAKEZqKJhZNoF-29ymEmAjiYfVn64q5mHrMY9sC2NZ=EDqTHjeA@mail.gmail.com' \
    --to=losemyheaven@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).