Subject: bin/6248: lfs_cleanerd could use syslog() for notices, instead of err()/warn()
To: None <gnats-bugs@gnats.netbsd.org, perseant@hhhh.org, margo@eecs.harvard.edu>
From: None <perseant@hhhh.org>
List: netbsd-bugs
Date: 10/04/1998 15:55:32
>Number:         6248
>Category:       bin
>Synopsis:       lfs_cleanerd does not send even critical failures to syslogd
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sun Oct  4 16:05:00 1998
>Last-Modified:
>Originator:     Konrad Schroder
>Organization:
-------------------------------------------------------------------------
Konrad Schroder           http://www.hitl.washington.edu/people/perseant/
System Administrator                         perseant@hitl.washington.edu
Human Interface Technology Lab                     Voice: +1.206.616.1478
Box 352142, University of Washington, 98195, USA     FAX: +1.206.543.5380
>Release:        Sep 14, 1998
>Environment:
System: NetBSD inle 1.3 NetBSD 1.3 (INLE) #1: Sun Apr 19 15:01:29 PDT 1998 perseant@gro:/usr/src/sys/arch/i386/compile/INLE i386

>Description:
        The only diagnostics that lfs_cleanerd gives when it is not run
        with the debugging flag (-d) is its exit status.  It would be
        more useful to be able to look at error/warning messages in the
        syslog.  The enclosed patch makes these changes:

                 1) If -d is not given, error and warning messages are
                    sent to syslog.  Severity is LOG_ERROR or
                    LOG_WARNING depending on whether the first argument
                    to err() was 1 or 0 (and if it was 1, exit() is called).
                 2) If -d is given, they are also sent to stdout (syslog
                    is passed LOG_PERROR);
                 3) If "-dd" is given, output that previously required
                    compiling with -DVERBOSE is given.
>How-To-Repeat:
>Fix:
*** lfs_cleanerd.1.3H/cleanerd.c	Sat Sep 26 14:20:51 1998
--- lfs_cleanerd/cleanerd.c	Sun Oct  4 13:58:11 1998
***************
*** 57,67 ****
--- 57,70 ----
  #include <time.h>
  #include <unistd.h>
  
+ #include <syslog.h>
+ 
  #include "clean.h"
  char *special = "cleanerd";
  int do_small = 0;
  int do_mmap = 0;
  int stat_report = 0;
+ int debug = 0;
  struct cleaner_stats {
  	double	util_tot;
  	double	util_sos;
***************
*** 142,153 ****
  		 *
  		 * priority = ((seg_size - live) * age) / (seg_size + live)
  		 */
- #ifdef VERBOSE
  		if (live < 0 || live > seg_size(lfsp)) {
! 			err(0, "Bad segusage count: %d", live);
  			live = 0;
  		}
- #endif
  		return (lblkno(lfsp, seg_size(lfsp) - live) * age)
  			/ lblkno(lfsp, seg_size(lfsp) + live);
  	}
--- 145,154 ----
  		 *
  		 * priority = ((seg_size - live) * age) / (seg_size + live)
  		 */
  		if (live < 0 || live > seg_size(lfsp)) {
!                         syslog(LOG_NOTICE,"bad segusage count: %d", live);
  			live = 0;
  		}
  		return (lblkno(lfsp, seg_size(lfsp) - live) * age)
  			/ lblkno(lfsp, seg_size(lfsp) + live);
  	}
***************
*** 163,173 ****
  	struct timeval timeout;		/* sleep timeout */
  	fsid_t fsid;
  	long clean_opts;		/* cleaning options */
! 	int nodaemon, segs_per_clean;
  	int opt, cmd_err;
  	char *fs_name;			/* name of filesystem to clean */
  
! 	cmd_err = nodaemon = 0;
  	clean_opts = 0;
  	segs_per_clean = 1;
  	while ((opt = getopt(argc, argv, "bdmn:r:s")) != -1) {
--- 164,174 ----
  	struct timeval timeout;		/* sleep timeout */
  	fsid_t fsid;
  	long clean_opts;		/* cleaning options */
! 	int segs_per_clean;
  	int opt, cmd_err;
  	char *fs_name;			/* name of filesystem to clean */
  
! 	cmd_err = debug = 0;
  	clean_opts = 0;
  	segs_per_clean = 1;
  	while ((opt = getopt(argc, argv, "bdmn:r:s")) != -1) {
***************
*** 180,186 ****
  				clean_opts |= CLEAN_BYTES;
  				break;
  			case 'd':	/* Debug mode. */
! 				nodaemon = 1;
  				break;
  			case 'm':
  				do_mmap = 1;
--- 181,187 ----
  				clean_opts |= CLEAN_BYTES;
  				break;
  			case 'd':	/* Debug mode. */
! 				debug++;
  				break;
  			case 'm':
  				do_mmap = 1;
***************
*** 201,207 ****
  	argc -= optind;
  	argv += optind;
  	if (cmd_err || (argc != 1))
! 		err(1, "usage: lfs_cleanerd [-smd] fs_name");
  
  	fs_name = argv[0];
  
--- 202,208 ----
  	argc -= optind;
  	argv += optind;
  	if (cmd_err || (argc != 1))
! 		err(1, "usage: lfs_cleanerd [-bdms] [-n nsegs] [-r report_freq] fs_name");
  
  	fs_name = argv[0];
  
***************
*** 213,221 ****
  		err(1, "lfs_cleanerd: filesystem %s isn't an LFS!", fs_name);
  	}
  
! 	if (!nodaemon)	/* should we become a daemon, chdir to / & close fd's */
  		if (daemon(0, 0) == -1)
  			err(1, "lfs_cleanerd: couldn't become a daemon!");
  
  	timeout.tv_sec = 5*60; /* five minutes */
  	timeout.tv_usec = 0;
--- 214,228 ----
  		err(1, "lfs_cleanerd: filesystem %s isn't an LFS!", fs_name);
  	}
  
!         /* should we become a daemon, chdir to / & close fd's */
! 	if (debug == 0) {
  		if (daemon(0, 0) == -1)
  			err(1, "lfs_cleanerd: couldn't become a daemon!");
+                 openlog("lfs_cleanerd", LOG_NDELAY|LOG_PID, LOG_DAEMON);
+         } else {
+                 openlog("lfs_cleanerd", LOG_NDELAY|LOG_PID|LOG_PERROR,
+                         LOG_DAEMON);
+         }
  
  	timeout.tv_sec = 5*60; /* five minutes */
  	timeout.tv_usec = 0;
***************
*** 233,246 ****
  		if (clean_loop(fsp, segs_per_clean, clean_opts))
  			continue;
  
! #ifdef VERBOSE
! 		(void)printf("Cleaner going to sleep.\n");
! #endif
  		if (lfs_segwait(&fsid, &timeout) < 0)
! 			err(0, "lfs_segwait: returned error\n");	
! #ifdef VERBOSE
! 		(void)printf("Cleaner waking up.\n");
! #endif
  	}
  }
  
--- 240,251 ----
  		if (clean_loop(fsp, segs_per_clean, clean_opts))
  			continue;
  
!                 if(debug > 1)
!                     syslog(LOG_DEBUG,"Cleaner going to sleep.\n");
  		if (lfs_segwait(&fsid, &timeout) < 0)
! 			syslog(LOG_WARNING,"lfs_segwait returned error\n");
!                 if(debug > 1)
!                     syslog(LOG_DEBUG,"Cleaner waking up.\n");
  	}
  }
  
***************
*** 268,285 ****
  	 * space is less than BUSY_LIM % of possible clean space.
  	 */
  	now = time((time_t *)NULL);
! #ifdef VERBOSE
! 	printf("db_per_seg = %lu max_free_segs = %lu, bfree = %u avail = %d ",
  	    db_per_seg, max_free_segs, fsp->fi_lfs.lfs_bfree,
  	    fsp->fi_lfs.lfs_avail);
