static void performUnmounts(void) {
	int status;
	struct stat st_buf;

	printf("disabling swap...\n");
	disableSwap();

	printf("unmounting filesystems...\n"); 
	unmountFilesystems();

	/* We've lost /mnt/runtime where /lib is a link to put the old
	   /lib back so that our mdadm invocation below works. */
	if (lstat("/lib64", &st_buf) == 0) {
		unlink("/lib64");
		rename("/lib64_old", "/lib64");
	} else {
		unlink("/lib");
		rename("/lib_old", "/lib");
	}
	unlink("/usr");
	rename("/usr_old", "/usr");

	printf("waiting for mdraid sets to become clean...\n"); 
	status = system("/sbin/mdadm --wait-clean --scan");
	if (!WIFEXITED(status))
		printf("Error: mdadm did not terminate normally\n");
	else if (WEXITSTATUS(status))
		printf("Error: mdadm exited with status: %d\n",
		       WEXITSTATUS(status));
}
Esempio n. 2
0
void shutDown(int noKill, int doReboot, int doPowerOff) {
    sync(); sync();

    if (!testing && !noKill) {
	printf("sending termination signals...");
	kill(-1, 15);
	sleep(2);
	printf("done\n");

	printf("sending kill signals...");
	kill(-1, 9);
	sleep(2);
	printf("done\n");
    }

    printf("disabling swap...\n");
    disableSwap();

    printf("unmounting filesystems...\n"); 
    unmountFilesystems();

    if (doReboot) {
	printf("rebooting system\n");
	sleep(2);

#if USE_MINILIBC
	reboot(0xfee1dead, 672274793, 0x1234567);
#else
	reboot(RB_AUTOBOOT);
#endif
    } else if (doPowerOff)  {
        printf("powering off system\n");
        reboot(RB_POWER_OFF);
    } else {
	printf("you may safely reboot your system\n");
        signal(SIGINT, rebootHandler);
        while (1) sleep(60);
    }

    exit(0);

    return;
}