diff options
author | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-02-17 00:40:32 +0000 |
---|---|---|
committer | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-02-17 00:40:32 +0000 |
commit | 213cf9aa005bffa8082551e44e9aec566cec93d0 (patch) | |
tree | efe2b3d5c9361301a3956d83105ad9c39b4c04ca /init | |
parent | ea2719de826ab93f2265f1cdab9eb8d1a93244fc (diff) | |
download | busybox-w32-213cf9aa005bffa8082551e44e9aec566cec93d0.tar.gz busybox-w32-213cf9aa005bffa8082551e44e9aec566cec93d0.tar.bz2 busybox-w32-213cf9aa005bffa8082551e44e9aec566cec93d0.zip |
Throw out the obsolete INIT_CHROOT junk
git-svn-id: svn://busybox.net/trunk/busybox@1841 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'init')
-rw-r--r-- | init/init.c | 91 |
1 files changed, 0 insertions, 91 deletions
diff --git a/init/init.c b/init/init.c index 9c96726d9..9046a14a8 100644 --- a/init/init.c +++ b/init/init.c | |||
@@ -660,94 +660,6 @@ static void reboot_signal(int sig) | |||
660 | exit(0); | 660 | exit(0); |
661 | } | 661 | } |
662 | 662 | ||
663 | #if defined BB_FEATURE_INIT_CHROOT | ||
664 | |||
665 | #warning BB_FEATURE_INIT_CHROOT is out of date and should be rewritten to us | ||
666 | #warning pivot root instead. Do not even bother till this work is done... | ||
667 | #warning You have been warned. | ||
668 | |||
669 | static void check_chroot(int sig) | ||
670 | { | ||
671 | char *argv_init[2] = { "init", NULL, }; | ||
672 | char *envp_init[3] = { "HOME=/", "TERM=linux", NULL, }; | ||
673 | char rootpath[256], *tc; | ||
674 | int fd; | ||
675 | |||
676 | if ((fd = open("/proc/sys/kernel/init-chroot", O_RDONLY)) == -1) { | ||
677 | message(CONSOLE, | ||
678 | "SIGHUP recived, but could not open proc file\r\n"); | ||
679 | sleep(2); | ||
680 | return; | ||
681 | } | ||
682 | if (read(fd, rootpath, sizeof(rootpath)) == -1) { | ||
683 | message(CONSOLE, | ||
684 | "SIGHUP recived, but could not read proc file\r\n"); | ||
685 | sleep(2); | ||
686 | return; | ||
687 | } | ||
688 | close(fd); | ||
689 | |||
690 | if (rootpath[0] == '\0') { | ||
691 | message(CONSOLE, | ||
692 | "SIGHUP recived, but new root is not valid: %s\r\n", | ||
693 | rootpath); | ||
694 | sleep(2); | ||
695 | return; | ||
696 | } | ||
697 | |||
698 | tc = strrchr(rootpath, '\n'); | ||
699 | *tc = '\0'; | ||
700 | |||
701 | /* Ok, making it this far means we commit */ | ||
702 | message(CONSOLE, "Please stand by, changing root to `%s'.\r\n", | ||
703 | rootpath); | ||
704 | |||
705 | /* kill all other programs first */ | ||
706 | message(CONSOLE, "Sending SIGTERM to all processes.\r\n"); | ||
707 | kill(-1, SIGTERM); | ||
708 | sleep(2); | ||
709 | sync(); | ||
710 | |||
711 | message(CONSOLE, "Sending SIGKILL to all processes.\r\n"); | ||
712 | kill(-1, SIGKILL); | ||
713 | sleep(2); | ||
714 | sync(); | ||
715 | |||
716 | /* ok, we don't need /proc anymore. we also assume that the signaling | ||
717 | * process left the rest of the filesystems alone for us */ | ||
718 | umount("/proc"); | ||
719 | |||
720 | /* Ok, now we chroot. Hopefully we only have two things mounted, the | ||
721 | * new chroot'd mount point, and the old "/" mount. s, | ||
722 | * we go ahead and unmount the old "/". This should trigger the kernel | ||
723 | * to set things up the Right Way(tm). */ | ||
724 | |||
725 | if (!chroot(rootpath)) | ||
726 | umount("/dev/root"); | ||
727 | |||
728 | /* If the chroot fails, we are already too far to turn back, so we | ||
729 | * continue and hope that executing init below will revive the system */ | ||
730 | |||
731 | /* close all of our descriptors and open new ones */ | ||
732 | close(0); | ||
733 | close(1); | ||
734 | close(2); | ||
735 | open("/dev/console", O_RDWR, 0); | ||
736 | dup(0); | ||
737 | dup(0); | ||
738 | |||
739 | message(CONSOLE, "Executing real init...\r\n"); | ||
740 | /* execute init in the (hopefully) new root */ | ||
741 | execve("/sbin/init", argv_init, envp_init); | ||
742 | |||
743 | message(CONSOLE, | ||
744 | "ERROR: Could not exec new init. Press %s to reboot.\r\n", | ||
745 | (secondConsole == NULL) /* serial console */ | ||
746 | ? "Reset" : "CTRL-ALT-DEL"); | ||
747 | return; | ||
748 | } | ||
749 | #endif /* BB_FEATURE_INIT_CHROOT */ | ||
750 | |||
751 | #endif /* ! DEBUG_INIT */ | 663 | #endif /* ! DEBUG_INIT */ |
752 | 664 | ||
753 | void new_initAction(initActionEnum action, char *process, char *cons) | 665 | void new_initAction(initActionEnum action, char *process, char *cons) |
@@ -945,9 +857,6 @@ extern int init_main(int argc, char **argv) | |||
945 | signal(SIGUSR2, halt_signal); | 857 | signal(SIGUSR2, halt_signal); |
946 | signal(SIGINT, reboot_signal); | 858 | signal(SIGINT, reboot_signal); |
947 | signal(SIGTERM, reboot_signal); | 859 | signal(SIGTERM, reboot_signal); |
948 | #if defined BB_FEATURE_INIT_CHROOT | ||
949 | signal(SIGHUP, check_chroot); | ||
950 | #endif | ||
951 | 860 | ||
952 | /* Turn off rebooting via CTL-ALT-DEL -- we get a | 861 | /* Turn off rebooting via CTL-ALT-DEL -- we get a |
953 | * SIGINT on CAD so we can shut things down gracefully... */ | 862 | * SIGINT on CAD so we can shut things down gracefully... */ |