| 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 | 6 |
| 6 #include <dirent.h> | |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <string.h> |
| 9 #include <sys/stat.h> | 10 #include <sys/stat.h> |
| 10 #include <string> | 11 #include <string> |
| 11 | 12 |
| 12 #include "auto_lock.h" | 13 #include "nacl_mounts/mount.h" |
| 13 #include "mount.h" | 14 #include "utils/auto_lock.h" |
| 14 #include "mount_node.h" | |
| 15 | 15 |
| 16 MountNode::MountNode(Mount* mount, int ino, int dev) | 16 MountNode::MountNode(Mount* mount, int ino, int dev) |
| 17 : mount_(mount) { | 17 : mount_(mount) { |
| 18 memset(&stat_, 0, sizeof(stat_)); | 18 memset(&stat_, 0, sizeof(stat_)); |
| 19 stat_.st_ino = ino; | 19 stat_.st_ino = ino; |
| 20 stat_.st_dev = dev; | 20 stat_.st_dev = dev; |
| 21 } | 21 } |
| 22 | 22 |
| 23 MountNode::~MountNode() { | 23 MountNode::~MountNode() { |
| 24 } | 24 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 int MountNode::Write(size_t offs, const void* buf, size_t count) { | 67 int MountNode::Write(size_t offs, const void* buf, size_t count) { |
| 68 errno = EINVAL; | 68 errno = EINVAL; |
| 69 return -1; | 69 return -1; |
| 70 } | 70 } |
| 71 | 71 |
| 72 int MountNode::GetLinks() const { | 72 int MountNode::GetLinks() const { |
| 73 return stat_.st_nlink; | 73 return stat_.st_nlink; |
| 74 } | 74 } |
| 75 | 75 |
| 76 int MountNode::GetMode() const { | 76 int MountNode::GetMode() const { |
| 77 return stat_.st_mode & ~_S_IFMT; | 77 return stat_.st_mode & ~S_IFMT; |
| 78 } | 78 } |
| 79 | 79 |
| 80 size_t MountNode::GetSize() const { | 80 size_t MountNode::GetSize() const { |
| 81 return stat_.st_size; | 81 return stat_.st_size; |
| 82 } | 82 } |
| 83 | 83 |
| 84 int MountNode::GetType() const { | 84 int MountNode::GetType() const { |
| 85 return stat_.st_mode & _S_IFMT; | 85 return stat_.st_mode & S_IFMT; |
| 86 } | 86 } |
| 87 | 87 |
| 88 bool MountNode::IsaDir() const { | 88 bool MountNode::IsaDir() const { |
| 89 return (stat_.st_mode & _S_IFDIR) != 0; | 89 return (stat_.st_mode & S_IFDIR) != 0; |
| 90 } | 90 } |
| 91 | 91 |
| 92 bool MountNode::IsaFile() const { | 92 bool MountNode::IsaFile() const { |
| 93 return (stat_.st_mode & _S_IFREG) != 0; | 93 return (stat_.st_mode & S_IFREG) != 0; |
| 94 } | 94 } |
| 95 | 95 |
| 96 bool MountNode::IsaTTY() const { | 96 bool MountNode::IsaTTY() const { |
| 97 return (stat_.st_mode & _S_IFCHR) != 0; | 97 return (stat_.st_mode & S_IFCHR) != 0; |
| 98 } | 98 } |
| 99 | 99 |
| 100 | 100 |
| 101 int MountNode:: AddChild(const std::string& name, MountNode* node) { | 101 int MountNode:: AddChild(const std::string& name, MountNode* node) { |
| 102 errno = ENOTDIR; | 102 errno = ENOTDIR; |
| 103 return -1; | 103 return -1; |
| 104 } | 104 } |
| 105 | 105 |
| 106 int MountNode::RemoveChild(const std::string& name) { | 106 int MountNode::RemoveChild(const std::string& name) { |
| 107 errno = ENOTDIR; | 107 errno = ENOTDIR; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 120 | 120 |
| 121 void MountNode::Link() { | 121 void MountNode::Link() { |
| 122 Acquire(); | 122 Acquire(); |
| 123 stat_.st_nlink++; | 123 stat_.st_nlink++; |
| 124 } | 124 } |
| 125 | 125 |
| 126 void MountNode::Unlink() { | 126 void MountNode::Unlink() { |
| 127 stat_.st_nlink--; | 127 stat_.st_nlink--; |
| 128 Release(); | 128 Release(); |
| 129 } | 129 } |
| 130 | |
| OLD | NEW |