| 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_mounts/mount_node.h" | 5 #include "nacl_mounts/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_mounts/mount.h" | 13 #include "nacl_mounts/mount.h" |
| 14 #include "utils/auto_lock.h" | 14 #include "utils/auto_lock.h" |
| 15 | 15 |
| 16 MountNode::MountNode(Mount* mount, int ino, int dev) | 16 static const int USR_ID = 1001; |
| 17 static const int GRP_ID = 1002; |
| 18 |
| 19 MountNode::MountNode(Mount* mount) |
| 17 : mount_(mount) { | 20 : mount_(mount) { |
| 18 memset(&stat_, 0, sizeof(stat_)); | 21 memset(&stat_, 0, sizeof(stat_)); |
| 19 stat_.st_ino = ino; | 22 stat_.st_gid = GRP_ID; |
| 20 stat_.st_dev = dev; | 23 stat_.st_uid = USR_ID; |
| 21 | 24 |
| 22 // Mount should normally never be NULL, but may be null in tests. | 25 // Mount should normally never be NULL, but may be null in tests. |
| 23 if (mount_) | 26 if (mount_) |
| 24 mount_->OnNodeCreated(); | 27 mount_->OnNodeCreated(this); |
| 25 } | 28 } |
| 26 | 29 |
| 27 MountNode::~MountNode() { | 30 MountNode::~MountNode() { |
| 28 if (mount_) | |
| 29 mount_->OnNodeDestroyed(); | |
| 30 } | 31 } |
| 31 | 32 |
| 32 bool MountNode::Init(int mode, short uid, short gid) { | 33 bool MountNode::Init(int perm) { |
| 33 stat_.st_mode = mode; | 34 stat_.st_mode |= perm; |
| 34 stat_.st_gid = gid; | |
| 35 stat_.st_uid = uid; | |
| 36 return true; | 35 return true; |
| 37 } | 36 } |
| 38 | 37 |
| 39 void MountNode::Destroy() { | 38 void MountNode::Destroy() { |
| 40 Close(); | 39 if (mount_) { |
| 41 } | 40 mount_->OnNodeDestroyed(this); |
| 42 | 41 } |
| 43 int MountNode::Close() { | |
| 44 FSync(); | |
| 45 return 0; | |
| 46 } | 42 } |
| 47 | 43 |
| 48 int MountNode::FSync() { | 44 int MountNode::FSync() { |
| 49 return 0; | 45 return 0; |
| 50 } | 46 } |
| 51 | 47 |
| 52 int MountNode::GetDents(size_t offs, struct dirent* pdir, size_t count) { | 48 int MountNode::GetDents(size_t offs, struct dirent* pdir, size_t count) { |
| 53 errno = ENOTDIR; | 49 errno = ENOTDIR; |
| 54 return -1; | 50 return -1; |
| 55 } | 51 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 | 127 |
| 132 void MountNode::Link() { | 128 void MountNode::Link() { |
| 133 Acquire(); | 129 Acquire(); |
| 134 stat_.st_nlink++; | 130 stat_.st_nlink++; |
| 135 } | 131 } |
| 136 | 132 |
| 137 void MountNode::Unlink() { | 133 void MountNode::Unlink() { |
| 138 stat_.st_nlink--; | 134 stat_.st_nlink--; |
| 139 Release(); | 135 Release(); |
| 140 } | 136 } |
| OLD | NEW |