[Boost-bugs] [Boost C++ Libraries] #5850: last_write_time on Windows may not work on SMB2-network-mounted drive

Subject: [Boost-bugs] [Boost C++ Libraries] #5850: last_write_time on Windows may not work on SMB2-network-mounted drive
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-08-31 15:22:14


#5850: last_write_time on Windows may not work on SMB2-network-mounted drive
------------------------------------------------+---------------------------
 Reporter: Ken Harris <kharris@…> | Owner: bemandawes
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: filesystem
  Version: Boost 1.47.0 | Severity: Problem
 Keywords: last_write_time network file |
------------------------------------------------+---------------------------
 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

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/5850>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:07 UTC