From: Karel Zak <kzak@redhat.com>
To: Neil Horman <nhorman@tuxdriver.com>
Cc: util-linux@vger.kernel.org, kerolasa@gmail.com,
grawity@gmail.com, ingenit@zoho.com
Subject: Re: [PATCH v3] sys-tools: Enhance unshare command to support the switching of namespaces
Date: Mon, 7 Jan 2013 15:05:23 +0100 [thread overview]
Message-ID: <20130107140523.GA8265@x2.net.home> (raw)
In-Reply-To: <1356711738-1573-1-git-send-email-nhorman@tuxdriver.com>
On Fri, Dec 28, 2012 at 11:22:18AM -0500, Neil Horman wrote:
> sys-utils/unshare.1 | 34 +++++++++++++++---------
> sys-utils/unshare.c | 74 ++++++++++++++++++++++++++++++++++++++++++-----------
> 2 files changed, 81 insertions(+), 27 deletions(-)
Applied with some changes, please check/verify the changes in git, thanks.
> +static void close_files(void)
> +{
> + int i;
> + for (i=0; ns_pids[i] > 0; i++)
> + close(ns_pids[i]);
> + close_stdout();
> +}
this is unnecessary, but O_CLOEXEC is probably good idea
> + while((c = getopt_long(argc, argv, "hVm:u:i:n:", longopts, NULL)) != -1) {
> + ns = NULL;
optional argument means "::" not ":"
> + if (optarg && ns) {
> + if (nscount >= NUM_ENTRIES)
> + err(EXIT_FAILURE, _("Too many new namespaces specified"));
> + pid = strtoul(optarg, NULL, 10);
for the short options the 'optarg' starts with '=', so you need
optarg++
> + for (nscount = 0; ns_pids[nscount] > 0; nscount++)
> + if (-1 == setns(ns_pids[nscount], 0))
> + err(EXIT_FAILURE, _("setns failed"));
> +
> if(-1 == unshare(unshare_flags))
> err(EXIT_FAILURE, _("unshare failed"));
it seems that unshare() should not be called if unshare_flags == 0
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
next prev parent reply other threads:[~2013-01-07 14:05 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-19 19:06 [PATCH] sys-tools: Add setns utility to sys-tools Neil Horman
2012-12-19 20:16 ` Mantas M.
2012-12-19 21:01 ` Neil Horman
2012-12-19 23:15 ` Sami Kerola
2012-12-20 9:24 ` Karel Zak
2012-12-20 11:17 ` Sami Kerola
2012-12-20 15:34 ` Neil Horman
2012-12-20 18:22 ` [PATCH v2] sys-tools: Enhance unshare command to support the switching of namespaces Neil Horman
2012-12-28 12:54 ` Ángel González
2012-12-28 16:12 ` Neil Horman
2012-12-28 19:33 ` Ángel González
2012-12-28 21:26 ` Neil Horman
2012-12-28 16:22 ` [PATCH v3] " Neil Horman
2013-01-02 21:33 ` Neil Horman
2013-01-07 14:05 ` Karel Zak [this message]
2013-01-07 14:58 ` Neil Horman
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=20130107140523.GA8265@x2.net.home \
--to=kzak@redhat.com \
--cc=grawity@gmail.com \
--cc=ingenit@zoho.com \
--cc=kerolasa@gmail.com \
--cc=nhorman@tuxdriver.com \
--cc=util-linux@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox