| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2011 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2011 The Native Client Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 #include "MemNode.h" | 7 #include "MemNode.h" |
| 8 #include <assert.h> | 8 #include <assert.h> |
| 9 #include <errno.h> | 9 #include <errno.h> |
| 10 #include <nacl-mounts/util/DebugPrint.h> |
| 10 #include <stdio.h> | 11 #include <stdio.h> |
| 11 #include <stdlib.h> | 12 #include <stdlib.h> |
| 12 | 13 |
| 13 MemNode::MemNode() { | 14 MemNode::MemNode() { |
| 14 data_ = NULL; | 15 data_ = NULL; |
| 15 len_ = 0; | 16 len_ = 0; |
| 16 capacity_ = 0; | 17 capacity_ = 0; |
| 17 use_count_ = 0; | 18 use_count_ = 0; |
| 18 } | 19 } |
| 19 | 20 |
| 20 MemNode::~MemNode() { | 21 MemNode::~MemNode() { |
| 21 children_.clear(); | 22 children_.clear(); |
| 22 } | 23 } |
| 23 | 24 |
| 24 int MemNode::stat(struct stat *buf) { | 25 int MemNode::stat(struct stat *buf) { |
| 26 if (!buf) return 0; |
| 25 memset(buf, 0, sizeof(struct stat)); | 27 memset(buf, 0, sizeof(struct stat)); |
| 26 buf->st_ino = (ino_t)slot_; | 28 buf->st_ino = (ino_t)slot_; |
| 27 if (is_dir()) { | 29 if (is_dir()) { |
| 28 buf->st_mode = S_IFDIR | 0777; | 30 buf->st_mode = S_IFDIR | 0777; |
| 29 } else { | 31 } else { |
| 30 buf->st_mode = S_IFREG | 0777; | 32 buf->st_mode = S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH |
| 33 | S_IWOTH; |
| 31 buf->st_size = len_; | 34 buf->st_size = len_; |
| 32 } | 35 } |
| 33 buf->st_uid = 1001; | 36 buf->st_uid = 1001; |
| 34 buf->st_gid = 1002; | 37 buf->st_gid = 1002; |
| 35 buf->st_blksize = 1024; | 38 buf->st_blksize = 1024; |
| 36 return 0; | 39 return 0; |
| 37 } | 40 } |
| 38 | 41 |
| 39 void MemNode::AddChild(int child) { | 42 void MemNode::AddChild(int child) { |
| 40 if (!is_dir()) { | 43 if (!is_dir()) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 58 set_capacity(len); | 61 set_capacity(len); |
| 59 } | 62 } |
| 60 | 63 |
| 61 std::list<int> *MemNode::children() { | 64 std::list<int> *MemNode::children() { |
| 62 if (is_dir()) { | 65 if (is_dir()) { |
| 63 return &children_; | 66 return &children_; |
| 64 } else { | 67 } else { |
| 65 return NULL; | 68 return NULL; |
| 66 } | 69 } |
| 67 } | 70 } |
| OLD | NEW |