[klibc] mknod: allow to specify mode

some bootup scripts assume that you can set permissions.
-> http://bugs.debian.org/469577
this allows for static dev to set permissions of devices
without leaving root holes.

inspiration taken on mknod from klibc-extra of archlinux.
size increase is not big compaired to gain:
size usr/utils/shared/mknod
   text    data     bss     dec     hex filename
    978       0       8     986     3da usr/utils/shared/mknod.old
   1090       0       8    1098     44a usr/utils/shared/mknod
   9312      32      48    9392    24b0 usr/utils/static/mknod.old
   9520      32      48    9600    2580 usr/utils/static/mknod

Signed-off-by: maximilian attems <max@stro.at>
diff --git a/usr/utils/mknod.c b/usr/utils/mknod.c
index 89f0da4..14f8fdd 100644
--- a/usr/utils/mknod.c
+++ b/usr/utils/mknod.c
@@ -1,12 +1,14 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <sys/stat.h>
 
 char *progname;
 
 static __noreturn usage(void)
 {
-	fprintf(stderr, "Usage: %s name {b|c|p} major minor\n", progname);
+	fprintf(stderr, "Usage: %s [-m mode] name {b|c|p} major minor\n",
+			progname);
 	exit(1);
 }
 
@@ -14,11 +16,16 @@
 {
 	char *name, *type, typec, *endp;
 	unsigned int major_num, minor_num;
-	mode_t mode;
+	mode_t mode, mode_set = 0;
 	dev_t dev;
 
 	progname = *argv++;
 
+	if (argv[0][0] == '-' && argv[0][1] == 'm' && !argv[0][2]) {
+		mode_set = strtoul(argv[1], &endp, 8);
+		argv += 2;
+	}
+
 	name = *argv++;
 	if (!name)
 		usage();
@@ -66,5 +73,10 @@
 		exit(1);
 	}
 
+	if (mode_set && chmod(name, mode_set)) {
+		perror("chmod");
+		exit(1);
+	}
+
 	exit(0);
 }