-#include "internal.h"
-#include <stdio.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-
-static const char mknod_usage[] = "mknod file b|c|u|p major minor\n"
-"\tMake special files.\n"
-"\n"
-"\tb:\tMake a block (buffered) device.\n"
-"\tc or u:\tMake a character (un-buffered) device.\n"
-"\tp:\tMake a named pipe. Major and minor are ignored for named pipes.\n";
-
-int
-mknod_main(int argc, char** argv)
+/* vi: set sw=4 ts=4: */
+/*
+ * mknod implementation for busybox
+ *
+ * Copyright (C) 2003 Manuel Novoa III <mjn3@codepoet.org>
+ *
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
+ */
+//config:config MKNOD
+//config: bool "mknod (4.5 kb)"
+//config: default y
+//config: help
+//config: mknod is used to create FIFOs or block/character special
+//config: files with the specified names.
+
+//applet:IF_MKNOD(APPLET_NOEXEC(mknod, mknod, BB_DIR_BIN, BB_SUID_DROP, mknod))
+
+//kbuild:lib-$(CONFIG_MKNOD) += mknod.o
+
+/* BB_AUDIT SUSv3 N/A -- Matches GNU behavior. */
+
+//usage:#define mknod_trivial_usage
+//usage: "[-m MODE] " IF_SELINUX("[-Z] ") "NAME TYPE [MAJOR MINOR]"
+//usage:#define mknod_full_usage "\n\n"
+//usage: "Create a special file (block, character, or pipe)\n"
+//usage: "\n -m MODE Creation mode (default a=rw)"
+//usage: IF_SELINUX(
+//usage: "\n -Z Set security context"
+//usage: )
+//usage: "\nTYPE:"
+//usage: "\n b Block device"
+//usage: "\n c or u Character device"
+//usage: "\n p Named pipe (MAJOR MINOR must be omitted)"
+//usage:
+//usage:#define mknod_example_usage
+//usage: "$ mknod /dev/fd0 b 2 0\n"
+//usage: "$ mknod -m 644 /tmp/pipe p\n"
+
+#include <sys/sysmacros.h> // For makedev
+
+#include "libbb.h"
+#include "libcoreutils/coreutils.h"
+
+/* This is a NOEXEC applet. Be very careful! */
+
+static const char modes_chars[] ALIGN1 = { 'p', 'c', 'u', 'b', 0, 1, 1, 2 };
+static const mode_t modes_cubp[] = { S_IFIFO, S_IFCHR, S_IFBLK };
+
+int mknod_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+int mknod_main(int argc UNUSED_PARAM, char **argv)