[comp.sources.bugs] Fsanalyze v4.1 PATCH #1

mjy@sdti.SDTI.COM (Michael J. Young) (12/16/88)

This is an official patch to fsanalyze v4.1.

Description:
   1.	On System V without fsstat(1M), Fsanalyze version 4.1 always
	reports that the file system needs checking, and aborts.  The
	override flag "-o" has no effect.  This problem does not show
	up if the HAVE_FSSTAT macro is defined in the Makefile.

	There are actually three problems here.  One is a missing test of
	"override" in chk_fs() when fsstat(1M) isn't used.  Another problem
	is a bug in the definition of the is_ok() macro in fsconfig.h, in
	which the definition is not surrounded by parentheses.  The third
	problem is that some systems don't support the s_state member at all.
	This patch fixes all of these problems.

	However, there is a much more basic problem with the is_ok() macro.
	System V doesn't seem to update the superblock state (s_state) as
	documented when the file system is dismounted.  The state is never
	set to FsOKAY, as documented, but to some other value (0x588fxxxx,
	where xxxx is different each time the file system is dismounted).  I
	still haven't figured out exactly what is being done here, although
	I'm sure it's related to the time of the dismount.  Perhaps someone
	who understands what's happening here could enlighten me.

   2.	Systems without fifos belch on the IS_SPECIAL macro in fsanalyze.h

   3.	Some of the definitions in fsconfig.h depend on <sys/param.h> and
	<sys/filsys.h>.  These and related header files have been moved
	from fsanalyze.h into fsconfig.h.

   4.	When errors occur early, print_report() results in divide-by-zero
	errors.

   5.	Some early BSD-derived filesystem superblocks don't have the fs_optim
	member.  This caused compile-time errors in print_report().

   6.	Some compilers don't like to negate a messy macro in if statements.
	Changing "!IS_SPECIAL(...)" to "IS_SPECIAL(...) == 0" seems to make
	the problem disappear (I hope).

Fix:
	Apply the following patch.
----------------------------------
Index: fsanalyze.8
Prereq: 4.1
*** ../oldtest/fsanalyze.8	Thu Dec 15 15:50:14 1988
--- fsanalyze.8	Thu Dec 15 15:51:05 1988
***************
*** 169,175
  .br
  fsanalyze /dev/dsk/0s2 *  # analyze files in current dir
  .SH FILES
! /usr/include/sys/filesys.h	super block structure
  .br
  /usr/include/sys/ino.h		disk inode structure
  .br

--- 169,175 -----
  .br
  fsanalyze /dev/dsk/0s2 *  # analyze files in current dir
  .SH FILES
! /usr/include/sys/filsys.h	super block structure
  .br
  /usr/include/sys/ino.h		disk inode structure
  .br
***************
*** 187,190
  .br
  Internet : mjy@sdti.SDTI.COM
  .SH VERSION
! 4.1 \- 88/11/16 17:29:54

--- 187,190 -----
  .br
  Internet : mjy@sdti.SDTI.COM
  .SH VERSION
! 4.1.1.1 \- 88/12/14 11:07:34

Index: fsanalyze.c
Prereq: 4.1
*** ../oldtest/fsanalyze.c	Thu Dec 15 15:50:14 1988
--- fsanalyze.c	Thu Dec 15 15:51:06 1988
***************
*** 1,4
! static char sccsid[] = "@(#)$Id: fsanalyze.c, V4.1 88/11/16 17:30:08 $";
  
  /*
   * fsanalyze.c - file system analyzer

--- 1,4 -----
! static char sccsid[] = "@(#)$Id: fsanalyze.c, V4.1.1.1 88/12/14 11:01:28 $";
  
  /*
   * fsanalyze.c - file system analyzer
***************
*** 2,8
  
  /*
   * fsanalyze.c - file system analyzer
!  * Version  : 4.1 - 88/11/16 17:30:08
   *
   * Author   : Michael J. Young
   * USmail   : Software Development Technologies, Inc.

--- 2,8 -----
  
  /*
   * fsanalyze.c - file system analyzer
!  * Version  : 4.1.1.1 - 88/12/14 11:01:28
   *
   * Author   : Michael J. Young
   * USmail   : Software Development Technologies, Inc.
***************
*** 71,76
   *
   * Wed Nov 16 11:31:32 EST 1988 - M. Young (mjy@sdti.SDTI.COM),
   *    Placed under SCCS
   */
  
  /*

--- 71,80 -----
   *
   * Wed Nov 16 11:31:32 EST 1988 - M. Young (mjy@sdti.SDTI.COM),
   *    Placed under SCCS
+  *
+  * Tue Dec 13 13:19:48 EST 1988 - M. Young (mjy@sdti.SDTI.COM),
+  *    Changed use of IS_SPECIAL macro to avoid bug in some USG
+  *    compilers.
   */
  
  /*
***************
*** 168,174
                   * (for BSD systems with symbolic links)
                   */
                  if ((f_stat.st_dev == fs_device) &&
!                     !IS_SPECIAL (f_stat.st_mode)){
                      anal_file (f_stat.st_ino, argv[next_param]);
                      }
                  }

--- 172,178 -----
                   * (for BSD systems with symbolic links)
                   */
                  if ((f_stat.st_dev == fs_device) &&
!                     IS_SPECIAL (f_stat.st_mode) == 0){
                      anal_file (f_stat.st_ino, argv[next_param]);
                      }
                  }

Index: fsanalyze.h
Prereq: 4.1
*** ../oldtest/fsanalyze.h	Thu Dec 15 15:50:14 1988
--- fsanalyze.h	Thu Dec 15 15:51:06 1988
***************
*** 1,4
! /* @(#)$Id: fsanalyze.h, V4.1 88/11/16 17:30:22 $ */
  
  /*
   * fsanalyze.h - file system analyzer header file

--- 1,4 -----
! /* @(#)$Id: fsanalyze.h, V4.1.1.2 88/12/15 15:47:33 $ */
  
  /*
   * fsanalyze.h - file system analyzer header file
***************
*** 2,8
  
  /*
   * fsanalyze.h - file system analyzer header file
!  * Version  : 4.1 - 88/11/16 17:30:22
   *
   * Author   : Michael J. Young
   * USmail   : Software Development Technologies, Inc.

--- 2,8 -----
  
  /*
   * fsanalyze.h - file system analyzer header file
!  * Version  : 4.1.1.2 - 88/12/15 15:47:33
   *
   * Author   : Michael J. Young
   * USmail   : Software Development Technologies, Inc.
***************
*** 41,46
   *
   * Wed Nov 16 11:31:32 EST 1988 - M. Young (mjy@sdti.SDTI.COM),
   *    Placed under SCCS
   */
  
  #include <sys/param.h>

--- 41,53 -----
   *
   * Wed Nov 16 11:31:32 EST 1988 - M. Young (mjy@sdti.SDTI.COM),
   *    Placed under SCCS
+  *
+  * Tue Dec 13 11:49:56 EST 1988 - M. Young (mjy@sdti.SDTI.COM),
+  *    <sys/fs.h> and friends now included by fsconfig.h.  Also added
+  *    "fs_type_flag" declaration
+  *
+  * Thu Dec 15 15:23:45 EST 1988 - M. Young (mjy@sdti.SDTI.COM),
+  *    Fixed IS_SPECIAL to handle systems without fifos
   */
  
  #include <sys/stat.h>
***************
*** 43,68
   *    Placed under SCCS
   */
  
- #include <sys/param.h>
- 
- #if (FS_TYPE == FS_ATT)
- # include <sys/types.h>
- # include <sys/filsys.h>
- # include <sys/ino.h>
- #endif
- 
- #if (FS_TYPE == FS_BSD)
- # include <sys/fs.h>
- # include <sys/inode.h>
- #endif
- 
- #if (FS_TYPE == FS_BSD_NFS)
- # include <sys/time.h>
- # include <ufs/fs.h>
- # include <sys/vnode.h>
- # include <ufs/inode.h>
- #endif
- 
  #include <sys/stat.h>
  #include <varargs.h>
  #include <stdio.h>

