Commit 994478b0 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

util: Make mkdirpat more generic

 - take @mode into account
 - return system error codes on error

travis-ci: success for Multiple nested deleted dentries fix
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent cf5c57bf
......@@ -1510,7 +1510,7 @@ static int prepare_cgroup_dirs(char **controllers, int n_controllers, char *paux
return -1;
}
if (mkdirpat(cg, paux)) {
if (mkdirpat(cg, paux, 0755)) {
pr_perror("Can't make cgroup dir %s", paux);
return -1;
}
......
......@@ -247,7 +247,7 @@ static inline bool issubpath(const char *path, const char *sub_path)
/*
* mkdir -p
*/
int mkdirpat(int fd, const char *path);
int mkdirpat(int fd, const char *path, int mode);
/*
* Tests whether a path is a prefix of another path. This is different than
......
......@@ -801,14 +801,14 @@ struct vma_area *alloc_vma_area(void)
return p;
}
int mkdirpat(int fd, const char *path)
int mkdirpat(int fd, const char *path, int mode)
{
size_t i;
char made_path[PATH_MAX], *pos;
if (strlen(path) >= PATH_MAX) {
pr_err("path %s is longer than PATH_MAX\n", path);
return -1;
return -ENOSPC;
}
strcpy(made_path, path);
......@@ -821,9 +821,10 @@ int mkdirpat(int fd, const char *path)
pos = strchr(made_path + i, '/');
if (pos)
*pos = '\0';
if (mkdirat(fd, made_path, 0755) < 0 && errno != EEXIST) {
if (mkdirat(fd, made_path, mode) < 0 && errno != EEXIST) {
int ret = -errno;
pr_perror("couldn't mkdirpat directory %s", made_path);
return -1;
return ret;
}
if (pos) {
*pos = '/';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment