]> Shamusworld >> Repos - init-ng/commitdiff
Switch from _GNU_SOURCE to _DEFAULT_SOURCE.
authorShamus Hammons <jlhamm@acm.org>
Mon, 3 Apr 2017 17:26:14 +0000 (12:26 -0500)
committerShamus Hammons <jlhamm@acm.org>
Mon, 3 Apr 2017 17:26:14 +0000 (12:26 -0500)
init-ng.c

index 3b969be0e62235aa03ee59df65cc1f0e173d1d9d..d161b844b71a08e8f3f5fa177cc2de222161d1ab 100644 (file)
--- a/init-ng.c
+++ b/init-ng.c
 // (C) 2017 Underground Software
 //
 
-#define _GNU_SOURCE            // Without this, functions in unistd.h go missing
+#define _DEFAULT_SOURCE                // Without this, functions in unistd.h go missing
 #include <unistd.h>
 #include <errno.h>
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <linux/reboot.h>
+#include <sys/reboot.h>
 #include <sys/syscall.h>
 #include <sys/socket.h>
 #include <sys/types.h>
@@ -221,9 +221,8 @@ void ShutDown(int cmd)
        // to work without any problem as is.
        while (waitpid(pid, NULL, 0) != pid);
 
-       // Could just call sync() as well...
-       syscall(SYS_sync);
-       syscall(SYS_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2C, cmd);
+       sync();
+       reboot(cmd);
 }
 
 
@@ -278,7 +277,7 @@ int main(int argc, char * argv[])
                        }
                        else if (strcmp(argv[1], "test") == 0)
                        {
-                               ShutDown(LINUX_REBOOT_CMD_POWER_OFF);
+                               ShutDown(RB_POWER_OFF);
                        }
                        else
                                printf("Invalid command\n");
@@ -363,15 +362,15 @@ int main(int argc, char * argv[])
                // Now do something with it...
                if (strcmp(buf, "poweroff") == 0)
                {
-                       ShutDown(LINUX_REBOOT_CMD_POWER_OFF);
+                       ShutDown(RB_POWER_OFF);
                }
                else if (strcmp(buf, "restart") == 0)
                {
-                       ShutDown(LINUX_REBOOT_CMD_RESTART);
+                       ShutDown(RB_AUTOBOOT);
                }
                else if (strcmp(buf, "halt") == 0)
                {
-                       ShutDown(LINUX_REBOOT_CMD_HALT);
+                       ShutDown(RB_HALT_SYSTEM);
                }
                else if (strcmp(buf, "status") == 0)
                {