micro-utils/coreutils/chroot.c
Your Name 7eed71d9b2 mk
2023-10-13 15:34:16 +03:00

22 lines
389 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 <= 2) {
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 = 2; i < argc; i++)
system(argv[i]);
}