--- 50,55 -----
   *    Fixed IS_SPECIAL to handle systems without fifos
   */
  
  #include <sys/stat.h>
  #include <varargs.h>
  #include <stdio.h>
***************
*** 67,81
  #include <varargs.h>
  #include <stdio.h>
  
- /*
-  * ROOTINO doesn't seem to be defined in System V Release 3, so define
-  * it here if necessary.
-  */
- 
- #ifndef	ROOTINO
- # define ROOTINO	2
- #endif
- 
  /***************************************************************************
   *                            Basic Definitions                            *
   ***************************************************************************/

--- 54,59 -----
  #include <varargs.h>
  #include <stdio.h>
  
  /***************************************************************************
   *                            Basic Definitions                            *
   ***************************************************************************/
***************
*** 122,127
  # define IS_SOK(a) FALSE
  #endif /* BSD sockets */
  
  #define IS_SPECIAL(a) \
          ((((a) & S_IFMT) == S_IFBLK) || \
          (((a) & S_IFMT) == S_IFCHR) || \

--- 100,111 -----
  # define IS_SOK(a) FALSE
  #endif /* BSD sockets */
  
+ #ifdef	S_IFIFO
+ # define IS_FIFO(a) (((a) & S_IFMT) == S_IFIFO)
+ #else
+ # define IS_FIFO(a) FALSE
+ #endif
+ 
  #define IS_SPECIAL(a) \
          ((((a) & S_IFMT) == S_IFBLK) || \
          (((a) & S_IFMT) == S_IFCHR) || \
***************
*** 125,132
  #define IS_SPECIAL(a) \
          ((((a) & S_IFMT) == S_IFBLK) || \
          (((a) & S_IFMT) == S_IFCHR) || \
!         (((a) & S_IFMT) == S_IFIFO) || \
!         IS_NAM(a) || IS_LNK(a) || IS_SOK(a))
  
  /*
   * per-file statistics structure

--- 109,115 -----
  #define IS_SPECIAL(a) \
          ((((a) & S_IFMT) == S_IFBLK) || \
          (((a) & S_IFMT) == S_IFCHR) || \
!         IS_FIFO(a) || IS_NAM(a) || IS_LNK(a) || IS_SOK(a))
  
  /*
   * per-file statistics structure
***************
*** 168,173
  extern int block_size;                  /* bytes per logical block */
  extern int cyl_size;                    /* physical sectors per cylinder */
  extern dev_t fs_device;                 /* device ID of file system */
  
  /*
   * calculated global statistics

--- 151,161 -----
  extern int block_size;                  /* bytes per logical block */
  extern int cyl_size;                    /* physical sectors per cylinder */
  extern dev_t fs_device;                 /* device ID of file system */
+ 
+ extern int fs_type_flag;		/* flag used to distinguish between
+ 					 * fs_type 1 and 2 -- used in some
+ 					 * macros in <sys/param.h> (kludge)
+ 					 */
  
  /*
   * calculated global statistics

Index: fsconfig.h
Prereq: 4.1.1.1
*** ../oldtest/fsconfig.h	Thu Dec 15 15:50:14 1988
--- fsconfig.h	Thu Dec 15 15:51:08 1988
***************
*** 1,4
! /* @(#)$Id: fsconfig.h, V4.1.1.1 88/11/18 17:38:35 $ */
  
  /*
   * fsconfig.h - fsanalyze configuration-specific definitions

--- 1,4 -----
! /* @(#)$Id: fsconfig.h, V4.1.1.2 88/12/14 11:00:19 $ */
  
  /*
   * fsconfig.h - fsanalyze configuration-specific definitions
***************
*** 2,8
  
  /*
   * fsconfig.h - fsanalyze configuration-specific definitions
!  * Version  : 4.1.1.1 - 88/11/18 17:38:35
   *
   * Author   : Michael J. Young
   * USmail   : Software Development Technologies, Inc.

--- 2,8 -----
  
  /*
   * fsconfig.h - fsanalyze configuration-specific definitions
!  * Version  : 4.1.1.2 - 88/12/14 11:00:19
   *
   * Author   : Michael J. Young
   * USmail   : Software Development Technologies, Inc.
***************
*** 49,54
   *
   * Fri Nov 18 17:37:08 EST 1988 - M. Young (mjy@sdti.SDTI.COM),
   *    Removed #defines for SUPERBOFF for all but XENIX/286
   */
  
  /*

--- 49,63 -----
   *
   * Fri Nov 18 17:37:08 EST 1988 - M. Young (mjy@sdti.SDTI.COM),
   *    Removed #defines for SUPERBOFF for all but XENIX/286
+  *
+  * Fri Dec  2 16:33:23 EST 1988 - M. Young (mjy@sdti.SDTI.COM),
+  *    Fixed bug in is_ok() macro
+  *
+  * Tue Dec 13 11:45:02 EST 1988 - M. Young (mjy@sdti.SDTI.COM),
+  *    Reorganized header files to have fsconfig.h include <sys/fs.h>
+  *    directly, rather than in fsanalyze.h.  Also, added support for
+  *    fs_type_flag, a kludge to permit some macros (like FsBSIZE) to
+  *    be used from <sys/param.h> on System V derivatives.
   */
  
  /*
***************
*** 92,97
  # define OS_TYPE    OS_ATT
  #endif
  
  
  /***************************************************************************
   *                            file system macros                           *

--- 101,110 -----
  # define OS_TYPE    OS_ATT
  #endif
  
+ /*
+  * Include header files needed by fsconfig.h
+  */
+ #include <sys/param.h>
  
  #if (FS_TYPE == FS_ATT)
  # include <sys/types.h>
***************
*** 93,98
  #endif
  
  
  /***************************************************************************
   *                            file system macros                           *
   ***************************************************************************/

--- 106,130 -----
   */
  #include <sys/param.h>
  
+ #if (FS_TYPE == FS_ATT)
+ # include <sys/types.h>
+ # include <sys/filsys.h>
+ # include <sys/ino.h>
+ #endif
+ 
+ #if (FS_TYPE == FS_BSD)
+ # include <sys/fs.h>
+ # include <sys/inode.h>
+ #endif
+ 
+ #if (FS_TYPE == FS_BSD_NFS)
+ # include <sys/time.h>
+ # include <ufs/fs.h>
+ # include <sys/vnode.h>
+ # include <ufs/inode.h>
+ #endif
+ 
+ 
  /***************************************************************************
   *                            file system macros                           *
   ***************************************************************************/
***************
*** 114,119
   *    MAXINDIR                  Maximum number of indirect blocks per block
   *                              (based on largest possible block size of any
   *                              file system)
   *    inopb(fs)                 Number of inodes per block of a given file
   *                              system
   *    nindir(fs)                Number of indirect blocks per block in a

--- 146,154 -----
   *    MAXINDIR                  Maximum number of indirect blocks per block
   *                              (based on largest possible block size of any
   *                              file system)
+  *    set_fs_type_flag(fs)      Used only for System V derivatives, is a kludge
+  *                              that allows some macros in <sys/param.h> to
+  *                              be used.
   *    inopb(fs)                 Number of inodes per block of a given file
   *                              system
   *    nindir(fs)                Number of indirect blocks per block in a
***************
*** 182,187
  # define DEV_BSIZE      512
  
  /*
   * MAXBSIZE is defined as the largest possible BSIZE for any file system.
   * The largest I have come across in System V ports is 2048.  If a larger
   * one is encountered, MAXBSIZE should be increased accordingly.

--- 217,245 -----
  # define DEV_BSIZE      512
  
  /*
+  * ROOTINO doesn't seem to be defined in System V Release 3, so define
+  * it here if necessary.
+  */
+ # ifndef  ROOTINO
+ #  define ROOTINO	2
+ # endif
+ 
+ /*
+  * the following is used to set the fs_type_flag variable that will be used
+  * by some systems to determine file system type.  This is used by some macros
+  * in <sys/param.h>, which will be referenced by subsequent macros.
+  */
+ # ifdef	Fs2b
+ #  ifdef Fs2BLK
+ #   define set_fs_type_flag(fs)	((fs)->s_type == Fs2b ? Fs2BLK : 0)
+ #  else
+ #   define set_fs_type_flag(fs) ((fs)->s_type == Fs2b ? 0x2000 : 0)
+ #  endif
+ # else
+ #  define set_fs_type_flag(fs) (0)
+ # endif
+ 
+ /*
   * MAXBSIZE is defined as the largest possible BSIZE for any file system.
   * The largest I have come across in System V ports is 2048.  If a larger
   * one is encountered, MAXBSIZE should be increased accordingly.
***************
*** 190,196
  # define MAXINOPB       (MAXBSIZE / sizeof (struct dinode))
  # define MAXINDIR       (MAXBSIZE / sizeof (daddr_t))
  # ifdef FsINOPB
! #  define inopb(fs)	FsINOPB(fs)
  # else
  #  define inopb(fs)     INOPB
  # endif

--- 248,254 -----
  # define MAXINOPB       (MAXBSIZE / sizeof (struct dinode))
  # define MAXINDIR       (MAXBSIZE / sizeof (daddr_t))
  # ifdef FsINOPB
! #  define inopb(fs)	FsINOPB(fs_type_flag)
  # else
  #  define inopb(fs)     INOPB
  # endif
***************
*** 195,201
  #  define inopb(fs)     INOPB
  # endif
  # ifdef FsNINDIR
! #  define nindir(fs)	FsNINDIR(fs)
  # else
  #  define nindir(fs)    NINDIR
  # endif

--- 253,259 -----
  #  define inopb(fs)     INOPB
  # endif
  # ifdef FsNINDIR
! #  define nindir(fs)	FsNINDIR(fs_type_flag)
  # else
  #  define nindir(fs)    NINDIR
  # endif
***************
*** 208,215
   * file system, whereas SBUFSIZE is set to the larger.  If this is
   * different in your system, change the following macro accordingly.
   */
! # ifdef Fs2b
! #  define bsize(fs)      ((fs)->s_type == Fs2b ? SBUFSIZE : BSIZE)
  # else
  #  define bsize(fs)	 (BSIZE)
  # endif

--- 266,273 -----
   * file system, whereas SBUFSIZE is set to the larger.  If this is
   * different in your system, change the following macro accordingly.
   */
! # ifdef FsBSIZE
! #  define bsize(fs)      FsBSIZE(fs_type_flag)
  # else
  #  define bsize(fs)	 (BSIZE)
  # endif
***************
*** 239,245
  #  if (OS_TYPE == OS_XENIX_286)
  #   define is_ok(fs) (TRUE)
  #  else
! #   define is_ok(fs) ((fs)->s_state == FsOKAY) || ((fs)->s_state == FsACTIVE)
  #  endif
  # endif
  

--- 297,307 -----
  #  if (OS_TYPE == OS_XENIX_286)
  #   define is_ok(fs) (TRUE)
  #  else
! #   ifdef FsOKAY
! #    define is_ok(fs) (((fs)->s_state == FsOKAY) || ((fs)->s_state == FsACTIVE))
! #   else
! #    define is_ok(fs) (TRUE)
! #   endif
  #  endif
  # endif
  
***************
*** 287,292
  # define first_inode      0
  # define iblkno(fs)       ((fs)->fs_iblkno)
  # define sec_per_cyl(fs)  ((fs)->fs_spc)
  
  /*
   * How do we determine file system integrity on a BSD file system?

--- 349,359 -----
  # define first_inode      0
  # define iblkno(fs)       ((fs)->fs_iblkno)
  # define sec_per_cyl(fs)  ((fs)->fs_spc)
+ 
+ /*
+  * set_fs_type_flag is unused for BSD filesystems
+  */
+ # define set_fs_type_flag(fs) (0)
  
  /*
   * How do we determine file system integrity on a BSD file system?

Index: init.c
Prereq: 4.1
*** ../oldtest/init.c	Thu Dec 15 15:50:14 1988
--- init.c	Thu Dec 15 15:51:09 1988
***************
*** 1,4
! static char sccsid[] = "@(#)$Id: init.c, V4.1 88/11/16 17:30:51 $";
  
  /*
   * init.c - initialization and usage code

--- 1,4 -----
! static char sccsid[] = "@(#)$Id: init.c, V4.1.1.1 88/12/14 11:00:33 $";
  
  /*
   * init.c - initialization and usage code
***************
*** 2,8
  
  /*
   * init.c - initialization and usage code
!  * Version  : 4.1 - 88/11/16 17:30:51
   *
   * Author   : Michael J. Young
   * USmail   : Software Development Technologies, Inc.

--- 2,8 -----
  
  /*
   * init.c - initialization and usage code
!  * Version  : 4.1.1.1 - 88/12/14 11:00:33
   *
   * Author   : Michael J. Young
   * USmail   : Software Development Technologies, Inc.
***************
*** 33,38
   *
   * Wed Nov 16 11:31:32 EST 1988 - M. Young (mjy@sdti.SDTI.COM),
   *    Placed under SCCS
   */
  
  #include "fsconfig.h"

--- 33,45 -----
   *
   * Wed Nov 16 11:31:32 EST 1988 - M. Young (mjy@sdti.SDTI.COM),
   *    Placed under SCCS
+  *
+  * Fri Dec  2 15:47:30 EST 1988 - M. Young (mjy@sdti.SDTI.COM),
+  *    Added "override" test to non-HAVE_FSSTAT version of chk_fs()
+  *
+  * Wed Dec 14 10:46:13 EST 1988 - M. Young (mjy@sdti.SDTI.COM),
+  *    Added code to set "fs_type_flag" variable according to file
+  *    system type (System V derivatives)
   */
  
  #include "fsconfig.h"
***************
*** 54,59
  int cyl_size             = 0;           /* physical sectors per cylinder */
  dev_t fs_device          = 0;           /* device ID of file system */
  
  /*
   * fsanalyze command-line flags
   */

--- 61,71 -----
  int cyl_size             = 0;           /* physical sectors per cylinder */
  dev_t fs_device          = 0;           /* device ID of file system */
  
+ int fs_type_flag         = 0;		/* flag used to distinguish between
+ 					 * fs_type 1 and 2 -- used in some
+ 					 * macros in <sys/param.h> (kludge)
+ 					 */
+ 
  /*
   * fsanalyze command-line flags
   */
***************
*** 70,76
   */
  void version(){
      printf ("\nFile System Analyzer\n");
!     printf ("Version : 4.1 - 88/11/16 17:30:51, Patch Level #%d\n", patch_level);
      }
  
  /*

--- 82,88 -----
   */
  void version(){
      printf ("\nFile System Analyzer\n");
!     printf ("Version : 4.1 - 88/12/14 11:00:33, Patch Level #%d\n", patch_level);
      }
  
  /*
***************
*** 176,182
      /*
       * Check the integrity of the file system manually, if possible.
       */
!     if (!is_ok(fil_sys)){
          fprintf (stderr, "\"%s\" needs checking\n", fs);
          return (FALSE);
          }

--- 188,194 -----
      /*
       * Check the integrity of the file system manually, if possible.
       */
!     if (!is_ok(fil_sys) && !override){
          fprintf (stderr, "\"%s\" needs checking\n", fs);
          return (FALSE);
          }
***************
*** 183,188
  
  #endif  /* HAVE_FSSTAT */
  
      return (TRUE);
      }
  

--- 195,206 -----
  
  #endif  /* HAVE_FSSTAT */
  
+     /*
+      * set the file system type flag kludge used by some of the macros
+      * in <sys/param.h> in System V versions
+      */
+     fs_type_flag = set_fs_type_flag(fil_sys);
+ 
      return (TRUE);
      }
  
