Commit 57ce9f7
smb: client: fix missing timestamp updates after ftruncate(2)
Mask off ATTR_MTIME|ATTR_CTIME bits on ATTR_SIZE (e.g. ftruncate(2))
to prevent the client from sending set info calls and then disabling
automatic timestamp updates on server side as per MS-FSA 2.1.4.17.
---8<---
import os
import time
filename = '/mnt/foo'
def print_stat(prefix):
st = os.stat(filename)
print(prefix, ': ', time.ctime(st.st_atime), time.ctime(st.st_ctime))
fd = os.open(filename, os.O_CREAT|os.O_TRUNC|os.O_WRONLY, 0o644)
print_stat('old')
os.ftruncate(fd, 10)
time.sleep(2)
os.write(fd, b'foo')
os.close(fd)
time.sleep(2)
print_stat('new')
---8<---
Before patch:
$ mount.cifs //srv/share /mnt -o ...
$ python3 run.py
old : Fri Oct 3 13:47:03 2025 Fri Oct 3 13:47:03 2025
new : Fri Oct 3 13:47:00 2025 Fri Oct 3 13:47:03 2025
After patch:
$ mount.cifs //srv/share /mnt -o ...
$ python3 run.py
old : Fri Oct 3 13:48:39 2025 Fri Oct 3 13:48:39 2025
new : Fri Oct 3 13:48:41 2025 Fri Oct 3 13:48:41 2025
Signed-off-by: Paulo Alcantara (Red Hat) <pc@manguebit.org>
Cc: Frank Sorenson <sorenson@redhat.com>
Reviewed-by: David Howells <dhowells@redhat.com>
Cc: linux-cifs@vger.kernel.org
Signed-off-by: Steve French <stfrench@microsoft.com>1 parent 110fee6 commit 57ce9f7
1 file changed
Lines changed: 8 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3156 | 3156 | | |
3157 | 3157 | | |
3158 | 3158 | | |
3159 | | - | |
3160 | | - | |
3161 | | - | |
| 3159 | + | |
| 3160 | + | |
| 3161 | + | |
3162 | 3162 | | |
3163 | | - | |
3164 | | - | |
| 3163 | + | |
3165 | 3164 | | |
3166 | 3165 | | |
3167 | 3166 | | |
| |||
3335 | 3334 | | |
3336 | 3335 | | |
3337 | 3336 | | |
3338 | | - | |
3339 | | - | |
3340 | | - | |
| 3337 | + | |
| 3338 | + | |
| 3339 | + | |
3341 | 3340 | | |
3342 | | - | |
3343 | | - | |
| 3341 | + | |
3344 | 3342 | | |
3345 | 3343 | | |
3346 | 3344 | | |
| |||
0 commit comments