OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 #include <assert.h> | 6 #include <assert.h> |
7 #include <list> | 7 #include <list> |
8 #include <utility> | 8 #include <utility> |
9 #include "../console/ConsoleMount.h" | 9 #include "../console/ConsoleMount.h" |
| 10 #include "../dev/DevMount.h" |
10 #include "KernelProxy.h" | 11 #include "KernelProxy.h" |
11 #include "MountManager.h" | 12 #include "MountManager.h" |
12 | 13 |
13 static pthread_once_t kp_once_ = PTHREAD_ONCE_INIT; | 14 static pthread_once_t kp_once_ = PTHREAD_ONCE_INIT; |
14 KernelProxy *KernelProxy::kp_instance_; | 15 KernelProxy *KernelProxy::kp_instance_; |
15 | 16 |
16 #ifndef MAXPATHLEN | 17 #ifndef MAXPATHLEN |
17 #define MAXPATHLEN 256 | 18 #define MAXPATHLEN 256 |
18 #endif | 19 #endif |
19 | 20 |
20 KernelProxy::KernelProxy() { | 21 KernelProxy::KernelProxy() { |
21 if (pthread_mutex_init(&kp_lock_, NULL)) assert(0); | 22 if (pthread_mutex_init(&kp_lock_, NULL)) assert(0); |
22 cwd_ = Path("/"); | 23 cwd_ = Path("/"); |
23 mm_.Init(); | 24 mm_.Init(); |
24 | 25 |
25 // Setup file descriptors 0, 1, and 2 for STDIN, STDOUT, and STDERR | 26 // Setup file descriptors 0, 1, and 2 for STDIN, STDOUT, and STDERR |
26 int ret = mkdir("/dev", 0777); | 27 int ret = mkdir("/dev", 0777); |
27 assert(ret == 0); | 28 assert(ret == 0); |
| 29 DevMount* dev_mount = new DevMount(); |
| 30 ret = mm_.AddMount(dev_mount, "/dev"); |
| 31 assert(ret == 0); |
28 ret = mkdir("/dev/fd", 0777); | 32 ret = mkdir("/dev/fd", 0777); |
29 assert(ret == 0); | 33 assert(ret == 0); |
30 ConsoleMount *console_mount = new ConsoleMount(); | 34 ConsoleMount *console_mount = new ConsoleMount(); |
31 ret = mm_.AddMount(console_mount, "/dev/fd"); | 35 ret = mm_.AddMount(console_mount, "/dev/fd"); |
32 assert(ret == 0); | 36 assert(ret == 0); |
33 int fd = open("/dev/fd/0", O_CREAT | O_RDWR, 0); | 37 int fd = open("/dev/fd/0", O_CREAT | O_RDWR, 0); |
34 assert(fd == 0); | 38 assert(fd == 0); |
35 fd = open("/dev/fd/1", O_CREAT | O_RDWR, 0); | 39 fd = open("/dev/fd/1", O_CREAT | O_RDWR, 0); |
36 assert(fd == 1); | 40 assert(fd == 1); |
37 fd = open("/dev/fd/2", O_CREAT | O_RDWR, 0); | 41 fd = open("/dev/fd/2", O_CREAT | O_RDWR, 0); |
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
837 | 841 |
838 int KernelProxy::ppoll(struct pollfd *fds, nfds_t nfds, | 842 int KernelProxy::ppoll(struct pollfd *fds, nfds_t nfds, |
839 const struct timespec *timeout, | 843 const struct timespec *timeout, |
840 const sigset_t *sigmask, size_t sigset_size) { | 844 const sigset_t *sigmask, size_t sigset_size) { |
841 errno = ENOSYS; | 845 errno = ENOSYS; |
842 fprintf(stderr, "ppoll has not been implemented!\n"); | 846 fprintf(stderr, "ppoll has not been implemented!\n"); |
843 return -1; | 847 return -1; |
844 } | 848 } |
845 #endif | 849 #endif |
846 | 850 |
OLD | NEW |