/* shutdown.c: * * Copyright (C) 1998 Kenneth Albanowski , * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * JUN/99 -- copied from shutdown.c to make new reboot command. * (gerg@snapgear.com) * AUG/99 -- added delay option to reboot */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include int main(int argc, char *argv[]) { int delay = 0; /* delay in seconds before rebooting */ int rc; int force = 0; while ((rc = getopt(argc, argv, "h?d:f")) > 0) { switch (rc) { case 'd': delay = atoi(optarg); break; case 'f': force = 1; break; case 'h': case '?': default: printf("usage: reboot [-h] [-d ] [-f]\n"); exit(0); break; } } if(delay > 0) sleep(delay); #ifdef CONFIG_DISKtel printf("unmounting /home\n"); if(umount("/home") != 0){ printf("unmounting failed!!!\n"); } #endif #ifdef CONFIG_USER_FLATFSD_FLATFSD if (!force) { /* Ask flatfsd to reboot us safely */ execlp("flatfsd", "flatfsd", "-b", NULL); /* if this returns, then force a reboot */ } #endif kill(1, SIGTSTP); sync(); signal(SIGTERM,SIG_IGN); signal(SIGHUP,SIG_IGN); setpgrp(); kill(-1, SIGTERM); sleep(1); kill(-1, SIGHUP); sleep(1); sync(); sleep(1); reboot(0x01234567); exit(0); /* Shrug */ }