Added some defines and compile-time conditionals to make some

components of sysvinit compile on FreeBSD.
This commit is contained in:
Jesse Smith 2018-12-09 19:32:04 -04:00
parent 5dc965ba10
commit be8d584161
6 changed files with 47 additions and 4 deletions

View File

@ -13,7 +13,8 @@ sysvinit (2.94) unreleased; urgency=low
is taken.
* Removed unnecessary malloc.h includes. Memory allocation
and freeing is now handled in stdlib.h
* Added defines for FreeBSD to make some components compile
on FreeBSD 11.
sysvinit (2.93) released; urgency=low

View File

@ -47,7 +47,15 @@
#include <getopt.h>
#include <dirent.h>
#include <fcntl.h>
#ifdef __linux__
#include <pty.h>
#endif
#ifdef __FreeBSD__
#include <termios.h>
#include <libutil.h>
#endif
#include <ctype.h>
#ifdef __linux__
#include <sys/mount.h>

View File

@ -52,7 +52,11 @@ Version information is not placed in the top-level Makefile by default
#include <string.h>
#include <signal.h>
#include <termios.h>
#ifdef __FreeBSD__
#include <utmpx.h>
#else
#include <utmp.h>
#endif
#include <ctype.h>
#include <stdarg.h>
#include <sys/ttydefaults.h>
@ -62,6 +66,9 @@ Version information is not placed in the top-level Makefile by default
#ifdef WITH_SELINUX
# include <selinux/selinux.h>
#endif
#ifdef __FreeBSD__
extern char **environ;
#endif
#ifdef __i386__
# ifdef __GLIBC__
@ -521,8 +528,12 @@ int receive_state(int fd)
* Set the process title.
*/
#ifdef __GNUC__
#ifndef __FreeBSD__
__attribute__ ((format (printf, 1, 2)))
#endif
#endif
/* This function already exists on FreeBSD. No need to delcare it. */
#ifndef __FreeBSD__
static int setproctitle(char *fmt, ...)
{
va_list ap;
@ -542,6 +553,7 @@ static int setproctitle(char *fmt, ...)
return len;
}
#endif
/*
* Set console_dev to a working console.
@ -2160,9 +2172,11 @@ int make_pipe(int fd)
/*
* Attempt to re-exec.
* Renaming to my_re_exec since re_exec is now a common function name
* which conflicts.
*/
static
void re_exec(void)
void my_re_exec(void)
{
CHILD *ch;
sigset_t mask, oldset;
@ -2279,7 +2293,7 @@ void fifo_new_level(int level)
runlevel = read_level(level);
if (runlevel == 'U') {
runlevel = oldlevel;
re_exec();
my_re_exec();
} else {
if (oldlevel != 'S' && runlevel == 'S') console_stty();
if (runlevel == '6' || runlevel == '0' ||
@ -2681,7 +2695,7 @@ void process_signals()
#endif
if (runlevel == 'U') {
runlevel = oldlevel;
re_exec();
my_re_exec();
} else {
if (oldlevel != 'S' && runlevel == 'S') console_stty();
if (runlevel == '6' || runlevel == '0' ||

View File

@ -154,3 +154,12 @@ extern char prevlevel;
#define D_WROTE_WTMP_RLEVEL -16
#define D_WROTE_UTMP_RLEVEL -17
#ifdef __FreeBSD__
#define UTMP_FILE "/var/run/utmp"
#define RUN_LVL 1
struct utmp
{
char ut_id[4];
};
#endif

View File

@ -54,13 +54,20 @@
#include <signal.h>
#include <fcntl.h>
#include <stdarg.h>
#ifdef __FreeBSD__
#include <utmpx.h>
#else
#include <utmp.h>
#endif
#include <syslog.h>
#include "paths.h"
#include "reboot.h"
#include "initreq.h"
#include "init.h"
#ifdef __FreeBSD__
extern char **environ;
#endif
#define MESSAGELEN 256

View File

@ -32,7 +32,11 @@
#include <time.h>
#include <fcntl.h>
#include <string.h>
#ifdef __FreeBSD__
#include <utmpx.h>
#else
#include <utmp.h>
#endif
#include "init.h"
#include "initreq.h"