MCPcopy Create free account
hub / github.com/coreutils/coreutils / process_dir

Function process_dir

src/mkdir.c:163–199  ·  view source on GitHub ↗

Process a command-line file name. */

Source from the content-addressed store, hash-verified

161
162/* Process a command-line file name. */
163static int
164process_dir (char *dir, struct savewd *wd, void *options)
165{
166 struct mkdir_options const *o = options;
167
168 /* If possible set context before DIR created. */
169 if (o->set_security_context)
170 {
171 if (! o->make_ancestor_function
172 && defaultcon (o->set_security_context, dir, S_IFDIR) < 0
173 && ! ignorable_ctx_err (errno))
174 error (0, errno, _("failed to set default creation context for %s"),
175 quoteaf (dir));
176 }
177
178 int ret = (make_dir_parents (dir, wd, o->make_ancestor_function, options,
179 o->mode, announce_mkdir,
180 o->mode_bits, (uid_t) -1, (gid_t) -1, true)
181 ? EXIT_SUCCESS
182 : EXIT_FAILURE);
183
184 /* FIXME: Due to the current structure of make_dir_parents()
185 we don't have the facility to call defaultcon() before the
186 final component of DIR is created. So for now, create the
187 final component with the context from previous component
188 and here we set the context for the final component. */
189 if (ret == EXIT_SUCCESS && o->set_security_context
190 && o->make_ancestor_function)
191 {
192 if (! restorecon (o->set_security_context, last_component (dir), false)
193 && ! ignorable_ctx_err (errno))
194 error (0, errno, _("failed to restore context for %s"),
195 quoteaf (dir));
196 }
197
198 return ret;
199}
200
201int
202main (int argc, char **argv)

Callers

nothing calls this directly

Calls 3

ignorable_ctx_errFunction · 0.85
defaultconFunction · 0.70
restoreconFunction · 0.70

Tested by

no test coverage detected