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: Ken Harris <kharris@…> 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:

  1. fopen("r+b")/fwrite/fclose a file.
  2. boost::filesystem::last_write_time(file, some other specific time)
  3. 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

Attachments (1)

bbug.cpp (3.9 KB ) - added by Ken Harris <kharris@…> 11 years ago.

Download all attachments as: .zip

Change History (2)

by Ken Harris <kharris@…>, 11 years ago

Attachment: bbug.cpp added

comment:1 by Beman Dawes, 11 years ago

Status: newassigned
Note: See TracTickets for help on using tickets.