summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2005-03-03 11:22:44 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2005-03-03 11:22:44 (GMT)
commit7fe60c0a0ae2fe4586491867c902bb13df403285 (patch)
treef014cc1f0b4dfb19588dc5144ff343f11e48c352 /Modules
parentdf37c8c1ad51b6f8527e2cd398788e49cd686654 (diff)
downloadcpython-7fe60c0a0ae2fe4586491867c902bb13df403285.zip
cpython-7fe60c0a0ae2fe4586491867c902bb13df403285.tar.gz
cpython-7fe60c0a0ae2fe4586491867c902bb13df403285.tar.bz2
Patches #749830, #1144555: allow UNIX mmap size to default to current
file size.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/mmapmodule.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c
index e1a2f42..aaa4925 100644
--- a/Modules/mmapmodule.c
+++ b/Modules/mmapmodule.c
@@ -896,11 +896,14 @@ new_mmap_object(PyObject *self, PyObject *args, PyObject *kwdict)
/* on OpenVMS we must ensure that all bytes are written to the file */
fsync(fd);
# endif
- if (fstat(fd, &st) == 0 && S_ISREG(st.st_mode) &&
- (size_t)map_size > st.st_size) {
- PyErr_SetString(PyExc_ValueError,
- "mmap length is greater than file size");
- return NULL;
+ if (fstat(fd, &st) == 0 && S_ISREG(st.st_mode)) {
+ if (map_size == 0) {
+ map_size = (int)st.st_size;
+ } else if ((size_t)map_size > st.st_size) {
+ PyErr_SetString(PyExc_ValueError,
+ "mmap length is greater than file size");
+ return NULL;
+ }
}
#endif
m_obj = PyObject_New (mmap_object, &mmap_object_type);