Question

As you can see in http://lxr.linux.no/#linux+v3.9.5/fs/namei.c#L1751

    for(;;) {
            struct qstr this;
            long len;
            int type;

            err = may_lookup(nd);
            if (err)
                    break;

            len = hash_name(name, &this.hash);

at the last line, I never find struct qstr has a member name hash, only thing I found is:

struct qstr {
        union { 
                struct {
                        HASH_LEN_DECLARE;
                };
                u64 hash_len;
        };
        const unsigned char *name;
};

can anyone tell me what happened?

Was it helpful?

Solution

Here you can find that HASH_LEN_DECLARE is defined as:

/* The hash is always the low bits of hash_len */
#ifdef __LITTLE_ENDIAN
#define HASH_LEN_DECLARE u32 hash; u32 len;
#else
#define HASH_LEN_DECLARE u32 len; u32 hash;
#endif

if little-endian (machine stores the least significant byte first) hash is the first member, else hash is the last member.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top