2006-02-15 12:18:21 +01:00
|
|
|
/*
|
|
|
|
newroot.c
|
|
|
|
|
|
|
|
Replace the current root with a new one
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2009-08-12 21:57:37 +02:00
|
|
|
#include <sys/mount.h>
|
2006-02-15 12:18:21 +01:00
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
int r;
|
|
|
|
char *dev;
|
|
|
|
|
|
|
|
if (argc != 2)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Usage: newroot <block-special>\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
dev= argv[1];
|
2009-05-13 17:39:44 +02:00
|
|
|
r= mount(dev, "/", 0 /* !ro */, NULL, NULL);
|
2006-02-15 12:18:21 +01:00
|
|
|
if (r != 0)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "newroot: mount failed: %s\n", strerror(errno));
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|