| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "nacl_io/passthroughfs/passthrough_fs.h" | 5 #include "nacl_io/passthroughfs/passthrough_fs.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 | 8 |
| 9 #include "nacl_io/kernel_handle.h" | 9 #include "nacl_io/kernel_handle.h" |
| 10 #include "nacl_io/kernel_wrap_real.h" | 10 #include "nacl_io/kernel_wrap_real.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 } | 26 } |
| 27 | 27 |
| 28 public: | 28 public: |
| 29 // Normal read/write operations on a file | 29 // Normal read/write operations on a file |
| 30 virtual Error Read(const HandleAttr& attr, | 30 virtual Error Read(const HandleAttr& attr, |
| 31 void* buf, | 31 void* buf, |
| 32 size_t count, | 32 size_t count, |
| 33 int* out_bytes) { | 33 int* out_bytes) { |
| 34 *out_bytes = 0; | 34 *out_bytes = 0; |
| 35 | 35 |
| 36 off_t new_offset; | 36 int64_t new_offset; |
| 37 int err = _real_lseek(real_fd_, attr.offs, 0, &new_offset); | 37 int err = _real_lseek(real_fd_, attr.offs, 0, &new_offset); |
| 38 if (err) | 38 if (err) |
| 39 return err; | 39 return err; |
| 40 | 40 |
| 41 size_t nread; | 41 size_t nread; |
| 42 err = _real_read(real_fd_, buf, count, &nread); | 42 err = _real_read(real_fd_, buf, count, &nread); |
| 43 if (err) | 43 if (err) |
| 44 return err; | 44 return err; |
| 45 | 45 |
| 46 *out_bytes = static_cast<int>(nread); | 46 *out_bytes = static_cast<int>(nread); |
| 47 return 0; | 47 return 0; |
| 48 } | 48 } |
| 49 | 49 |
| 50 virtual Error Write(const HandleAttr& attr, | 50 virtual Error Write(const HandleAttr& attr, |
| 51 const void* buf, | 51 const void* buf, |
| 52 size_t count, | 52 size_t count, |
| 53 int* out_bytes) { | 53 int* out_bytes) { |
| 54 *out_bytes = 0; | 54 *out_bytes = 0; |
| 55 | 55 |
| 56 off_t new_offset; | 56 int64_t new_offset; |
| 57 int err = _real_lseek(real_fd_, attr.offs, 0, &new_offset); | 57 int err = _real_lseek(real_fd_, attr.offs, 0, &new_offset); |
| 58 if (err) | 58 if (err) |
| 59 return err; | 59 return err; |
| 60 | 60 |
| 61 size_t nwrote; | 61 size_t nwrote; |
| 62 err = _real_write(real_fd_, buf, count, &nwrote); | 62 err = _real_write(real_fd_, buf, count, &nwrote); |
| 63 if (err) | 63 if (err) |
| 64 return err; | 64 return err; |
| 65 | 65 |
| 66 *out_bytes = static_cast<int>(nwrote); | 66 *out_bytes = static_cast<int>(nwrote); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 // Not implemented by NaCl. | 174 // Not implemented by NaCl. |
| 175 return ENOSYS; | 175 return ENOSYS; |
| 176 } | 176 } |
| 177 | 177 |
| 178 Error PassthroughFs::Rename(const Path& path, const Path& newpath) { | 178 Error PassthroughFs::Rename(const Path& path, const Path& newpath) { |
| 179 // Not implemented by NaCl. | 179 // Not implemented by NaCl. |
| 180 return ENOSYS; | 180 return ENOSYS; |
| 181 } | 181 } |
| 182 | 182 |
| 183 } // namespace nacl_io | 183 } // namespace nacl_io |
| OLD | NEW |