On 2012-09-16, at 12:46 PM, Li Xi wrote:
> 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?

Definitely looks like a bug.  Could you please file a ticket at 
http://bugs.whamcloud.com/ and submit a patch for this?  Please see the 
http://wiki.whamcloud.com/display/PUB/Submitting+Changes page for details.

Cheers, Andreas
--
Andreas Dilger                       Whamcloud, Inc.
Principal Lustre Engineer            http://www.whamcloud.com/




_______________________________________________
Lustre-discuss mailing list
[email protected]
http://lists.lustre.org/mailman/listinfo/lustre-discuss

Reply via email to