Skip to contentSkip to conversation

smb: client: report correct st_size for SMB and NFS symlinks

PATCH New Paulo Alcantara 1 participant 1 message Nov 28, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 smb: client: report correct st_size for SMB and NFS symlinks

We can't rely on FILE_STANDARD_INFORMATION::EndOfFile for reparse points as they will be always zero. Set it to symlink target's length as specified by POSIX.

This will make stat() family of syscalls return the correct st_size for such files.

---
 fs/smb/client/inode.c | 2 ++
 1 file changed, 2 insertions(+)
fs/smb/client/inode.c +2 -0
index 01c7d2973d66..0b05e664008e 100644
@@ -866,6 +866,8 @@ static void cifs_open_info_to_fattr(struct cifs_fattr *fattr,
 
 out_reparse:
 	if (S_ISLNK(fattr->cf_mode)) {
+		if (likely(data->symlink_target))
+			fattr->cf_eof = strnlen(data->symlink_target, PATH_MAX);
 		fattr->cf_symlink_target = data->symlink_target;
 		data->symlink_target = NULL;
 	}
Signature · 1 line
2.43.0