Chromium Code Reviews| 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_io/kernel_proxy.h" | 5 #include "nacl_io/kernel_proxy.h" |
| 6 | 6 |
| 7 | 7 |
| 8 #include <assert.h> | 8 #include <assert.h> |
| 9 #include <errno.h> | 9 #include <errno.h> |
| 10 #include <fcntl.h> | 10 #include <fcntl.h> |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 // Clean up the MountFactories. | 78 // Clean up the MountFactories. |
| 79 for (MountFactoryMap_t::iterator i = factories_.begin(); | 79 for (MountFactoryMap_t::iterator i = factories_.begin(); |
| 80 i != factories_.end(); | 80 i != factories_.end(); |
| 81 ++i) { | 81 ++i) { |
| 82 delete i->second; | 82 delete i->second; |
| 83 } | 83 } |
| 84 | 84 |
| 85 delete ppapi_; | 85 delete ppapi_; |
| 86 } | 86 } |
| 87 | 87 |
| 88 void KernelProxy::Init(PepperInterface* ppapi) { | 88 Error KernelProxy::Init(PepperInterface* ppapi) { |
| 89 Error rtn = 0; | |
| 89 ppapi_ = ppapi; | 90 ppapi_ = ppapi; |
| 90 dev_ = 1; | 91 dev_ = 1; |
| 91 | 92 |
| 92 factories_["memfs"] = new TypedMountFactory<MountMem>; | 93 factories_["memfs"] = new TypedMountFactory<MountMem>; |
| 93 factories_["dev"] = new TypedMountFactory<MountDev>; | 94 factories_["dev"] = new TypedMountFactory<MountDev>; |
| 94 factories_["html5fs"] = new TypedMountFactory<MountHtml5Fs>; | 95 factories_["html5fs"] = new TypedMountFactory<MountHtml5Fs>; |
| 95 factories_["httpfs"] = new TypedMountFactory<MountHttp>; | 96 factories_["httpfs"] = new TypedMountFactory<MountHttp>; |
| 96 factories_["passthroughfs"] = new TypedMountFactory<MountPassthrough>; | 97 factories_["passthroughfs"] = new TypedMountFactory<MountPassthrough>; |
| 97 | 98 |
| 98 int result; | 99 int result; |
| 99 result = mount("", "/", "passthroughfs", 0, NULL); | 100 result = mount("", "/", "passthroughfs", 0, NULL); |
| 100 assert(result == 0); | 101 assert(result == 0); |
| 102 if (result != 0) | |
|
binji
2013/08/24 01:35:57
maybe use assert(false) inside the if instead?
| |
| 103 rtn = errno; | |
| 101 | 104 |
| 102 result = mount("", "/dev", "dev", 0, NULL); | 105 result = mount("", "/dev", "dev", 0, NULL); |
| 103 assert(result == 0); | 106 assert(result == 0); |
| 107 if (result != 0) | |
| 108 rtn = errno; | |
| 104 | 109 |
| 105 // Open the first three in order to get STDIN, STDOUT, STDERR | 110 // Open the first three in order to get STDIN, STDOUT, STDERR |
| 106 open("/dev/stdin", O_RDONLY); | 111 int fd; |
| 107 open("/dev/stdout", O_WRONLY); | 112 fd = open("/dev/stdin", O_RDONLY); |
| 108 open("/dev/stderr", O_WRONLY); | 113 assert(fd == 0); |
| 114 fd = open("/dev/stdout", O_WRONLY); | |
| 115 assert(fd == 1); | |
| 116 fd = open("/dev/stderr", O_WRONLY); | |
| 117 assert(fd == 2); | |
| 109 | 118 |
| 110 #ifdef PROVIDES_SOCKET_API | 119 #ifdef PROVIDES_SOCKET_API |
| 111 host_resolver_.Init(ppapi_); | 120 host_resolver_.Init(ppapi_); |
| 112 #endif | 121 #endif |
| 113 | 122 |
| 114 StringMap_t args; | 123 StringMap_t args; |
| 115 socket_mount_.reset(new MountSocket()); | 124 socket_mount_.reset(new MountSocket()); |
| 116 socket_mount_->Init(0, args, ppapi); | 125 result = socket_mount_->Init(0, args, ppapi); |
| 126 assert(result == 0); | |
| 127 if (result != 0) | |
| 128 rtn = result; | |
| 129 | |
| 130 return rtn; | |
| 117 } | 131 } |
| 118 | 132 |
| 119 int KernelProxy::open_resource(const char* path) { | 133 int KernelProxy::open_resource(const char* path) { |
| 120 ScopedMount mnt; | 134 ScopedMount mnt; |
| 121 Path rel; | 135 Path rel; |
| 122 | 136 |
| 123 Error error = AcquireMountAndRelPath(path, &mnt, &rel); | 137 Error error = AcquireMountAndRelPath(path, &mnt, &rel); |
| 124 if (error) { | 138 if (error) { |
| 125 errno = error; | 139 errno = error; |
| 126 return -1; | 140 return -1; |
| (...skipping 1241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1368 errno = ENOTSOCK; | 1382 errno = ENOTSOCK; |
| 1369 return -1; | 1383 return -1; |
| 1370 } | 1384 } |
| 1371 | 1385 |
| 1372 return 0; | 1386 return 0; |
| 1373 } | 1387 } |
| 1374 | 1388 |
| 1375 #endif // PROVIDES_SOCKET_API | 1389 #endif // PROVIDES_SOCKET_API |
| 1376 | 1390 |
| 1377 } // namespace_nacl_io | 1391 } // namespace_nacl_io |
| OLD | NEW |