summaryrefslogtreecommitdiffstats
path: root/toolbox/mknod.c
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2014-12-11 18:33:46 -0800
committerElliott Hughes <enh@google.com>2014-12-11 18:33:46 -0800
commit71cf21fe1f2fede09b1ec073e785908568b29252 (patch)
tree892f1b03ac5f73879a6cb357ae9647351f1a5a62 /toolbox/mknod.c
parentd1090ea0287e980e286d7622093564fdb0e00b0e (diff)
downloadsystem_core-71cf21fe1f2fede09b1ec073e785908568b29252.zip
system_core-71cf21fe1f2fede09b1ec073e785908568b29252.tar.gz
system_core-71cf21fe1f2fede09b1ec073e785908568b29252.tar.bz2
Lose mknod to toybox.
Change-Id: Ib81efed6c06a776626a42c25508b15461e495288
Diffstat (limited to 'toolbox/mknod.c')
-rw-r--r--toolbox/mknod.c95
1 files changed, 0 insertions, 95 deletions
diff --git a/toolbox/mknod.c b/toolbox/mknod.c
deleted file mode 100644
index 0fedece..0000000
--- a/toolbox/mknod.c
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 2014, The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google, Inc. nor the names of its contributors
- * may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/stat.h>
-
-static int print_usage() {
- fprintf(stderr, "mknod <path> [b|c|u|p] <major> <minor>\n");
- return EXIT_FAILURE;
-}
-
-int mknod_main(int argc, char **argv) {
- char *path = NULL;
- int major = 0;
- int minor = 0;
- int args = 0;
- mode_t mode = 0660;
-
- /* Check correct argument count is 3 or 5 */
- if (argc != 3 && argc != 5) {
- fprintf(stderr, "Incorrect argument count\n");
- return print_usage();
- }
-
- path = argv[1];
-
- const char node_type = *argv[2];
- switch (node_type) {
- case 'b':
- mode |= S_IFBLK;
- args = 5;
- break;
- case 'c':
- case 'u':
- mode |= S_IFCHR;
- args = 5;
- break;
- case 'p':
- mode |= S_IFIFO;
- args = 3;
- break;
- default:
- fprintf(stderr, "Invalid node type '%c'\n", node_type);
- return print_usage();
- }
-
- if (argc != args) {
- if (args == 5) {
- fprintf(stderr, "Node type '%c' requires <major> and <minor>\n", node_type);
- } else {
- fprintf(stderr, "Node type '%c' does not require <major> and <minor>\n", node_type);
- }
- return print_usage();
- }
-
- if (args == 5) {
- major = atoi(argv[3]);
- minor = atoi(argv[4]);
- }
-
- if (mknod(path, mode, makedev(major, minor))) {
- perror("Unable to create node");
- return EXIT_FAILURE;
- }
- return 0;
-}