! 	printf("clean = %d\n", fsp->fi_cip->clean);
! #endif
  	if ((fsp->fi_lfs.lfs_bfree - fsp->fi_lfs.lfs_avail > db_per_seg &&
  	    fsp->fi_lfs.lfs_avail < db_per_seg) ||
  	    (fsp->fi_cip->clean < max_free_segs &&
  	    (fsp->fi_cip->clean <= MIN_SEGS(&fsp->fi_lfs) ||
! 	    fsp->fi_cip->clean < max_free_segs * BUSY_LIM))) {
! 		printf("Cleaner Running  at %s (%d of %lu segments available)\n",
  		    ctime(&now), fsp->fi_cip->clean, max_free_segs);
  		clean_fs(fsp, cost_benefit, nsegs, options);
  		return (1);
--- 273,294 ----
  	 * space is less than BUSY_LIM % of possible clean space.
  	 */
  	now = time((time_t *)NULL);
! 
!         if(debug > 1) {
!             syslog(LOG_DEBUG, "db_per_seg = %lu max_free_segs = %lu, bfree = %u avail = %d ",
                     db_per_seg, max_free_segs, fsp->fi_lfs.lfs_bfree,
                     fsp->fi_lfs.lfs_avail);
!             syslog(LOG_DEBUG, "clean = %d\n", fsp->fi_cip->clean);
!         }
! 
              if ((fsp->fi_lfs.lfs_bfree - fsp->fi_lfs.lfs_avail > db_per_seg &&
                   fsp->fi_lfs.lfs_avail < db_per_seg) ||
                  (fsp->fi_cip->clean < max_free_segs &&
                   (fsp->fi_cip->clean <= MIN_SEGS(&fsp->fi_lfs) ||
!                   fsp->fi_cip->clean < max_free_segs * BUSY_LIM)))
!             {
!                 if(debug)
!                     syslog(LOG_DEBUG, "Cleaner Running  at %s (%d of %lu segments available)\n",
                             ctime(&now), fsp->fi_cip->clean, max_free_segs);
  		clean_fs(fsp, cost_benefit, nsegs, options);
  		return (1);
***************
*** 296,307 ****
  		if (loadavg[ONE_MIN] == 0.0 && loadavg[FIVE_MIN] &&
  		    fsp->fi_cip->clean < max_free_segs * IDLE_LIM) {
  		        clean_fs(fsp, cost_benefit, nsegs, options);
! 			printf("Cleaner Running  at %s (system idle)\n",
  			    ctime(&now));
  			return (1);
  		}
  	} 
! 	printf("Cleaner Not Running at %s\n", ctime(&now));
  	return (0);
  }
  
--- 305,318 ----
  		if (loadavg[ONE_MIN] == 0.0 && loadavg[FIVE_MIN] &&
  		    fsp->fi_cip->clean < max_free_segs * IDLE_LIM) {
  		        clean_fs(fsp, cost_benefit, nsegs, options);
!                         if(debug)
!                             syslog(LOG_DEBUG, "Cleaner Running  at %s (system idle)\n",
                                     ctime(&now));
  			return (1);
  		}
  	}
!         if(debug)
!             syslog(LOG_DEBUG, "Cleaner Not Running at %s", ctime(&now));
  	return (0);
  }
  
***************
*** 319,333 ****
  
  	if ((segs =
  	    malloc(fsp->fi_lfs.lfs_nseg * sizeof(struct seglist))) == NULL) {
! 		err(0, "malloc failed");
  		return;
  	}
  	i = choose_segments(fsp, segs, cost_func);
! #ifdef VERBOSE
! 	printf("clean_fs: found %d segments to clean in file system %s\n",
  		i, fsp->fi_statfsp->f_mntonname);
! 	fflush(stdout);
! #endif
  	if (i) {
  		/* Check which cleaning algorithm to use. */
  		if (options & CLEAN_BYTES) {
--- 330,344 ----
  
  	if ((segs =
  	    malloc(fsp->fi_lfs.lfs_nseg * sizeof(struct seglist))) == NULL) {
! 		syslog(LOG_WARNING,"malloc failed: %m");
  		return;
  	}
  	i = choose_segments(fsp, segs, cost_func);
! 
!         if(debug > 1)
!             syslog(LOG_DEBUG, "clean_fs: found %d segments to clean in file system %s\n",
                     i, fsp->fi_statfsp->f_mntonname);
! 
  	if (i) {
  		/* Check which cleaning algorithm to use. */
  		if (options & CLEAN_BYTES) {
***************
*** 341,347 ****
  				else if (lfs_segclean(&fsp->fi_statfsp->f_fsid,
  				    sp->sl_id) < 0)
  					perror("lfs_segclean failed");
! 				printf("Cleaned segment %d (%d bytes)\n",
  				    sp->sl_id, sp->sl_bytes);
  				cleaned_bytes += sp->sl_bytes;
  			}
--- 352,359 ----
  				else if (lfs_segclean(&fsp->fi_statfsp->f_fsid,
  				    sp->sl_id) < 0)
  					perror("lfs_segclean failed");
!                                 if(debug)
!                                     syslog(LOG_DEBUG, "Cleaned segment %d (%d bytes)\n",
                                             sp->sl_id, sp->sl_bytes);
  				cleaned_bytes += sp->sl_bytes;
  			}
***************
*** 352,358 ****
  				else if (lfs_segclean(&fsp->fi_statfsp->f_fsid,
  				    sp->sl_id) < 0)
  					perror("lfs_segclean failed");
! 				printf("Completed cleaning segment %d\n", sp->sl_id);
  			}
  	}
  	free(segs);
--- 364,371 ----
  				else if (lfs_segclean(&fsp->fi_statfsp->f_fsid,
  				    sp->sl_id) < 0)
  					perror("lfs_segclean failed");
! 				if(debug)
!                                     syslog(LOG_DEBUG,"Completed cleaning segment %d\n", sp->sl_id);
  			}
  	}
  	free(segs);
***************
*** 390,398 ****
  
  	lfsp = &fsp->fi_lfs;
  
! #ifdef VERBOSE
! 	(void)printf("Entering choose_segments\n");
! #endif
  	dump_super(lfsp);
  	dump_cleaner_info(fsp->fi_cip);
  
--- 403,410 ----
  
  	lfsp = &fsp->fi_lfs;
  
!         if(debug > 1)
!             syslog(LOG_DEBUG,"Entering choose_segments\n");
  	dump_super(lfsp);
  	dump_cleaner_info(fsp->fi_cip);
  
***************
*** 402,410 ****
  		if (!(sup->su_flags & SEGUSE_DIRTY) ||
  		    sup->su_flags & SEGUSE_ACTIVE)
  			continue;
! #ifdef VERBOSE
! 		(void)printf("\tchoosing segment %d\n", i);
! #endif
  		sp->sl_cost = (*cost_func)(fsp, sup);
  		sp->sl_id = i;
  		sp->sl_bytes = sup->su_nbytes;
--- 414,421 ----
  		if (!(sup->su_flags & SEGUSE_DIRTY) ||
  		    sup->su_flags & SEGUSE_ACTIVE)
  			continue;
!                 if(debug > 1)
!                     syslog(LOG_DEBUG, "\tchoosing segment %d\n", i);
  		sp->sl_cost = (*cost_func)(fsp, sup);
  		sp->sl_id = i;
  		sp->sl_bytes = sup->su_nbytes;
***************
*** 412,420 ****
  	}
  	nsegs = sp - seglist;
  	qsort(seglist, nsegs, sizeof(struct seglist), cost_compare);
! #ifdef VERBOSE
! 	(void)printf("Returning %d segments\n", nsegs);
! #endif
  	return (nsegs);
  }
  
--- 423,432 ----
  	}
  	nsegs = sp - seglist;
  	qsort(seglist, nsegs, sizeof(struct seglist), cost_compare);
! 
!         if(debug > 1)
!             syslog(LOG_DEBUG,"Returning %d segments\n", nsegs);
! 
  	return (nsegs);
  }
  
