Make ancestor directory DIR, whose last component is COMPONENT, with options OPTIONS. Assume the working directory is COMPONENT's parent. Return 0 if successful and the resulting directory is readable, 1 if successful but the resulting directory is not readable, -1 (setting errno) otherwise. */
| 132 | readable, 1 if successful but the resulting directory is not |
| 133 | readable, -1 (setting errno) otherwise. */ |
| 134 | static int |
| 135 | make_ancestor (char const *dir, char const *component, void *options) |
| 136 | { |
| 137 | struct mkdir_options const *o = options; |
| 138 | |
| 139 | if (o->set_security_context |
| 140 | && defaultcon (o->set_security_context, component, S_IFDIR) < 0 |
| 141 | && ! ignorable_ctx_err (errno)) |
| 142 | error (0, errno, _("failed to set default creation context for %s"), |
| 143 | quoteaf (dir)); |
| 144 | |
| 145 | if (o->umask_ancestor != o->umask_self) |
| 146 | umask (o->umask_ancestor); |
| 147 | int r = mkdir (component, S_IRWXUGO); |
| 148 | if (o->umask_ancestor != o->umask_self) |
| 149 | { |
| 150 | int mkdir_errno = errno; |
| 151 | umask (o->umask_self); |
| 152 | errno = mkdir_errno; |
| 153 | } |
| 154 | if (r == 0) |
| 155 | { |
| 156 | r = (o->umask_ancestor & S_IRUSR) != 0; |
| 157 | announce_mkdir (dir, options); |
| 158 | } |
| 159 | return r; |
| 160 | } |
| 161 | |
| 162 | /* Process a command-line file name. */ |
| 163 | static int |
nothing calls this directly
no test coverage detected