Skip to content

Commit

Permalink
lxccontainer: do_add_remove_node()
Browse files Browse the repository at this point in the history
thread-safety: s/exit()/_exit()/g

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
  • Loading branch information
Christian Brauner committed Aug 23, 2018
1 parent 06e3cd0 commit 9717124
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/lxc/lxccontainer.c
Expand Up @@ -3975,47 +3975,47 @@ static bool do_add_remove_node(pid_t init_pid, const char *path, bool add,

ret = chroot(chrootpath);
if (ret < 0)
exit(EXIT_FAILURE);
_exit(EXIT_FAILURE);

ret = chdir("/");
if (ret < 0)
exit(EXIT_FAILURE);
_exit(EXIT_FAILURE);

/* remove path if it exists */
ret = faccessat(AT_FDCWD, path, F_OK, AT_SYMLINK_NOFOLLOW);
if(ret == 0) {
ret = unlink(path);
if (ret < 0) {
ERROR("%s - Failed to remove \"%s\"", strerror(errno), path);
exit(EXIT_FAILURE);
_exit(EXIT_FAILURE);
}
}

if (!add)
exit(EXIT_SUCCESS);
_exit(EXIT_SUCCESS);

/* create any missing directories */
tmp = strdup(path);
if (!tmp)
exit(EXIT_FAILURE);
_exit(EXIT_FAILURE);

directory_path = dirname(tmp);
ret = mkdir_p(directory_path, 0755);
if (ret < 0 && errno != EEXIST) {
ERROR("%s - Failed to create path \"%s\"", strerror(errno), directory_path);
free(tmp);
exit(EXIT_FAILURE);
_exit(EXIT_FAILURE);
}

/* create the device node */
ret = mknod(path, st->st_mode, st->st_rdev);
free(tmp);
if (ret < 0) {
ERROR("%s - Failed to create device node at \"%s\"", strerror(errno), path);
exit(EXIT_FAILURE);
_exit(EXIT_FAILURE);
}

exit(EXIT_SUCCESS);
_exit(EXIT_SUCCESS);
}

static bool add_remove_device_node(struct lxc_container *c, const char *src_path, const char *dest_path, bool add)
Expand Down

0 comments on commit 9717124

Please sign in to comment.