XLOG_DEFAULT.
(cmdoption): take unsigned int as flags argument, and print any
errors as XLOG_ERROR (which cannot be turned off).
(switch_option): remove old code which disallowed you from turning
off flags that were set when Amd started up. Now, you can turn
any log option on/off at start time or later on (via amq -x),
other than the two mandatory options (fatal+error).
* include/am_utils.h (XLOG_*): remove unused XLOG_DEFSTR. Define
XLOG_MASK to mask out unused flag bits. Define XLOG_DEFAULT to be
what it was before (fatal + error + user + warning + info), but
use the new mask. Remove extern's for xlog_level and
xlog_level_init. Change extern for cmdoption() to take an
unsigned flags argument.
* doc/am-utils.texi, amq/amq.8, scripts/amd.conf.5, amd/amd.8:
document mandatory log options
(fatal+error) which cannot be turned off and are always on by
default. They must be on so that Amd can report crucial errors,
including those related to setting flags on/off.
* hlfsd/hlfsd.c (main): remove hack to initialize log_options.
* wire-test/wire-test.c: remove reference to unused xlog_level.
* amd/mapc.c (mapc_create): 'alloc' flags variable should be
unsigned.
* amd/get_args.c (get_args): no need for hack using
xlog_level_init.
2005-08-14 Erez Zadok <ezk@cs.sunysb.edu>
+ * libamu/xutil.c: make xlog_level static, and initialize it to
+ XLOG_DEFAULT.
+ (cmdoption): take unsigned int as flags argument, and print any
+ errors as XLOG_ERROR (which cannot be turned off).
+ (switch_option): remove old code which disallowed you from turning
+ off flags that were set when Amd started up. Now, you can turn
+ any log option on/off at start time or later on (via amq -x),
+ other than the two mandatory options (fatal+error).
+
+ * include/am_utils.h (XLOG_*): remove unused XLOG_DEFSTR. Define
+ XLOG_MASK to mask out unused flag bits. Define XLOG_DEFAULT to be
+ what it was before (fatal + error + user + warning + info), but
+ use the new mask. Remove extern's for xlog_level and
+ xlog_level_init. Change extern for cmdoption() to take an
+ unsigned flags argument.
+
+ * doc/am-utils.texi, amq/amq.8, scripts/amd.conf.5, amd/amd.8:
+ document mandatory log options
+ (fatal+error) which cannot be turned off and are always on by
+ default. They must be on so that Amd can report crucial errors,
+ including those related to setting flags on/off.
+
+ * hlfsd/hlfsd.c (main): remove hack to initialize log_options.
+
+ * wire-test/wire-test.c: remove reference to unused xlog_level.
+
+ * amd/mapc.c (mapc_create): 'alloc' flags variable should be
+ unsigned.
+
+ * amd/get_args.c (get_args): no need for hack using
+ xlog_level_init.
+
* amd/Makefile.am: separate sources common to amd and sun2amd into
a special, locally-built only, static library called libaminfo.a.
XXX: Dan, document sun_map_syntax flag in more detail in am-utils.texi and
(more briefly) in amd.conf.5. And in this NEWS file, also briefly.
+Changed slightly how Amd behaves when you try to change log_options after
+Amd started (options can be turned on/off via "amq -x ARG"). It used to be
+that Amd won't let you turn off options which were on when Amd started.
+That limited users' ability to reduce Amd's logging levels to a minimum.
+Now, Amd will allow you to turn on/off any option, other than the two
+options "fatal" and "error." Both are on by default and considered
+mandatory. These two don't produce a lot of log messages, so your logs will
+remain small, but they are important to keep on, so Amd can report serious
+problems (including errors relating to incorrectly setting other log
+options).
+
*** Notes specific to am-utils version 6.1.1
New amd.conf global parameter: forced_unmounts (default to "no"). If set to
.BI \-x " options"
Specify run-time logging options. The options are a comma separated
list chosen from: fatal, error, user, warn, info, map, stats, all.
+Note that "fatal" and "error" are mandatory and cannot be turned off.
.TP
.BI \-y " domain"
return NULL;
while (tmp_map) {
- if (STREQ(tmp_map->cfm_dir,name)) {
+ if (STREQ(tmp_map->cfm_dir, name)) {
return tmp_map;
}
tmp_map = tmp_map->cfm_next;
exit(1);
}
- /* make sure there are some default options defined */
- if (xlog_level_init == ~0) {
- switch_option("");
- }
#ifdef DEBUG
usage += switch_option("debug");
#endif /* DEBUG */
mnt_map *m = ALLOC(struct mnt_map);
map_type *mt;
time_t modify;
- int alloc = 0;
+ u_int alloc = 0;
cmdoption(opt, mapc_opt, &alloc);
.BI \-x " log_options"
Ask the automounter to use the logging options specified in
.I log_options
-from now on.
+from now on. Note that the "fatal" and "error" options cannot be turned
+off.
.TP
.BI \-D " log_options"
@table @code
@item fatal
-Fatal errors
+Fatal errors (cannot be turned off)
@item error
-Non-fatal errors
+Non-fatal errors (cannot be turned off)
@item user
Non-fatal user errors
@item warn
@subsection @t{log_options} Parameter
@cindex log_options Parameter
-(type=string, default no logging options). Same as the @code{-x}
+(type=string, default fatal+error+user+warning+info). Same as the @code{-x}
option to @i{Amd}. Specify any logging options for @i{Amd}. Options
are comma delimited, and can be preceded by the string @samp{no} to
negate their meaning. The @samp{debug} logging option is only available
@item debug
debug messages
@item error
-non-fatal system errors
+non-fatal system errors (cannot be turned off)
@item fatal
-fatal errors
+fatal errors (cannot be turned off)
@item info
information
@item map
@code{-D} options have exactly the same effect as @i{Amd}'s corresponding
command line options.
-When @i{Amd} receives a @code{-x} flag it limits the log options being
-modified to those which were not enabled at startup. This prevents a
-user turning @emph{off} any logging option which was specified at
-startup, though any which have been turned on since then can still be
-turned off. The @code{-D} option has a similar behavior.
+When @i{Amd} receives the @code{-x} flag, it disallows turning off the
+@samp{fatal} or @samp{error} flags. Both are on by default. They are
+mandatory so that @i{Amd} could report important errors, including
+errors relating to turning flags on/off.
@c ################################################################
@node FSinfo, Hlfsd, Run-time Administration, Top
opterrs++;
}
- /* set some default debugging options */
- if (xlog_level_init == ~0)
- switch_option("");
/* need my pid before any dlog/plog */
am_set_mypid();
#ifdef DEBUG
#define XLOG_DEBUG 0x0020
#define XLOG_MAP 0x0040
#define XLOG_STATS 0x0080
-#define XLOG_DEFSTR "all,nomap,nostats" /* Default log options */
+#define XLOG_MASK 0x00ff /* mask for all flags */
+#define XLOG_MANDATORY (XLOG_FATAL|XLOG_ERROR) /* cannot turn these off */
#define XLOG_ALL (XLOG_FATAL|XLOG_ERROR|XLOG_USER|XLOG_WARNING|XLOG_INFO|XLOG_MAP|XLOG_STATS)
+/* default: fatal + error + user + warning + info */
+#define XLOG_DEFAULT (XLOG_MASK & (XLOG_ALL & ~XLOG_MAP & ~XLOG_STATS))
+
+ /* default: no logging options */
#define clocktime() (clock_valid ? clock_valid : time(&clock_valid))
extern int foreground; /* Foreground process */
extern int orig_umask; /* umask() on startup */
-extern int xlog_level; /* Logging level */
-extern int xlog_level_init;
extern serv_state amd_state; /* Should we go now */
extern struct in_addr myipaddr; /* (An) IP address of this host */
extern struct opt_tab xlog_opt[];
extern char *strnsave(const char *, int);
extern int amu_close(int fd);
extern int bind_resv_port(int, u_short *);
-extern int cmdoption(char *, struct opt_tab *, int *);
+extern int cmdoption(char *, struct opt_tab *, u_int *);
extern int compute_automounter_mount_flags(mntent_t *);
extern int compute_mount_flags(mntent_t *);
extern int get_amd_program_number(void);
#ifdef HAVE_SYSLOG
int syslogging;
#endif /* HAVE_SYSLOG */
-int xlog_level = XLOG_ALL & ~XLOG_MAP & ~XLOG_STATS;
-int xlog_level_init = ~0;
+static u_int xlog_level = XLOG_DEFAULT;
static int amd_program_number = AMQ_PROGRAM;
time_t clock_valid = 0;
int
-cmdoption(char *s, struct opt_tab *optb, int *flags)
+cmdoption(char *s, struct opt_tab *optb, u_int *flags)
{
char *p = s;
int errs = 0;
* This will log to stderr when parsing the command line
* since any -l option will not yet have taken effect.
*/
- plog(XLOG_USER, "option \"%s\" not recognized", s);
+ plog(XLOG_ERROR, "option \"%s\" not recognized", s);
errs++;
}
int
switch_option(char *opt)
{
- int xl = xlog_level;
+ u_int xl = xlog_level;
int rc = cmdoption(opt, xlog_opt, &xl);
- if (rc) {
- rc = EINVAL;
- } else {
- /*
- * Keep track of initial log level, and
- * don't allow options to be turned off.
- */
- if (xlog_level_init == ~0)
- xlog_level_init = xl;
- else
- xl |= xlog_level_init;
- xlog_level = xl;
+ if (rc) /* if got any error, don't update flags */
+ return EINVAL;
+
+ /*
+ * Don't allow "mandatory" flags to be turned off, because
+ * we must always be able to report on flag re/setting errors.
+ */
+ if ((xl & XLOG_MANDATORY) != XLOG_MANDATORY) {
+ plog(XLOG_ERROR, "cannot turn of mandatory logging options");
+ xl |= XLOG_MANDATORY;
}
+ if (xlog_level != xl)
+ xlog_level = xl; /* set new flags */
return rc;
}
+
#ifdef LOG_DAEMON
/*
* get syslog facility to use.
using the LOG_LOCAL7 facility (if it exists on the system).
.TP
-.BR log_options " (string, default no logging options)"
+.BR log_options " (string, default=fatal+error+user+warning+info)"
Same as the
.B \-x
option to Amd. Specify any logging options for Amd. Options are comma
.nf
\fBall\fR all messages
\fBdebug\fR debug messages
-\fBerror\fR non-fatal system errors
-\fBfatal\fR fatal errors
+\fBerror\fR non-fatal system errors (cannot be turned off)
+\fBfatal\fR fatal errors (cannot be turned off)
\fBinfo\fR information
\fBmap\fR map errors
\fBstats\fR additional statistical information
memmove((voidp) &ip->sin_addr, (voidp) hp->h_addr, sizeof(ip->sin_addr));
ip->sin_port = htons(NFS_PORT);
- xlog_level = 0; /* turn off debugging */
fprintf(stderr, "NFS Version and protocol tests to host \"%s\"...\n", testhost);
proto = "udp";
for (nv=2; nv<=3; ++nv) {