+#define must_mount(src, target, fs, opts) \
+ do { \
+ int err = 0; \
+ if ((err = mount(src, target, fs, opts))) { \
+ syslog(2, "mount fs %s to %s failed (%d)\n", fs, target, errno); \
+ return err; \
+ } \
+ } while (0)
+
+#define maybe_mount(src, target, fs, opts) \
+ do { \
+ int err = 0; \
+ if ((err = mount(src, target, fs, opts))) { \
+ syslog(2, "mount fs %s to %s failed (%d)\n", fs, target, errno); \
+ } \
+ } while (0)
+
+#define check(statement) \
+ ({ \
+ int err = 0; \
+ if ((err = (statement)) < 0) { \
+ syslog(2, #statement " failed: %d", err); \
+ _exit(1); \
+ } \
+ err; \
+ })
+
+int
+init_termios(int fd) {
+ struct termios term;
+
+ check(tcgetattr(fd, &term));
+
+ term.c_lflag = ICANON | IEXTEN | ISIG | ECHO | ECHOE | ECHONL;
+ term.c_iflag = ICRNL | IGNBRK;
+ term.c_oflag = ONLCR | OPOST;
+ term.c_cflag = CREAD | CLOCAL | CS8 | CPARENB;
+ term.c_cc[VERASE] = 0x7f;
+
+ cfsetispeed(&term, B9600);
+ cfsetospeed(&term, B9600);
+
+ check(tcsetattr(fd, 0, &term));
+
+ return 0;
+}
+
+const char* sh_argv[] = { "/bin/sh", 0 };
+const char* sh_envp[] = { 0 };
+