[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lustre-discuss
Subject:    [Lustre-discuss] A question about ll_listxattr()
From:       adilger () whamcloud ! com (Andreas Dilger)
Date:       2012-09-18 7:22:38
Message-ID: 9782817D-B467-44B9-BAB6-7E3D2B7D954A () whamcloud ! com
[Download RAW message or body]

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/


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic