Commit 8e90ed8c authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

util: add a function for running scripts

Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 45fa1848
......@@ -323,5 +323,6 @@ static inline int read_img_str(int fd, char **pstr, int size)
extern void *shmalloc(size_t bytes);
extern void shfree_last(void *ptr);
extern int run_scripts(char *action);
#endif /* UTIL_H_ */
......@@ -387,3 +387,20 @@ void shfree_last(void *ptr)
sh_bytes_left += sh_last_size;
sh_last_size = 0;
}
int run_scripts(char *action)
{
struct script *script;
int ret = 0;
if (setenv("CRTOOLS_SCRIPT_ACTION", action, 1)) {
pr_perror("Can't set CRTOOL_SCRIPT_ACTION=%s\n", action);
return -1;
}
list_for_each_entry(script, &opts.scripts, node)
ret |= system(script->path);
unsetenv("CRTOOLS_SCRIPT_ACTION");
return ret;
}
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