From: Steven Stewart-Gallus <sstewartgallus00@mylangara.bc.ca>
To: Andy Lutomirski <luto@amacapital.net>
Cc: linux-kernel@vger.kernel.org
Subject: Re: How is pivot_root intended to be used?
Date: Thu, 04 Sep 2014 07:35:08 +0000 (GMT) [thread overview]
Message-ID: <faeccadf18ff.5408162c@langara.bc.ca> (raw)
In-Reply-To: <5406202A.30401@amacapital.net>
Thank you, I think I will change the code to be like:
int old_root = open("/", O_DIRECTORY);
if (-1 == old_root) {
perror("open");
return EXIT_FAILURE;
}
if (-1 == syscall(__NR_pivot_root, ".", ".")) {
perror("pivot_root");
return EXIT_FAILURE;
}
if (-1 == fchdir(old_root)) {
perror("fchdir");
return EXIT_FAILURE;
}
if (-1 == umount2(".", MNT_DETACH)) {
perror("umount");
return EXIT_FAILURE;
}
if (-1 == close(old_root)) {
perror("close");
return EXIT_FAILURE;
}
if (-1 == chdir("/")) {
perror("chdir");
return EXIT_FAILURE;
}
This seems more understandable to me and less likely to have bugs later on.
prev parent reply other threads:[~2014-09-04 7:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-01 21:19 How is pivot_root intended to be used? Steven Stewart-Gallus
2014-09-02 19:53 ` Andy Lutomirski
2014-09-04 7:35 ` Steven Stewart-Gallus [this message]
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=faeccadf18ff.5408162c@langara.bc.ca \
--to=sstewartgallus00@mylangara.bc.ca \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
/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