summaryrefslogtreecommitdiffstats
path: root/sbin/devd
diff options
context:
space:
mode:
authorasomers <asomers@FreeBSD.org>2014-03-07 23:30:48 +0000
committerasomers <asomers@FreeBSD.org>2014-03-07 23:30:48 +0000
commit94889417b97b6a9e30e7d591f83784988e4b2888 (patch)
treeb99eaae61526b694cc2f189a88e8e28109b9c6bd /sbin/devd
parent2c64d4aa1f66230814029bf17de6b4536a64ece8 (diff)
downloadFreeBSD-src-94889417b97b6a9e30e7d591f83784988e4b2888.zip
FreeBSD-src-94889417b97b6a9e30e7d591f83784988e4b2888.tar.gz
sbin/devd/devd.8
sbin/devd/devd.cc Add a -q flag to devd that will suppress syslog logging at LOG_NOTICE or below. Requested by: ian@ and imp@ MFC after: 3 weeks Sponsored by: Spectra Logic Corporation
Diffstat (limited to 'sbin/devd')
-rw-r--r--sbin/devd/devd.84
-rw-r--r--sbin/devd/devd.cc28
2 files changed, 19 insertions, 13 deletions
diff --git a/sbin/devd/devd.8 b/sbin/devd/devd.8
index 1869de6..fa34df2 100644
--- a/sbin/devd/devd.8
+++ b/sbin/devd/devd.8
@@ -33,7 +33,7 @@
.Nd "device state change daemon"
.Sh SYNOPSIS
.Nm
-.Op Fl dn
+.Op Fl dnq
.Op Fl f Ar file
.Op Fl l Ar num
.Sh DESCRIPTION
@@ -63,6 +63,8 @@ The default connection limit is 10.
.It Fl n
Do not process all pending events before becoming a daemon.
Instead, call daemon right away.
+.It Fl q
+Quiet mode. Only log messages at priority LOG_WARNING or above.
.El
.Sh IMPLEMENTATION NOTES
The
diff --git a/sbin/devd/devd.cc b/sbin/devd/devd.cc
index 2bb14f1..77f74c6 100644
--- a/sbin/devd/devd.cc
+++ b/sbin/devd/devd.cc
@@ -129,8 +129,9 @@ static const char detach = '-';
static struct pidfh *pfh;
-int dflag;
-int nflag;
+static int no_daemon = 0;
+static int daemonize_quick = 0;
+static int quiet_mode = 0;
static unsigned total_events = 0;
static volatile sig_atomic_t got_siginfo = 0;
static volatile sig_atomic_t romeo_must_die = 0;
@@ -291,7 +292,7 @@ match::do_match(config &c)
* can consume excessive amounts of systime inside of connect(). Only
* log when we're in -d mode.
*/
- if (dflag) {
+ if (no_daemon) {
devdlog(LOG_DEBUG, "Testing %s=%s against %s, invert=%d\n",
_var.c_str(), value.c_str(), _re.c_str(), _inv);
}
@@ -401,7 +402,7 @@ var_list::set_variable(const string &var, const string &val)
* can consume excessive amounts of systime inside of connect(). Only
* log when we're in -d mode.
*/
- if (dflag)
+ if (no_daemon)
devdlog(LOG_DEBUG, "setting %s=%s\n", var.c_str(), val.c_str());
_vars[var] = val;
}
@@ -945,7 +946,7 @@ event_loop(void)
accepting = 1;
max_fd = max(fd, server_fd) + 1;
while (!romeo_must_die) {
- if (!once && !dflag && !nflag) {
+ if (!once && !no_daemon && !daemonize_quick) {
// Check to see if we have any events pending.
tv.tv_sec = 0;
tv.tv_usec = 0;
@@ -1139,9 +1140,9 @@ devdlog(int priority, const char* fmt, ...)
va_list argp;
va_start(argp, fmt);
- if (dflag)
+ if (no_daemon)
vfprintf(stderr, fmt, argp);
- else
+ else if ((! quiet_mode) || (priority <= LOG_WARNING))
vsyslog(priority, fmt, argp);
va_end(argp);
}
@@ -1149,7 +1150,7 @@ devdlog(int priority, const char* fmt, ...)
static void
usage()
{
- fprintf(stderr, "usage: %s [-dn] [-l connlimit] [-f file]\n",
+ fprintf(stderr, "usage: %s [-dnq] [-l connlimit] [-f file]\n",
getprogname());
exit(1);
}
@@ -1179,10 +1180,10 @@ main(int argc, char **argv)
int ch;
check_devd_enabled();
- while ((ch = getopt(argc, argv, "df:l:n")) != -1) {
+ while ((ch = getopt(argc, argv, "df:l:nq")) != -1) {
switch (ch) {
case 'd':
- dflag++;
+ no_daemon = 1;
break;
case 'f':
configfile = optarg;
@@ -1191,7 +1192,10 @@ main(int argc, char **argv)
max_clients = MAX(1, strtoul(optarg, NULL, 0));
break;
case 'n':
- nflag++;
+ daemonize_quick = 1;
+ break;
+ case 'q':
+ quiet_mode = 1;
break;
default:
usage();
@@ -1199,7 +1203,7 @@ main(int argc, char **argv)
}
cfg.parse();
- if (!dflag && nflag) {
+ if (!no_daemon && daemonize_quick) {
cfg.open_pidfile();
daemon(0, 0);
cfg.write_pidfile();
OpenPOWER on IntegriCloud