file if user passed non-zero "truncate_log" flag.
* include/am_utils.h: switch_to_logfile() now takes a 3rd arg.
* amd/get_args.c (get_args): pass "truncate_log" flag as per
amd.conf global settings.
* amd/conf.c (gopt_truncate_log): store global value of
truncate_log flag.
* amd/amq_subr.c (amqproc_setopt_1_svc), hlfsd/hlfsd.c (main,
reload): don't truncate log file when calling switch_to_logfile().
* amd/amd.h (CFM_TRUNCATE_LOG): new flag. Fix comment typo.
* NEWS, doc/am-utils.texi (truncate_log Parameter),
scripts/amd.conf.5, scripts/amd.conf-sample (log_file): document
new truncate_log amd.conf parameter.
2005-07-25 Erez Zadok <ezk@cs.sunysb.edu>
+ * libamu/xutil.c (switch_to_logfile): truncate a regular-file log
+ file if user passed non-zero "truncate_log" flag.
+
+ * include/am_utils.h: switch_to_logfile() now takes a 3rd arg.
+
+ * amd/get_args.c (get_args): pass "truncate_log" flag as per
+ amd.conf global settings.
+
+ * amd/conf.c (gopt_truncate_log): store global value of
+ truncate_log flag.
+
+ * amd/amq_subr.c (amqproc_setopt_1_svc), hlfsd/hlfsd.c (main,
+ reload): don't truncate log file when calling switch_to_logfile().
+
+ * amd/amd.h (CFM_TRUNCATE_LOG): new flag. Fix comment typo.
+
+ * NEWS, doc/am-utils.texi (truncate_log Parameter),
+ scripts/amd.conf.5, scripts/amd.conf-sample (log_file): document
+ new truncate_log amd.conf parameter.
+
* amd/conf.c (gopt_forced_unmounts): check Linux kernel version
and alert if your version may be too old for MNT_FORCE to work
(before 2.4.0) or for MNT_DETACH to work (before 2.6.0).
on Amd's own mount point. This functionality is available for Linux, BSD44
systems, Solaris, OSF/1, and partially for AIX.
+New amd.conf global parameter: truncate_log (default to "no"). If set to
+"yes", then Amd will truncate the log file (if it's a regular file) on
+startup. This could be useful when conducting extensive testing on Amd maps
+(or Amd itself) and you don't want to see log data from a previous run in
+the same file.
+
- minor new ports:
i386-pc-linux-fc4
i386-pc-linux-suse9.3
* SUCH DAMAGE.
*
*
- * $Id: amd.h,v 1.67 2005/07/20 03:32:30 ezk Exp $
+ * $Id: amd.h,v 1.68 2005/07/26 01:48:13 ezk Exp $
*
*/
#define CFM_NFS_INSECURE_PORT 0x00002000
#define CFM_DOMAIN_STRIP 0x00004000
#define CFM_NORMALIZE_SLASHES 0x00008000 /* normalize slashes? */
-#define CFM_FORCED_UNMOUNTS 0x00010000 /* normalize slashes? */
+#define CFM_FORCED_UNMOUNTS 0x00010000 /* forced unmounts? */
+#define CFM_TRUNCATE_LOG 0x00020000 /* truncate log file? */
+
/* defaults global flags: plock, tcpwrappers, and autofs/lofs */
#define CFM_DEFAULT_FLAGS (CFM_PROCESS_LOCK|CFM_USE_TCPWRAPPERS|CFM_AUTOFS_USE_LOFS|CFM_DOMAIN_STRIP|CFM_NORMALIZE_SLASHES)
* SUCH DAMAGE.
*
*
- * $Id: amq_subr.c,v 1.19 2005/01/03 20:56:45 ezk Exp $
+ * $Id: amq_subr.c,v 1.20 2005/07/26 01:48:13 ezk Exp $
*
*/
/*
case AMOPT_LOGFILE:
if (gopt.logfile && opt->as_str
&& STREQ(gopt.logfile, opt->as_str)) {
- if (switch_to_logfile(opt->as_str, orig_umask))
+ if (switch_to_logfile(opt->as_str, orig_umask, 0))
rc = EINVAL;
} else {
rc = EACCES;
* SUCH DAMAGE.
*
*
- * $Id: conf.c,v 1.34 2005/07/25 23:49:41 ezk Exp $
+ * $Id: conf.c,v 1.35 2005/07/26 01:48:13 ezk Exp $
*
*/
static int gopt_search_path(const char *val);
static int gopt_selectors_in_defaults(const char *val);
static int gopt_show_statfs_entries(const char *val);
+static int gopt_truncate_log(const char *val);
static int gopt_unmount_on_exit(const char *val);
static int gopt_use_tcpwrappers(const char *val);
static int gopt_vendor(const char *val);
{"selectors_on_default", gopt_selectors_in_defaults},
{"selectors_in_defaults", gopt_selectors_in_defaults},
{"show_statfs_entries", gopt_show_statfs_entries},
+ {"truncate_log", gopt_truncate_log},
{"unmount_on_exit", gopt_unmount_on_exit},
{"use_tcpwrappers", gopt_use_tcpwrappers},
{"vendor", gopt_vendor},
}
+static int
+gopt_truncate_log(const char *val)
+{
+ if (STREQ(val, "yes")) {
+ gopt.flags |= CFM_TRUNCATE_LOG;
+ return 0;
+ } else if (STREQ(val, "no")) {
+ gopt.flags &= ~CFM_TRUNCATE_LOG;
+ return 0;
+ }
+
+ fprintf(stderr, "conf: unknown value to truncate_log \"%s\"\n", val);
+ return 1; /* unknown value */
+}
+
+
static int
gopt_unmount_on_exit(const char *val)
{
* SUCH DAMAGE.
*
*
- * $Id: get_args.c,v 1.33 2005/07/07 23:34:23 ezk Exp $
+ * $Id: get_args.c,v 1.34 2005/07/26 01:48:13 ezk Exp $
*
*/
exit(0);
}
- if (switch_to_logfile(gopt.logfile, orig_umask) != 0)
+ if (switch_to_logfile(gopt.logfile, orig_umask,
+ (gopt.flags & CFM_TRUNCATE_LOG)) != 0)
plog(XLOG_USER, "Cannot switch logfile");
return;
@c
@c %W% (Berkeley) %G%
@c
-@c $Id: am-utils.texi,v 1.105 2005/07/21 05:22:47 ezk Exp $
+@c $Id: am-utils.texi,v 1.106 2005/07/26 01:48:13 ezk Exp $
@c
@setfilename am-utils.info
* restart_mounts Parameter::
* selectors_in_defaults Parameter::
* show_statfs_entries Parameter::
+* truncate_log Parameter::
* unmount_on_exit Parameter::
* use_tcpwrappers Parameter::
* vendor Parameter::
Deprecated form: selectors_on_default.
@c ----------------------------------------------------------------
-@node show_statfs_entries Parameter, unmount_on_exit Parameter, selectors_in_defaults Parameter, Global Parameters
+@node show_statfs_entries Parameter, truncate_log Parameter, selectors_in_defaults Parameter, Global Parameters
@comment node-name, next, previous, up
@subsection @t{show_statfs_entries} Parameter
@cindex show_statfs_entries Parameter
the @b{statfs}(2) system call).
@c ----------------------------------------------------------------
-@node unmount_on_exit Parameter, use_tcpwrappers Parameter, show_statfs_entries Parameter, Global Parameters
+@node truncate_log Parameter, unmount_on_exit Parameter, show_statfs_entries Parameter, Global Parameters
+@comment node-name, next, previous, up
+@subsection @t{truncate_log} Parameter
+@cindex truncate_log Parameter
+
+(type=boolean), default=@samp{no}). If @samp{yes}, then @i{Amd} will
+truncate the log file (if it's a regular file) on startup. This could
+be useful when conducting extensive testing on @i{Amd} maps (or
+@i{Amd} itself) and you don't want to see log data from a previous run
+in the same file.
+
+@c ----------------------------------------------------------------
+@node unmount_on_exit Parameter, use_tcpwrappers Parameter, truncate_log Parameter, Global Parameters
@comment node-name, next, previous, up
@subsection @t{unmount_on_exit} Parameter
@cindex unmount_on_exit Parameter
* SUCH DAMAGE.
*
*
- * $Id: hlfsd.c,v 1.32 2005/02/27 23:53:22 ezk Exp $
+ * $Id: hlfsd.c,v 1.33 2005/07/26 01:48:13 ezk Exp $
*
* HLFSD was written at Columbia University Computer Science Department, by
* Erez Zadok <ezk@cs.columbia.edu> and Alexander Dupuy <dupuy@cs.columbia.edu>
*dot = '\0';
orig_umask = umask(0);
if (logfile)
- switch_to_logfile(logfile, orig_umask);
+ switch_to_logfile(logfile, orig_umask, 0);
#ifndef MOUNT_TABLE_ON_FILE
if (amuDebug(D_MTAB))
* can be rotated)
*/
if (signum == SIGHUP && logfile)
- switch_to_logfile(logfile, orig_umask);
+ switch_to_logfile(logfile, orig_umask, 0);
/*
* parent performs the reload, while the child continues to serve
* SUCH DAMAGE.
*
*
- * $Id: am_utils.h,v 1.68 2005/07/21 05:22:47 ezk Exp $
+ * $Id: am_utils.h,v 1.69 2005/07/26 01:48:13 ezk Exp $
*
*/
extern void nfs_program_2(struct svc_req *rqstp, SVCXPRT *transp);
extern int pickup_rpc_reply(voidp, int, voidp, XDRPROC_T_TYPE);
extern int switch_option(char *);
-extern int switch_to_logfile(char *logfile, int orig_umask);
+extern int switch_to_logfile(char *logfile, int orig_umask, int truncate_log);
extern mntlist *read_mtab(char *, const char *);
#ifndef HAVE_TRANSPORT_TYPE_TLI
extern struct sockaddr_in *amu_svc_getcaller(SVCXPRT *xprt);
* SUCH DAMAGE.
*
*
- * $Id: xutil.c,v 1.38 2005/07/07 23:34:23 ezk Exp $
+ * $Id: xutil.c,v 1.39 2005/07/26 01:48:13 ezk Exp $
*
*/
* Change current logfile
*/
int
-switch_to_logfile(char *logfile, int old_umask)
+switch_to_logfile(char *logfile, int old_umask, int truncate_log)
{
FILE *new_logfp = stderr;
plog(XLOG_WARNING, "syslog option not supported, logging unchanged");
#endif /* not HAVE_SYSLOG */
- } else {
+ } else { /* regular log file */
(void) umask(old_umask);
+ if (truncate_log)
+ truncate(logfile, 0);
new_logfp = fopen(logfile, "a");
umask(0);
}
print_version = no | yes
# (amd -l)
log_file = /dev/stderr | /var/log/amd | syslog[:facility]
+# should we truncate the log file on startup?
+truncate_log = no | yes
# NFS (RPC) retry interval/counter, in tenths of secs (amd -t interval.counter)
nfs_retry_interval = 8
nfs_retransmit_counter = 11 (eleven retransmission attempts)
.\"
.\" %W% (Berkeley) %G%
.\"
-.\" $Id: amd.conf.5,v 1.38 2005/07/20 03:32:31 ezk Exp $
+.\" $Id: amd.conf.5,v 1.39 2005/07/26 01:48:13 ezk Exp $
.\"
.TH AMD.CONF 5 "7 August 1997"
.SH NAME
entries (keys) they have when "df" runs. (This is accomplished by returning
non-zero values to the statfs(2) system call).
+.TP
+.BR truncate_log " (boolean), default=no)"
+If "yes," then the log file (if it is a regular file), will be truncated
+upon startup.
+
.TP
.BR unmount_on_exit " (boolean), default=no)"
If "yes," then amd will attempt to unmount all file systems which it knows