summaryrefslogtreecommitdiffstats
path: root/init
diff options
context:
space:
mode:
Diffstat (limited to 'init')
-rw-r--r--init/builtins.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/init/builtins.c b/init/builtins.c
index bfdd654..06ef96d 100644
--- a/init/builtins.c
+++ b/init/builtins.c
@@ -229,6 +229,7 @@ int do_insmod(int nargs, char **args)
int do_mkdir(int nargs, char **args)
{
mode_t mode = 0755;
+ int ret;
/* mkdir <path> [mode] [owner] [group] */
@@ -236,7 +237,12 @@ int do_mkdir(int nargs, char **args)
mode = strtoul(args[2], 0, 8);
}
- if (mkdir(args[1], mode)) {
+ ret = mkdir(args[1], mode);
+ /* chmod in case the directory already exists */
+ if (ret == -1 && errno == EEXIST) {
+ ret = chmod(args[1], mode);
+ }
+ if (ret == -1) {
return -errno;
}