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

Side by Side Diff: native_client_sdk/src/libraries/nacl_io/passthroughfs/real_node.cc

Issue 832413004: [NaCl SDK] nacl_io: Change default root filesystem type from passthroughfs to memfs Base URL: https://chromium.googlesource.com/chromium/src.git@cleanup_path
Patch Set: Created 5 years, 11 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/passthroughfs/real_node.h" 5 #include "nacl_io/passthroughfs/real_node.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include "nacl_io/kernel_handle.h" 10 #include "nacl_io/kernel_handle.h"
11 #include "nacl_io/kernel_wrap_real.h" 11 #include "nacl_io/kernel_wrap_real.h"
12 #include "nacl_io/log.h" 12 #include "nacl_io/log.h"
13 13
14 namespace nacl_io { 14 namespace nacl_io {
15
15 RealNode::RealNode(Filesystem* filesystem, int real_fd, bool close_on_destroy) 16 RealNode::RealNode(Filesystem* filesystem, int real_fd, bool close_on_destroy)
16 : Node(filesystem), 17 : Node(filesystem),
17 real_fd_(real_fd), 18 real_fd_(real_fd),
18 close_on_destroy_(close_on_destroy) 19 close_on_destroy_(close_on_destroy)
19 { 20 {
21 GetStat(&stat_);
20 } 22 }
21 23
22 void RealNode::Destroy() { 24 void RealNode::Destroy() {
23 if (close_on_destroy_) 25 if (close_on_destroy_)
24 _real_close(real_fd_); 26 _real_close(real_fd_);
25 real_fd_ = -1; 27 real_fd_ = -1;
26 } 28 }
27 29
28 // Normal read/write operations on a file 30 // Normal read/write operations on a file
29 Error RealNode::Read(const HandleAttr& attr, 31 Error RealNode::Read(const HandleAttr& attr,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 84
83 Error RealNode::FTruncate(off_t size) { 85 Error RealNode::FTruncate(off_t size) {
84 // TODO(binji): what to do here? 86 // TODO(binji): what to do here?
85 return ENOSYS; 87 return ENOSYS;
86 } 88 }
87 89
88 Error RealNode::GetDents(size_t offs, 90 Error RealNode::GetDents(size_t offs,
89 struct dirent* pdir, 91 struct dirent* pdir,
90 size_t count, 92 size_t count,
91 int* out_bytes) { 93 int* out_bytes) {
92 size_t nread; 94 return _real_getdents(real_fd_, pdir, count, (size_t*)out_bytes);
93 int err = _real_getdents(real_fd_, pdir, count, &nread);
94 if (err)
95 return err;
96 return nread;
97 } 95 }
98 96
99 Error RealNode::GetStat(struct stat* stat) { 97 Error RealNode::GetStat(struct stat* stat) {
100 int err = _real_fstat(real_fd_, stat); 98 int err = _real_fstat(real_fd_, stat);
101 if (err) 99 if (err)
102 return err; 100 return err;
103 // On windows, fstat() of stdin/stdout/stderr returns all zeros 101 // On windows, fstat() of stdin/stdout/stderr returns all zeros
104 // for the permission bits. This can cause problems down the 102 // for the permission bits. This can cause problems down the
105 // line. For example, CanOpen() will fail. 103 // line. For example, CanOpen() will fail.
106 // TODO(sbc): Fix this within sel_ldr instead. 104 // TODO(sbc): Fix this within sel_ldr instead.
(...skipping 22 matching lines...) Expand all
129 size_t offset, 127 size_t offset,
130 void** out_addr) { 128 void** out_addr) {
131 *out_addr = addr; 129 *out_addr = addr;
132 int err = _real_mmap(out_addr, length, prot, flags, real_fd_, offset); 130 int err = _real_mmap(out_addr, length, prot, flags, real_fd_, offset);
133 if (err) 131 if (err)
134 return err; 132 return err;
135 return 0; 133 return 0;
136 } 134 }
137 135
138 } 136 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698