Skip to content

Commit ae2cd7f

Browse files
Paulo Alcantarasmfrench
authored andcommitted
cifs: smb2ops: Fix listxattr() when there are no EAs
As per listxattr(2): On success, a nonnegative number is returned indicating the size of the extended attribute name list. On failure, -1 is returned and errno is set appropriately. In SMB1, when the server returns an empty EA list through a listxattr(), it will correctly return 0 as there are no EAs for the given file. However, in SMB2+, it returns -ENODATA in listxattr() which is wrong since the request and response were sent successfully, although there's no actual EA for the given file. This patch fixes listxattr() for SMB2+ by returning 0 in cifs_listxattr() when the server returns an empty list of EAs. Signed-off-by: Paulo Alcantara <[email protected]> Reviewed-by: Aurelien Aptel <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent f7c4396 commit ae2cd7f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

fs/cifs/smb2ops.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,9 +589,15 @@ smb2_query_eas(const unsigned int xid, struct cifs_tcon *tcon,
589589

590590
SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
591591

592+
/*
593+
* If ea_name is NULL (listxattr) and there are no EAs, return 0 as it's
594+
* not an error. Otherwise, the specified ea_name was not found.
595+
*/
592596
if (!rc)
593597
rc = move_smb2_ea_to_cifs(ea_data, buf_size, smb2_data,
594598
SMB2_MAX_EA_BUF, ea_name);
599+
else if (!ea_name && rc == -ENODATA)
600+
rc = 0;
595601

596602
kfree(smb2_data);
597603
return rc;

0 commit comments

Comments
 (0)