***************
*** 315,321
      if (cyl_size == 0){
         cyl_size = sec_per_cyl(fil_sys);
         }
! 
      return i;                /* return # of next argument to be processed */
      }
  

--- 333,339 -----
      if (cyl_size == 0){
         cyl_size = sec_per_cyl(fil_sys);
         }
!     
      return i;                /* return # of next argument to be processed */
      }

Index: patchlevel.h
Prereq: 4.1
*** ../oldtest/patchlevel.h	Thu Dec 15 15:50:14 1988
--- patchlevel.h	Thu Dec 15 15:51:10 1988
***************
*** 1,4
! /* @(#)$Id: patchlevel.h, V4.1 88/11/16 17:55:39 $ */
  
  /*
   * patchlevel.h - current patch level

--- 1,4 -----
! /* @(#)$Id: patchlevel.h, V4.1.1.1 88/12/02 16:36:19 $ */
  
  /*
   * patchlevel.h - current patch level
***************
*** 2,8
  
  /*
   * patchlevel.h - current patch level
!  * Version  : 4.1 - 88/11/16 17:55:39
   *
   * Author   : Michael J. Young
   * USmail   : Software Development Technologies, Inc.

--- 2,8 -----
  
  /*
   * patchlevel.h - current patch level
!  * Version  : 4.1.1.1 - 88/12/02 16:36:19
   *
   * Author   : Michael J. Young
   * USmail   : Software Development Technologies, Inc.
***************
*** 22,26
   * =========================================================================
   */
  
! #define patch_level 0
  

--- 22,26 -----
   * =========================================================================
   */
  
! #define patch_level 1

Index: report.c
Prereq: 4.1
*** ../oldtest/report.c	Thu Dec 15 15:50:14 1988
--- report.c	Thu Dec 15 16:19:23 1988
***************
*** 1,4
! static char sccsid[] = "@(#)$Id: report.c, V4.1 88/11/16 17:31:13 $";
  
  /*
   * report.c - print analysis report

--- 1,4 -----
! static char sccsid[] = "@(#)$Id: report.c, V4.1.1.1 88/12/15 16:10:35 $";
  
  /*
   * report.c - print analysis report
***************
*** 2,8
  
  /*
   * report.c - print analysis report
!  * Version  : 4.1 - 88/11/16 17:31:13
   *
   * Author   : Michael J. Young
   * USmail   : Software Development Technologies, Inc.

--- 2,8 -----
  
  /*
   * report.c - print analysis report
!  * Version  : 4.1.1.1 - 88/12/15 16:10:35
   *
   * Author   : Michael J. Young
   * USmail   : Software Development Technologies, Inc.
***************
*** 33,38
   *
   * Wed Nov 16 11:31:32 EST 1988 - M. Young (mjy@sdti.SDTI.COM),
   *    Placed under SCCS
   */
  
  #include "fsconfig.h"