***************
*** 424,445 ****
  	FS_INFO *fsp;	/* file system information */
  	int id;		/* segment number */
  {
! 	BLOCK_INFO *block_array, *bp;
  	SEGUSE *sp;
  	struct lfs *lfsp;
  	struct tossstruct t;
  	double util;
  	caddr_t seg_buf;
! 	int num_blocks, maxblocks, clean_blocks;
  
  	lfsp = &fsp->fi_lfs;
  	sp = SEGUSE_ENTRY(lfsp, fsp->fi_segusep, id);
  
! #ifdef VERBOSE
! 	(void)printf("cleaning segment %d: contains %lu bytes\n", id,
  	    (unsigned long)sp->su_nbytes);
! 	fflush(stdout);
! #endif
  	/* XXX could add debugging to verify that segment is really empty */
  	if (sp->su_nbytes == sp->su_nsums * LFS_SUMMARY_SIZE) {
  		++cleaner_stats.segs_empty;
--- 436,457 ----
  	FS_INFO *fsp;	/* file system information */
  	int id;		/* segment number */
  {
! 	BLOCK_INFO *block_array, *bp, *_bip;
  	SEGUSE *sp;
  	struct lfs *lfsp;
  	struct tossstruct t;
  	double util;
  	caddr_t seg_buf;
! 	int num_blocks, maxblocks, clean_blocks, i;
!         unsigned long *lp;
  
  	lfsp = &fsp->fi_lfs;
  	sp = SEGUSE_ENTRY(lfsp, fsp->fi_segusep, id);
  
!         if(debug > 1)
!             syslog(LOG_DEBUG, "cleaning segment %d: contains %lu bytes\n", id,
                     (unsigned long)sp->su_nbytes);
! 
  	/* XXX could add debugging to verify that segment is really empty */
  	if (sp->su_nbytes == sp->su_nsums * LFS_SUMMARY_SIZE) {
  		++cleaner_stats.segs_empty;
***************
*** 448,469 ****
  
  	/* map the segment into a buffer */
  	if (mmap_segment(fsp, id, &seg_buf, do_mmap) < 0) {
! 		err(0, "mmap_segment failed");
  		++cleaner_stats.segs_error;
  		return (-1);
  	}
  	/* get a list of blocks that are contained by the segment */
  	if (lfs_segmapv(fsp, id, seg_buf, &block_array, &num_blocks) < 0) {
! 		err(0, "clean_segment: lfs_segmapv failed");
  		++cleaner_stats.segs_error;
  		return (-1);
  	}
  	cleaner_stats.blocks_read += fsp->fi_lfs.lfs_ssize;
  
! #ifdef VERBOSE
! 	(void)printf("lfs_segmapv returned %d blocks\n", num_blocks);
! 	fflush(stdout);
! #endif
  
  	/* get the current disk address of blocks contained by the segment */
  	if (lfs_bmapv(&fsp->fi_statfsp->f_fsid, block_array, num_blocks) < 0) {
--- 460,479 ----
  
  	/* map the segment into a buffer */
  	if (mmap_segment(fsp, id, &seg_buf, do_mmap) < 0) {
! 		syslog(LOG_WARNING,"clean_segment: mmap_segment failed: %m");
  		++cleaner_stats.segs_error;
  		return (-1);
  	}
  	/* get a list of blocks that are contained by the segment */
  	if (lfs_segmapv(fsp, id, seg_buf, &block_array, &num_blocks) < 0) {
! 		syslog(LOG_WARNING,"clean_segment: lfs_segmapv failed");
  		++cleaner_stats.segs_error;
  		return (-1);
  	}
  	cleaner_stats.blocks_read += fsp->fi_lfs.lfs_ssize;
  
!         if(debug > 1)
!             syslog(LOG_DEBUG, "lfs_segmapv returned %d blocks\n", num_blocks);
  
  	/* get the current disk address of blocks contained by the segment */
  	if (lfs_bmapv(&fsp->fi_statfsp->f_fsid, block_array, num_blocks) < 0) {
***************
*** 481,502 ****
  	if (num_blocks && bi_tossold(&t, block_array + num_blocks - 1, NULL))
  		--num_blocks;
  
! #ifdef VERBOSE
! 	{
! 		BLOCK_INFO *_bip;
! 		u_long *lp;
! 		int i;
! 
! 		(void)printf("after bmapv still have %d blocks\n", num_blocks);
! 		fflush(stdout);
  		if (num_blocks)
! 			printf("BLOCK INFOS\n");
  		for (_bip = block_array, i=0; i < num_blocks; ++_bip, ++i) {
  			PRINT_BINFO(_bip);
  			lp = (u_long *)_bip->bi_bp;
  		}
  	}
! #endif
  	++cleaner_stats.segs_cleaned;
  	cleaner_stats.blocks_written += num_blocks;
  	util = ((double)num_blocks / fsp->fi_lfs.lfs_ssize);
--- 491,506 ----
  	if (num_blocks && bi_tossold(&t, block_array + num_blocks - 1, NULL))
  		--num_blocks;
  
!         if(debug > 1) {
!             syslog(LOG_DEBUG, "after bmapv still have %d blocks\n", num_blocks);
              if (num_blocks)
!                 syslog(LOG_DEBUG, "BLOCK INFOS\n");
              for (_bip = block_array, i=0; i < num_blocks; ++_bip, ++i) {
                  PRINT_BINFO(_bip);
                  lp = (u_long *)_bip->bi_bp;
              }
          }
! 
  	++cleaner_stats.segs_cleaned;
  	cleaner_stats.blocks_written += num_blocks;
  	util = ((double)num_blocks / fsp->fi_lfs.lfs_ssize);
***************
*** 511,517 ****
  		clean_blocks = maxblocks < num_blocks ? maxblocks : num_blocks;
  		if (lfs_markv(&fsp->fi_statfsp->f_fsid,
  		    bp, clean_blocks) < 0) {
! 			err(0, "clean_segment: lfs_markv failed");
  			++cleaner_stats.segs_error;
  			return (-1);
  		}
--- 515,521 ----
  		clean_blocks = maxblocks < num_blocks ? maxblocks : num_blocks;
  		if (lfs_markv(&fsp->fi_statfsp->f_fsid,
  		    bp, clean_blocks) < 0) {
! 			syslog(LOG_WARNING,"clean_segment: lfs_markv failed: %m");
  			++cleaner_stats.segs_error;
  			return (-1);
  		}
***************
*** 546,561 ****
  {
  	double avg = 0.0;
  
! 	printf("lfs_cleanerd:\t%s%d\n\t\t%s%d\n\t\t%s%d\n\t\t%s%d\n\t\t%s%d\n",
  		"blocks_read    ", cleaner_stats.blocks_read,
  		"blocks_written ", cleaner_stats.blocks_written,
  		"segs_cleaned   ", cleaner_stats.segs_cleaned,
  		"segs_empty     ", cleaner_stats.segs_empty,
  		"seg_error      ", cleaner_stats.segs_error);
! 	printf("\t\t%s%5.2f\n\t\t%s%5.2f\n",
  		"util_tot       ", cleaner_stats.util_tot,
  		"util_sos       ", cleaner_stats.util_sos);
! 	printf("\t\tavg util: %4.2f std dev: %9.6f\n",
  		avg = cleaner_stats.util_tot / cleaner_stats.segs_cleaned,
  		cleaner_stats.util_sos / cleaner_stats.segs_cleaned - avg * avg);
  
--- 550,565 ----
  {
  	double avg = 0.0;
  
! 	syslog(LOG_DEBUG, "lfs_cleanerd:\t%s%d\n\t\t%s%d\n\t\t%s%d\n\t\t%s%d\n\t\t%s%d\n",
  		"blocks_read    ", cleaner_stats.blocks_read,
  		"blocks_written ", cleaner_stats.blocks_written,
  		"segs_cleaned   ", cleaner_stats.segs_cleaned,
  		"segs_empty     ", cleaner_stats.segs_empty,
  		"seg_error      ", cleaner_stats.segs_error);
! 	syslog(LOG_DEBUG, "\t\t%s%5.2f\n\t\t%s%5.2f\n",
  		"util_tot       ", cleaner_stats.util_tot,
  		"util_sos       ", cleaner_stats.util_sos);
! 	syslog(LOG_DEBUG, "\t\tavg util: %4.2f std dev: %9.6f\n",
  		avg = cleaner_stats.util_tot / cleaner_stats.segs_cleaned,
  		cleaner_stats.util_sos / cleaner_stats.segs_cleaned - avg * avg);
  
*** lfs_cleanerd.1.3H/library.c	Sat Sep 12 04:07:49 1998
--- lfs_cleanerd/library.c	Sun Oct  4 14:08:53 1998
***************
*** 58,63 ****
--- 58,64 ----
  #include <stdlib.h>
  #include <string.h>
  #include <unistd.h>
+ #include <syslog.h>
  
  #include "clean.h"
  
***************
*** 72,77 ****
--- 73,79 ----
  int	 pseg_valid __P((FS_INFO *, SEGSUM *));
  void	 print_SEGSUM __P((struct lfs *, SEGSUM *));
  
+ extern int debug;
  extern u_long cksum __P((void *, size_t));	/* XXX */
  
  /*
***************
*** 125,132 ****
  	memset(fsp, 0, sizeof(FS_INFO));
  
  	fsp->fi_statfsp = lstatfsp;
! 	if (get_superblock (fsp, &fsp->fi_lfs))
! 		err(1, "get_fs_info: get_superblock failed");
  	fsp->fi_daddr_shift =
  	     fsp->fi_lfs.lfs_bshift - fsp->fi_lfs.lfs_fsbtodb;
  	get_ifile (fsp, use_mmap);
--- 127,136 ----
  	memset(fsp, 0, sizeof(FS_INFO));
  
  	fsp->fi_statfsp = lstatfsp;
! 	if (get_superblock (fsp, &fsp->fi_lfs)) {
! 		syslog(LOG_ERR, "Exiting: get_fs_info: get_superblock failed: %m");
!                 exit(1);
!         }
  	fsp->fi_daddr_shift =
  	     fsp->fi_lfs.lfs_bshift - fsp->fi_lfs.lfs_fsbtodb;
  	get_ifile (fsp, use_mmap);
***************
*** 144,151 ****
  	int use_mmap;
  {
  
! 	if (statfs(fsp->fi_statfsp->f_mntonname, fsp->fi_statfsp))
! 		err(1, "reread_fs_info: statfs failed");
  	get_ifile (fsp, use_mmap);
  }
  
--- 148,157 ----
  	int use_mmap;
  {
  
! 	if (statfs(fsp->fi_statfsp->f_mntonname, fsp->fi_statfsp)) {
! 		syslog(LOG_ERR, "Exiting: reread_fs_info: statfs failed: %m");
!                 exit(1);
!         }
  	get_ifile (fsp, use_mmap);
  }
  
***************
*** 165,171 ****
  	strcat(mntfromname, fsp->fi_statfsp->f_mntfromname+5);
  
  	if ((fid = open(mntfromname, O_RDONLY, (mode_t)0)) < 0) {
! 		err(0, "get_superblock: bad open");
  		return (-1);
  	}
  
--- 171,177 ----
  	strcat(mntfromname, fsp->fi_statfsp->f_mntfromname+5);
  
  	if ((fid = open(mntfromname, O_RDONLY, (mode_t)0)) < 0) {
!                 syslog(LOG_WARNING,"get_superblock: bad open: %m");
  		return (-1);
  	}
  
***************
*** 197,207 ****
  	strcat(strcat(strcpy(ifile_name, fsp->fi_statfsp->f_mntonname), "/"),
  	    IFILE_NAME);
  
! 	if ((fid = open(ifile_name, O_RDWR, (mode_t)0)) < 0)
! 		err(1, "get_ifile: bad open");
  
! 	if (fstat (fid, &file_stat))
! 		err(1, "get_ifile: fstat failed");
  
  	if (use_mmap && file_stat.st_size == fsp->fi_ifile_length) {
  		(void) close(fid);
--- 203,217 ----
  	strcat(strcat(strcpy(ifile_name, fsp->fi_statfsp->f_mntonname), "/"),
  	    IFILE_NAME);
  
! 	if ((fid = open(ifile_name, O_RDWR, (mode_t)0)) < 0) {
! 		syslog(LOG_ERR, "Exiting: get_ifile: bad open: %m");
!                 exit(1);
!         }
  
! 	if (fstat (fid, &file_stat)) {
! 		syslog(LOG_ERR, "Exiting: get_ifile: fstat failed: %m");
!                 exit(1);
!         }
  
  	if (use_mmap && file_stat.st_size == fsp->fi_ifile_length) {
  		(void) close(fid);
***************
*** 214,235 ****
  			munmap((caddr_t)fsp->fi_cip, fsp->fi_ifile_length);
  		ifp = mmap ((caddr_t)0, file_stat.st_size,
  		    PROT_READ|PROT_WRITE, MAP_FILE|MAP_PRIVATE, fid, (off_t)0);
! 		if (ifp ==  (caddr_t)(-1))
! 			err(1, "get_ifile: mmap failed");
  	} else {
  		if (fsp->fi_cip)
  			free(fsp->fi_cip);
! 		if (!(ifp = malloc (file_stat.st_size)))
! 			err (1, "get_ifile: malloc failed");
  redo_read:
  		count = read (fid, ifp, (size_t) file_stat.st_size);
  
! 		if (count < 0)
! 			err(1, "get_ifile: bad ifile read");
  		else if (count < file_stat.st_size) {
! 			err(0, "get_ifile");
! 			if (lseek(fid, 0, SEEK_SET) < 0)
! 				err(1, "get_ifile: bad ifile lseek");
  			goto redo_read;
  		}
  	}
--- 224,253 ----
  			munmap((caddr_t)fsp->fi_cip, fsp->fi_ifile_length);
  		ifp = mmap ((caddr_t)0, file_stat.st_size,
  		    PROT_READ|PROT_WRITE, MAP_FILE|MAP_PRIVATE, fid, (off_t)0);
! 		if (ifp ==  (caddr_t)(-1)) {
!                     syslog(LOG_ERR, "Exiting: get_ifile: mmap failed: %m");
!                     exit(1);
!                 }
  	} else {
  		if (fsp->fi_cip)
  			free(fsp->fi_cip);
! 		if (!(ifp = malloc (file_stat.st_size))) {
! 			syslog(LOG_ERR, "Exiting: get_ifile: malloc failed: %m");
!                         exit(1);
!                 }
  redo_read:
  		count = read (fid, ifp, (size_t) file_stat.st_size);
  
! 		if (count < 0) {
! 			syslog(LOG_ERR, "Exiting: get_ifile: bad ifile read: %m");
!                         exit(1);
!                 }
  		else if (count < file_stat.st_size) {
! 			syslog(LOG_WARNING, "get_ifile: %m");
! 			if (lseek(fid, 0, SEEK_SET) < 0) {
!                                 syslog(LOG_ERR, "Exiting: get_ifile: bad ifile lseek: %m");
!                                 exit(1);
!                         }
  			goto redo_read;
  		}
  	}
***************
*** 268,285 ****
  	BLOCK_INFO **blocks;	/* OUT: array of block_info for live blocks */
  	int *bcount;		/* OUT: number of active blocks in segment */
  {
! 	BLOCK_INFO *bip;
  	SEGSUM *sp;
  	SEGUSE *sup;
  	FINFO *fip;
  	struct lfs *lfsp;
  	caddr_t s;
  	daddr_t pseg_addr, seg_addr;
! 	int nelem, nblocks, nsegs, sumsize;
  	time_t timestamp;
- #if defined(DIAGNOSTIC)
- 	int i;
- #endif
  
  	i = 0;
  	lfsp = &fsp->fi_lfs;
--- 286,300 ----
  	BLOCK_INFO **blocks;	/* OUT: array of block_info for live blocks */
  	int *bcount;		/* OUT: number of active blocks in segment */
  {
! 	BLOCK_INFO *bip, *_bip;
  	SEGSUM *sp;
  	SEGUSE *sup;
  	FINFO *fip;
  	struct lfs *lfsp;
  	caddr_t s;
  	daddr_t pseg_addr, seg_addr;
! 	int nelem, nblocks, nsegs, sumsize, i;
  	time_t timestamp;
  
  	i = 0;
  	lfsp = &fsp->fi_lfs;
***************
*** 291,299 ****
  	s = seg_buf + (sup->su_flags & SEGUSE_SUPERBLOCK ? LFS_SBPAD : 0);
  	seg_addr = sntoda(lfsp, seg);
  	pseg_addr = seg_addr + (sup->su_flags & SEGUSE_SUPERBLOCK ? btodb(LFS_SBPAD) : 0);
! #ifdef VERBOSE
! 		printf("\tsegment buffer at: %p\tseg_addr 0x%x\n", s, seg_addr);
! #endif /* VERBOSE */
  
  	*bcount = 0;
  	for (nsegs = 0, timestamp = 0; nsegs < sup->su_nsums; nsegs++) {
--- 306,315 ----
  	s = seg_buf + (sup->su_flags & SEGUSE_SUPERBLOCK ? LFS_SBPAD : 0);
  	seg_addr = sntoda(lfsp, seg);
  	pseg_addr = seg_addr + (sup->su_flags & SEGUSE_SUPERBLOCK ? btodb(LFS_SBPAD) : 0);
! 
!         if(debug > 1)
!             syslog(LOG_DEBUG, "\tsegment buffer at: %p\tseg_addr 0x%x\n", s, seg_addr);
! 
  
  	*bcount = 0;
  	for (nsegs = 0, timestamp = 0; nsegs < sup->su_nsums; nsegs++) {
***************
*** 301,307 ****
  
  		nblocks = pseg_valid(fsp, sp);
  		if (nblocks <= 0) {
! 			printf("Warning: invalid segment summary at 0x%x\n",
  			    pseg_addr);
  			break;
  		}
--- 317,323 ----
  
  		nblocks = pseg_valid(fsp, sp);
  		if (nblocks <= 0) {
!                         syslog(LOG_DEBUG, "Warning: invalid segment summary at 0x%x\n",
  			    pseg_addr);
  			break;
  		}
***************
*** 321,327 ****
  			fip = (FINFO *)(&fip->fi_blocks[fip->fi_nblocks]);
  		}
  		if (sumsize > LFS_SUMMARY_SIZE) {
! 			fprintf(stderr,
  			    "Segment %d summary block too big: %d\n",
  			    seg, sumsize);
  			exit(1);
--- 337,343 ----
  			fip = (FINFO *)(&fip->fi_blocks[fip->fi_nblocks]);
  		}
  		if (sumsize > LFS_SUMMARY_SIZE) {
!                         syslog(LOG_ERR,
  			    "Exiting: segment %d summary block too big: %d\n",
  			    seg, sumsize);
  			exit(1);
***************
*** 342,357 ****
  	}
  	qsort(bip, *bcount, sizeof(BLOCK_INFO), bi_compare);
  	toss(bip, bcount, sizeof(BLOCK_INFO), bi_toss, NULL);
- #ifdef VERBOSE
- 	{
- 		BLOCK_INFO *_bip;
- 		int i;
  
! 		printf("BLOCK INFOS\n");
  		for (_bip = bip, i=0; i < *bcount; ++_bip, ++i)
  			PRINT_BINFO(_bip);
  	}
! #endif
  	*blocks = bip;
  	return (0);
  
--- 358,370 ----
  	}
  	qsort(bip, *bcount, sizeof(BLOCK_INFO), bi_compare);
  	toss(bip, bcount, sizeof(BLOCK_INFO), bi_toss, NULL);
  
!         if(debug > 1) {
!             syslog(LOG_DEBUG, "BLOCK INFOS\n");
              for (_bip = bip, i=0; i < *bcount; ++_bip, ++i)
                  PRINT_BINFO(_bip);
          }
! 
  	*blocks = bip;
  	return (0);
  
***************
*** 383,391 ****
  	int db_frag;
  	u_long page_size;
  
! #ifdef VERBOSE
! 	printf("FILE INFOS\n");
! #endif
  	db_per_block = fsbtodb(&fsp->fi_lfs, 1);
  	page_size = fsp->fi_lfs.lfs_bsize;
  	bp = seg_buf + datobyte(fsp, psegaddr - segaddr) + LFS_SUMMARY_SIZE;
--- 396,404 ----
  	int db_frag;
  	u_long page_size;
  
!         if(debug > 1)
!             syslog(LOG_DEBUG, "FILE INFOS\n");
! 
  	db_per_block = fsbtodb(&fsp->fi_lfs, 1);
  	page_size = fsp->fi_lfs.lfs_bsize;
  	bp = seg_buf + datobyte(fsp, psegaddr - segaddr) + LFS_SUMMARY_SIZE;
***************
*** 421,432 ****
  				db_frag = fragstodb(&(fsp->fi_lfs),
  				    numfrags(&(fsp->fi_lfs),
  				    fip->fi_lastlength));
! #ifdef VERBOSE
! 				printf("lastlength, frags: %d, %d, %d\n",
  				    fip->fi_lastlength, db_frag,
  				    bytetoda(fsp, db_frag));
! 				fflush(stdout);
! #endif
  				bip->bi_size = fip->fi_lastlength;
  				bp += fip->fi_lastlength;
  				psegaddr += db_frag;
--- 434,445 ----
  				db_frag = fragstodb(&(fsp->fi_lfs),
  				    numfrags(&(fsp->fi_lfs),
  				    fip->fi_lastlength));
! 
!                                 if(debug > 1)
!                                     syslog(LOG_DEBUG, "lastlength, frags: %d, %d, %d\n",
                                             fip->fi_lastlength, db_frag,
                                             bytetoda(fsp, db_frag));
! 
  				bip->bi_size = fip->fi_lastlength;
  				bp += fip->fi_lastlength;
  				psegaddr += db_frag;
***************
*** 464,472 ****
  
  	bp = bip + *countp;
  	lfsp = &fsp->fi_lfs;
! #ifdef VERBOSE
! 	(void) printf("INODES:\n");
! #endif
  	daddrp = (daddr_t *)((caddr_t)sp + LFS_SUMMARY_SIZE);
  	for (i = 0; i < sp->ss_ninos; ++i) {
  		if (i % INOPB(lfsp) == 0) {
--- 477,486 ----
  
  	bp = bip + *countp;
  	lfsp = &fsp->fi_lfs;
! 
!         if(debug > 1)
!             syslog(LOG_DEBUG, "INODES:\n");
! 
  	daddrp = (daddr_t *)((caddr_t)sp + LFS_SUMMARY_SIZE);
  	for (i = 0; i < sp->ss_ninos; ++i) {
  		if (i % INOPB(lfsp) == 0) {
***************
*** 565,571 ****
  	strcat(mntfromname, fsp->fi_statfsp->f_mntfromname+5);
  
  	if ((fid = open(mntfromname, O_RDONLY, (mode_t)0)) < 0) {
! 		err(0, "mmap_segment: bad open");
  		return (-1);
  	}
  
--- 579,585 ----
  	strcat(mntfromname, fsp->fi_statfsp->f_mntfromname+5);
  
  	if ((fid = open(mntfromname, O_RDONLY, (mode_t)0)) < 0) {
!                 syslog(LOG_WARNING,"mmap_segment: bad open: %m");
  		return (-1);
  	}
  
***************
*** 573,602 ****
  		*segbuf = mmap ((caddr_t)0, seg_size(lfsp), PROT_READ,
  		    MAP_FILE|MAP_SHARED, fid, seg_byte);
  		if (*(long *)segbuf < 0) {
! 			err(0, "mmap_segment: mmap failed");
  			return (0);
  		}
  	} else {
! #ifdef VERBOSE
! 		printf("mmap_segment\tseg_daddr: %lu\tseg_size: %lu\tseg_offset: %qu\n",
  		    (u_long)seg_daddr, (u_long)ssize, seg_byte);
! #endif
  		/* malloc the space for the buffer */
  		*segbuf = malloc(ssize);
  		if (!*segbuf) {
! 			err(0, "mmap_segment: malloc failed");
  			return (0);
  		}
  
  		/* read the segment data into the buffer */
  		if (lseek (fid, seg_byte, SEEK_SET) != seg_byte) {
! 			err (0, "mmap_segment: bad lseek");
  			free(*segbuf);
  			return (-1);
  		}
  
  		if (read (fid, *segbuf, ssize) != ssize) {
! 			err (0, "mmap_segment: bad read");
  			free(*segbuf);
  			return (-1);
  		}
--- 587,616 ----
  		*segbuf = mmap ((caddr_t)0, seg_size(lfsp), PROT_READ,
  		    MAP_FILE|MAP_SHARED, fid, seg_byte);
  		if (*(long *)segbuf < 0) {
!                         syslog(LOG_WARNING,"mmap_segment: mmap failed: %m");
  			return (0);
  		}
  	} else {
!                 if(debug > 1)
!                         syslog(LOG_DEBUG, "mmap_segment\tseg_daddr: %lu\tseg_size: %lu\tseg_offset: %qu\n",
                                 (u_long)seg_daddr, (u_long)ssize, seg_byte);
!             
  		/* malloc the space for the buffer */
  		*segbuf = malloc(ssize);
  		if (!*segbuf) {
! 			syslog(LOG_WARNING,"mmap_segment: malloc failed: %m");
  			return (0);
  		}
  
  		/* read the segment data into the buffer */
  		if (lseek (fid, seg_byte, SEEK_SET) != seg_byte) {
! 			syslog(LOG_WARNING,"mmap_segment: bad lseek: %m");
  			free(*segbuf);
  			return (-1);
  		}
  
  		if (read (fid, *segbuf, ssize) != ssize) {
! 			syslog(LOG_WARNING,"mmap_segment: bad read: %m");
  			free(*segbuf);
  			return (-1);
  		}
***************
*** 628,635 ****
  {
  	if (p)
  		(void) dump_summary(lfsp, p, DUMP_ALL, NULL);
! 	else printf("0x0");
! 	fflush(stdout);
  }
  
  int
--- 642,649 ----
  {
  	if (p)
  		(void) dump_summary(lfsp, p, DUMP_ALL, NULL);
! 	else
!                 syslog(LOG_DEBUG, "0x0");
  }
  
  int
*** lfs_cleanerd.1.3H/misc.c	Wed Oct  8 04:19:44 1997
--- lfs_cleanerd/misc.c	Sun Oct  4 14:09:26 1998
***************
*** 53,58 ****
--- 53,59 ----
  #include <stdlib.h>
  #include <string.h>
  #include <unistd.h>
+ #include <syslog.h>
  
  #include "clean.h"
  
***************
*** 67,76 ****
  {
  	int rbytes;
  
! 	if (lseek(fd, off, SEEK_SET) < 0)
! 		err(1, "%s: %s", special, strerror(errno));
! 	if ((rbytes = read(fd, p, len)) < 0)
! 		err(1, "%s: %s", special, strerror(errno));
! 	if (rbytes != len)
! 		err(1, "%s: short read (%d, not %d)", special, rbytes, len);
  }
--- 68,83 ----
  {
  	int rbytes;
  
! 	if (lseek(fd, off, SEEK_SET) < 0) {
!             syslog(LOG_ERR, "Exiting: %s: lseek: %m", special);
!             exit(1);
!         }
! 	if ((rbytes = read(fd, p, len)) < 0) {
!             syslog(LOG_ERR, "Exiting: %s: read: %m", special);
!             exit(1);
!         }
! 	if (rbytes != len) {
!             syslog(LOG_ERR, "Exiting: %s: short read (%d, not %d)", special, rbytes, len);
!             exit(1);
!         }
  }
*** lfs_cleanerd.1.3H/print.c	Sat Sep 12 04:07:49 1998
--- lfs_cleanerd/print.c	Sun Oct  4 14:09:55 1998
***************
*** 53,60 ****
--- 53,63 ----
  #include <stdlib.h>
  #include <stdio.h>
  #include <time.h>
+ #include <syslog.h>
+ 
  #include "clean.h"
  
+ extern int debug;
  extern u_long cksum __P((void *, size_t));	/* XXX */
  
  /*
***************
*** 80,127 ****
  		return(-1);
  
  	if (flags & DUMP_SUM_HEADER) {
! 		(void)printf("    %s0x%X\t%s%d\t%s%d\n    %s0x%X\t%s0x%X",
  			"next     ", sp->ss_next,
  			"nfinfo   ", sp->ss_nfinfo,
  			"ninos    ", sp->ss_ninos,
  			"sumsum   ", sp->ss_sumsum,
  			"datasum  ", sp->ss_datasum );
! 		(void)printf("\tcreate   %s", ctime((time_t *)&sp->ss_create));
  	}
  
  	numblocks = (sp->ss_ninos + INOPB(lfsp) - 1) / INOPB(lfsp);
  
  	/* Dump out inode disk addresses */
  	if (flags & DUMP_INODE_ADDRS)
! 		printf("    Inode addresses:");
  
  	dp = (daddr_t *)((caddr_t)sp + LFS_SUMMARY_SIZE);
  	for (--dp, i = 0; i < sp->ss_ninos; --dp)
  		if (flags & DUMP_INODE_ADDRS) {
! 			(void)printf("\t0x%lx", (u_long)*dp);
! 			if (++i % 7 == 0)
! 				(void)printf("\n");
  		} else
  			++i;
  	if (iaddrp)
  		*iaddrp = ++dp;
- 	if (flags & DUMP_INODE_ADDRS)
- 		printf("\n");
  
  	for (fp = (FINFO *)(sp + 1), i = 0; i < sp->ss_nfinfo; ++i) {
  		numblocks += fp->fi_nblocks;
  		if (flags & DUMP_FINFOS) {
! 			(void)printf("    %s%d version %d nblocks %d\n",
  			    "FINFO for inode: ", fp->fi_ino,
  			    fp->fi_version, fp->fi_nblocks);
  			dp = &(fp->fi_blocks[0]);
  			for (j = 0; j < fp->fi_nblocks; j++, dp++) {
! 				(void)printf("\t%d", *dp);
! 				if ((j % 8) == 7)
! 					(void)printf("\n");
  			}
- 			if ((j % 8) != 0)
- 				(void)printf("\n");
  			fp = (FINFO *)dp;
  		} else {
  			fp = (FINFO *)(&fp->fi_blocks[fp->fi_nblocks]);
--- 83,122 ----
  		return(-1);
  
  	if (flags & DUMP_SUM_HEADER) {
!                 syslog(LOG_DEBUG, "    %s0x%X\t%s%d\t%s%d\n    %s0x%X\t%s0x%X",
  			"next     ", sp->ss_next,
  			"nfinfo   ", sp->ss_nfinfo,
  			"ninos    ", sp->ss_ninos,
  			"sumsum   ", sp->ss_sumsum,
  			"datasum  ", sp->ss_datasum );
! 		syslog(LOG_DEBUG, "\tcreate   %s", ctime((time_t *)&sp->ss_create));
  	}
  
  	numblocks = (sp->ss_ninos + INOPB(lfsp) - 1) / INOPB(lfsp);
  
  	/* Dump out inode disk addresses */
  	if (flags & DUMP_INODE_ADDRS)
!                 syslog(LOG_DEBUG, "    Inode addresses:");
  
  	dp = (daddr_t *)((caddr_t)sp + LFS_SUMMARY_SIZE);
  	for (--dp, i = 0; i < sp->ss_ninos; --dp)
  		if (flags & DUMP_INODE_ADDRS) {
!                         syslog(LOG_DEBUG, "\t0x%lx", (u_long)*dp);
  		} else
  			++i;
  	if (iaddrp)
  		*iaddrp = ++dp;
  
  	for (fp = (FINFO *)(sp + 1), i = 0; i < sp->ss_nfinfo; ++i) {
  		numblocks += fp->fi_nblocks;
  		if (flags & DUMP_FINFOS) {
! 			syslog(LOG_DEBUG, "    %s%d version %d nblocks %d\n",
  			    "FINFO for inode: ", fp->fi_ino,
  			    fp->fi_version, fp->fi_nblocks);
  			dp = &(fp->fi_blocks[0]);
  			for (j = 0; j < fp->fi_nblocks; j++, dp++) {
!                             syslog(LOG_DEBUG, "\t%d", *dp);
  			}
  			fp = (FINFO *)dp;
  		} else {
  			fp = (FINFO *)(&fp->fi_blocks[fp->fi_nblocks]);
***************
*** 130,144 ****
  	return (numblocks);
  }
  
- #ifdef VERBOSE
  void
  dump_cleaner_info(ipage)
  	void *ipage;
  {
  	CLEANERINFO *cip;
  
  	cip = (CLEANERINFO *)ipage;
! 	(void)printf("segments clean\t%d\tsegments dirty\t%d\n\n",
  	    cip->clean, cip->dirty);
  }
  
--- 125,141 ----
  	return (numblocks);
  }
  
  void
  dump_cleaner_info(ipage)
  	void *ipage;
  {
  	CLEANERINFO *cip;
  
+         if(debug <= 1)
+             return;
+ 
  	cip = (CLEANERINFO *)ipage;
! 	syslog(LOG_DEBUG,"segments clean\t%d\tsegments dirty\t%d\n\n",
  	    cip->clean, cip->dirty);
  }
  
***************
*** 148,228 ****
  {
  	int i;
  
! 	(void)printf("%s0x%X\t%s0x%X\t%s%d\t%s%d\n",
  		"magic    ", lfsp->lfs_magic,
  		"version  ", lfsp->lfs_version,
  		"size     ", lfsp->lfs_size,
  		"ssize    ", lfsp->lfs_ssize);
! 	(void)printf("%s%d\t\t%s%d\t%s%d\t%s%d\n",
  		"dsize    ", lfsp->lfs_dsize,
  		"bsize    ", lfsp->lfs_bsize,
  		"fsize    ", lfsp->lfs_fsize,
  		"frag     ", lfsp->lfs_frag);
  
! 	(void)printf("%s%d\t\t%s%d\t%s%d\t%s%d\n",
  		"minfree  ", lfsp->lfs_minfree,
  		"inopb    ", lfsp->lfs_inopb,
  		"ifpb     ", lfsp->lfs_ifpb,
  		"nindir   ", lfsp->lfs_nindir);
  
! 	(void)printf("%s%d\t\t%s%d\t%s%d\t%s%d\n",
  		"nseg     ", lfsp->lfs_nseg,
  		"nspf     ", lfsp->lfs_nspf,
  		"cleansz  ", lfsp->lfs_cleansz,
  		"segtabsz ", lfsp->lfs_segtabsz);
  
! 	(void)printf("%s0x%X\t%s%d\t%s0x%qX\t%s%lu\n",
  		"segmask  ", lfsp->lfs_segmask,
  		"segshift ", lfsp->lfs_segshift,
  		"bmask    ", (u_quad_t)lfsp->lfs_bmask,
  		"bshift   ", (u_long)lfsp->lfs_bshift);
  
! 	(void)printf("%s0x%qX\t\t%s%lu\t%s0x%qX\t%s%lu\n",
  		"ffmask   ", (u_quad_t)lfsp->lfs_ffmask,
  		"ffshift  ", (u_long)lfsp->lfs_ffshift,
  		"fbmask   ", (u_quad_t)lfsp->lfs_fbmask,
  		"fbshift  ", (u_long)lfsp->lfs_fbshift);
  
! 	(void)printf("%s%d\t\t%s0x%X\t%s0x%qx\n",
  		"fsbtodb  ", lfsp->lfs_fsbtodb,
  		"cksum    ", lfsp->lfs_cksum,
  		"maxfilesize  ", lfsp->lfs_maxfilesize);
  
! 	(void)printf("Superblock disk addresses:\t");
  	for (i = 0; i < LFS_MAXNUMSB; i++) {
! 		(void)printf(" 0x%X", lfsp->lfs_sboffs[i]);
! 		if ( i == (LFS_MAXNUMSB >> 1))
! 			(void)printf("\n\t\t\t\t");
  	}
- 	(void)printf("\n");
  
! 	(void)printf("Checkpoint Info\n");
! 	(void)printf("%s%d\t%s0x%X\t%s%d\n",
  		"free     ", lfsp->lfs_free,
  		"idaddr   ", lfsp->lfs_idaddr,
  		"ifile    ", lfsp->lfs_ifile);
! 	(void)printf("%s%d\t%s%d\t%s%d\n",
  		"bfree    ", lfsp->lfs_bfree,
  		"avail    ", lfsp->lfs_avail,
  		"uinodes  ", lfsp->lfs_uinodes);
! 	(void)printf("%s%d\t%s0x%X\t%s0x%X\n%s0x%X\t%s0x%X\t",
  		"nfiles   ", lfsp->lfs_nfiles,
  		"lastseg  ", lfsp->lfs_lastseg,
  		"nextseg  ", lfsp->lfs_nextseg,
  		"curseg   ", lfsp->lfs_curseg,
  		"offset   ", lfsp->lfs_offset);
! 	(void)printf("tstamp   %s", ctime((time_t *)&lfsp->lfs_tstamp));
! 	(void)printf("\nIn-Memory Information\n");
! 	(void)printf("%s%d\t%s0x%X\t%s%d\t%s%d\t%s%d\n",
  		"seglock  ", lfsp->lfs_seglock,
  		"iocount  ", lfsp->lfs_iocount,
  		"writer   ", lfsp->lfs_writer,
  		"dirops   ", lfsp->lfs_dirops,
  		"doifile  ", lfsp->lfs_doifile );
! 	(void)printf("%s%d\t%s%d\t%s0x%X\t%s%d\n",
  		"nactive  ", lfsp->lfs_nactive,
  		"fmod     ", lfsp->lfs_fmod,
  		"clean    ", lfsp->lfs_clean,
  		"ronly    ", lfsp->lfs_ronly);
  }
- #endif /* VERBOSE */
--- 145,221 ----
  {
  	int i;
  
! 	syslog(LOG_DEBUG,"%s0x%X\t%s0x%X\t%s%d\t%s%d\n",
  		"magic    ", lfsp->lfs_magic,
  		"version  ", lfsp->lfs_version,
  		"size     ", lfsp->lfs_size,
  		"ssize    ", lfsp->lfs_ssize);
! 	syslog(LOG_DEBUG, "%s%d\t\t%s%d\t%s%d\t%s%d\n",
  		"dsize    ", lfsp->lfs_dsize,
  		"bsize    ", lfsp->lfs_bsize,
  		"fsize    ", lfsp->lfs_fsize,
  		"frag     ", lfsp->lfs_frag);
  
! 	syslog(LOG_DEBUG, "%s%d\t\t%s%d\t%s%d\t%s%d\n",
  		"minfree  ", lfsp->lfs_minfree,
  		"inopb    ", lfsp->lfs_inopb,
  		"ifpb     ", lfsp->lfs_ifpb,
  		"nindir   ", lfsp->lfs_nindir);
  
! 	syslog(LOG_DEBUG, "%s%d\t\t%s%d\t%s%d\t%s%d\n",
  		"nseg     ", lfsp->lfs_nseg,
  		"nspf     ", lfsp->lfs_nspf,
  		"cleansz  ", lfsp->lfs_cleansz,
  		"segtabsz ", lfsp->lfs_segtabsz);
  
! 	syslog(LOG_DEBUG, "%s0x%X\t%s%d\t%s0x%qX\t%s%lu\n",
  		"segmask  ", lfsp->lfs_segmask,
  		"segshift ", lfsp->lfs_segshift,
  		"bmask    ", (u_quad_t)lfsp->lfs_bmask,
  		"bshift   ", (u_long)lfsp->lfs_bshift);
  
! 	syslog(LOG_DEBUG, "%s0x%qX\t\t%s%lu\t%s0x%qX\t%s%lu\n",
  		"ffmask   ", (u_quad_t)lfsp->lfs_ffmask,
  		"ffshift  ", (u_long)lfsp->lfs_ffshift,
  		"fbmask   ", (u_quad_t)lfsp->lfs_fbmask,
  		"fbshift  ", (u_long)lfsp->lfs_fbshift);
  
! 	syslog(LOG_DEBUG, "%s%d\t\t%s0x%X\t%s0x%qx\n",
  		"fsbtodb  ", lfsp->lfs_fsbtodb,
  		"cksum    ", lfsp->lfs_cksum,
  		"maxfilesize  ", lfsp->lfs_maxfilesize);
  
! 	syslog(LOG_DEBUG, "Superblock disk addresses:\t");
  	for (i = 0; i < LFS_MAXNUMSB; i++) {
! 		syslog(LOG_DEBUG, " 0x%X", lfsp->lfs_sboffs[i]);
  	}
  
! 	syslog(LOG_DEBUG, "Checkpoint Info\n");
! 	syslog(LOG_DEBUG, "%s%d\t%s0x%X\t%s%d\n",
  		"free     ", lfsp->lfs_free,
  		"idaddr   ", lfsp->lfs_idaddr,
  		"ifile    ", lfsp->lfs_ifile);
! 	syslog(LOG_DEBUG, "%s%d\t%s%d\t%s%d\n",
  		"bfree    ", lfsp->lfs_bfree,
  		"avail    ", lfsp->lfs_avail,
  		"uinodes  ", lfsp->lfs_uinodes);
! 	syslog(LOG_DEBUG, "%s%d\t%s0x%X\t%s0x%X\n%s0x%X\t%s0x%X\t",
  		"nfiles   ", lfsp->lfs_nfiles,
  		"lastseg  ", lfsp->lfs_lastseg,
  		"nextseg  ", lfsp->lfs_nextseg,
  		"curseg   ", lfsp->lfs_curseg,
  		"offset   ", lfsp->lfs_offset);
! 	syslog(LOG_DEBUG, "tstamp   %s", ctime((time_t *)&lfsp->lfs_tstamp));
! 	syslog(LOG_DEBUG, "\nIn-Memory Information\n");
! 	syslog(LOG_DEBUG, "%s%d\t%s0x%X\t%s%d\t%s%d\t%s%d\n",
  		"seglock  ", lfsp->lfs_seglock,
  		"iocount  ", lfsp->lfs_iocount,
  		"writer   ", lfsp->lfs_writer,
  		"dirops   ", lfsp->lfs_dirops,
  		"doifile  ", lfsp->lfs_doifile );
! 	syslog(LOG_DEBUG, "%s%d\t%s%d\t%s0x%X\t%s%d\n",
  		"nactive  ", lfsp->lfs_nactive,
  		"fmod     ", lfsp->lfs_fmod,
  		"clean    ", lfsp->lfs_clean,
  		"ronly    ", lfsp->lfs_ronly);
  }
*** lfs_cleanerd.1.3H/clean.h	Sat Sep 12 04:07:49 1998
--- lfs_cleanerd/clean.h	Sun Oct  4 14:44:05 1998
***************
*** 121,170 ****
  /*
   * USEFUL DEBUGGING FUNCTIONS:
   */
! #ifdef VERBOSE
! #define PRINT_FINFO(fp, ip) { \
! 	(void)printf("    %s %s%d version %d nblocks %d\n", \
  	    (ip)->if_version > (fp)->fi_version ? "TOSSING" : "KEEPING", \
  	    "FINFO for inode: ", (fp)->fi_ino, \
  	    (fp)->fi_version, (fp)->fi_nblocks); \
- 	fflush(stdout); \
  }
  
! #define PRINT_INODE(b, bip) { \
! 	(void) printf("\t%s inode: %d daddr: 0x%lx create: %s\n", \
  	    b ? "KEEPING" : "TOSSING", (bip)->bi_inode, (long)(bip)->bi_daddr, \
  	    ctime((time_t *)&(bip)->bi_segcreate)); \
- 	fflush(stdout); \
  }
  
! #define PRINT_BINFO(bip) { \
! 	(void)printf("\tinode: %d lbn: %d daddr: 0x%lx create: %s\n", \
  	    (bip)->bi_inode, (bip)->bi_lbn, (unsigned long)(bip)->bi_daddr, \
  	    ctime((time_t *)&(bip)->bi_segcreate)); \
- 	fflush(stdout); \
  }
  
! #define PRINT_SEGUSE(sup, n) { \
! 	(void)printf("Segment %d nbytes=%lu\tflags=%c%c%c ninos=%d nsums=%d lastmod: %s\n", \
  			n, (unsigned long)(sup)->su_nbytes, \
  			(sup)->su_flags & SEGUSE_DIRTY ? 'D' : 'C', \
  			(sup)->su_flags & SEGUSE_ACTIVE ? 'A' : ' ', \
  			(sup)->su_flags & SEGUSE_SUPERBLOCK ? 'S' : ' ', \
  			(sup)->su_ninos, (sup)->su_nsums, \
  			ctime((time_t *)&(sup)->su_lastmod)); \
- 	fflush(stdout); \
  }
  
  void	 dump_super __P((struct lfs *));
  void	 dump_cleaner_info __P((void *));
  void	 print_SEGSUM __P(( struct lfs *, SEGSUM *));
  void	 print_CLEANERINFO __P((CLEANERINFO *));
- #else
- #define	PRINT_FINFO(fp, ip)
- #define	PRINT_INODE(b, bip)
- #define PRINT_BINFO(bip)
- #define	PRINT_SEGUSE(sup, n)
- #define	dump_cleaner_info(cip)
- #define	dump_super(lfsp)
- #endif
  __END_DECLS
--- 122,158 ----
  /*
   * USEFUL DEBUGGING FUNCTIONS:
   */
! #define PRINT_FINFO(fp, ip) if(debug > 1) { \
! 	syslog(LOG_DEBUG,"    %s %s%d version %d nblocks %d\n", \
  	    (ip)->if_version > (fp)->fi_version ? "TOSSING" : "KEEPING", \
  	    "FINFO for inode: ", (fp)->fi_ino, \
  	    (fp)->fi_version, (fp)->fi_nblocks); \
  }
  
! #define PRINT_INODE(b, bip) if(debug > 1) { \
! 	syslog(LOG_DEBUG,"\t%s inode: %d daddr: 0x%lx create: %s\n", \
  	    b ? "KEEPING" : "TOSSING", (bip)->bi_inode, (long)(bip)->bi_daddr, \
  	    ctime((time_t *)&(bip)->bi_segcreate)); \
  }
  
! #define PRINT_BINFO(bip) if(debug > 1 ) { \
! 	syslog(LOG_DEBUG,"\tinode: %d lbn: %d daddr: 0x%lx create: %s\n", \
  	    (bip)->bi_inode, (bip)->bi_lbn, (unsigned long)(bip)->bi_daddr, \
  	    ctime((time_t *)&(bip)->bi_segcreate)); \
  }
  
! #define PRINT_SEGUSE(sup, n) if(debug > 1) { \
! 	syslog(LOG_DEBUG,"Segment %d nbytes=%lu\tflags=%c%c%c ninos=%d nsums=%d lastmod: %s\n", \
  			n, (unsigned long)(sup)->su_nbytes, \
  			(sup)->su_flags & SEGUSE_DIRTY ? 'D' : 'C', \
  			(sup)->su_flags & SEGUSE_ACTIVE ? 'A' : ' ', \
  			(sup)->su_flags & SEGUSE_SUPERBLOCK ? 'S' : ' ', \
  			(sup)->su_ninos, (sup)->su_nsums, \
  			ctime((time_t *)&(sup)->su_lastmod)); \
  }
  
  void	 dump_super __P((struct lfs *));
  void	 dump_cleaner_info __P((void *));
  void	 print_SEGSUM __P(( struct lfs *, SEGSUM *));
  void	 print_CLEANERINFO __P((CLEANERINFO *));
  __END_DECLS

>Audit-Trail:
>Unformatted: