Quote:
Originally Posted by
jlliagre
I see nothing
Good point I forgot the
code:
c code:
if (mkdir(arg, mode) < 0)
{
if (!pflag || !(errno == ENOENT || errno == EEXIST || errno == ENOTDIR))
{
error(ERROR_system(0), "%s:", arg);
continue;
}
if (errno == EEXIST)
continue;
/*
* -p option, preserve intermediates
* first eliminate trailing /'s
*/
while (n > 0 && arg[--n] == '/');
arg[n + 1] = 0;
for (name = arg, n = *arg; n;)
{
/* skip over slashes */
while (*arg == '/')
arg++;
/* skip to next component */
while ((n = *arg) && n != '/')
arg++;
*arg = 0;
if (mkdir(name, n ? dmode : mode) < 0 && errno != EEXIST && access(name, F_OK) < 0)
{
*arg = n;
error(ERROR_system(0), "%s:", name);
break;
}
if (!(*arg = n) && (mode & (S_ISVTX|S_ISUID|S_ISGID)))
{
if (stat(name, &st))
{
error(ERROR_system(0), "%s: cannot stat", name);
break;
}
if ((st.st_mode & (S_ISVTX|S_ISUID|S_ISGID)) != (mode & (S_ISVTX|S_ISUID|S_ISGID)) && chmod(name, mode))
{
error(ERROR_system(0), "%s: cannot change mode from %s to %s", name, fmtperm(st.st_mode & (S_ISVTX|S_ISUID|S_ISGID)), fmtperm(mode));
break;
}
}
}
}