<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0"
    xmlns:hatena="http://www.hatena.ne.jp/info/xmlns#"
    xml:lang="ja">
    <channel>
        <title>Linux kernel source - lookup_one_len</title>
        <link>http://kernel.g.hatena.ne.jp/keyword/lookup_one_len</link>
        <description>Linux kernel source - lookup_one_len</description>
        <language>ja</language>
    </channel>

    <item>
        <title>lookup_one_len</title>
        <link>http://kernel.g.hatena.ne.jp/keyword/lookup_one_len?kid=101</link>
        <description><![CDATA[
		<div class="section">
			<p><a class="keyword" href="http://kernel.g.hatena.ne.jp/keyword/fs/namei%2Ec">fs/namei.c</a></p>
			<p>ファイル名に対応するdentryを探す。なければdentryを確保する。</p>
<pre>
/* SMP-safe */
<a class="keyword" href="http://kernel.g.hatena.ne.jp/keyword/struct%20dentry">struct dentry</a> * <a class="keyword" href="http://kernel.g.hatena.ne.jp/keyword/lookup_one_len">lookup_one_len</a>(<a class="okeyword" href="http://d.hatena.ne.jp/keyword/const">const</a> <a class="okeyword" href="http://d.hatena.ne.jp/keyword/char">char</a> * name, <a class="keyword" href="http://kernel.g.hatena.ne.jp/keyword/struct%20dentry">struct dentry</a> * <a class="okeyword" href="http://d.hatena.ne.jp/keyword/base">base</a>, int <a class="okeyword" href="http://d.hatena.ne.jp/keyword/len">len</a>)
{
        unsigned long hash;
        <a class="keyword" href="http://kernel.g.hatena.ne.jp/keyword/struct%20qstr">struct qstr</a> this;
        unsigned int c;

        this.name = name;
        this.<a class="okeyword" href="http://d.hatena.ne.jp/keyword/len">len</a> = <a class="okeyword" href="http://d.hatena.ne.jp/keyword/len">len</a>;
        if (!<a class="okeyword" href="http://d.hatena.ne.jp/keyword/len">len</a>)
                goto <a class="okeyword" href="http://d.hatena.ne.jp/keyword/access">access</a>;

        hash = init_name_hash();
        while (<a class="okeyword" href="http://d.hatena.ne.jp/keyword/len">len</a>--) {
                c = *(<a class="okeyword" href="http://d.hatena.ne.jp/keyword/const">const</a> unsigned <a class="okeyword" href="http://d.hatena.ne.jp/keyword/char">char</a> *)name++;
                if (c == '/' || c == '\0')
                        goto <a class="okeyword" href="http://d.hatena.ne.jp/keyword/access">access</a>;
                hash = partial_name_hash(c, hash);
        }
        this.hash = end_name_hash(hash);

        return __lookup_hash(&this, <a class="okeyword" href="http://d.hatena.ne.jp/keyword/base">base</a>, NULL);
<a class="okeyword" href="http://d.hatena.ne.jp/keyword/access">access</a>:
        return ERR_PTR(-EACCES);
}
</pre>
			<p>lookup_hashが__lookup_hashに変更された模様。</p>
			<p>以下は<a class="okeyword" href="http://d.hatena.ne.jp/keyword/debian">debian</a> sarge の kernel 2.6.3。</p>
<pre>
/* SMP-safe */
<a class="keyword" href="http://kernel.g.hatena.ne.jp/keyword/struct%20dentry">struct dentry</a> * <a class="keyword" href="http://kernel.g.hatena.ne.jp/keyword/lookup_one_len">lookup_one_len</a>(<a class="okeyword" href="http://d.hatena.ne.jp/keyword/const">const</a> <a class="okeyword" href="http://d.hatena.ne.jp/keyword/char">char</a> * name, <a class="keyword" href="http://kernel.g.hatena.ne.jp/keyword/struct%20dentry">struct dentry</a> * <a class="okeyword" href="http://d.hatena.ne.jp/keyword/base">base</a>, int <a class="okeyword" href="http://d.hatena.ne.jp/keyword/len">len</a>)
{
        unsigned long hash;
        <a class="keyword" href="http://kernel.g.hatena.ne.jp/keyword/struct%20qstr">struct qstr</a> this;
        unsigned int c;

        this.name = name;
        this.<a class="okeyword" href="http://d.hatena.ne.jp/keyword/len">len</a> = <a class="okeyword" href="http://d.hatena.ne.jp/keyword/len">len</a>;
        if (!<a class="okeyword" href="http://d.hatena.ne.jp/keyword/len">len</a>)
                goto <a class="okeyword" href="http://d.hatena.ne.jp/keyword/access">access</a>;

        hash = init_name_hash();
        while (<a class="okeyword" href="http://d.hatena.ne.jp/keyword/len">len</a>--) {
                c = *(<a class="okeyword" href="http://d.hatena.ne.jp/keyword/const">const</a> unsigned <a class="okeyword" href="http://d.hatena.ne.jp/keyword/char">char</a> *)name++;
                if (c == '/' || c == '\0')
                        goto <a class="okeyword" href="http://d.hatena.ne.jp/keyword/access">access</a>;
                hash = partial_name_hash(c, hash);
        }
        this.hash = end_name_hash(hash);

        return lookup_hash(&this, <a class="okeyword" href="http://d.hatena.ne.jp/keyword/base">base</a>);
<a class="okeyword" href="http://d.hatena.ne.jp/keyword/access">access</a>:
        return ERR_PTR(-EACCES);
}
</pre>
		</div>
]]></description>
        <pubDate>Wed, 16 Apr 2008 01:32:03 +0900</pubDate>

    </item>

</rss>

