Permalink
Browse files

Remove barely-usable, unstable BSD support, fix PID tracking a bit.

  • Loading branch information...
Subsentient committed May 8, 2014
1 parent 9de2f08 commit 5d7ec01df5e5a67f0e38d7798e7d0a449a06a23e
Showing with 71 additions and 286 deletions.
  1. +0 −19 buildepoch.sh
  2. +4 −15 src/actions.c
  3. +8 −31 src/config.c
  4. +0 −2 src/console.c
  5. +9 −25 src/epoch.h
  6. +19 −30 src/main.c
  7. +2 −2 src/membus.c
  8. +0 −15 src/modes.c
  9. +29 −14 src/parse.c
  10. +0 −133 src/utilfuncs.c
View
@@ -147,25 +147,6 @@ rm -rf objects built
mkdir objects
cd objects
-if [ $(uname -s) = "Linux" ]; then
- CFLAGS=$CFLAGS" -DLINUX"
-fi
-
-if [ $(uname -s) = "OpenBSD" ]; then
- CFLAGS=$CFLAGS" -DOPENBSD"
- LDFLAGS=$LDFLAGS" -lutil -static"
-fi
-
-if [ $(uname -s) = "NetBSD" ]; then
- CFLAGS=$CFLAGS" -DNETBSD"
- LDFLAGS=$LDFLAGS" -lutil -static"
-fi
-
-if [ $(uname -s) = "FreeBSD" ]; then
- CFLAGS=$CFLAGS" -DFREEBSD"
- LDFLAGS=$LDFLAGS" -lutil -static"
-fi
-
CMD "$CC $CFLAGS -c ../src/actions.c"
CMD "$CC $CFLAGS -c ../src/config.c"
CMD "$CC $CFLAGS -c ../src/console.c"
View
@@ -11,9 +11,7 @@
#include <time.h>
#include <unistd.h>
#include <sys/reboot.h>
-#ifdef LINUX
#include <sys/mount.h>
-#endif
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
@@ -24,9 +22,7 @@
#include "epoch.h"
/*Prototypes.*/
-#ifdef LINUX
static void MountVirtuals(void);
-#endif
static void PrimaryLoop(void);
static void ApplyGlobalEnvVars(void);
@@ -37,7 +33,6 @@ static Bool ContinuePrimaryLoop = true;
struct _EnvVarList *GlobalEnvVars;
/*Functions.*/
-#ifdef LINUX
static void MountVirtuals(void)
{
enum { MVIRT_PROC, MVIRT_SYSFS, MVIRT_DEVFS, MVIRT_PTS, MVIRT_SHM };
@@ -84,7 +79,6 @@ static void MountVirtuals(void)
}
}
-#endif
static void PrimaryLoop(void)
{ /*Loop that provides essentially everything we cycle through.*/
@@ -543,7 +537,6 @@ void ReexecuteEpoch(void)
exit(0);
}
-#ifdef LINUX
void PerformExec(const char *Cmd)
{
unsigned long Inc = 0, NumSpaces = 1, cOffset = 0, Inc2 = 0;
@@ -627,7 +620,6 @@ void PerformPivotRoot(const char *NewRoot, const char *OldRootDir)
chdir("/"); /*Reset working directory*/
}
-#endif /*LINUX*/
void FinaliseLogStartup(Bool BlankLog)
@@ -697,9 +689,9 @@ void LaunchBootup(void)
{
WriteLogLine(CONSOLE_COLOR_CYAN VERSIONSTRING " Booting up\n" "Compiled " __DATE__ " " __TIME__ CONSOLE_ENDCOLOR "\n", true);
}
-#ifdef LINUX
+
MountVirtuals(); /*Mounts any virtual filesystems, upon request.*/
-#endif
+
if (Hostname[0] != '\0')
{ /*The system hostname.*/
char TmpBuf[MAX_LINE_SIZE];
@@ -735,7 +727,7 @@ void LaunchBootup(void)
WriteLogLine(TmpBuf, true);
}
-#ifdef LINUX
+
if (DisableCAD)
{
const char *CADMsg[2] = { "Epoch has taken control of CTRL-ALT-DEL events.",
@@ -755,7 +747,7 @@ void LaunchBootup(void)
{
WriteLogLine("Epoch will not request control of CTRL-ALT-DEL events.", true);
}
-#endif
+
WriteLogLine(CONSOLE_COLOR_YELLOW "Starting all objects.\n" CONSOLE_ENDCOLOR, true);
if (!RunAllObjects(true))
@@ -877,9 +869,6 @@ void LaunchShutdown(signed long Signal)
printf("%s%s%s\n", CONSOLE_COLOR_CYAN, AttemptMsg, CONSOLE_ENDCOLOR);
sync(); /*Force sync of disks in case somebody forgot.*/
-#ifndef LINUX
- if (Signal == OSCTL_POWEROFF) Signal = Signal | OSCTL_HALT;
-#endif
reboot(Signal); /*Send the signal.*/
View
@@ -354,12 +354,7 @@ rStatus InitConfig(const char *CurConfigFile)
}
else if (!strncmp(Worker, (CurrentAttribute = "DisableCAD"), sizeof "DisableCAD" - 1))
{ /*Should we disable instant reboots on CTRL-ALT-DEL?*/
-#ifndef LINUX
- snprintf(ErrBuf, sizeof ErrBuf, CONFIGWARNTXT
- "DisableCAD is not implemented for non-linux platforms.\nLine %lu in \"%s\".", LineNum, CurConfigFile);
- SpitWarning(ErrBuf);
- WriteLogLine(ErrBuf, true);
-#else
+
if (!GetLineDelim(Worker, DelimCurr))
{
ConfigProblem(CurConfigFile, CONFIG_EMISSINGVAL, CurrentAttribute, NULL, LineNum);
@@ -380,7 +375,6 @@ rStatus InitConfig(const char *CurConfigFile)
ConfigProblem(CurConfigFile, CONFIG_EBADVAL, CurrentAttribute, DelimCurr, LineNum);
}
-#endif
continue;
}
else if (!strncmp(Worker, (CurrentAttribute = "BlankLogOnBoot"), sizeof "BlankLogOnBoot" - 1))
@@ -531,12 +525,6 @@ rStatus InitConfig(const char *CurConfigFile)
/*This will mount /dev, /proc, /sys, /dev/pts, and /dev/shm on boot time, upon request.*/
else if (!strncmp(Worker, (CurrentAttribute = "MountVirtual"), strlen("MountVirtual")))
{
- #ifndef LINUX
- snprintf(ErrBuf, sizeof ErrBuf, CONFIGWARNTXT "MountVirtual is only useful as a Linux config attribute,\n"
- "and is not implemented for non-linux platforms.");
- SpitWarning(ErrBuf);
- WriteLogLine(ErrBuf, true);
- #else
const char *TWorker = DelimCurr;
unsigned long Inc = 0;
char CurArg[MAX_DESCRIPT_SIZE];
@@ -585,7 +573,6 @@ rStatus InitConfig(const char *CurConfigFile)
{
ConfigProblem(CurConfigFile, CONFIG_ETRUNCATED, CurrentAttribute, DelimCurr, LineNum);
}
- #endif
continue;
}
/*Now we get into the actual attribute tags.*/
@@ -973,10 +960,11 @@ rStatus InitConfig(const char *CurConfigFile)
{
CurObj->Opts.StopFailIsCritical = true;
}
- else if (!strcmp(CurArg, "FORK"))
+ else if (!strncmp(CurArg, "FORK", sizeof "FORK" - 1))
{
#ifndef NOMMU
CurObj->Opts.Fork = true;
+ if (!strcmp(CurArg, "FORKN")) CurObj->Opts.ForkScanOnce = true;
#else
snprintf(ErrBuf, sizeof ErrBuf, CONFIGWARNTXT "Object \"%s\" has specified the FORK option,\n"
"but this is not supported on NOMMU builds. Disabling the object.", CurObj->ObjectID);
@@ -987,23 +975,11 @@ rStatus InitConfig(const char *CurConfigFile)
}
else if (!strcmp(CurArg, "EXEC"))
{
- #ifdef LINUX
CurObj->Opts.Exec = true;
- #else
- const char *const String = CONFIGWARNTXT "This is not a Linux build, and EXEC support is not implemented for non-linux platforms\n"
- "because the usefulness of this outside of Linux is questionable.";
- SpitWarning(String);
- WriteLogLine(String, true);
- #endif
}
else if (!strcmp(CurArg, "PIVOT"))
{
- #ifdef LINUX
CurObj->Opts.PivotRoot = true;
- #else
- SpitWarning("This is not a Linux build, and PIVOT support is not implemented for non-linux platforms\n"
- "because the usefulness of this outside of Linux is questionable.");
- #endif
}
else if (!strcmp(CurArg, "RAWDESCRIPTION"))
{
@@ -1017,6 +993,10 @@ rStatus InitConfig(const char *CurConfigFile)
{
CurObj->Opts.AutoRestart = true;
}
+ else if (!strcmp(CurArg, "NOTRACK"))
+ {
+ CurObj->Opts.NoTrack = true;
+ }
else if (!strcmp(CurArg, "FORCESHELL"))
{
#ifndef NOSHELL
@@ -2929,9 +2909,8 @@ rStatus ReloadConfig(void)
/*Do this to prevent some weird options from being changeable by a config reload.*/
GlobalOpts[0] = EnableLogging;
-#ifdef LINUX
GlobalOpts[1] = DisableCAD;
-#endif
+
WriteLogLine("CONFIG: Initializing new configuration.", true);
if (!InitConfig(ConfigFile))
@@ -2964,9 +2943,7 @@ rStatus ReloadConfig(void)
/*And then restore those options to their previous states.*/
EnableLogging = GlobalOpts[0];
-#ifdef LINUX
DisableCAD = GlobalOpts[1];
-#endif
if (!ConfigOK) return ConfigOK;
View
@@ -16,9 +16,7 @@
/*The banner we show upon startup.*/
struct _BootBanner BootBanner;
/*Should we Disable CTRL-ALT-DEL instant reboots?*/
-#ifdef LINUX
Bool DisableCAD = true;
-#endif
static const char *const ExitStrings[] = { CONSOLE_COLOR_RED "FAIL" CONSOLE_ENDCOLOR,
CONSOLE_COLOR_GREEN "Done" CONSOLE_ENDCOLOR,
View
@@ -63,24 +63,11 @@
#define VERSIONSTRING "Epoch Init System (git/master)"
/*Power control magic.*/
-#ifndef LINUX /*BSD.*/
- #define OSCTL_REBOOT 0
- #define OSCTL_HALT 0x8
-
- #ifdef OPENBSD
- #define OSCTL_POWEROFF 0x1000
- #elif defined FREEBSD
- #define OSCTL_POWEROFF 0x4000
- #else /*This is probably not correct for anything beyond netbsd, but we need a generic else so I can hit F8 in Geany and build.*/
- #define OSCTL_POWEROFF 0x800 /*Bitwise or-ed to turn on, don't worry, it matches.*/
- #endif
-#else /*We're Linux*/
- #define OSCTL_REBOOT 0x1234567
- #define OSCTL_HALT 0xcdef0123
- #define OSCTL_POWEROFF 0x4321fedc
- #define OSCTL_DISABLE_CTRLALTDEL 0 /*Now isn't this hilarious. It's zero.*/
- #define OSCTL_ENABLE_CTRLALTDEL 0x89abcdef
-#endif /*LINUX*/
+#define OSCTL_REBOOT 0x1234567
+#define OSCTL_HALT 0xcdef0123
+#define OSCTL_POWEROFF 0x4321fedc
+#define OSCTL_DISABLE_CTRLALTDEL 0 /*Now isn't this hilarious. It's zero.*/
+#define OSCTL_ENABLE_CTRLALTDEL 0x89abcdef
/*Colors for text output.*/
#define CONSOLE_COLOR_BLACK "\033[30m"
@@ -123,10 +110,8 @@
#define MEMBUS_CODE_REBOOT "INIT_REBOOT"
#define MEMBUS_CODE_RESET "EPOCH_REINIT" /*Forces a reset of the object table.*/
-#ifdef LINUX
#define MEMBUS_CODE_CADON "CADON"
#define MEMBUS_CODE_CADOFF "CADOFF"
-#endif /*LINUX*/
/*Codes that one expects to find information after.*/
#define MEMBUS_CODE_OBJSTART "OBJSTART"
#define MEMBUS_CODE_OBJSTOP "OBJSTOP"
@@ -160,7 +145,8 @@ enum _StopMode { STOP_NONE, STOP_COMMAND, STOP_PID, STOP_PIDFILE, STOP_INVALID }
enum { COPT_HALTONLY = 1, COPT_PERSISTENT, COPT_FORK, COPT_SERVICE, COPT_AUTORESTART,
COPT_FORCESHELL, COPT_NOSTOPWAIT, COPT_STOPTIMEOUT, COPT_TERMSIGNAL,
- COPT_RAWDESCRIPTION, COPT_PIVOTROOT, COPT_EXEC, COPT_RUNONCE, COPT_MAX };
+ COPT_RAWDESCRIPTION, COPT_PIVOTROOT, COPT_EXEC, COPT_RUNONCE, COPT_FORKSCANONCE,
+ COPT_NOTRACK, COPT_MAX };
/*Trinary return values for functions.*/
typedef enum { FAILURE, SUCCESS, WARNING } rStatus;
@@ -230,8 +216,10 @@ typedef struct _EpochObjectTable
unsigned int RunOnce : 1; /*Tells us to disable ourselves upon completion whenever we are started.*/
unsigned int StartFailIsCritical : 1; /*Starting this object is so important we're going to drop you to a shell if it fails.*/
unsigned int StopFailIsCritical : 1; /*Same but for stopping.*/
+ unsigned int NoTrack : 1; /*Don't track the PID with AdvancedPIDFind().*/
#ifndef NOMMU
unsigned int Fork : 1; /*Essentially do the same thing (with an Epoch twist) as Command& in sh.*/
+ unsigned int ForkScanOnce : 1; /*Same as Fork, but only scans through the PID once.*/
#endif
} Opts;
@@ -297,9 +285,7 @@ extern ObjTable *ObjectTable;
extern struct _BootBanner BootBanner;
extern char CurRunlevel[MAX_DESCRIPT_SIZE];
extern struct _MemBusInterface MemBus;
-#ifdef LINUX
extern Bool DisableCAD;
-#endif
extern char Hostname[256];
extern char Domainname[256];
extern struct _HaltParams HaltParams;
@@ -352,10 +338,8 @@ extern void EmergencyShell(void);
extern void ReexecuteEpoch(void);
extern void RecoverFromReexec(Bool ViaMemBus);
extern void FinaliseLogStartup(Bool BlankLog);
-#ifdef LINUX
extern void PerformExec(const char *Cmd_);
extern void PerformPivotRoot(const char *NewRoot, const char *OldRootDir);
-#endif
/*modes.c*/
extern rStatus SendPowerControl(const char *MembusCode);
Oops, something went wrong.

1 comment on commit 5d7ec01

@Subsentient

This comment has been minimized.

Show comment
Hide comment
@Subsentient

Subsentient May 9, 2014

Owner

I think I owe a good explanation as to why I've removed BSD support.
I want to be perfectly clear here.

I think BSD is still important, but let's face it. They don't want my init system, at least most of them. Now, Epoch was originally designed for Linux. Everything I've done with Epoch has been for Linux before my BSD fling.
That means that properly porting Epoch would be a big job, and I don't use BSD or come in contact with BSD, or know how to deal with BSD enough to properly test Epoch on these platforms, much less know what additions might be necessary to make an init system work well under them.

To be quite blunt, Epoch's code was turning into a smelly pile of crap because of all the preprocessing nightmares that were necessary to make BSD support work. I'm afraid that if things had stayed the same, I would have had a very hard time maintaining Epoch in the future. I couldn't get NetBSD installed properly to clone git and build Epoch, OpenBSD support was buggy and strange with PID tracking problems, and I never got it to work under FreeBSD at all, because I never wrote the process monitoring code for AdvancedPIDFind() for FreeBSD.

I'd be willing to work with someone who knows C, BSD inner boot processes, etc to make Epoch work under the various BSD platforms, but I can't picture myself doing this on my own. I obviously haven't deleted the BSD code, you can still checkout the last revision to have BSD support and poke around there.

In the meantime, I'm working on things to prepare for 1.1. I've got a few extra nice features in mind, and I'll be done soon.

Owner

Subsentient commented on 5d7ec01 May 9, 2014

I think I owe a good explanation as to why I've removed BSD support.
I want to be perfectly clear here.

I think BSD is still important, but let's face it. They don't want my init system, at least most of them. Now, Epoch was originally designed for Linux. Everything I've done with Epoch has been for Linux before my BSD fling.
That means that properly porting Epoch would be a big job, and I don't use BSD or come in contact with BSD, or know how to deal with BSD enough to properly test Epoch on these platforms, much less know what additions might be necessary to make an init system work well under them.

To be quite blunt, Epoch's code was turning into a smelly pile of crap because of all the preprocessing nightmares that were necessary to make BSD support work. I'm afraid that if things had stayed the same, I would have had a very hard time maintaining Epoch in the future. I couldn't get NetBSD installed properly to clone git and build Epoch, OpenBSD support was buggy and strange with PID tracking problems, and I never got it to work under FreeBSD at all, because I never wrote the process monitoring code for AdvancedPIDFind() for FreeBSD.

I'd be willing to work with someone who knows C, BSD inner boot processes, etc to make Epoch work under the various BSD platforms, but I can't picture myself doing this on my own. I obviously haven't deleted the BSD code, you can still checkout the last revision to have BSD support and poke around there.

In the meantime, I'm working on things to prepare for 1.1. I've got a few extra nice features in mind, and I'll be done soon.

Please sign in to comment.