--- 33,42 -----
   *
   * Wed Nov 16 11:31:32 EST 1988 - M. Young (mjy@sdti.SDTI.COM),
   *    Placed under SCCS
+  *
+  * Thu Dec 15 15:32:39 EST 1988 - M. Young (mjy@sdti.SDTI.COM),
+  *    Removed some potential divide-by-zero errors, added support for
+  *    BSD filesystems without fs_optim
   */
  
  #include "fsconfig.h"
***************
*** 74,80
      fragm = potential_seeks ? (float)seeks/(float)potential_seeks : 0.0;
      rel_cost = seeks ? (float)total_seek_distance / (float)seeks : 0.0;
      rotations = potential_seeks ? (float)rotates/(float)potential_seeks : 0.0;
!     bused_p = (float)blocks/(float)(blocks+freespace(fil_sys,0));
      num_files = num_inodes(fil_sys) - free_inodes;
      iused_p = (float)num_files/(float)num_inodes(fil_sys);
      ind_p = num_files ? (float)indirects/(float)num_files : 0.0;

--- 78,84 -----
      fragm = potential_seeks ? (float)seeks/(float)potential_seeks : 0.0;
      rel_cost = seeks ? (float)total_seek_distance / (float)seeks : 0.0;
      rotations = potential_seeks ? (float)rotates/(float)potential_seeks : 0.0;
