diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c index 06197275956d..283527337d0c 100644 --- a/fs/smb/server/smb2pdu.c +++ b/fs/smb/server/smb2pdu.c @@ -2934,6 +2934,16 @@ static void smb2_update_xattrs(struct ksmbd_tree_connect *tcon, rc = ksmbd_vfs_get_dos_attrib_xattr(mnt_idmap(path->mnt), path->dentry, &da); if (rc > 0) { + /* + * Don't report a stale SPARSE bit (e.g. left over from a + * previous client, or from before the share was reconfigured) + * when the share isn't currently advertising sparse-file + * support. Time Machine sparsebundle band files rely on + * sparse status being accurate, since macOS decides whether + * to use FSCTL_SET_SPARSE based on it. + */ + if (!(server_conf.share_fake_fscaps & FILE_SUPPORTS_SPARSE_FILES)) + da.attr &= ~FILE_ATTRIBUTE_SPARSE_FILE; fp->f_ci->m_fattr = cpu_to_le32(da.attr); fp->create_time = da.create_time; fp->itime = da.itime;