From: "Serge E. Hallyn" <serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
To: Oren Laadan <orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
Cc: Linux Containers <containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org>
Subject: [PATCH] make uts_ns=n compile
Date: Mon, 15 Mar 2010 17:50:18 -0500 [thread overview]
Message-ID: <20100315225018.GA2544@us.ibm.com> (raw)
One of those unfortunate patches that turns out hard to read, but
it just moves the #ifdef'd part of do_restore_uts_ns into
ifdef'd helpers.
Signed-off-by: Serge E. Hallyn <serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
---
checkpoint/namespace.c | 50 +++++++++++++++++++++++++++++++----------------
1 files changed, 33 insertions(+), 17 deletions(-)
diff --git a/checkpoint/namespace.c b/checkpoint/namespace.c
index 4b3ac5a..3bd8e85 100644
--- a/checkpoint/namespace.c
+++ b/checkpoint/namespace.c
@@ -53,22 +53,17 @@ int checkpoint_uts_ns(struct ckpt_ctx *ctx, void *ptr)
return do_checkpoint_uts_ns(ctx, (struct uts_namespace *) ptr);
}
-static struct uts_namespace *do_restore_uts_ns(struct ckpt_ctx *ctx)
+#ifdef CONFIG_UTS_NS
+static inline struct uts_namespace *ckpt_do_copy_uts_ns(struct ckpt_ctx *ctx,
+ struct ckpt_hdr_utsns *h)
{
- struct ckpt_hdr_utsns *h;
- struct uts_namespace *uts_ns = NULL;
- struct new_utsname *name;
-
- h = ckpt_read_obj_type(ctx, sizeof(*h), CKPT_HDR_UTS_NS);
- if (IS_ERR(h))
- return (struct uts_namespace *) h;
+ struct new_utsname *name = NULL;
+ struct uts_namespace *uts_ns;
-#ifdef CONFIG_UTS_NS
uts_ns = create_uts_ns();
- if (!uts_ns) {
- uts_ns = ERR_PTR(-ENOMEM);
- goto out;
- }
+ if (!uts_ns)
+ return ERR_PTR(-ENOMEM);
+
down_read(&uts_sem);
name = &uts_ns->name;
memcpy(name->sysname, h->sysname, sizeof(name->sysname));
@@ -78,16 +73,37 @@ static struct uts_namespace *do_restore_uts_ns(struct ckpt_ctx *ctx)
memcpy(name->machine, h->machine, sizeof(name->machine));
memcpy(name->domainname, h->domainname, sizeof(name->domainname));
up_read(&uts_sem);
+ return uts_ns;
+}
#else
+static inline struct uts_namespace *ckpt_do_copy_uts_ns(struct ckpt_ctx *ctx,
+ struct ckpt_hdr_utsns *h)
+{
+ struct uts_namespace *uts_ns;
+
/* complain if image contains multiple namespaces */
- if (ctx->stats.uts_ns) {
- uts_ns = ERR_PTR(-EEXIST);
- goto out;
- }
+ if (ctx->stats.uts_ns)
+ return ERR_PTR(-EEXIST);
+
uts_ns = current->nsproxy->uts_ns;
get_uts_ns(uts_ns);
+ return uts_ns;
+}
#endif
+static struct uts_namespace *do_restore_uts_ns(struct ckpt_ctx *ctx)
+{
+ struct ckpt_hdr_utsns *h;
+ struct uts_namespace *uts_ns;
+
+ h = ckpt_read_obj_type(ctx, sizeof(*h), CKPT_HDR_UTS_NS);
+ if (IS_ERR(h))
+ return (struct uts_namespace *) h;
+
+ uts_ns = ckpt_do_copy_uts_ns(ctx, h);
+ if (IS_ERR(uts_ns))
+ goto out;
+
ctx->stats.uts_ns++;
out:
ckpt_hdr_put(ctx, h);
--
1.6.1
reply other threads:[~2010-03-15 22:50 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20100315225018.GA2544@us.ibm.com \
--to=serue-r/jw6+rmf7hqt0dzr+alfa@public.gmane.org \
--cc=containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org \
--cc=orenl-eQaUEPhvms7ENvBUuze7eA@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.