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

Function make_ancestor

src/mkdir.c:134–160  ·  view source on GitHub ↗

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. */

Source from the content-addressed store, hash-verified

132 readable, 1 if successful but the resulting directory is not
133 readable, -1 (setting errno) otherwise. */
134static int
135make_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. */
163static int

Callers

nothing calls this directly

Calls 3

ignorable_ctx_errFunction · 0.85
defaultconFunction · 0.70
announce_mkdirFunction · 0.70

Tested by

no test coverage detected