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

Side by Side Diff: native_client_sdk/src/libraries/nacl_io/kernel_proxy.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, 2 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 (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_io/kernel_proxy.h" 5 #include "nacl_io/kernel_proxy.h"
6 6
7 #include <assert.h> 7 #include <assert.h>
8 #include <errno.h> 8 #include <errno.h>
9 #include <fcntl.h> 9 #include <fcntl.h>
10 #include <limits.h> 10 #include <limits.h>
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 delete i->second; 70 delete i->second;
71 } 71 }
72 } 72 }
73 73
74 Error KernelProxy::Init(PepperInterface* ppapi) { 74 Error KernelProxy::Init(PepperInterface* ppapi) {
75 Error rtn = 0; 75 Error rtn = 0;
76 ppapi_ = ppapi; 76 ppapi_ = ppapi;
77 dev_ = 1; 77 dev_ = 1;
78 78
79 factories_["memfs"] = new TypedFsFactory<MemFs>; 79 factories_["memfs"] = new TypedFsFactory<MemFs>;
80 factories_["dev"] = new TypedFsFactory<DevFs>; 80 factories_["devfs"] = new TypedFsFactory<DevFs>;
81 factories_["html5fs"] = new TypedFsFactory<Html5Fs>; 81 factories_["html5fs"] = new TypedFsFactory<Html5Fs>;
82 factories_["httpfs"] = new TypedFsFactory<HttpFs>; 82 factories_["httpfs"] = new TypedFsFactory<HttpFs>;
83 factories_["passthroughfs"] = new TypedFsFactory<PassthroughFs>; 83 factories_["passthroughfs"] = new TypedFsFactory<PassthroughFs>;
84 84
85 ScopedFilesystem root_fs; 85 ScopedFilesystem root_fs;
86 rtn = MountInternal("", "/", "passthroughfs", 0, NULL, false, &root_fs); 86 rtn = MountInternal("", "/", "memfs", 0, NULL, false, &root_fs);
87 if (rtn != 0)
88 return rtn;
89 rtn = this->mkdir("/dev", 0777);
87 if (rtn != 0) 90 if (rtn != 0)
88 return rtn; 91 return rtn;
89 92
90 ScopedFilesystem fs; 93 ScopedFilesystem fs;
91 rtn = MountInternal("", "/dev", "dev", 0, NULL, false, &fs); 94 rtn = MountInternal("", "/dev", "devfs", 0, NULL, false, &fs);
92 if (rtn != 0) 95 if (rtn != 0)
93 return rtn; 96 return rtn;
94 dev_fs_ = sdk_util::static_scoped_ref_cast<DevFs>(fs); 97 dev_fs_ = sdk_util::static_scoped_ref_cast<DevFs>(fs);
95 98
96 // Create the filesystem nodes for / and /dev afterward. They can't be 99 // Create the filesystem nodes for / and /dev afterward. They can't be
97 // created the normal way because the dev filesystem didn't exist yet. 100 // created the normal way because the dev filesystem didn't exist yet.
98 rtn = CreateFsNode(root_fs); 101 rtn = CreateFsNode(root_fs);
99 if (rtn != 0) 102 if (rtn != 0)
100 return rtn; 103 return rtn;
101 104
102 rtn = CreateFsNode(dev_fs_); 105 rtn = CreateFsNode(dev_fs_);
103 if (rtn != 0) 106 if (rtn != 0)
104 return rtn; 107 return rtn;
105 108
106 // Open the first three in order to get STDIN, STDOUT, STDERR 109 // Open the first three in order to get STDIN, STDOUT, STDERR
107 int fd; 110 int fd;
108 fd = open("/dev/stdin", O_RDONLY, 0); 111 fd = this->open("/dev/stdin", O_RDONLY, 0);
109 if (fd < 0) { 112 if (fd < 0) {
110 LOG_ERROR("failed to open /dev/stdin: %s", strerror(errno)); 113 LOG_ERROR("failed to open /dev/stdin: %s", strerror(errno));
111 return errno; 114 return errno;
112 } 115 }
113 assert(fd == 0); 116 assert(fd == 0);
114 117
115 fd = open("/dev/stdout", O_WRONLY, 0); 118 fd = this->open("/dev/stdout", O_WRONLY, 0);
116 if (fd < 0) { 119 if (fd < 0) {
117 LOG_ERROR("failed to open /dev/stdout: %s", strerror(errno)); 120 LOG_ERROR("failed to open /dev/stdout: %s", strerror(errno));
118 return errno; 121 return errno;
119 } 122 }
120 assert(fd == 1); 123 assert(fd == 1);
121 124
122 fd = open("/dev/stderr", O_WRONLY, 0); 125 fd = this->open("/dev/stderr", O_WRONLY, 0);
123 if (fd < 0) { 126 if (fd < 0) {
124 LOG_ERROR("failed to open /dev/sterr: %s", strerror(errno)); 127 LOG_ERROR("failed to open /dev/sterr: %s", strerror(errno));
125 return errno; 128 return errno;
126 } 129 }
127 assert(fd == 2); 130 assert(fd == 2);
128 131
129 #ifdef PROVIDES_SOCKET_API 132 #ifdef PROVIDES_SOCKET_API
130 host_resolver_.Init(ppapi_); 133 host_resolver_.Init(ppapi_);
131 #endif 134 #endif
132 135
(...skipping 1709 matching lines...) Expand 10 before | Expand all | Expand 10 after
1842 errno = ENOTSOCK; 1845 errno = ENOTSOCK;
1843 return -1; 1846 return -1;
1844 } 1847 }
1845 1848
1846 return 0; 1849 return 0;
1847 } 1850 }
1848 1851
1849 #endif // PROVIDES_SOCKET_API 1852 #endif // PROVIDES_SOCKET_API
1850 1853
1851 } // namespace_nacl_io 1854 } // namespace_nacl_io
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698