Skip to content

Commit e606934

Browse files
committed
Mount devtmpfs filesystem for NodeOS & updated documentation
1 parent 7243ea5 commit e606934

2 files changed

Lines changed: 17 additions & 7 deletions

File tree

README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,22 @@ system when there's no more running ones. It was initially based on
77

88
## Why?
99

10-
NodeOS is an operating system build entirely on Node.js, also it's `PID 1` init
11-
[century](https://github.com/NodeOS/node-century). Problem is, since v0.11.15
12-
the version of v8 was changed from v3.26.33 to v3.28.73, and a bug was inserted
13-
that forbid to use it as `PID 1` anymore. Due to this, we need to use a more
14-
"traditional" C-based init executable.
10+
NodeOS is an operating system build entirely on Node.js, and also it was its
11+
`PID 1` init process ([century](https://github.com/NodeOS/node-century)).
12+
Problem is, on v0.11.15 Node.js upgraded the version of v8 from v3.26.33 to
13+
v3.28.73, and a regression was introducced that don't allow to use it as `PID 1`
14+
anymore, seems related to the need of having a `devtmpfs` filesystem mounted on
15+
`/dev` and not only defined a `/dev/console` device file. Due to this, we need
16+
to mount it previously to any instance of Node.js can be executed, but also we
17+
can this way control better the processes termination and cleanly shutdown the
18+
system instead of get a *Kernel panic*.
1519

1620
## How?
1721

18-
There are 3 signals that sinit will act on.
22+
There are 3 signals that NodeOS-init will act on.
1923

2024
* *SIGCHLD*: reap children
21-
* *SIGINT*: reboots the machine (or alternatively via ctrl-alt-del)
25+
* *SIGINT*: reboots the machine (or alternatively via `ctrl-alt-del`)
2226
* *SIGTERM*: send the `SIGTERM` to all its child processes and later shutdown
2327

2428
It also shutdown the machine when it detect there are no more child processes.

init.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <linux/reboot.h>
44

5+
#include <sys/mount.h>
56
#include <sys/reboot.h>
67
#include <sys/types.h>
78
#include <sys/wait.h>
@@ -148,6 +149,11 @@ int main(int argc, char* argv[])
148149
// Prepare signals
149150
sigset_t set = prepareSignals();
150151

152+
// Mount `devtmpfs` filesystem in `/dev`. This is mandatory for Node.js on
153+
// NodeOS, but it's fairly common so it doesn't hurts (too much...)
154+
if(mount("devtmpfs", "/dev", "devtmpfs", 0, NULL) == -1)
155+
perror("mount");
156+
151157
// Exec init command
152158
spawn(getCommand(argc, argv));
153159

0 commit comments

Comments
 (0)