OLD | NEW |
1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 /* Copyright (c) 2012 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/mount_node_mem.h" | 5 #include "nacl_io/mount_node_mem.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include "nacl_io/osstat.h" | 10 #include "nacl_io/osstat.h" |
11 #include "sdk_util/auto_lock.h" | 11 #include "sdk_util/auto_lock.h" |
12 | 12 |
| 13 namespace nacl_io { |
| 14 |
13 #define BLOCK_SIZE (1 << 16) | 15 #define BLOCK_SIZE (1 << 16) |
14 #define BLOCK_MASK (BLOCK_SIZE - 1) | 16 #define BLOCK_MASK (BLOCK_SIZE - 1) |
15 | 17 |
16 MountNodeMem::MountNodeMem(Mount* mount) | 18 MountNodeMem::MountNodeMem(Mount* mount) |
17 : MountNode(mount), data_(NULL), capacity_(0) { | 19 : MountNode(mount), data_(NULL), capacity_(0) { |
18 stat_.st_mode |= S_IFREG; | 20 stat_.st_mode |= S_IFREG; |
19 } | 21 } |
20 | 22 |
21 MountNodeMem::~MountNodeMem() { free(data_); } | 23 MountNodeMem::~MountNodeMem() { free(data_); } |
22 | 24 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 88 |
87 // If we failed, then adjust size according to what we keep | 89 // If we failed, then adjust size according to what we keep |
88 if (new_size > capacity_) | 90 if (new_size > capacity_) |
89 new_size = capacity_; | 91 new_size = capacity_; |
90 | 92 |
91 // Update the size and return the new size | 93 // Update the size and return the new size |
92 stat_.st_size = static_cast<off_t>(new_size); | 94 stat_.st_size = static_cast<off_t>(new_size); |
93 return EIO; | 95 return EIO; |
94 } | 96 } |
95 | 97 |
| 98 } // namespace nacl_io |
| 99 |
OLD | NEW |