diff options
author | Matt Kraai <kraai@debian.org> | 2001-08-24 19:51:54 +0000 |
---|---|---|
committer | Matt Kraai <kraai@debian.org> | 2001-08-24 19:51:54 +0000 |
commit | ac20ce1924a0eb563acfda6533a80701cd611bfa (patch) | |
tree | 5209668fde99a5caa4ed41d8d61c73770fcae646 /libbb/make_directory.c | |
parent | 2a953aed3831f8705444e720783ad4781904a625 (diff) | |
download | busybox-w32-ac20ce1924a0eb563acfda6533a80701cd611bfa.tar.gz busybox-w32-ac20ce1924a0eb563acfda6533a80701cd611bfa.tar.bz2 busybox-w32-ac20ce1924a0eb563acfda6533a80701cd611bfa.zip |
Canonicalize dirname(3) behavior.
Diffstat (limited to 'libbb/make_directory.c')
-rw-r--r-- | libbb/make_directory.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/libbb/make_directory.c b/libbb/make_directory.c index 7b7fde911..a06a410d2 100644 --- a/libbb/make_directory.c +++ b/libbb/make_directory.c | |||
@@ -50,13 +50,17 @@ int make_directory (char *path, long mode, int flags) | |||
50 | 50 | ||
51 | if (stat (path, &st) < 0 && errno == ENOENT) { | 51 | if (stat (path, &st) < 0 && errno == ENOENT) { |
52 | int status; | 52 | int status; |
53 | char *parent = dirname (path); | 53 | char *buf, *parent; |
54 | mode_t mask = umask (0); | 54 | mode_t mask; |
55 | |||
56 | mask = umask (0); | ||
55 | umask (mask); | 57 | umask (mask); |
56 | 58 | ||
59 | buf = xstrdup (path); | ||
60 | parent = dirname (buf); | ||
57 | status = make_directory (parent, (0777 & ~mask) | 0300, | 61 | status = make_directory (parent, (0777 & ~mask) | 0300, |
58 | FILEUTILS_RECUR); | 62 | FILEUTILS_RECUR); |
59 | free (parent); | 63 | free (buf); |
60 | 64 | ||
61 | if (status < 0 || make_directory (path, mode, 0) < 0) | 65 | if (status < 0 || make_directory (path, mode, 0) < 0) |
62 | return -1; | 66 | return -1; |