micro-utils/coreutils/chroot.c
Your Name b701e39fbb .
2023-10-18 21:44:56 +03:00

24 lines
400 B
C

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
int main(const int argc, const char **argv) {
if (argc < 3) {
printf("chroot [dir] [\"command arg\"]\n");
return 0;
}
if (chroot(argv[1]) == -1) {
fprintf(stderr, "chroot: %s\n", strerror(errno));
return 1;
}
chdir("/");
for (int i = 1; i < argc; i++)
system(argv[i]);
return 0;
}