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.h" | 5 #include "nacl_io/mount_node.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <string.h> | 9 #include <string.h> |
10 #include <sys/stat.h> | 10 #include <sys/stat.h> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "nacl_io/kernel_wrap_real.h" | 13 #include "nacl_io/kernel_wrap_real.h" |
14 #include "nacl_io/mount.h" | 14 #include "nacl_io/mount.h" |
15 #include "nacl_io/osmman.h" | 15 #include "nacl_io/osmman.h" |
16 #include "utils/auto_lock.h" | 16 #include "utils/auto_lock.h" |
17 | 17 |
18 static const int USR_ID = 1001; | 18 static const int USR_ID = 1001; |
19 static const int GRP_ID = 1002; | 19 static const int GRP_ID = 1002; |
20 | 20 |
21 MountNode::MountNode(Mount* mount) | 21 MountNode::MountNode(Mount* mount) |
22 : mount_(mount) { | 22 : mount_(mount) { |
23 memset(&stat_, 0, sizeof(stat_)); | 23 memset(&stat_, 0, sizeof(stat_)); |
24 stat_.st_gid = GRP_ID; | 24 stat_.st_gid = GRP_ID; |
25 stat_.st_uid = USR_ID; | 25 stat_.st_uid = USR_ID; |
26 | 26 |
27 // Mount should normally never be NULL, but may be null in tests. | 27 // Mount should normally never be NULL, but may be null in tests. |
| 28 // If NULL, at least set the inode to a valid (nonzero) value. |
28 if (mount_) | 29 if (mount_) |
29 mount_->OnNodeCreated(this); | 30 mount_->OnNodeCreated(this); |
| 31 else |
| 32 stat_.st_ino = 1; |
30 } | 33 } |
31 | 34 |
32 MountNode::~MountNode() { | 35 MountNode::~MountNode() { |
33 } | 36 } |
34 | 37 |
35 bool MountNode::Init(int perm) { | 38 bool MountNode::Init(int perm) { |
36 stat_.st_mode |= perm; | 39 stat_.st_mode |= perm; |
37 return true; | 40 return true; |
38 } | 41 } |
39 | 42 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 | 163 |
161 void MountNode::Link() { | 164 void MountNode::Link() { |
162 Acquire(); | 165 Acquire(); |
163 stat_.st_nlink++; | 166 stat_.st_nlink++; |
164 } | 167 } |
165 | 168 |
166 void MountNode::Unlink() { | 169 void MountNode::Unlink() { |
167 stat_.st_nlink--; | 170 stat_.st_nlink--; |
168 Release(); | 171 Release(); |
169 } | 172 } |
OLD | NEW |