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 #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 Loading... |
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_["devfs"] = new TypedFsFactory<DevFs>; |
| 81 // 'devfs' used to be known as simply 'dev' |
80 factories_["dev"] = new TypedFsFactory<DevFs>; | 82 factories_["dev"] = new TypedFsFactory<DevFs>; |
81 factories_["html5fs"] = new TypedFsFactory<Html5Fs>; | 83 factories_["html5fs"] = new TypedFsFactory<Html5Fs>; |
82 factories_["httpfs"] = new TypedFsFactory<HttpFs>; | 84 factories_["httpfs"] = new TypedFsFactory<HttpFs>; |
83 factories_["passthroughfs"] = new TypedFsFactory<PassthroughFs>; | 85 factories_["passthroughfs"] = new TypedFsFactory<PassthroughFs>; |
84 | 86 |
85 ScopedFilesystem root_fs; | 87 ScopedFilesystem root_fs; |
86 rtn = MountInternal("", "/", "passthroughfs", 0, NULL, false, &root_fs); | 88 rtn = MountInternal("", "/", "memfs", 0, NULL, false, &root_fs); |
| 89 if (rtn != 0) |
| 90 return rtn; |
| 91 rtn = this->mkdir("/dev", 0777); |
87 if (rtn != 0) | 92 if (rtn != 0) |
88 return rtn; | 93 return rtn; |
89 | 94 |
90 ScopedFilesystem fs; | 95 ScopedFilesystem fs; |
91 rtn = MountInternal("", "/dev", "dev", 0, NULL, false, &fs); | 96 rtn = MountInternal("", "/dev", "devfs", 0, NULL, false, &fs); |
92 if (rtn != 0) | 97 if (rtn != 0) |
93 return rtn; | 98 return rtn; |
94 dev_fs_ = sdk_util::static_scoped_ref_cast<DevFs>(fs); | 99 dev_fs_ = sdk_util::static_scoped_ref_cast<DevFs>(fs); |
95 | 100 |
96 // Create the filesystem nodes for / and /dev afterward. They can't be | 101 // 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. | 102 // created the normal way because the dev filesystem didn't exist yet. |
98 rtn = CreateFsNode(root_fs); | 103 rtn = CreateFsNode(root_fs); |
99 if (rtn != 0) | 104 if (rtn != 0) |
100 return rtn; | 105 return rtn; |
101 | 106 |
102 rtn = CreateFsNode(dev_fs_); | 107 rtn = CreateFsNode(dev_fs_); |
103 if (rtn != 0) | 108 if (rtn != 0) |
104 return rtn; | 109 return rtn; |
105 | 110 |
106 // Open the first three in order to get STDIN, STDOUT, STDERR | 111 // Open the first three in order to get STDIN, STDOUT, STDERR |
107 int fd; | 112 int fd; |
108 fd = open("/dev/stdin", O_RDONLY, 0); | 113 fd = this->open("/dev/stdin", O_RDONLY, 0); |
109 if (fd < 0) { | 114 if (fd < 0) { |
110 LOG_ERROR("failed to open /dev/stdin: %s", strerror(errno)); | 115 LOG_ERROR("failed to open /dev/stdin: %s", strerror(errno)); |
111 return errno; | 116 return errno; |
112 } | 117 } |
113 assert(fd == 0); | 118 assert(fd == 0); |
114 | 119 |
115 fd = open("/dev/stdout", O_WRONLY, 0); | 120 fd = this->open("/dev/stdout", O_WRONLY, 0); |
116 if (fd < 0) { | 121 if (fd < 0) { |
117 LOG_ERROR("failed to open /dev/stdout: %s", strerror(errno)); | 122 LOG_ERROR("failed to open /dev/stdout: %s", strerror(errno)); |
118 return errno; | 123 return errno; |
119 } | 124 } |
120 assert(fd == 1); | 125 assert(fd == 1); |
121 | 126 |
122 fd = open("/dev/stderr", O_WRONLY, 0); | 127 fd = this->open("/dev/stderr", O_WRONLY, 0); |
123 if (fd < 0) { | 128 if (fd < 0) { |
124 LOG_ERROR("failed to open /dev/sterr: %s", strerror(errno)); | 129 LOG_ERROR("failed to open /dev/sterr: %s", strerror(errno)); |
125 return errno; | 130 return errno; |
126 } | 131 } |
127 assert(fd == 2); | 132 assert(fd == 2); |
128 | 133 |
129 #ifdef PROVIDES_SOCKET_API | 134 #ifdef PROVIDES_SOCKET_API |
130 host_resolver_.Init(ppapi_); | 135 host_resolver_.Init(ppapi_); |
131 #endif | 136 #endif |
132 | 137 |
(...skipping 1685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1818 errno = ENOTSOCK; | 1823 errno = ENOTSOCK; |
1819 return -1; | 1824 return -1; |
1820 } | 1825 } |
1821 | 1826 |
1822 return 0; | 1827 return 0; |
1823 } | 1828 } |
1824 | 1829 |
1825 #endif // PROVIDES_SOCKET_API | 1830 #endif // PROVIDES_SOCKET_API |
1826 | 1831 |
1827 } // namespace_nacl_io | 1832 } // namespace_nacl_io |
OLD | NEW |