Opened 17 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 , 16 years ago
Guest type: | other → Linux |
---|
comment:2 by , 16 years ago
Component: | other → shared folders |
---|---|
Summary: | linux guest on windows host: cannot write more than 1023 bytes at once on shared drive via C++ ofstream → Cannot write more than 1023 bytes at once on shared drive via C++ ofstream |
comment:3 by , 15 years ago
Version: | VirtualBox 1.5.4 → VirtualBox 2.1.4 |
---|
comment:4 by , 15 years ago
Version: | VirtualBox 2.1.4 → VirtualBox 2.2.4 |
---|
comment:5 by , 15 years ago
Summary: | Cannot write more than 1023 bytes at once on shared drive via C++ ofstream → Cannot write more than 1023 bytes at once on shared drive via C++ ofstream => Fixed in SVN |
---|
comment:6 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Finally fixed in SVN. The fix will be available in the next release.