VirtualBox

Opened 16 years ago

Closed 15 years ago

#1187 closed defect (fixed)

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

Reported by: Dirk Farin Owned by:
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 (6)

comment:1 by Frank Mehnert, 16 years ago

Guest type: otherLinux

comment:2 by Frank Mehnert, 16 years ago

Component: othershared folders
Summary: linux guest on windows host: cannot write more than 1023 bytes at once on shared drive via C++ ofstreamCannot write more than 1023 bytes at once on shared drive via C++ ofstream

comment:3 by Frank Mehnert, 15 years ago

Version: VirtualBox 1.5.4VirtualBox 2.1.4

comment:4 by Frank Mehnert, 15 years ago

Version: VirtualBox 2.1.4VirtualBox 2.2.4

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

comment:5 by Frank Mehnert, 15 years ago

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

comment:6 by Sander van Leeuwen, 15 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.

© 2023 Oracle
ContactPrivacy policyTerms of Use