[vbox-dev] Possibly a way to fix Ticket #6473 Wrong timestamp for files write in shared folders
frank.mehnert at oracle.com
Wed Feb 29 13:33:27 PST 2012
actually this was a helpful investigation. Indeed the file modification
time is handled different between a Windows host and a Linux host when
using RTFileWrite and a Windows guest does apparently first open the
file, then sets the modification time and writes to that file afterwards.
The fix is probably to cache the file modification time and set it
before the file is closed (the Microsoft documentation for WriteFile
says that the file must be closed to get the file modification time
On Wednesday 29 February 2012 19:00:23 Eugen Labun wrote:
> Dear All,
> I investigated the bug "#6473 Wrong timestamp for files write in shared
> folders"  a bit. Hope this info could help to fix it.
> One and the same VM (WinXP) has been run on a Windows host (Win7 32bit) and
> on a Linux host (Ubuntu 11.10) using VirtualBox 4.1.8. The last guest
> additions (4.1.8) are installed in the guest OS.
> - The bug with wrong timestamps only exists on the Linux host, on Windows
> is all OK! - If (filesize==0) then the timestamp is correct even on the
> Linux host (this has been also reported by skosner in ).
> That is, the file will be *created* with proper attribites! Only after its
> content is written into (i.e. if filesize > 0), the timestamp gets
> resetted to the current one in case of Linux host!
> So I looked into the sources and found that VBox uses RTFileWrite for
> actual file writing .
> The Windows implementation of RTFileWrite is here , the one used by
> Linux here  (please correct me if I'm wrong!). The only real difference
> between is that the Windows impl. calls ´WriteFile´ , and the Linux
> impl. calls ´write´.
> And here IMO is the root of the problem: whereas ´WriteFile´ doesn't alter
> file attributes (at least not in my test environment), the Linux' ´write´
> always resets the timestamp!
> More specifically, the ´write´ resets the "modified"(st_mtime) and
> "created"(st_ctime) parts, as explicitly stated here .
> Unfortunately, I'm not experienced in Linux system programming, so cannot
> provide a patch. The ´cp -p´ command or copy with GNOME's Nautilus are
> known to copy files preserving their attributes.
> Perhaps, VirtualBox could also use the same (or similar) technique that it
> uses for file creation (remember, files of 0 bytes have correct
> timestamps) for correction of attributes *after* applying RTFileWrite
> (here )?
> Hope this old and very annoying bug will be eventually fixed.
> Best regards,
> Eugen Labun
>  https://www.virtualbox.org/ticket/6473
> Folders/vbsf.cpp#L1451 
> io-win.cpp#L483 
> leio-posix.cpp#L495 
> io-win.cpp#L502 
> leio-posix.cpp#L514  Michael Kerrisk. "The Linux programming interface:
> a Linux and UNIX system programming handbook". 2010.
> See "Table 15-2: Effect of various functions on file timestamps" on p.
> vbox-dev mailing list
> vbox-dev at virtualbox.org
Dr.-Ing. Frank Mehnert
Senior Manager Software Development Desktop Virtualization, VirtualBox
ORACLE Deutschland B.V. & Co. KG | Werkstr. 24 | 71384 Weinstadt, Germany
Hauptverwaltung: Riesstr. 25, D-80992 München
Registergericht: Amtsgericht München, HRA 95603
Komplementärin: ORACLE Deutschland Verwaltung B.V.
Hertogswetering 163/167, 3543 AS Utrecht, Niederlande
Handelsregister der Handelskammer Midden-Niederlande, Nr. 30143697
Geschäftsführer: Jürgen Kunz, Marcel van de Molen, Alexander van der Ven
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 198 bytes
Desc: This is a digitally signed message part.
Url : http://www.virtualbox.org/pipermail/vbox-dev/attachments/20120229/b6a20a76/attachment-0001.bin
More information about the vbox-dev