summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorShane Kearns <shane.kearns@accenture.com>2011-12-15 13:29:30 (GMT)
committerShane Kearns <shane.kearns@accenture.com>2011-12-15 13:49:06 (GMT)
commit3a4728e169ef59896f8f1c7f1c9a3abc814c83cf (patch)
tree76c11e90ae855cb482edc12ecd564b3c4a195917 /src/corelib
parentba3f5ec3884aafb6c9761ef8719b82d4345245fa (diff)
downloadQt-3a4728e169ef59896f8f1c7f1c9a3abc814c83cf.zip
Qt-3a4728e169ef59896f8f1c7f1c9a3abc814c83cf.tar.gz
Qt-3a4728e169ef59896f8f1c7f1c9a3abc814c83cf.tar.bz2
Symbian - Fix QFile::map with non page aligned offsets
Although it is not documented, RFileMap native API requires the offset into the file to be a multiple of the page size. Round down the offset requested by the user to the page size. Add back the difference before returning the base address to the user. e.g. if the offset passed to QFile::map was 5000: The offset passed to RFileMap will be 4096 The address returned to the user will be the RFileMap::Base() + 904 The modified address is used to key the hash of file mappings, so that QFile::unmap() can be passed the modified address without needing changes. Reviewed-by: mread Task-number: ou1cimx#953054
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/io/qfsfileengine_unix.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp
index 4961722..781a5f0 100644
--- a/src/corelib/io/qfsfileengine_unix.cpp
+++ b/src/corelib/io/qfsfileengine_unix.cpp
@@ -1058,22 +1058,24 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, QFile::MemoryMapFla
TInt nativeMapError = KErrNone;
RFileMap mapping;
TUint mode(EFileMapRemovableMedia);
+ TUint64 nativeOffset = offset & ~(mapping.PageSizeInBytes() - 1);
+
//If the file was opened for write or read/write, then open the map for read/write
if (openMode & QIODevice::WriteOnly)
mode |= EFileMapWrite;
if (symbianFile.SubSessionHandle()) {
- nativeMapError = mapping.Open(symbianFile, offset, size, mode);
+ nativeMapError = mapping.Open(symbianFile, nativeOffset, size, mode);
} else {
//map file by name if we don't have a native handle
QString fn = QFileSystemEngine::absoluteName(fileEntry).nativeFilePath();
TUint filemode = EFileShareReadersOrWriters | EFileRead;
if (openMode & QIODevice::WriteOnly)
filemode |= EFileWrite;
- nativeMapError = mapping.Open(qt_s60GetRFs(), qt_QString2TPtrC(fn), filemode, offset, size, mode);
+ nativeMapError = mapping.Open(qt_s60GetRFs(), qt_QString2TPtrC(fn), filemode, nativeOffset, size, mode);
}
if (nativeMapError == KErrNone) {
QScopedResource<RFileMap> ptr(mapping); //will call Close if adding to mapping throws an exception
- uchar *address = mapping.Base();
+ uchar *address = mapping.Base() + (offset - nativeOffset);
maps[address] = mapping;
ptr.take();
return address;