Commit 0133a23a authored by Cyrill Gorcunov's avatar Cyrill Gorcunov

restore: Add opening core file

Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@gmail.com>
parent f8c46a5d
......@@ -1218,11 +1218,13 @@ static int restore_all_tasks(pid_t pid)
return restore_root_task(path, pstree_fd);
}
static void restorer_test(void)
static void restorer_test(pid_t pid)
{
restorer_fcall_t restorer_fcall;
char path[64];
void *args_rip;
void *exec_mem;
long ret;
exec_mem = mmap(0, RESTORER_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANON, 0, 0);
if (exec_mem == MAP_FAILED) {
......@@ -1236,8 +1238,11 @@ static void restorer_test(void)
args_rip = (void *)restorer_fcall(RESTORER_CMD__GET_ARG_OFFSET);
strcpy(args_rip, "Hello from restorer!\n");
restorer_fcall(RESTORER_CMD__PR_ARG_STRING);
snprintf(path, sizeof(path), "core-%d.img", pid);
strcpy(args_rip, path);
ret = restorer_fcall(RESTORER_CMD__RESTORE_CORE);
pr_info("RESTORER_CMD__RESTORE_CORE: %lx\n", ret);
exit(0);
......@@ -1245,7 +1250,7 @@ static void restorer_test(void)
int cr_restore_tasks(pid_t pid, struct cr_options *opts)
{
restorer_test();
restorer_test(pid);
if (opts->leader_only)
return restore_one_task(pid);
......
......@@ -13,8 +13,12 @@
#include "util.h"
#include "image.h"
#include "crtools.h"
#include "restorer.h"
#define get_rt_sigframe_addr(stack) \
(struct rt_sigframe *)(stack - sizeof(long))
#define lea_args_off(p) \
do { \
asm volatile( \
......@@ -25,6 +29,16 @@
: "memory"); \
} while (0)
static void always_inline write_string(char *str)
{
int len = 0;
while (str[len])
len++;
sys_write(1, str, len);
}
long restorer(long cmd)
{
long ret;
......@@ -64,6 +78,20 @@ long restorer(long cmd)
*/
case RESTORER_CMD__RESTORE_CORE:
{
char *core_path;
int fd_core;
struct core_entry core_entry;
struct rt_sigframe *frame;
lea_args_off(core_path);
write_string(core_path);
write_string("\n");
fd_core = sys_open(core_path, O_RDONLY, CR_FD_PERM);
return fd_core;
/*
* Unmap all but self, note that we reply on
* caller that it has placed this execution
......
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