fix musl problem with dirname, now for all users of bb_make_directory()

function                                             old     new   delta
bb_make_directory                                    412     419      +7
install_main                                         793     769     -24
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 7/-24)             Total: -17 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko
2016-12-04 10:42:07 +01:00
parent fdb4421e00
commit 4bd0c2ab38
2 changed files with 16 additions and 11 deletions

View File

@ -35,9 +35,20 @@ int FAST_FUNC bb_make_directory(char *path, long mode, int flags)
char c;
struct stat st;
/* Happens on bb_make_directory(dirname("no_slashes"),...) */
if (LONE_CHAR(path, '.'))
/* "path" can be a result of dirname().
* dirname("no_slashes") returns ".", possibly read-only.
* musl dirname() can return read-only "/" too.
* We need writable string. And for "/", "." (and ".."?)
* nothing needs to be created anyway.
*/
if (LONE_CHAR(path, '/'))
return 0;
if (path[0] == '.') {
if (path[1] == '\0')
return 0; /* "." */
// if (path[1] == '.' && path[2] == '\0')
// return 0; /* ".." */
}
org_mask = cur_mask = (mode_t)-1L;
s = path;