[Lustre-discuss] A question about ll_listxattr()

Li Xi pkuelelixi at gmail.com
Sun Sep 16 09:46:53 PDT 2012


I have a question about function ll_listxattr(). According to the standard,
listxattr(2) should return -1if the size of the list buffer is too small to
hold the result. However ll_listxattr() will return a value bigger than
buffer size in some cases.

Let's assume listxattr(2) returns SIZE when it is called with a large
enough list buffer. If it's called with a list buffer whose size is smaller
than SIZE but bigger than SIZE-12, then listxattr(2)  will return SIZE too.
I got the result on Lustre-2.2. I believe it is not a correct result.

The following codes in ll_listxattr() causes this problem:

                if (buffer && (rc + total_len) <= size) {
                        buffer += rc;
                        memcpy(buffer,XATTR_LUSTRE_PREFIX, prefix_len);
                        memcpy(buffer+prefix_len, "lov", name_len);
                        buffer[prefix_len + name_len] = '\0';
                rc2 = total_len;

I think when '(rc + total_len) <= size' is false and the buffer is not
NULL, the return valuse should be set to -1.

Is that a problem or a feature?


Li Xi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lustre.org/pipermail/lustre-discuss-lustre.org/attachments/20120917/6262463b/attachment.htm>

More information about the lustre-discuss mailing list