diff -Naur util-linux-2.12q.orig/login-utils/simpleinit.c util-linux-2.12q/login-utils/simpleinit.c
--- util-linux-2.12q.orig/login-utils/simpleinit.c	2004-12-15 22:23:25.000000000 +0200
+++ util-linux-2.12q/login-utils/simpleinit.c	2005-06-11 16:00:56.000000000 +0300
@@ -44,7 +45,7 @@
 #endif
 #include "my_crypt.h"
 #include "pathnames.h"
-#include "linux_reboot.h"
+#include "my_reboot.h"
 #include "xstrncpy.h"
 #include "nls.h"
 #include "simpleinit.h"
@@ -171,7 +172,7 @@
 	bindtextdomain(PACKAGE, LOCALEDIR);
 	textdomain(PACKAGE);
 
-	my_reboot (LINUX_REBOOT_CMD_CAD_OFF);
+	my_reboot (MY_REBOOT_CMD_CAD_OFF);
 	/*  Find script to run. Command-line overrides config file overrides
 	    built-in default  */
 	for (i = 0; i < NUMCMD; i++) inittab[i].pid = -1;
@@ -707,7 +708,7 @@
 	execl (_PATH_REBOOT, _PATH_REBOOT, (char *) 0);
 
     /* fork or exec failed, try the hard way... */
-    my_reboot (LINUX_REBOOT_CMD_RESTART);
+    my_reboot (MY_REBOOT_CMD_RESTART);
 }   /*  End Function sigint_handler  */
 
 static void sigchild_handler (int sig)
diff -Naur util-linux-2.12q.orig/sys-utils/ctrlaltdel.c util-linux-2.12q/sys-utils/ctrlaltdel.c
--- util-linux-2.12q.orig/sys-utils/ctrlaltdel.c	2001-03-15 12:09:59.000000000 +0200
+++ util-linux-2.12q/sys-utils/ctrlaltdel.c	2005-06-11 16:00:56.000000000 +0300
@@ -11,7 +11,7 @@
 #include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
-#include "linux_reboot.h"
+#include "my_reboot.h"
 #include "nls.h"
 
 int
