[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-id: <faeccadf18ff.5408162c@langara.bc.ca>
Date: Thu, 04 Sep 2014 07:35:08 +0000 (GMT)
From: Steven Stewart-Gallus <sstewartgallus00@...angara.bc.ca>
To: Andy Lutomirski <luto@...capital.net>
Cc: linux-kernel@...r.kernel.org
Subject: Re: How is pivot_root intended to be used?
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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists