/* Returns a negative error number on failure, or the number of bytes used / required on success.  */
static int ext4_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size)
/* Returns a negative error number on failure, or the number of bytes used / required on success.  */
static int ext4_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size)
{
	int i_error, b_error;
	down_read(&EXT4_I(dentry->d_inode)->xattr_sem);
	i_error = ext4_xattr_ibody_list(dentry, buffer, buffer_size);
	if (i_error < 0) {
		b_error = 0;
	} else {
		if (buffer) {
			buffer += i_error;
			buffer_size -= i_error;
		}
		b_error = ext4_xattr_block_list(dentry, buffer, buffer_size);
		if (b_error < 0)
			i_error = 0;
	}
	up_read(&EXT4_I(dentry->d_inode)->xattr_sem);
	return i_error + b_error;
}