@@ -29,12 +29,12 @@
 	}
 
 	if(argc == 2 && !strcmp("hard", argv[1])) {
-		if(my_reboot(LINUX_REBOOT_CMD_CAD_ON) < 0) {
+		if(my_reboot(MY_REBOOT_CMD_CAD_ON) < 0) {
 			perror("ctrlaltdel: reboot");
 			exit(1);
 		}
 	} else if(argc == 2 && !strcmp("soft", argv[1])) {
-		if(my_reboot(LINUX_REBOOT_CMD_CAD_OFF) < 0) {
+		if(my_reboot(MY_REBOOT_CMD_CAD_OFF) < 0) {
 			perror("ctrlaltdel: reboot");
 			exit(1);
 		}
diff -Naur util-linux-2.12q.orig/login-utils/shutdown.c util-linux-2.12q/login-utils/shutdown.c
--- util-linux-2.12q.orig/login-utils/shutdown.c	2004-09-17 01:38:16.000000000 +0300
+++ util-linux-2.12q/login-utils/shutdown.c	2005-06-11 16:00:56.000000000 +0300
@@ -72,7 +72,7 @@
 #include <dirent.h>
 #include <sys/stat.h>
 #include <sys/utsname.h>
-#include "linux_reboot.h"
+#include "my_reboot.h"
 #include "pathnames.h"
 #include "xstrncpy.h"
 #include "nls.h"
@@ -425,13 +425,13 @@
 	syncwait (1);
 
 	if(opt_reboot) {
-		my_reboot(LINUX_REBOOT_CMD_RESTART); /* RB_AUTOBOOT */
+		my_reboot(MY_REBOOT_CMD_RESTART); /* RB_AUTOBOOT */
 		my_puts(_("\nWhy am I still alive after reboot?"));
 	} else {
 		my_puts(_("\nNow you can turn off the power..."));
 
 		/* allow C-A-D now, faith@cs.unc.edu, re-fixed 8-Jul-96 */
-		my_reboot(LINUX_REBOOT_CMD_CAD_ON); /* RB_ENABLE_CAD */
+		my_reboot(MY_REBOOT_CMD_CAD_ON); /* RB_ENABLE_CAD */
 		sleep (1);  /*  Wait for devices to finish writing to media  */
 		do_halt(halt_action);
 	}
@@ -446,7 +446,7 @@
 	if (strcasecmp (action, "power_off") == 0) {
 		printf(_("Calling kernel power-off facility...\n"));
 		fflush(stdout);
-		my_reboot(LINUX_REBOOT_CMD_POWER_OFF);
+		my_reboot(MY_REBOOT_CMD_POWER_OFF);
 		printf(_("Error powering off\t%s\n"), ERRSTRING);
 		fflush(stdout);
 		sleep (2);
@@ -463,7 +463,7 @@
 		sleep (2);
 	}
 
-	my_reboot(LINUX_REBOOT_CMD_HALT); /* RB_HALT_SYSTEM */
+	my_reboot(MY_REBOOT_CMD_HALT); /* RB_HALT_SYSTEM */
 }
 
 void
diff -Naur util-linux-2.12q.orig/lib/my_reboot.h util-linux-2.12q/lib/my_reboot.h
--- util-linux-2.12q.orig/lib/my_reboot.h	1970-01-01 02:00:00.000000000 +0200
+++ util-linux-2.12q/lib/my_reboot.h	2005-06-11 16:16:51.000000000 +0300
@@ -0,0 +1,51 @@
+#ifndef MY_REBOOT_H
+#define MY_REBOOT_H
+
+extern int my_reboot(int);
+
+#if defined(__linux__)
+/*
+ * Magic values required to use _reboot() system call.
+ */
+
+#define	LINUX_REBOOT_MAGIC1	0xfee1dead
+#define	LINUX_REBOOT_MAGIC2	672274793
+#define	LINUX_REBOOT_MAGIC2A	85072278
+#define	LINUX_REBOOT_MAGIC2B	369367448
+
+
+/*
+ * Commands accepted by the _reboot() system call.
+ *
+ * RESTART     Restart system using default command and mode.
+ * HALT        Stop OS and give system control to ROM monitor, if any.
+ * CAD_ON      Ctrl-Alt-Del sequence causes RESTART command.
+ * CAD_OFF     Ctrl-Alt-Del sequence sends SIGINT to init task.
+ * POWER_OFF   Stop OS and remove all power from system, if possible.
+ * RESTART2    Restart system using given command string.
+ */
+
+#define	MY_REBOOT_CMD_RESTART	0x01234567
+#define	MY_REBOOT_CMD_HALT	0xCDEF0123
+#define	MY_REBOOT_CMD_CAD_ON	0x89ABCDEF
+#define	MY_REBOOT_CMD_CAD_OFF	0x00000000
+#define	MY_REBOOT_CMD_POWER_OFF	0x4321FEDC
+#define	MY_REBOOT_CMD_RESTART2	0xA1B2C3D4
+
+#elif defined(__GNU__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+
+#include <sys/reboot.h>
+
+#define	MY_REBOOT_CMD_RESTART	RB_AUTOBOOT
+#define	MY_REBOOT_CMD_HALT	RB_HALT
+#define	MY_REBOOT_CMD_CAD_ON	0xFFFFFFFF
+#define	MY_REBOOT_CMD_CAD_OFF	0xFFFFFFFF
+#define	MY_REBOOT_CMD_POWER_OFF	RB_POWEROFF
+#define	MY_REBOOT_CMD_RESTART2	RB_AUTOBOOT
+
+#else
+#error "No reboot commands defined on this port"
+#endif
+
+#endif
+
diff -Naur util-linux-2.12q.orig/lib/my_reboot.c util-linux-2.12q/lib/my_reboot.c
--- util-linux-2.12q.orig/lib/my_reboot.c	1999-07-09 05:56:36.000000000 +0300
+++ util-linux-2.12q/lib/my_reboot.c	2005-06-11 16:23:56.000000000 +0300
@@ -1,7 +1,7 @@
 /* Including <unistd.h> makes sure that on a glibc system
    <features.h> is included, which again defines __GLIBC__ */
 #include <unistd.h>
-#include "linux_reboot.h"
+#include "my_reboot.h"
 
 #define USE_LIBC
 
@@ -17,7 +17,13 @@
 #endif
 int
 my_reboot(int cmd) {
-	return REBOOT(cmd);
+#ifndef __linux__
+	if (cmd != MY_REBOOT_CMD_CAD_ON && cmd != MY_REBOOT_CMD_CAD_OFF)
+#endif
+		return REBOOT(cmd);
+#ifndef __linux__
+	return 0;
+#endif
 }
 
 #else /* no USE_LIBC */
diff -Naur util-linux-2.12q.orig/lib/linux_reboot.h util-linux-2.12q/lib/linux_reboot.h
--- util-linux-2.12q.orig/lib/linux_reboot.h	1999-07-09 05:56:36.000000000 +0300
+++ util-linux-2.12q/lib/linux_reboot.h	1970-01-01 02:00:00.000000000 +0200
@@ -1,30 +0,0 @@
-extern int my_reboot(int);
-
-/*
- * Magic values required to use _reboot() system call.
- */
-
-#define	LINUX_REBOOT_MAGIC1	0xfee1dead
-#define	LINUX_REBOOT_MAGIC2	672274793
-#define	LINUX_REBOOT_MAGIC2A	85072278
-#define	LINUX_REBOOT_MAGIC2B	369367448
-
-
-/*
- * Commands accepted by the _reboot() system call.
- *
- * RESTART     Restart system using default command and mode.
- * HALT        Stop OS and give system control to ROM monitor, if any.
- * CAD_ON      Ctrl-Alt-Del sequence causes RESTART command.
- * CAD_OFF     Ctrl-Alt-Del sequence sends SIGINT to init task.
- * POWER_OFF   Stop OS and remove all power from system, if possible.
- * RESTART2    Restart system using given command string.
- */
-
-#define	LINUX_REBOOT_CMD_RESTART	0x01234567
-#define	LINUX_REBOOT_CMD_HALT		0xCDEF0123
-#define	LINUX_REBOOT_CMD_CAD_ON		0x89ABCDEF
-#define	LINUX_REBOOT_CMD_CAD_OFF	0x00000000
-#define	LINUX_REBOOT_CMD_POWER_OFF	0x4321FEDC
-#define	LINUX_REBOOT_CMD_RESTART2	0xA1B2C3D4
-
diff -Naur util-linux-2.12q.orig/lib/Makefile util-linux-2.12q/lib/Makefile
--- util-linux-2.12q.orig/lib/Makefile	2002-11-02 15:51:26.000000000 +0200
+++ util-linux-2.12q/lib/Makefile	2005-06-11 16:00:56.000000000 +0300
@@ -1,11 +1,12 @@
 include ../make_include
 include ../MCONFIG
 
 all: err.o my_reboot.o setproctitle.o env.o carefulputc.o xstrncpy.o md5.o
 
 err.o: err.c
 
-my_reboot.o: my_reboot.c linux_reboot.h
+my_reboot.o: my_reboot.c my_reboot.h
 
 env.o: env.h
 
diff -Naur util-linux-2.12q.orig/sys-utils/Makefile util-linux-2.12q/sys-utils/Makefile
--- util-linux-2.12q.orig/sys-utils/Makefile	2004-11-15 19:47:47.000000000 +0200
+++ util-linux-2.12q/sys-utils/Makefile	2005-06-11 16:00:56.000000000 +0300
@@ -67,7 +79,7 @@
 # Rules for everything else
 
 arch: arch.o
-ctrlaltdel.o: ctrlaltdel.c $(LIB)/linux_reboot.h
+ctrlaltdel.o: ctrlaltdel.c $(LIB)/my_reboot.h
 ctrlaltdel: ctrlaltdel.o $(LIB)/my_reboot.o
 cytune.o: cytune.c cyclades.h
 cytune: cytune.o
diff -Naur util-linux-2.12q.orig/login-utils/Makefile util-linux-2.12q/login-utils/Makefile
--- util-linux-2.12q.orig/login-utils/Makefile	2004-11-23 18:06:57.000000000 +0200
+++ util-linux-2.12q/login-utils/Makefile	2005-06-11 16:00:56.000000000 +0300
@@ -97,10 +102,10 @@
 initctl.o simpleinit.o: simpleinit.h
 agetty.o islocal.o last.o setpwnam.o shutdown.o simpleinit.o \
 	vipw.o: $(LIB)/pathnames.h
-shutdown.o simpleinit.o: $(LIB)/linux_reboot.h
+shutdown.o simpleinit.o: $(LIB)/my_reboot.h
 wall.o: ttymsg.h $(LIB)/carefulputc.h
 
-agetty: agetty.o $(LIB)/xstrncpy.o
+agetty: agetty.o $(LIB)/xstrncpy.o $(LIB)/xgethostname.o
 chfn: chfn.o islocal.o setpwnam.o $(SELINUXOBJS) $(LIB)/env.o $(LIB)/xstrncpy.o
 	$(CC) $(LDFLAGS) -o $@ $^ $(CRYPT) $(PAM) $(SELINUXLLIB)
 chsh: chsh.o islocal.o setpwnam.o $(SELINUXOBJS) $(LIB)/env.o
