mirror of
https://github.com/checkpoint-restore/criu
synced 2025-09-01 23:05:39 +00:00
util: add a function for running scripts
Signed-off-by: Andrey Vagin <avagin@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
committed by
Pavel Emelyanov
parent
45fa18487d
commit
8e90ed8c4d
@@ -323,5 +323,6 @@ static inline int read_img_str(int fd, char **pstr, int size)
|
|||||||
|
|
||||||
extern void *shmalloc(size_t bytes);
|
extern void *shmalloc(size_t bytes);
|
||||||
extern void shfree_last(void *ptr);
|
extern void shfree_last(void *ptr);
|
||||||
|
extern int run_scripts(char *action);
|
||||||
|
|
||||||
#endif /* UTIL_H_ */
|
#endif /* UTIL_H_ */
|
||||||
|
17
util.c
17
util.c
@@ -387,3 +387,20 @@ void shfree_last(void *ptr)
|
|||||||
sh_bytes_left += sh_last_size;
|
sh_bytes_left += sh_last_size;
|
||||||
sh_last_size = 0;
|
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;
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user