From: "Serge E. Hallyn" <serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
To: Linux Containers <containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org>
Subject: [PATCH 1/2] introduce sys_restore
Date: Fri, 25 Jul 2008 17:58:49 -0500 [thread overview]
Message-ID: <20080725225849.GA28764@us.ibm.com> (raw)
In-Reply-To: <20080725225655.GA28276-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Create a useless (?) sys_restore system call. All it does
is read a "checkpoint file" :) for a pid number and a file
to execute.
Since we don't take things like argv and envp and registers
from the checkpoint file, in order to make this easily
testable, we take those things as arguments.
Signed-off-by: Serge Hallyn <serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Signed-off-by: Dave Hansen <dave-gkUM19QKKo4@public.gmane.org>
---
arch/x86/kernel/process_32.c | 10 ++++++++
arch/x86/kernel/syscall_table_32.S | 2 +
kernel/fork.c | 43 ++++++++++++++++++++++++++++++++++++
3 files changed, 55 insertions(+), 0 deletions(-)
diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
index 0c3927a..e11627d 100644
--- a/arch/x86/kernel/process_32.c
+++ b/arch/x86/kernel/process_32.c
@@ -688,6 +688,16 @@ out:
return error;
}
+long do_restore(unsigned int fd,
+ char __user * __user *argv,
+ char __user * __user *envp,
+ struct pt_regs *regs);
+
+asmlinkage long sys_restore(struct pt_regs regs)
+{
+ return do_restore(regs.bx, regs.cx, regs.dx, ®s);
+}
+
#define top_esp (THREAD_SIZE - sizeof(unsigned long))
#define top_ebp (THREAD_SIZE - 2*sizeof(unsigned long))
diff --git a/arch/x86/kernel/syscall_table_32.S b/arch/x86/kernel/syscall_table_32.S
index adff556..019a8e4 100644
--- a/arch/x86/kernel/syscall_table_32.S
+++ b/arch/x86/kernel/syscall_table_32.S
@@ -326,3 +326,5 @@ ENTRY(sys_call_table)
.long sys_fallocate
.long sys_timerfd_settime /* 325 */
.long sys_timerfd_gettime
+ .long sys_restore
+
diff --git a/kernel/fork.c b/kernel/fork.c
index adefc11..0e43f69 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1679,3 +1679,46 @@ int unshare_files(struct files_struct **displaced)
task_unlock(task);
return 0;
}
+
+
+#define CKPT_SIZE (PAGE_SIZE*4)
+char buf[CKPT_SIZE];
+char exe_filename[PAGE_SIZE];
+
+/*
+ * userspace will already have made us a new pidns
+ */
+long do_restore(unsigned int fd,
+ char __user * __user *argv,
+ char __user * __user *envp,
+ struct pt_regs *regs)
+{
+ int nr_scanned;
+ struct file *file;
+ long ret = -EBADF;
+ int fput_needed;
+ int pid;
+
+ if (!is_container_init(current)) {
+ printk("I am not init\n");
+ return -EPERM;
+ }
+
+ file = fget_light(fd, &fput_needed);
+ if (!file)
+ goto out;
+ ret = kernel_read(file, 0, buf, CKPT_SIZE);
+ fput_light(file, fput_needed);
+ if (ret <= 0)
+ goto out;
+
+ nr_scanned = sscanf(buf, "%d %s", &pid, exe_filename);
+
+ if (nr_scanned != 2)
+ return -EINVAL;
+
+
+ ret = do_execve(exe_filename, argv, envp, regs);
+out:
+ return ret;
+}
--
1.5.4.3
next prev parent reply other threads:[~2008-07-25 22:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-25 22:56 [PATCH 0/2] sys_restore prototype Serge E. Hallyn
[not found] ` <20080725225655.GA28276-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2008-07-25 22:58 ` Serge E. Hallyn [this message]
2008-07-25 22:59 ` [PATCH 2/2] sys_restore: set the pid number Serge E. Hallyn
[not found] ` <20080725225935.GB28764-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2008-07-27 2:33 ` [Devel] " Pavel Emelyanov
[not found] ` <488BDE7D.7090602-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
2008-07-29 18:31 ` Serge E. Hallyn
2008-07-28 22:00 ` [PATCH 0/2] sys_restore prototype Eric W. Biederman
[not found] ` <m1sktthdp3.fsf-B27657KtZYmhTnVgQlOflh2eb7JE58TQ@public.gmane.org>
2008-07-29 18:27 ` Serge E. Hallyn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080725225849.GA28764@us.ibm.com \
--to=serue-r/jw6+rmf7hqt0dzr+alfa@public.gmane.org \
--cc=containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.