!     bused_p = blocks ? (float)blocks/(float)(blocks+freespace(fil_sys,0)) : 0.0;
      num_files = num_inodes(fil_sys) - free_inodes;
      iused_p = num_inodes(fil_sys) ? (float)num_files/(float)num_inodes(fil_sys) : 0.0;
      ind_p = num_files ? (float)indirects/(float)num_files : 0.0;
***************
*** 76,82
      rotations = potential_seeks ? (float)rotates/(float)potential_seeks : 0.0;
      bused_p = (float)blocks/(float)(blocks+freespace(fil_sys,0));
      num_files = num_inodes(fil_sys) - free_inodes;
!     iused_p = (float)num_files/(float)num_inodes(fil_sys);
      ind_p = num_files ? (float)indirects/(float)num_files : 0.0;
      dind_p = num_files ? (float)double_indirects/(float)num_files : 0.0;
      tind_p = num_files ? (float)triple_indirects/(float)num_files : 0.0;

--- 80,86 -----
      rotations = potential_seeks ? (float)rotates/(float)potential_seeks : 0.0;
      bused_p = blocks ? (float)blocks/(float)(blocks+freespace(fil_sys,0)) : 0.0;
      num_files = num_inodes(fil_sys) - free_inodes;
!     iused_p = num_inodes(fil_sys) ? (float)num_files/(float)num_inodes(fil_sys) : 0.0;
      ind_p = num_files ? (float)indirects/(float)num_files : 0.0;
      dind_p = num_files ? (float)double_indirects/(float)num_files : 0.0;
      tind_p = num_files ? (float)triple_indirects/(float)num_files : 0.0;
