Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(650)

Side by Side Diff: native_client_sdk/src/libraries/nacl_mounts/mount_node_dir.cc

Issue 10829027: [NaCl SDK] Add nacl_mounts to NaCl SDK build. Experimental for now. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix for windows Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_dir.h"
5 6
6 #include <dirent.h>
7 #include <errno.h> 7 #include <errno.h>
8 #include <sys/stat.h> 8 #include <string.h>
9 9
10 #include "macros.h" 10 #include "nacl_mounts/osdirent.h"
11 #include "auto_lock.h" 11 #include "nacl_mounts/osstat.h"
12 #include "mount_node_dir.h" 12 #include "utils/macros.h"
13 #include "utils/auto_lock.h"
13 14
14 MountNodeDir::MountNodeDir(Mount* mount, int ino, int dev) 15 MountNodeDir::MountNodeDir(Mount* mount, int ino, int dev)
15 : MountNode(mount, ino, dev), 16 : MountNode(mount, ino, dev),
16 cache_(NULL) { 17 cache_(NULL) {
17 } 18 }
18 19
19 MountNodeDir::~MountNodeDir() { 20 MountNodeDir::~MountNodeDir() {
20 free(cache_); 21 free(cache_);
21 } 22 }
22 23
23 bool MountNodeDir::Init(int mode, short uid, short gid) { 24 bool MountNodeDir::Init(int mode, short uid, short gid) {
24 bool ok = MountNode::Init(mode, uid, gid); 25 bool ok = MountNode::Init(mode, uid, gid);
25 stat_.st_mode |= _S_IFDIR; 26 stat_.st_mode |= S_IFDIR;
26 return ok; 27 return ok;
27 } 28 }
28 29
29 int MountNodeDir::Read(size_t offs, void *buf, size_t count) { 30 int MountNodeDir::Read(size_t offs, void *buf, size_t count) {
30 errno = EISDIR; 31 errno = EISDIR;
31 return -1; 32 return -1;
32 } 33 }
33 34
34 int MountNodeDir::Truncate(size_t size) { 35 int MountNodeDir::Truncate(size_t size) {
35 errno = EISDIR; 36 errno = EISDIR;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 for (size_t index = 0; it != map_.end(); it++, index++) { 133 for (size_t index = 0; it != map_.end(); it++, index++) {
133 MountNode* node = it->second; 134 MountNode* node = it->second;
134 size_t len = it->first.length(); 135 size_t len = it->first.length();
135 cache_[index].d_ino = node->stat_.st_ino; 136 cache_[index].d_ino = node->stat_.st_ino;
136 cache_[index].d_reclen = sizeof(struct dirent); 137 cache_[index].d_reclen = sizeof(struct dirent);
137 cache_[index].d_name[len] = 0; 138 cache_[index].d_name[len] = 0;
138 strncpy(cache_[index].d_name, &it->first[0], len); 139 strncpy(cache_[index].d_name, &it->first[0], len);
139 } 140 }
140 } 141 }
141 } 142 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698