summaryrefslogtreecommitdiffstats
path: root/native_client_sdk/src
diff options
context:
space:
mode:
Diffstat (limited to 'native_client_sdk/src')
-rw-r--r--native_client_sdk/src/libraries/nacl_mounts/kernel_handle.cc5
-rw-r--r--native_client_sdk/src/libraries/nacl_mounts/mount_http.cc12
2 files changed, 7 insertions, 10 deletions
diff --git a/native_client_sdk/src/libraries/nacl_mounts/kernel_handle.cc b/native_client_sdk/src/libraries/nacl_mounts/kernel_handle.cc
index 5103542..f1f2600 100644
--- a/native_client_sdk/src/libraries/nacl_mounts/kernel_handle.cc
+++ b/native_client_sdk/src/libraries/nacl_mounts/kernel_handle.cc
@@ -27,12 +27,13 @@ KernelHandle::KernelHandle(Mount* mnt, MountNode* node, int mode)
off_t KernelHandle::Seek(off_t offset, int whence) {
size_t base;
+ size_t node_size = node_->GetSize();
switch (whence) {
default: return -1;
case SEEK_SET: base = 0; break;
case SEEK_CUR: base = offs_; break;
- case SEEK_END: base = node_->GetSize(); break;
+ case SEEK_END: base = node_size; break;
}
if (base + offset < 0) {
@@ -44,7 +45,7 @@ off_t KernelHandle::Seek(off_t offset, int whence) {
// Seeking past the end of the file will zero out the space between the old
// end and the new end.
- if (offs_ > node_->GetSize()) {
+ if (offs_ > node_size) {
if (node_->Truncate(offs_) < 0) {
errno = EINVAL;
return -1;
diff --git a/native_client_sdk/src/libraries/nacl_mounts/mount_http.cc b/native_client_sdk/src/libraries/nacl_mounts/mount_http.cc
index bd5fc40..f269a41 100644
--- a/native_client_sdk/src/libraries/nacl_mounts/mount_http.cc
+++ b/native_client_sdk/src/libraries/nacl_mounts/mount_http.cc
@@ -328,19 +328,15 @@ int MountNodeHttp::Truncate(size_t size) {
}
int MountNodeHttp::Write(size_t offs, const void* buf, size_t count) {
- // TODO(binji): supprt POST?
+ // TODO(binji): support POST?
errno = ENOSYS;
return -1;
}
size_t MountNodeHttp::GetSize() {
- struct stat stat;
- if (GetStat(&stat) == -1) {
- // errno is already set by GetStat.
- return -1;
- }
-
- return stat.st_size;
+ // TODO(binji): This value should be cached properly; i.e. obey the caching
+ // headers returned by the server.
+ return stat_.st_size;
}
MountNodeHttp::MountNodeHttp(Mount* mount, int ino, int dev,