lookup_one_len

lookup_one_len

fs/namei.c

ファイル名に対応するdentryを探す。なければdentryを確保する。

/* SMP-safe */
struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
{
        unsigned long hash;
        struct qstr this;
        unsigned int c;

        this.name = name;
        this.len = len;
        if (!len)
                goto access;

        hash = init_name_hash();
        while (len--) {
                c = *(const unsigned char *)name++;
                if (c == '/' || c == '\0')
                        goto access;
                hash = partial_name_hash(c, hash);
        }
        this.hash = end_name_hash(hash);

        return __lookup_hash(&this, base, NULL);
access:
        return ERR_PTR(-EACCES);
}

lookup_hashが__lookup_hashに変更された模様。

以下はdebian sarge の kernel 2.6.3。

/* SMP-safe */
struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
{
        unsigned long hash;
        struct qstr this;
        unsigned int c;

        this.name = name;
        this.len = len;
        if (!len)
                goto access;

        hash = init_name_hash();
        while (len--) {
                c = *(const unsigned char *)name++;
                if (c == '/' || c == '\0')
                        goto access;
                hash = partial_name_hash(c, hash);
        }
        this.hash = end_name_hash(hash);

        return lookup_hash(&this, base);
access:
        return ERR_PTR(-EACCES);
}