Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Question about tmpfs



Hi,
I have a question regarding the function tmpfs_alloc_node() in
fs/tmpfs/tmpfs_subr.c. When alloc'ing the area for symlinks,
there's this code:

l.171
        nnode->tn_size = strlen(target);
        if (nnode->tn_size == 0) {
                nnode->tn_spec.tn_lnk.tn_link = NULL;
                break;
        }
        nnode->tn_spec.tn_lnk.tn_link =
            tmpfs_strname_alloc(tmp, nnode->tn_size);
        if (nnode->tn_spec.tn_lnk.tn_link == NULL) {
                tmpfs_node_put(tmp, nnode);
                return ENOSPC;
        }
        memcpy(nnode->tn_spec.tn_lnk.tn_link, target, nnode->tn_size);

Only strlen(target) bytes are allocated for 'target', and only
strlen(target) bytes are copied from 'target' to 'tn_link'.

Why isn't the '\0' taken into account? Is this intentional?

Thanks.


Home | Main Index | Thread Index | Old Index