diff options
author | Chia-chi Yeh <chiachi@android.com> | 2011-07-08 12:57:36 -0700 |
---|---|---|
committer | Chia-chi Yeh <chiachi@android.com> | 2011-07-08 16:06:56 -0700 |
commit | 27164dce5f0788476449057c978fa24e62245cb8 (patch) | |
tree | 3ddfacbfa7bc7e012b28710e519620df993c47ce /init | |
parent | e89675584df1f02dd4642585493a19ac3e691bc5 (diff) | |
download | system_core-27164dce5f0788476449057c978fa24e62245cb8.zip system_core-27164dce5f0788476449057c978fa24e62245cb8.tar.gz system_core-27164dce5f0788476449057c978fa24e62245cb8.tar.bz2 |
init: make "mkdir" work even when the directory already exists.
This allows us to change permissions and ownerships of directories
in init scripts without adding additional commands.
Change-Id: I1815d6015953035251b98f28c0f3efd3c7f25f80
Diffstat (limited to 'init')
-rw-r--r-- | init/builtins.c | 8 |
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; } |