summaryrefslogtreecommitdiff
path: root/util/mmap_posix.cpp
diff options
context:
space:
mode:
authorAaron <aaron@10gen.com>2009-04-23 11:16:54 -0400
committerAaron <aaron@10gen.com>2009-04-23 11:16:54 -0400
commit64c5d55c59fac341a33bd69c4ac9a28aa71553cf (patch)
tree733c49046dcaecc9b66adc34e70203f78cab6718 /util/mmap_posix.cpp
parentb912d5ffda8cb0187cf70338cf623d1b142f425e (diff)
downloadmongo-64c5d55c59fac341a33bd69c4ac9a28aa71553cf.tar.gz
don't seg fault when run out of disk space
Diffstat (limited to 'util/mmap_posix.cpp')
-rw-r--r--util/mmap_posix.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/util/mmap_posix.cpp b/util/mmap_posix.cpp
index 5cd83a8021d..2503b84d5b7 100644
--- a/util/mmap_posix.cpp
+++ b/util/mmap_posix.cpp
@@ -61,6 +61,10 @@ namespace mongo {
return 0;
}
+ off_t filelen = lseek(fd, 0, SEEK_END);
+ massert( "file size allocation failed", filelen == length );
+ lseek( fd, 0, SEEK_SET );
+
view = mmap(NULL, length, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
if ( view == MAP_FAILED ) {
out() << " mmap() failed for " << filename << " len:" << length << " errno:" << errno << endl;