VirtualBox

Ticket #1187 (closed defect: fixed)

Opened 6 years ago

Last modified 5 years ago

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

Reported by: farin Owned by:
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

comment:1 Changed 6 years ago by frank

  • Guest type changed from other to Linux

comment:2 Changed 6 years ago by frank

  • 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

comment:3 Changed 5 years ago by frank

  • Version changed from VirtualBox 1.5.4 to VirtualBox 2.1.4

comment:4 Changed 5 years ago 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.

comment:5 Changed 5 years ago 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

comment:6 Changed 5 years ago by sandervl73

  • Status changed from new to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.

www.oracle.com
ContactPrivacy policyTerms of Use