Re: [PATCH] tmpfs: implement generic xattr support

From: Michal Suchanek
Date: Thu Apr 21 2011 - 03:00:22 EST


On 20 April 2011 15:43, Miklos Szeredi <miklos@xxxxxxxxxx> wrote:
> Phillip Lougher <phillip.lougher@xxxxxxxxx> writes:
>
>> On Tue, Apr 19, 2011 at 9:04 PM, Miklos Szeredi <miklos@xxxxxxxxxx> wrote:
>>
>>> +static ssize_t shmem_listxattr(struct dentry *dentry, char *buffer, size_t size)
>>
>>> + Â Â Â spin_lock(&dentry->d_inode->i_lock);
>>> + Â Â Â list_for_each_entry(xattr, &info->xattr_list, list) {
>>> + Â Â Â Â Â Â Â /* skip "trusted." attributes for unprivileged callers */
>>> + Â Â Â Â Â Â Â if (!trusted && xattr_is_trusted(xattr->name))
>>> + Â Â Â Â Â Â Â Â Â Â Â continue;
>>> +
>>> + Â Â Â Â Â Â Â used += strlen(xattr->name) + 1;
>>> + Â Â Â Â Â Â Â if (buffer) {
>>> + Â Â Â Â Â Â Â Â Â Â Â if (size < used) {
>>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â used = -ERANGE;
>>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â break;
>>> + Â Â Â Â Â Â Â Â Â Â Â }
>>> + Â Â Â Â Â Â Â Â Â Â Â strncpy(buffer, xattr->name, strlen(xattr->name) + 1);
>>>+ Â Â Â Â Â Â Â Â Â Â Â Âbuffer += strlen(xattr->name) + 1;
>>
>> Why are you doing a strncpy here? Âstrcpy() isn't going to copy more
>> than strlen(xattr->name) + 1 bytes, and you know buffer is large
>> enough to hold that because of the previous if (size < used) check?
>>
>> If you assigned the first strlen(xattr->name) + 1 to a temporary
>> variable, you could use memcpy here, and avoid the 3 repeated
>> strlen(xattr->name) calls.
>
> Yeah, makes sense.
>

Can you put up a branch with both overlayfs and xattrs?

I would like to point people at a repo with working implementation and
mirroring the kernel tree to add one patch is a bit overkill.

Thanks

Michal
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/