initctl: add hidden command line option -d,--debug

For developer use only.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2021-04-18 12:23:58 +02:00
1 parent 0168b765c1
commit 23a13fe1b6
4 files changed
+23 -3

No files matched your search

+7 -1
View File
@@ -51,6 +51,7 @@ struct cmd {
int icreate = 0;
int iforce = 0;
int ionce = 0;
int debug = 0;
int heading = 1;
int verbose = 0;
int plain = 0;
@@ -951,6 +952,7 @@ int main(int argc, char *argv[])
struct option long_options[] = {
{ "batch", 0, NULL, 'b' },
{ "create", 0, NULL, 'c' },
{ "debug", 0, NULL, 'd' },
{ "force", 0, NULL, 'f' },
{ "help", 0, NULL, 'h' },
{ "once", 0, NULL, '1' },
@@ -1012,7 +1014,7 @@ int main(int argc, char *argv[])
if (transform(progname(argv[0])))
return reboot_main(argc, argv);
while ((c = getopt_long(argc, argv, "1bcfh?pqtv", long_options, NULL)) != EOF) {
while ((c = getopt_long(argc, argv, "1bcdfh?pqtv", long_options, NULL)) != EOF) {
switch(c) {
case '1':
ionce = 1;
@@ -1026,6 +1028,10 @@ int main(int argc, char *argv[])
icreate = 1;
break;
case 'd':
debug = 1;
break;
case 'f':
iforce = 1;
break;
+2 -1
View File
@@ -257,7 +257,8 @@ int do_disable(char *arg, int check)
if (chdir(FINIT_RCSD))
err(1, "failed cd %s", FINIT_RCSD);
(void)chdir("enabled"); /* System *may* have enabled/ dir. */
if (chdir("enabled")) /* System *may* have enabled/ dir. */
dbg("Failed changing to %s/enabled/: %s", FINIT_RCSD, strerror(errno));
if (check && stat(arg, &st))
errx(1, "%s not (an) enabled (service).", arg);
-1
View File
@@ -26,7 +26,6 @@
#include <errno.h>
#include <regex.h>
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
#ifdef HAVE_TERMIOS_H
# include <termios.h>
+14
View File
@@ -28,6 +28,7 @@
#ifdef HAVE_TERMIOS_H
#include <poll.h>
#include <stdio.h>
#include <stdarg.h>
#include <sys/reboot.h>
#include <termios.h>
#endif
@@ -37,6 +38,7 @@
#define RB_SW_SUSPEND 0xd000fce2
#endif
extern int debug; /* defined in finit or initctl */
extern int ttrows;
extern int ttcols;
extern char *prognm;
@@ -72,6 +74,18 @@ int ttcooked (void);
#define ttcooked() 0
#endif
static inline void dbg(char *fmt, ...)
{
va_list ap;
if (!debug)
return;
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(ap);
}
static inline char *strterm(char *str, size_t len)
{
str[len - 1] = 0;