Magellan Linux

Contents of /trunk/mkinitrd-magellan/klibc/usr/utils/chroot.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 815 - (show annotations) (download)
Fri Apr 24 18:32:46 2009 UTC (15 years, 1 month ago) by niro
File MIME type: text/plain
File size: 416 byte(s)
-updated to klibc-1.5.15
1 /*
2 * by rmk
3 */
4 #include <unistd.h>
5 #include <stdio.h>
6
7 int main(int argc, char *argv[], char *envp[])
8 {
9 if (argc < 3) {
10 fprintf(stderr, "Usage: %s newroot command...\n", argv[0]);
11 return 1;
12 }
13
14 if (chroot(argv[1]) == -1) {
15 perror("chroot");
16 return 1;
17 }
18
19 if (chdir("/") == -1) {
20 perror("chdir");
21 return 1;
22 }
23
24 if (execvp(argv[2], argv + 2) == -1) {
25 perror("execvp");
26 return 1;
27 }
28
29 return 0;
30 }