minix/commands/chroot/chroot.c

29 lines
383 B
C
Raw Normal View History

2005-04-21 16:53:53 +02:00
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/wait.h>
2005-04-21 16:53:53 +02:00
int
main(int argc, char *argv[])
{
int status;
2005-04-21 16:53:53 +02:00
if(argc != 3) {
fprintf(stderr, "usage: %s <root> <command>\n", argv[0]);
return 1;
}
if(chroot(argv[1]) < 0) {
perror("chroot");
return 1;
}
status = system(argv[2]);
if(WIFEXITED(status))
return WEXITSTATUS(status);
return 1;
2005-04-21 16:53:53 +02:00
}