Opened 11 years ago
Last modified 11 years ago
#5850 assigned Bugs
last_write_time on Windows may not work on SMB2-network-mounted drive
Reported by: | Owned by: | Beman Dawes | |
---|---|---|---|
Milestone: | To Be Determined | Component: | filesystem |
Version: | Boost 1.47.0 | Severity: | Problem |
Keywords: | last_write_time network file | Cc: | cnewbold@… |
Description
Consider the following logical operation against a file on a network-mounted drive served over SMB2:
- fopen("r+b")/fwrite/fclose a file.
- boost::filesystem::last_write_time(file, some other specific time)
- fopen("rb")/fclose a file.
As soon as the file is opened in step 3, it appears that the SMB2/redirector actually closes the file and "flushes" its pending write in service of step 1. This has the effect of overwriting the time modification in step 2.
I believe this is happening because boost's non-POSIX/Windows implementation of last_write_time uses CreateFile() and asks only for FILE_WRITE_ATTRIBUTES. Using GENERIC_WRITE appears to work correctly.
Also note, calling utime() instead of boost::filesystem::last_write_time() works correctly.
Please see attached test code demonstrating boost's failure, utime()'s success, and native API workaround.
Please feel free to contact me for follow up. Thanks, -Ken