fiss-minit

A standalone service supervisor based on minit
Log | Files | Refs | README | LICENSE

commit 46a207e1fe036b733ea38312a2f8b03677b79dba
parent a72d3ccba330a3a9075a06601d6a12e5360a1072
Author: Friedel Schön <[email protected]>
Date:   Mon, 13 May 2024 16:33:46 +0200

remove unnecessary #ifdef-directives

Diffstat:
D.cvsignore | 16----------------
MMakefile | 2+-
Mftrigger.c | 56--------------------------------------------------------
Mminit-update.c | 12++++++------
Mminit.c | 43++++++-------------------------------------
Mminit.h | 15+++++++--------
Mmsvc.c | 1-
Mshutdown.c | 1-
8 files changed, 20 insertions(+), 126 deletions(-)

diff --git a/.cvsignore b/.cvsignore @@ -1,16 +0,0 @@ -minit -duh -msvc -pidfilehack -hard-reboot -write_proc -killall5 -shutdown -minit-update -serdo -ftrigger -waitinterface -waitport -powersave -governor -sepcode diff --git a/Makefile b/Makefile @@ -4,7 +4,7 @@ minit-update serdo ftrigger waitinterface waitport powersave # governor #CFLAGS=-pipe -march=i386 -fomit-frame-pointer -Os -I../dietlibc/include CC=gcc PIE= -CFLAGS=-Wall -W -pipe -fomit-frame-pointer -Os $(PIE) +CFLAGS=-pipe -fomit-frame-pointer -Os $(PIE) -Wextra -Wall CROSS= #CROSS=arm-linux- LDFLAGS=-s $(PIE) diff --git a/ftrigger.c b/ftrigger.c @@ -117,41 +117,6 @@ int main(int argc, char* argv[]) { exit(111); } -#if 0 - buffer_puts(buffer_1,"got event for wd "); - buffer_putulong(buffer_1,ie->wd); - if (ie->len) - buffer_putmflush(buffer_1," with filename \"",ie->name,"\"\n"); - else - buffer_putsflush(buffer_1," with no associated filename\n"); - struct { - unsigned int mask; - const char* string; - } strings[] = { - { 0x00000001,"IN_ACCESS" }, - { 0x00000002,"IN_MODIFY" }, - { 0x00000004,"IN_ATTRIB" }, - { 0x00000008,"IN_CLOSE_WRITE" }, - { 0x00000010,"IN_CLOSE_NOWRITE" }, - { 0x00000020,"IN_OPEN" }, - { 0x00000040,"IN_MOVED_FROM" }, - { 0x00000080,"IN_MOVED_TO" }, - { 0x00000100,"IN_CREATE" }, - { 0x00000200,"IN_DELETE" }, - { 0x00000400,"IN_DELETE_SELF" }, - { 0x00000800,"IN_MOVE_SELF" }, - { 0x00002000,"IN_UNMOUNT" }, - { 0x00004000,"IN_Q_OVERFLOW" }, - { 0x00008000,"IN_IGNORED" }, - }; - - for (i=0; i<(int)(sizeof(strings)/sizeof(strings[0])); ++i) { - if (ie->mask&strings[i].mask) - buffer_putm(buffer_1," ",strings[i].string); - } - buffer_putnlflush(buffer_1); - -#endif for (i = 0; i < n; ++i) { if (root[i].idf == ie->wd) { @@ -162,11 +127,6 @@ int main(int argc, char* argv[]) { continue; } if (ie->mask & (IN_DELETE_SELF | IN_MOVE_SELF)) { -#if 0 - buffer_putmflush(buffer_1,root[i].filename," was ", - ie->mask&IN_DELETE_SELF ? "deleted" : "renamed", - ", cancelling subscription\n"); -#endif inotify_rm_watch(in, ie->wd); root[i].idf = -1; goto again; @@ -174,10 +134,6 @@ int main(int argc, char* argv[]) { goto goodevent; } else if (root[i].idd == ie->wd) { if (!strcmp(ie->name, root[i].fileonly)) { -#if 0 - buffer_putmflush(buffer_1,"the file we were interested in, ", - root[i].filename,", has been created. Adding subscription.\n"); -#endif if (root[i].idf != -1) inotify_rm_watch(in, root[i].idf); root[i].idf = inotify_add_watch(in, root[i].filename, @@ -186,9 +142,6 @@ int main(int argc, char* argv[]) { /* if the file was created, it will be empty now, wait for * the IN_CLOSE_WRITE event. */ if (ie->mask & IN_CREATE) { -#if 0 - buffer_putmflush(buffer_1,"file was created, so it will be empty now. Skipping until we get a close event.\n"); -#endif goto again; } goto goodevent; @@ -196,20 +149,11 @@ int main(int argc, char* argv[]) { * interested in. fall through */ } else goto again; -#if 0 - buffer_putmflush(buffer_1,"(directory event for \"",root[i].filename,"\")\n"); -#endif } } -#if 0 - buffer_putmflush(buffer_1,"ignoring irrelevant event.\n"); -#endif goto again; goodevent: -#if 0 - buffer_putmflush(buffer_1,"got through to stat\n"); -#endif for (i = 0; i < n; ++i) { if (stat(root[i].filename, &ss) == 0 && memcmp(&ss, &root[i].ss, sizeof(ss))) { memcpy(&root[i].ss, &ss, sizeof(ss)); diff --git a/minit-update.c b/minit-update.c @@ -19,6 +19,12 @@ increases file size by almost 4k #define WITH_STRERROR */ +static struct process* root; + +static int infd, outfd; +static int maxprocess = -1; +static int processalloc; + static char buf[BUFLEN + 1]; static unsigned int verbose; @@ -105,12 +111,6 @@ void find_service(int subdir, char* name, char* parent) { if (service) { /* request and read a "struct process" from minit */ struct process tmp; -#if 0 - int j; - for (j=0; j<=maxprocess; ++j) { /* skip duplicates */ - if(!strcmp(root[j].name,service)) return 0; - } -#endif if (verbose) { buffer_puts(buffer_1, "minit-update: status for "); diff --git a/minit.c b/minit.c @@ -67,6 +67,12 @@ void* realloc(void* x, size_t size) { } #endif +static struct process* root; + +static int infd, outfd; +static int maxprocess = -1; +static int processalloc; + char** Argv; #undef printf @@ -207,15 +213,9 @@ void handlekilled(pid_t killed) { } if (killed == 0) return; i = findbypid(killed); -#if 0 - printf("%d exited, idx %d -> service %s\n",killed,i,i>=0?root[i].name:"[unknown]"); -#endif if (i >= 0) { root[i].pid = 0; if (root[i].respawn) { -#if 0 - printf("restarting %s\n",root[i].name); -#endif circsweep(); startservice(i, time(0) - root[i].startedat < 1, root[i].father); } else { @@ -407,10 +407,6 @@ int startservice(int service, int pause, int father) { if (root[service].circular) return 0; root[service].circular = 1; -#if 0 - printf("setting father of %d (%s) to %d (%s)\n", - service,root[service].name,father,father>=0?root[father].name:"[msvc]"); -#endif root[service].father = father; #ifdef HISTORY { @@ -451,16 +447,6 @@ int startservice(int service, int pause, int father) { free(s); pid = startnodep(service, pause); -#if 0 - write(1,"started service ",17); - write(1,root[service].name,str_len(root[service].name)); - write(1," -> ",4); - { - char buf[10]; - snprintf(buf,10,"%d\n",pid); - write(1,buf,str_len(buf)); - } -#endif close(dir); dir = -1; } @@ -478,16 +464,6 @@ void childhandler() { #ifdef debug write(2, "wait...", 7); #endif -#if 0 - if (getpid()!=1) { - char buf[100]; - _puts("childhandler() called from pid "); - buf[fmt_ulong(buf,getpid())]=0; - _puts(buf); - _puts("\n"); - return; - } -#endif #ifdef UPDATE if (doupdate) return; #endif @@ -713,14 +689,7 @@ int main(int argc, char* argv[]) { write(outfd, "1:", 2); { int i; -#if 0 - printf("looking for father==%d\n",idx); -#endif for (i = 0; i <= maxprocess; ++i) { -#if 0 - printf("pid of %d(%s) is %lu, father is %d\n", - i,root[i].name?root[i].name:"[none]",root[i].pid,root[i].father); -#endif if (root[i].father == idx) write(outfd, root[i].name, str_len(root[i].name) + 1); } diff --git a/minit.h b/minit.h @@ -1,9 +1,12 @@ +#pragma once + +#include <time.h> + #ifndef MINITROOT #define MINITROOT "/etc/minit" #endif -#ifndef NOVARS -static struct process { +struct process { char* name; /* char **argv; */ pid_t pid; @@ -13,9 +16,4 @@ static struct process { int father; /* the service who started me or -1 if I was started directly */ int __stdin, __stdout; int logservice; -}* root; - -static int infd, outfd; -static int maxprocess = -1; -static int processalloc; -#endif +}; +\ No newline at end of file diff --git a/msvc.c b/msvc.c @@ -10,7 +10,6 @@ #include <string.h> #include <sys/file.h> #include <unistd.h> -#define NOVARS #include "minit.h" static int infd, outfd; diff --git a/shutdown.c b/shutdown.c @@ -41,7 +41,6 @@ static inline int __write2(const char* s) { return write(2, s, strlen(s)); } #define USE_MINIT #ifdef USE_MINIT -# define NOVARS # include "minit.h" #endif