VirtualBox

Ticket #1187 (closed defect: fixed)

Opened 2 years ago

Last modified 5 months ago

Cannot write more than 1023 bytes at once on shared drive via C++ ofstream => Fixed in SVN

Reported by: farin Assigned to:
Priority: major Component: shared folders
Version: VirtualBox 2.2.4 Keywords: shared folders
Cc: Guest type: Linux
Host type: other

Description

I have a strange behaviour when writing files to shared folders on the host system. The configuration is: host: Windows-XP guest: Linux, Debian, 2.6.22 (lenny / testing) gcc on guest: 4.2.3

When using this simple test program, compiled on the guest linux system:


#include <iostream> #include <iomanip> #include <fstream>

int main(int argc, char *argv[]) {

char buf[5000];

for (int i=0;i<5000;i++) buf[i]=1;

std::ofstream os("out", std::ios::binary | std::ios::out); os.write(buf, 1024);

os << "end" << std::endl;

}


The program writes only 'zeros' instead of 'ones' when the output is a shared host folder (ntfs, mount options: "rw,exec,suid,dev"). This happens when the number of bytes written is >=1024. For chunks smaller than 1023, it works ok. It also works ok, if the output is on the guest file-system.

If the last line is removed (the file output is not flushed), no output is written at all (zero-length file). The ios::bad flag is not set after writing, claiming that everything went ok.

Replacing the ofstream output with fwrite-based code works ok for all sizes.

Not sure, if this is a stdc++ problem or a VirtualBox problem, but since the problem occurs with several gcc versions and only appears when writing to the host filesystem, it seems to be related to VirtualBox.

Change History

2008-07-07 21:32:38 changed by frank

  • guest changed from other to Linux.

2008-07-09 22:34:04 changed by frank

  • owner changed.
  • component changed from other to shared folders.
  • summary changed from linux guest on windows host: cannot write more than 1023 bytes at once on shared drive via C++ ofstream to Cannot write more than 1023 bytes at once on shared drive via C++ ofstream.

2009-03-25 22:09:18 changed by frank

  • version changed from VirtualBox 1.5.4 to VirtualBox 2.1.4.

2009-06-19 12:36:49 changed by frank

  • version changed from VirtualBox 2.1.4 to VirtualBox 2.2.4.

Finally fixed in SVN. The fix will be available in the next release.

2009-06-19 12:37:01 changed by frank

  • summary changed from Cannot write more than 1023 bytes at once on shared drive via C++ ofstream to Cannot write more than 1023 bytes at once on shared drive via C++ ofstream => Fixed in SVN.

2009-06-30 15:05:32 changed by sandervl73

  • status changed from new to closed.
  • resolution set to fixed.

© 2009 Sun Microsystems, Inc.
ContactPrivacy policy