***************
*** 85,92
      bdir_p = num_directories ? (float)big_directories/(float)num_directories : 0.0;
      link_p = num_files ? (float)linked_files/(float)num_files : 0.0;
      spec_p = num_files ? (float)num_specials/(float)num_files : 0.0;
!     indirb_p = (float)ind_blks/(float)(blocks+freespace(fil_sys,0));
!     wasted_p = (float)unuseable/(float)(fssize(fil_sys) * block_size);
  
      /*
       * print out report

--- 89,96 -----
      bdir_p = num_directories ? (float)big_directories/(float)num_directories : 0.0;
      link_p = num_files ? (float)linked_files/(float)num_files : 0.0;
      spec_p = num_files ? (float)num_specials/(float)num_files : 0.0;
!     indirb_p = blocks ? (float)ind_blks/(float)(blocks+freespace(fil_sys,0)) : 0.0;
!     wasted_p = (fssize(fil_sys)*block_size) ? (float)unuseable/(float)(fssize(fil_sys) * block_size) : 0.0;
  
      /*
       * print out report
***************
*** 110,115
          interleave, cyl_size);
  
  # if FS_TYPE == FS_BSD
      printf ("; Allocation Strategy = %s", 
          fil_sys->fs_optim == FS_OPTTIME ? "Time" : "Space");
  # endif

--- 114,120 -----
          interleave, cyl_size);
  
  # if FS_TYPE == FS_BSD
+ #  ifdef FS_OPTTIME
      printf ("; Allocation Strategy = %s", 
          fil_sys->fs_optim == FS_OPTTIME ? "Time" : "Space");
  #  endif
***************
*** 112,117
  # if FS_TYPE == FS_BSD
      printf ("; Allocation Strategy = %s", 
          fil_sys->fs_optim == FS_OPTTIME ? "Time" : "Space");
  # endif
  
      printf ("\nVolume Size = %ld blocks (%ld bytes)\n",

--- 117,123 -----
  #  ifdef FS_OPTTIME
      printf ("; Allocation Strategy = %s", 
          fil_sys->fs_optim == FS_OPTTIME ? "Time" : "Space");
+ #  endif
  # endif
  
      printf ("\nVolume Size = %ld blocks (%ld bytes)\n",
-- 
Mike Young
Software Development Technologies, Inc., Sudbury MA       Tel: +1 508 443 5779
Internet: mjy@sdti.sdti.com                 UUCP: {harvard,mit-eddie}!sdti!mjy