aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormaximilian attems <max@stro.at>2008-03-28 20:49:35 +0100
committermaximilian attems <max@stro.at>2008-03-28 21:25:36 +0100
commit045990b374200b1fb6deebfba7c1ba1970e3b158 (patch)
treee2b15ecb19bed73f8ca4bb85cab82863dcfde1cc
parentc841d5ee7fc1bce2a7ac309a9283fcfa77c9f868 (diff)
downloadklibc-045990b374200b1fb6deebfba7c1ba1970e3b158.tar.gz
[klibc] mknod: allow to specify modeklibc-1.5.9
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>
-rw-r--r--usr/utils/mknod.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/usr/utils/mknod.c b/usr/utils/mknod.c
index 89f0da41fd931..14f8fddf00d8d 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 @@ int main(int argc, char *argv[])
{
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 @@ int main(int argc, char *argv[])
exit(1);
}
+ if (mode_set && chmod(name, mode_set)) {
+ perror("chmod");
+ exit(1);
+ }
+
exit(0);
}