summaryrefslogtreecommitdiffstats
path: root/luni
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2011-05-24 21:07:53 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-05-24 21:07:53 -0700
commit23c3b7f76a8ec59d5329417d53d83b14242441de (patch)
treeb73dacbdd57c95cf6adc89a39d242713c3322c7b /luni
parent54709bdf6b22d02efed7d2fd967cbd4d11b3942d (diff)
parentc03e4ba8cd93513aabda061b00d516b54717c5fb (diff)
downloadlibcore-23c3b7f76a8ec59d5329417d53d83b14242441de.zip
libcore-23c3b7f76a8ec59d5329417d53d83b14242441de.tar.gz
libcore-23c3b7f76a8ec59d5329417d53d83b14242441de.tar.bz2
Merge "Fix a bug in FileChannel.map." into dalvik-dev
Diffstat (limited to 'luni')
-rw-r--r--luni/src/main/java/java/nio/FileChannelImpl.java8
1 files changed, 7 insertions, 1 deletions
diff --git a/luni/src/main/java/java/nio/FileChannelImpl.java b/luni/src/main/java/java/nio/FileChannelImpl.java
index 53c1e4d..bc13efd 100644
--- a/luni/src/main/java/java/nio/FileChannelImpl.java
+++ b/luni/src/main/java/java/nio/FileChannelImpl.java
@@ -228,7 +228,13 @@ final class FileChannelImpl extends FileChannel {
throw new NonReadableChannelException();
}
if (position + size > size()) {
- truncate(position + size);
+ // We can't defer to FileChannel.truncate because that will only make a file shorter,
+ // and we only care about making our backing file longer here.
+ try {
+ Libcore.os.ftruncate(fd, position + size);
+ } catch (ErrnoException errnoException) {
+ throw errnoException.rethrowAsIOException();
+ }
}
long alignment = position - position % Libcore.os.sysconf(_SC_PAGE_SIZE);
int offset = (int) (position - alignment);