Patches to upgrade Fsanalyze from v4.1 PL2 to v4.2

Michael J. Young mjy at sdti.SDTI.COM
Sat Jan 21 02:21:23 AEST 1989


This is an official upgrade to bring fsanalyze from v4.1 PL2 to v4.2.

This version contains the following new functionality:
	1.  A new option '-n' has been added which causes fsanalyze to
	    report the pathnames of the most-fragmented files, rather
	    than just the inode numbers.  This option uses ncheck to
	    do its dirty work.  Thanks to Chip Rosenthal (chip at vector.UUCP)
	    for providing the code for this.
	2.  A new option '-t' makes it possible to specify the number
	    of files to include in the most-fragmented file list.  The
	    default is still NUMOFFEND (10).
	3.  A new option '-s' causes fsanalyze to send progress reports
	    to stderr.  This is sometimes useful when the output of fsanalyze
	    is being captured to a file or piped to another process.

Please apply the following patches to the 4.1 PL2 source and run 'make'.
Note: make sure you have applied patches 1 & 2 before applying this patch.
If you have not received the two previous patches, they may be obtained from
me at mjy at sdti.SDTI.COM.
------------------
Index: Changes
Prereq: 4.1
*** ../prev/Changes	Fri Jan 20 10:12:38 1989
--- Changes	Fri Jan 20 10:14:37 1989
***************
*** 92,94
  
     Release 4.1 contains no major changes from 3.04, but resulted from
     placing the code under SCCS.

--- 92,104 -----
  
     Release 4.1 contains no major changes from 3.04, but resulted from
     placing the code under SCCS.
+ 
+    Release 4.2 adds three new options:
+ 	'-n' causes fsanalyze to report the pathnames of the most
+ 	     fragmented files.  The pathnames are generated by
+ 	     invoking ncheck.
+ 	'-s' causes fsanalyze to report its progress on stderr.
+ 	     This is sometimes useful when the output of fsanalyze
+ 	     is being captured to a file or piped to another process.
+ 	'-t' may be used to specify how many files to report in the
+ 	     most-fragmented file list.  The default is still 10 files.

Index: Mkfile.sun
Prereq: 4.1.1.1
*** ../prev/Mkfile.sun	Fri Jan 20 10:13:59 1989
--- Mkfile.sun	Fri Jan 20 10:14:40 1989
***************
*** 1,4
! ## @(#)$Id: Mkfile.sun, V4.1.1.1 89/01/10 10:48:45 $
  ##
  ## FSANALYZE makefile
  ## Version  : 4.1.1.1 - 89/01/10 10:48:45

--- 1,4 -----
! ## @(#)$Id: Mkfile.sun, V4.2 89/01/20 10:10:40 $
  ##
  ## FSANALYZE makefile
  ## Version  : 4.2 - 89/01/20 10:10:40
***************
*** 1,7
  ## @(#)$Id: Mkfile.sun, V4.1.1.1 89/01/10 10:48:45 $
  ##
  ## FSANALYZE makefile
! ## Version  : 4.1.1.1 - 89/01/10 10:48:45
  
  ## One of the things FSANALYZE displays is a list of the most fragmented
  ## files.  OFFEND determines how many of those files to report.

--- 1,7 -----
  ## @(#)$Id: Mkfile.sun, V4.2 89/01/20 10:10:40 $
  ##
  ## FSANALYZE makefile
! ## Version  : 4.2 - 89/01/20 10:10:40
  
  ## One of the things FSANALYZE displays is a list of the most fragmented
  ## files.  OFFEND determines how many of those files to report.

Index: Mkfile.sys5
Prereq: 4.1.1.1
*** ../prev/Mkfile.sys5	Fri Jan 20 10:14:00 1989
--- Mkfile.sys5	Fri Jan 20 10:14:41 1989
***************
*** 1,4
! ## @(#)$Id: Mkfile.sys5, V4.1.1.1 89/01/10 10:48:48 $
  ##
  ## FSANALYZE makefile
  ## Version  : 4.1.1.1 - 89/01/10 10:48:48

--- 1,4 -----
! ## @(#)$Id: Mkfile.sys5, V4.2 89/01/20 10:10:43 $
  ##
  ## FSANALYZE makefile
  ## Version  : 4.2 - 89/01/20 10:10:43
***************
*** 1,7
  ## @(#)$Id: Mkfile.sys5, V4.1.1.1 89/01/10 10:48:48 $
  ##
  ## FSANALYZE makefile
! ## Version  : 4.1.1.1 - 89/01/10 10:48:48
  
  ## One of the things FSANALYZE displays is a list of the most fragmented
  ## files.  OFFEND determines how many of those files to report.

--- 1,7 -----
  ## @(#)$Id: Mkfile.sys5, V4.2 89/01/20 10:10:43 $
  ##
  ## FSANALYZE makefile
! ## Version  : 4.2 - 89/01/20 10:10:43
  
  ## One of the things FSANALYZE displays is a list of the most fragmented
  ## files.  OFFEND determines how many of those files to report.

Index: Mkfile.uport
Prereq: 4.1.1.1
*** ../prev/Mkfile.uport	Fri Jan 20 10:14:01 1989
--- Mkfile.uport	Fri Jan 20 10:14:41 1989
***************
*** 1,4
! ## @(#)$Id: Mkfile.uport, V4.1.1.1 89/01/10 10:48:51 $
  ##
  ## FSANALYZE makefile
  ## Version  : 4.1.1.1 - 89/01/10 10:48:51

--- 1,4 -----
! ## @(#)$Id: Mkfile.uport, V4.2 89/01/20 10:10:46 $
  ##
  ## FSANALYZE makefile
  ## Version  : 4.2 - 89/01/20 10:10:46
***************
*** 1,7
  ## @(#)$Id: Mkfile.uport, V4.1.1.1 89/01/10 10:48:51 $
  ##
  ## FSANALYZE makefile
! ## Version  : 4.1.1.1 - 89/01/10 10:48:51
  
  ## One of the things FSANALYZE displays is a list of the most fragmented
  ## files.  OFFEND determines how many of those files to report.

--- 1,7 -----
  ## @(#)$Id: Mkfile.uport, V4.2 89/01/20 10:10:46 $
  ##
  ## FSANALYZE makefile
! ## Version  : 4.2 - 89/01/20 10:10:46
  
  ## One of the things FSANALYZE displays is a list of the most fragmented
  ## files.  OFFEND determines how many of those files to report.

Index: Mkfile.xenix
Prereq: 4.1.1.1
*** ../prev/Mkfile.xenix	Fri Jan 20 10:14:02 1989
--- Mkfile.xenix	Fri Jan 20 10:14:42 1989
***************
*** 1,4
! ## @(#)$Id: Mkfile.xenix, V4.1.1.1 89/01/10 10:48:54 $
  ##
  ## FSANALYZE makefile
  ## Version  : 4.1.1.1 - 89/01/10 10:48:54

--- 1,4 -----
! ## @(#)$Id: Mkfile.xenix, V4.2 89/01/20 10:10:49 $
  ##
  ## FSANALYZE makefile
  ## Version  : 4.2 - 89/01/20 10:10:49
***************
*** 1,7
  ## @(#)$Id: Mkfile.xenix, V4.1.1.1 89/01/10 10:48:54 $
  ##
  ## FSANALYZE makefile
! ## Version  : 4.1.1.1 - 89/01/10 10:48:54
  
  ## One of the things FSANALYZE displays is a list of the most fragmented
  ## files.  OFFEND determines how many of those files to report.

--- 1,7 -----
  ## @(#)$Id: Mkfile.xenix, V4.2 89/01/20 10:10:49 $
  ##
  ## FSANALYZE makefile
! ## Version  : 4.2 - 89/01/20 10:10:49
  
  ## One of the things FSANALYZE displays is a list of the most fragmented
  ## files.  OFFEND determines how many of those files to report.

Index: README
Prereq: 4.1.1.2
*** ../prev/README	Fri Jan 20 10:12:47 1989
--- README	Fri Jan 20 10:14:43 1989
***************
*** 1,5
  FSANALYZE - File System Analyzer tool
! Version  : 4.1.1.2 - 88/11/30 15:53:38
  
  Author   : Michael J. Young
  USmail   : Software Development Technologies, Inc.

--- 1,5 -----
  FSANALYZE - File System Analyzer tool
! Version  : 4.2 - 89/01/20 10:10:53
  
  Author   : Michael J. Young
  USmail   : Software Development Technologies, Inc.

Index: chkfile.c
Prereq: 4.1.1.1
*** ../prev/chkfile.c	Fri Jan 20 10:14:05 1989
--- chkfile.c	Fri Jan 20 10:14:45 1989
***************
*** 1,4
! static char sccsid[] = "@(#)$Id: chkfile.c, V4.1.1.1 89/01/10 10:48:57 $";
  
  /*
   * chkfile.c - analyze file

--- 1,4 -----
! static char sccsid[] = "@(#)$Id: chkfile.c, V4.2 89/01/20 10:10:56 $";
  
  /*
   * chkfile.c - analyze file
***************
*** 2,8
  
  /*
   * chkfile.c - analyze file
!  * Version  : 4.1.1.1 - 89/01/10 10:48:57
   *
   * Author   : Michael J. Young
   * USmail   : Software Development Technologies, Inc.

--- 2,8 -----
  
  /*
   * chkfile.c - analyze file
!  * Version  : 4.2 - 89/01/20 10:10:56
   *
   * Author   : Michael J. Young
   * USmail   : Software Development Technologies, Inc.
***************
*** 39,44
   *
   * Thu Jan  5 10:53:25 EST 1989 - Gerry Swislow (gerry at certif.UUCP),
   *    Fixed bugs in some debugging statements!
   */
  
  #include "fsconfig.h"

--- 39,47 -----
   *
   * Thu Jan  5 10:53:25 EST 1989 - Gerry Swislow (gerry at certif.UUCP),
   *    Fixed bugs in some debugging statements!
+  *
+  * Fri Jan 20 09:41:20 EST 1989 - M. Young (mjy at sdti.SDTI.COM),
+  *    Added '-s' flag
   */
  
  #include "fsconfig.h"
***************
*** 397,402
      struct dinode i_node[MAXINOPB];     /* holds a block of inodes */
      struct file_data data;              /* per-inode statistics */
  
      for (i = first_inode; i < num_inodes(fil_sys); i+=inopb(fil_sys)){
  
          /*

--- 400,409 -----
      struct dinode i_node[MAXINOPB];     /* holds a block of inodes */
      struct file_data data;              /* per-inode statistics */
  
+     if (status_flag){
+ 	fprintf (stderr, "Scanning %ld inodes...\n", (long) num_inodes(fil_sys));
+         }
+ 
      for (i = first_inode; i < num_inodes(fil_sys); i+=inopb(fil_sys)){
  
  	if (status_flag){
***************
*** 398,403
      struct file_data data;              /* per-inode statistics */
  
      for (i = first_inode; i < num_inodes(fil_sys); i+=inopb(fil_sys)){
  
          /*
           * for efficiency, read a block of i-nodes at a time

--- 405,414 -----
          }
  
      for (i = first_inode; i < num_inodes(fil_sys); i+=inopb(fil_sys)){
+ 
+ 	if (status_flag){
+ 	    fprintf (stderr, "inode %-20d\r", i);
+ 	    }
  
          /*
           * for efficiency, read a block of i-nodes at a time

Index: fragm.c
Prereq: 4.1
*** ../prev/fragm.c	Fri Jan 20 10:12:53 1989
--- fragm.c	Fri Jan 20 10:14:46 1989
***************
*** 1,4
! static char sccsid[] = "@(#)$Id: fragm.c, V4.1 88/11/16 17:29:42 $";
  
  /*
   * fragm.c - fragmentation analysis

--- 1,4 -----
! static char sccsid[] = "@(#)$Id: fragm.c, V4.2 89/01/20 10:11:04 $";
  
  /*
   * fragm.c - fragmentation analysis
***************
*** 2,8
  
  /*
   * fragm.c - fragmentation analysis
!  * Version  : 4.1 - 88/11/16 17:29:42
   *
   * Author   : Michael J. Young
   * USmail   : Software Development Technologies, Inc.

--- 2,8 -----
  
  /*
   * fragm.c - fragmentation analysis
!  * Version  : 4.2 - 89/01/20 10:11:04
   *
   * Author   : Michael J. Young
   * USmail   : Software Development Technologies, Inc.
***************
*** 33,38
   *
   * Wed Nov 16 11:31:32 EST 1988 - M. Young (mjy at sdti.SDTI.COM),
   *    Placed under SCCS
   */
  
  /*

--- 33,41 -----
   *
   * Wed Nov 16 11:31:32 EST 1988 - M. Young (mjy at sdti.SDTI.COM),
   *    Placed under SCCS
+  *
+  * Tue Jan 10 15:50:33 EST 1989 - M. Young (mjy at sdti.SDTI.COM),
+  *    Workaround for braindamaged compiler that can't divide 0L/(long).
   */
  
  /*
***************
*** 104,111
  {
      off_t bytes_per_cyl;
  
!     bytes_per_cyl = (off_t)cyl_size * DEV_BSIZE;
!     return (file_size / bytes_per_cyl);
      }
  
  /*

--- 107,119 -----
  {
      off_t bytes_per_cyl;
  
!     if (file_size == 0){
!         return 0L;
!         }
!     else {
!         bytes_per_cyl = (off_t)cyl_size * DEV_BSIZE;
!         return (file_size / bytes_per_cyl);
!         }
      }
  
  /*

Index: fsanalyze.8
Prereq: 4.1.1.1
*** ../prev/fsanalyze.8	Fri Jan 20 10:13:36 1989
--- fsanalyze.8	Fri Jan 20 10:14:47 1989
***************
*** 5,11
  .SH SYNOPSIS
  .B fsanalyze
  [
! .B \-deiov
  [
  .B \-b#
  ] [

--- 5,11 -----
  .SH SYNOPSIS
  .B fsanalyze
  [
! .B \-deinosv
  [
  .B \-b#
  ] [
***************
*** 12,17
  .B \-c#
  ] [
  .B \-g#
  ] ]
  .B special
  [

--- 12,19 -----
  .B \-c#
  ] [
  .B \-g#
+ ] [
+ .B \-t#
  ] ]
  .B special
  [
***************
*** 93,98
  another source of file system overhead.  Expressed as an absolute number and
  a percentage of the file system size.
  .LP
  .I Fsanalyze
  also lists the 10 most fragmented inodes in the file system.
  They are listed in decreasing order of fragmentation

--- 95,101 -----
  another source of file system overhead.  Expressed as an absolute number and
  a percentage of the file system size.
  .LP
+ By default,
  .I Fsanalyze
  also lists the 10 most fragmented inodes in the file system.
  The number of files listed may be changed using the
***************
*** 95,101
  .LP
  .I Fsanalyze
  also lists the 10 most fragmented inodes in the file system.
! They are listed in decreasing order of fragmentation
  based on the absolute number of fragments.  For example a 100-block file
  that contains 40 individual fragments is 39.39% fragmented (39 seeks / 99
  potential seeks), but is listed before a 2-block file that contains 2

--- 98,107 -----
  By default,
  .I Fsanalyze
  also lists the 10 most fragmented inodes in the file system.
! The number of files listed may be changed using the
! .B \-t
! option.
! The files are listed in decreasing order of fragmentation
  based on the absolute number of fragments.  For example a 100-block file
  that contains 40 individual fragments is 39.39% fragmented (39 seeks / 99
  potential seeks), but is listed before a 2-block file that contains 2
***************
*** 139,145
  assume '#' sectors per disk cylinder -- by default, this value is
  determined by information in the superblock.
  .IP \fB\-d\fR
! display inode numbers as they are examined.  This flag makes it easy to
  chart the progress of fsanalyze through the file system.  Used mainly for
  debugging.
  .IP \fB\-e\fR

--- 145,151 -----
  assume '#' sectors per disk cylinder -- by default, this value is
  determined by information in the superblock.
  .IP \fB\-d\fR
! Display inode numbers as they are examined.  This flag makes it easy to
  chart the progress of fsanalyze through the file system.  Used mainly for
  debugging.
  .IP \fB\-e\fR
***************
*** 154,159
  .IP \fB\-i\fR
  report double and triple indirection - the inode numbers are reported for
  files that contain double and/or triple data-block indirection.
  .IP \fB\-o\fR
  overrides file system integrity checks.  The file system will be analyzed
  even if

--- 160,172 -----
  .IP \fB\-i\fR
  report double and triple indirection - the inode numbers are reported for
  files that contain double and/or triple data-block indirection.
+ .IP \fB\-n\fR
+ shows the pathname of the files in the list of most fragmented files.
+ If an inode contains multiple links, only one pathname will be displayed,
+ but the display will note that there are other links.  This option may
+ cause
+ .I fsanalyze
+ to take longer to complete.
  .IP \fB\-o\fR
  overrides file system integrity checks.  The file system will be analyzed
  even if
***************
*** 162,167
  .I fsanalyze
  may give erroneous results if used on a damaged file system, but the file
  system itself will not be affected.
  .IP \fB\-v\fR
  causes the current version number and patch level to be displayed.
  .SH EXAMPLES

--- 175,192 -----
  .I fsanalyze
  may give erroneous results if used on a damaged file system, but the file
  system itself will not be affected.
+ .IP \fB\-s\fR
+ causes
+ .I fsanalyze
+ to display progress messages on
+ .I stderr .
+ This option is useful when the output of fsanalyze is being captured to a
+ file or piped to another process.
+ .IP \fB\-t#\fR
+ causes
+ .I fsanalyze
+ to list the '#' most fragmented files in its report.  The
+ default is 10.
  .IP \fB\-v\fR
  causes the current version number and patch level to be displayed.
  .SH EXAMPLES
***************
*** 187,190
  .br
  Internet : mjy at sdti.SDTI.COM
  .SH VERSION
! 4.1.1.1 \- 88/12/14 11:07:34

--- 212,215 -----
  .br
  Internet : mjy at sdti.SDTI.COM
  .SH VERSION
! 4.2 \- 89/01/20 10:11:09

Index: fsanalyze.c
Prereq: 4.1.1.2
*** ../prev/fsanalyze.c	Fri Jan 20 10:14:07 1989
--- fsanalyze.c	Fri Jan 20 10:14:48 1989
***************
*** 1,4
! static char sccsid[] = "@(#)$Id: fsanalyze.c, V4.1.1.2 89/01/10 10:49:05 $";
  
  /*
   * fsanalyze.c - file system analyzer

--- 1,4 -----
! static char sccsid[] = "@(#)$Id: fsanalyze.c, V4.2 89/01/20 10:11:13 $";
  
  /*
   * fsanalyze.c - file system analyzer
***************
*** 2,8
  
  /*
   * fsanalyze.c - file system analyzer
!  * Version  : 4.1.1.2 - 89/01/10 10:49:05
   *
   * Author   : Michael J. Young
   * USmail   : Software Development Technologies, Inc.

--- 2,8 -----
  
  /*
   * fsanalyze.c - file system analyzer
!  * Version  : 4.2 - 89/01/20 10:11:13
   *
   * Author   : Michael J. Young
   * USmail   : Software Development Technologies, Inc.
***************
*** 79,84
   * Mon Jan  9 13:08:04 EST 1989 - Wietse Z. Venema (wietse at wzv.UUCP),
   *    Fixed faulty test in error() which caused floating-point error
   *    when invoked on an non-existent filesystem.
   */
  
  /*

--- 79,87 -----
   * Mon Jan  9 13:08:04 EST 1989 - Wietse Z. Venema (wietse at wzv.UUCP),
   *    Fixed faulty test in error() which caused floating-point error
   *    when invoked on an non-existent filesystem.
+  *
+  * Fri Jan 20 09:40:06 EST 1989 - M. Young (mjy at sdti.SDTI.COM),
+  *    Added '-s' flag.
   */
  
  /*
***************
*** 145,151
          /*
           * no individual files to check, scan entire file system
           */
!         printf ("Analyzing file system %s...\n", special);
  
          /*
           * scan through all i-nodes in the file system

--- 148,159 -----
          /*
           * no individual files to check, scan entire file system
           */
! 	if (status_flag){
! 	    fprintf (stderr, "Analyzing file system %s...\n", special);
! 	    }
! 	else {
!             printf ("Analyzing file system %s...\n", special);
! 	    }
  
          /*
           * scan through all i-nodes in the file system

Index: fsanalyze.h
Prereq: 4.1.1.3
*** ../prev/fsanalyze.h	Fri Jan 20 10:14:09 1989
--- fsanalyze.h	Fri Jan 20 10:14:50 1989
***************
*** 1,4
! /* @(#)$Id: fsanalyze.h, V4.1.1.3 89/01/10 11:19:58 $ */
  
  /*
   * fsanalyze.h - file system analyzer header file

--- 1,4 -----
! /* @(#)$Id: fsanalyze.h, V4.2 89/01/20 10:11:16 $ */
  
  /*
   * fsanalyze.h - file system analyzer header file
***************
*** 2,8
  
  /*
   * fsanalyze.h - file system analyzer header file
!  * Version  : 4.1.1.3 - 89/01/10 11:19:58
   *
   * Author   : Michael J. Young
   * USmail   : Software Development Technologies, Inc.

--- 2,8 -----
  
  /*
   * fsanalyze.h - file system analyzer header file
!  * Version  : 4.2 - 89/01/20 10:11:16
   *
   * Author   : Michael J. Young
   * USmail   : Software Development Technologies, Inc.
***************
*** 52,57
   * Tue Jan 10 11:19:30 EST 1989 - M. Young (mjy at sdti.SDTI.COM),
   *    Changed format of IS_SPECIAL to prevent some braindamaged
   *    compilers from barfing on degenerate conditionals
   */
  
  #include <sys/stat.h>

--- 52,66 -----
   * Tue Jan 10 11:19:30 EST 1989 - M. Young (mjy at sdti.SDTI.COM),
   *    Changed format of IS_SPECIAL to prevent some braindamaged
   *    compilers from barfing on degenerate conditionals
+  *
+  * Tue Jan 10 14:07:10 EST 1989 - M. Young (mjy at sdti.SDTI.COM),
+  *    Added support for displaying pathnames of most fragmented files.
+  *    Also added support for user-specified number of fragmented files
+  *    to report.  Based on code developed by Chip Rosenthal
+  *    (chip at vector.UUCP).
+  *
+  * Fri Jan 20 09:46:19 EST 1989 - M. Young (mjy at sdti.SDTI.COM),
+  *    Added '-s' flag.
   */
  
  #include <sys/stat.h>
***************
*** 120,125
   */
  struct file_data {
      int inode;                          /* i-node number */
      long total_blocks;                  /* total blocks in file (incl 
  					 * indirect blocks */
      long data_blocks;                   /* total data blocks in file */

--- 129,135 -----
   */
  struct file_data {
      int inode;                          /* i-node number */
+     char *pathname;			/* pathname of file at this inode */
      long total_blocks;                  /* total blocks in file (incl 
  					 * indirect blocks */
      long data_blocks;                   /* total data blocks in file */
***************
*** 193,199
  extern long unuseable;                  /* unuseable bytes due to external
                                           * fragmentation */
  
! extern struct file_data file_log[];     /* worst offenders */
  
  
  /*

--- 203,209 -----
  extern long unuseable;                  /* unuseable bytes due to external
                                           * fragmentation */
  
! extern struct file_data *file_log;      /* worst offenders */
  
  
  /*
***************
*** 207,212
                                           * examined */
  extern boolean override;                /* override bad fs test */
  
  
  /***************************************************************************
   *                          Function Declarations                          *

--- 217,224 -----
                                           * examined */
  extern boolean override;                /* override bad fs test */
  
+ extern boolean show_names;		/* display pathname of severly
+ 					 * fragmanted i-nodes */
  
  extern int num_fragmented;		/* number of most-fragmented files
  					 * to report */
***************
*** 208,213
  extern boolean override;                /* override bad fs test */
  
  
  /***************************************************************************
   *                          Function Declarations                          *
   ***************************************************************************/

--- 220,231 -----
  extern boolean show_names;		/* display pathname of severly
  					 * fragmanted i-nodes */
  
+ extern int num_fragmented;		/* number of most-fragmented files
+ 					 * to report */
+ 
+ extern boolean status_flag;		/* if TRUE, display progress messages
+ 					 * on stderr */
+ 
  /***************************************************************************
   *                          Function Declarations                          *
   ***************************************************************************/
***************
*** 227,232
   */
  extern daddr_t blk_no();		/* get block number from inode structure */
  extern void get_inodes();		/* fetch inode(s) */
  
  /*
   * from fragm.c

--- 245,252 -----
   */
  extern daddr_t blk_no();		/* get block number from inode structure */
  extern void get_inodes();		/* fetch inode(s) */
+ extern char *Smalloc();			/* safe malloc() */
+ extern char *Srealloc();		/* safe realloc() */
  
  /*
   * from fragm.c
***************
*** 232,237
   * from fragm.c
   */
  extern void test_fragmentation();	/* fragmentation analyzer */
  
  /*
   * from chkfile.c

--- 252,258 -----
   * from fragm.c
   */
  extern void test_fragmentation();	/* fragmentation analyzer */
+ extern long minimum_seeks();		/* mimimum number of seeks per file */
  
  /*
   * from chkfile.c

Index: fsconfig.h
Prereq: 4.1.1.3
*** ../prev/fsconfig.h	Fri Jan 20 10:14:12 1989
--- fsconfig.h	Fri Jan 20 10:14:52 1989
***************
*** 1,4
! /* @(#)$Id: fsconfig.h, V4.1.1.3 89/01/10 10:49:14 $ */
  
  /*
   * fsconfig.h - fsanalyze configuration-specific definitions

--- 1,4 -----
! /* @(#)$Id: fsconfig.h, V4.2 89/01/20 10:11:21 $ */
  
  /*
   * fsconfig.h - fsanalyze configuration-specific definitions
***************
*** 2,8
  
  /*
   * fsconfig.h - fsanalyze configuration-specific definitions
!  * Version  : 4.1.1.3 - 89/01/10 10:49:14
   *
   * Author   : Michael J. Young
   * USmail   : Software Development Technologies, Inc.

--- 2,8 -----
  
  /*
   * fsconfig.h - fsanalyze configuration-specific definitions
!  * Version  : 4.2 - 89/01/20 10:11:21
   *
   * Author   : Michael J. Young
   * USmail   : Software Development Technologies, Inc.

Index: init.c
Prereq: 4.1.1.2
*** ../prev/init.c	Fri Jan 20 10:14:14 1989
--- init.c	Fri Jan 20 10:14:53 1989
***************
*** 1,4
! static char sccsid[] = "@(#)$Id: init.c, V4.1.1.2 89/01/10 10:49:22 $";
  
  /*
   * init.c - initialization and usage code

--- 1,4 -----
! static char sccsid[] = "@(#)$Id: init.c, V4.2 89/01/20 10:11:26 $";
  
  /*
   * init.c - initialization and usage code
***************
*** 2,8
  
  /*
   * init.c - initialization and usage code
!  * Version  : 4.1.1.2 - 89/01/10 10:49:22
   *
   * Author   : Michael J. Young
   * USmail   : Software Development Technologies, Inc.

--- 2,8 -----
  
  /*
   * init.c - initialization and usage code
!  * Version  : 4.2 - 89/01/20 10:11:26
   *
   * Author   : Michael J. Young
   * USmail   : Software Development Technologies, Inc.
***************
*** 44,49
   * Tue Jan 10 10:10:38 EST 1989 - M. Young (mjy at sdti.SDTI.COM),
   *    Is_ok() and is_mounted() macros now work correctly, thanks to
   *    enlightenment from Mark Nudelman (UNIX386!mark).
   */
  
  #include "fsconfig.h"

--- 44,58 -----
   * Tue Jan 10 10:10:38 EST 1989 - M. Young (mjy at sdti.SDTI.COM),
   *    Is_ok() and is_mounted() macros now work correctly, thanks to
   *    enlightenment from Mark Nudelman (UNIX386!mark).
+  *
+  * Tue Jan 10 14:09:13 EST 1989 - M. Young (mjy at sdti.SDTI.COM),
+  *    Added support to display pathnames of most fragmented files.
+  *    Also added flag to support user-specified number of fragmented
+  *    files to report. Based on code developed by Chip Rosenthal
+  *    (chip at vector.UUCP).
+  *
+  * Fri Jan 20 09:42:14 EST 1989 - M. Young (mjy at sdti.SDTI.COM),
+  *    Added '-s' flag.
   */
  
  #include "fsconfig.h"
***************
*** 81,86
                                           * examined */
  boolean override      = FALSE;          /* override bad fs test */
  
  /*
   * version : prints out the current version of fsanalyze
   */

--- 90,104 -----
                                           * examined */
  boolean override      = FALSE;          /* override bad fs test */
  
+ boolean show_names    = FALSE;		/* display pathname of severly
+ 					 * fragmanted i-nodes */
+ 
+ int num_fragmented    = NUMOFFEND;	/* number of most-fragmented
+ 					 * files to report */
+ 
+ boolean status_flag   = FALSE;		/* if TRUE, display progress
+ 					 * on stderr */
+ 
  /*
   * version : prints out the current version of fsanalyze
   */
***************
*** 86,92
   */
  void version(){
      printf ("\nFile System Analyzer\n");
!     printf ("Version : 4.1 - 89/01/10 10:49:22, Patch Level #%d\n", patch_level);
      }
  
  /*

--- 104,110 -----
   */
  void version(){
      printf ("\nFile System Analyzer\n");
!     printf ("Version : 4.2 - 89/01/20 10:11:26, Patch Level #%d\n", patch_level);
      }
  
  /*
***************
*** 95,101
   */
  void usage(){
      version();
!     printf ("Usage   : fsanalyze [-[deio] [-b#] [-c#] [-g#] ] special [file] ...\n");
      printf ("\nIf the [file] argument(s) are missing, the entire file system\n");
      printf ("is scanned.  Otherwise, only the specified files are examined.\n");
      printf ("Valid option are:\n\n");

--- 113,119 -----
   */
  void usage(){
      version();
!     printf ("Usage   : fsanalyze [-[deinosv] [-b#] [-c#] [-g#] [-t#] ] special [file] ...\n");
      printf ("\nIf the [file] argument(s) are missing, the entire file system\n");
      printf ("is scanned.  Otherwise, only the specified files are examined.\n");
      printf ("Valid option are:\n\n");
***************
*** 108,113
      printf ("\tg#\tassume an inter-block gap of '#' sectors;\n");
      printf ("\t\toverrides information contained in superblock.\n");
      printf ("\ti\treport data block double and triple indirection\n");
      printf ("\to\toverride error checking on file system argument\n");
      printf ("\tv\tdisplay current version number and patch level\n");
      exit(1);

--- 126,132 -----
      printf ("\tg#\tassume an inter-block gap of '#' sectors;\n");
      printf ("\t\toverrides information contained in superblock.\n");
      printf ("\ti\treport data block double and triple indirection\n");
+     printf ("\tn\tdisplay pathnames of most fragmented files.\n");
      printf ("\to\toverride error checking on file system argument\n");
      printf ("\ts\tdisplay progress messages on stderr\n");
      printf ("\tt#\tnumber of most-fragmented files to be reported\n");
***************
*** 109,114
      printf ("\t\toverrides information contained in superblock.\n");
      printf ("\ti\treport data block double and triple indirection\n");
      printf ("\to\toverride error checking on file system argument\n");
      printf ("\tv\tdisplay current version number and patch level\n");
      exit(1);
      }

--- 128,135 -----
      printf ("\ti\treport data block double and triple indirection\n");
      printf ("\tn\tdisplay pathnames of most fragmented files.\n");
      printf ("\to\toverride error checking on file system argument\n");
+     printf ("\ts\tdisplay progress messages on stderr\n");
+     printf ("\tt#\tnumber of most-fragmented files to be reported\n");
      printf ("\tv\tdisplay current version number and patch level\n");
      exit(1);
      }
***************
*** 223,229
  int argc;
  char *argv[];
  {
!     int i;                             /* loop counter */
      char *cp;                          /* cmd-line flag pointer */
      boolean special_found = FALSE;     /* TRUE = found special arg */
      boolean done;                      /* means of escaping while loop

--- 244,250 -----
  int argc;
  char *argv[];
  {
!     int i,j;                           /* loop counter */
      char *cp;                          /* cmd-line flag pointer */
      boolean special_found = FALSE;     /* TRUE = found special arg */
      boolean done;                      /* means of escaping while loop
***************
*** 300,305
                          rpt_indirects = TRUE;
                          break;
  
                          /* override bad fs test */
                      case 'o':
                          override = TRUE;

--- 321,333 -----
                          rpt_indirects = TRUE;
                          break;
  
+ 
+ 			/* display pathname of severly
+ 			 * fragmanted i-nodes */
+ 		    case 'n':
+ 			show_names = TRUE;
+ 			break;
+ 
                          /* override bad fs test */
                      case 'o':
                          override = TRUE;
***************
*** 305,310
                          override = TRUE;
                          break;
  
                      case 'v':
                          version();
  			exit(0);

--- 333,358 -----
                          override = TRUE;
                          break;
  
+ 			/* display status messages */
+ 		    case 's':
+ 			status_flag = TRUE;
+ 			break;
+ 
+ 			/* number of fragmented files to report */
+                     case 't':
+                         if (cp[1]){
+                             num_fragmented = atoi (++cp);
+                             done = TRUE;      /* force end of while loop */
+                             }
+                         else {
+                             num_fragmented = atoi (argv[++i]);
+                             }
+                         if (num_fragmented < 0){
+                             fprintf (stderr, "Illegal value for 't' option.  Assuming 0\n");
+ 			    num_fragmented = 0;
+                             }
+                         break;
+ 
                      case 'v':
                          version();
  			exit(0);
***************
*** 343,348
         cyl_size = sec_per_cyl(fil_sys);
         }
      
      return i;                /* return # of next argument to be processed */
      }
  

--- 391,406 -----
         cyl_size = sec_per_cyl(fil_sys);
         }
      
+     /*
+      * create and initialize worst-fragmented array
+      */
+     if (num_fragmented != 0){
+ 	file_log = (struct file_data *)Smalloc (num_fragmented * sizeof (struct file_data));
+ 	for (j = 0; j < num_fragmented; j++){
+ 	    init_stats (&file_log[j], 0, 0L);
+ 	    }
+ 	}
+ 
      return i;                /* return # of next argument to be processed */
      }
  
Index: patchlevel.h
Prereq: 4.1.1.2
*** ../prev/patchlevel.h	Fri Jan 20 10:14:16 1989
--- patchlevel.h	Fri Jan 20 10:14:54 1989
***************
*** 1,4
! /* @(#)$Id: patchlevel.h, V4.1.1.2 89/01/10 10:49:29 $ */
  
  /*
   * patchlevel.h - current patch level

--- 1,4 -----
! /* @(#)$Id: patchlevel.h, V4.2 89/01/20 10:11:33 $ */
  
  /*
   * patchlevel.h - current patch level
***************
*** 2,8
  
  /*
   * patchlevel.h - current patch level
!  * Version  : 4.1.1.2 - 89/01/10 10:49:29
   *
   * Author   : Michael J. Young
   * USmail   : Software Development Technologies, Inc.

--- 2,8 -----
  
  /*
   * patchlevel.h - current patch level
!  * Version  : 4.2 - 89/01/20 10:11:33
   *
   * Author   : Michael J. Young
   * USmail   : Software Development Technologies, Inc.
***************
*** 22,26
   * =========================================================================
   */
  
! #define patch_level 2
  

--- 22,26 -----
   * =========================================================================
   */
  
! #define patch_level 0
  
Index: report.c
Prereq: 4.1.1.2
*** ../prev/report.c	Fri Jan 20 10:14:18 1989
--- report.c	Fri Jan 20 10:14:55 1989
***************
*** 1,4
! static char sccsid[] = "@(#)$Id: report.c, V4.1.1.2 89/01/10 10:49:31 $";
  
  /*
   * report.c - print analysis report

--- 1,4 -----
! static char sccsid[] = "@(#)$Id: report.c, V4.2 89/01/20 10:11:36 $";
  
  /*
   * report.c - print analysis report
***************
*** 2,8
  
  /*
   * report.c - print analysis report
!  * Version  : 4.1.1.2 - 89/01/10 10:49:31
   *
   * Author   : Michael J. Young
   * USmail   : Software Development Technologies, Inc.

--- 2,8 -----
  
  /*
   * report.c - print analysis report
!  * Version  : 4.2 - 89/01/20 10:11:36
   *
   * Author   : Michael J. Young
   * USmail   : Software Development Technologies, Inc.
***************
*** 40,45
   * 
   * Thu Jan  5 10:31:21 EST 1989 - Rob McMahon (cudcv at warwick.ac.uk),
   *    Added conditionals for NFS file systems
   */
  
  #include "fsconfig.h"

--- 40,53 -----
   * 
   * Thu Jan  5 10:31:21 EST 1989 - Rob McMahon (cudcv at warwick.ac.uk),
   *    Added conditionals for NFS file systems
+  *
+  * Tue Jan 10 14:12:01 EST 1989 - M. Young (mjy at sdti.SDTI.COM),
+  *    Added support to display pathnames of most fragmented files.
+  *    Also permits user to specify number of most-fragmented files to report.
+  *    Based heavily on code developed by Chip Rosenthal (chip at vector.UUCP).
+  *
+  * Fri Jan 20 09:40:46 EST 1989 - M. Young (mjy at sdti.SDTI.COM),
+  *    Added '-s' flag.
   */
  
  #include "fsconfig.h"
***************
*** 46,51
  #include "fsanalyze.h"
  
  /*
   * print_report : calculates percentages and prints a summary report of
   * file system statistics
   */

--- 54,149 -----
  #include "fsanalyze.h"
  
  /*
+  * printstats : displays the statistics of the specified file.  If the
+  * argument is NULL, a page header is displayed instead.
+  */
+ void printstats(f)
+ struct file_data *f;
+ {
+     if ( f == NULL ) {
+ 	printf(" i-node  Size  Fragments   %%      Dist ");
+         }
+     else {
+ 	printf("%6d %6ld   %6ld  %6.2f%% %6.1f",
+ 	       f->inode, f->total_blocks, f->seeks+1, f->fragm*100, f->rel_cost);
+         }
+     }
+ 
+ 
+ /*
+  * get_pathnames() - find names of the most fragmented files
+  */
+ #ifndef LPNMAX
+ # define LPNMAX 128
+ #endif
+ 
+ void get_pathnames()
+ {
+     static char buf[1024], path[LPNMAX];
+     char *c;
+     int i, n;
+     FILE *pp;
+     extern char *strcpy(), *strcat(), *malloc(), *realloc();
+ 
+     if (status_flag){
+ 	fprintf (stderr, "Scanning for pathnames of most fragmented files...\n");
+         }
+ 
+     /*
+      * Initialize the pathnames list.
+      */
+     for ( i = 0 ; i < num_fragmented ; ++i ){
+ 	file_log[i].pathname = NULL;
+         }
+ 
+     (void) strcpy(buf,"ncheck -i ");
+     for ( i = 0 ; i < num_fragmented && file_log[i].inode > 0 ; ++i ) {
+ 	c = buf + strlen(buf);
+ 	(void) sprintf(c,"%d ",(int)file_log[i].inode);
+         }
+     (void) strcat(buf,special);
+ 
+     if ( (pp=popen(buf,"r")) == (FILE *) NULL ) {
+ 	perror("pipe to 'ncheck'");
+ 	return;
+         }
+ 
+     /*
+      * Sample "ncheck" output"
+      *   /dev/root:
+      *   1563	/bin/adb
+      *   2566	/bin/rmail
+      *   2566	/bin/smail
+      *   2547	/etc/fsanalyze
+      *   2583	/etc/renice
+      *   2368	/usr/lib/Llibccgi.a
+      */
+     while ( fgets(buf,sizeof buf,pp) != NULL ) {
+ 	if ( sscanf(buf,"%d %s",&n,path) != 2 || n <= 0 ){
+ 	    continue;
+ 	    }
+ 	for ( i = 0 ; i < num_fragmented ; ++i ) {
+ 	    if ( file_log[i].inode != n ){
+ 		continue;
+ 	        }
+ 	    if ( file_log[i].pathname == NULL ) {
+ 		file_log[i].pathname = Srealloc(NULL,strlen(path)+1);
+ 		(void) strcpy(file_log[i].pathname,path);
+ 	        }
+             else {
+ 		file_log[i].pathname = Srealloc(file_log[i].pathname,
+ 			strlen(file_log[i].pathname)+strlen(path)+3);
+ 		(void) strcat(file_log[i].pathname,", ");
+ 		(void) strcat(file_log[i].pathname,path);
+ 	        }
+ 	    }
+         }
+ 
+     (void) pclose(pp);
+     return;
+     }
+ 
+ /*
   * print_report : calculates percentages and prints a summary report of
   * file system statistics
   */
***************
*** 49,55
   * print_report : calculates percentages and prints a summary report of
   * file system statistics
   */
! void print_report (){
      char    minibuf[32];          /* line buffer */
      long    num_files;            /* number of inodes used
                                     * in file system */

--- 147,154 -----
   * print_report : calculates percentages and prints a summary report of
   * file system statistics
   */
! void print_report ()
! {
      char    minibuf[32];          /* line buffer */
      long    num_files;            /* number of inodes used
                                     * in file system */
***************
*** 76,81
              wasted_p;             /* wasted space due to external frag */
  
      /*
       * calculate percentages for report
       */
      fragm = potential_seeks ? (float)seeks/(float)potential_seeks : 0.0;

--- 175,186 -----
              wasted_p;             /* wasted space due to external frag */
  
      /*
+      * get names of severly fragmented files
+      */
+     if ( show_names )
+ 	get_pathnames();
+ 
+     /*
       * calculate percentages for report
       */
      fragm = potential_seeks ? (float)seeks/(float)potential_seeks : 0.0;
***************
*** 167,191
          sparse_files, sparse_p*100);
      printf ("Unused bytes in last blocks = %ld (%.2f%%)\n",
          unuseable, wasted_p*100);
!     printf ("                            %d Most Fragmented Files\n",NUMOFFEND);
!     printf (" i-node  Size  Fragments   %%      Dist  i-node  Size  Fragments   %%       Dist\n");
!     for (i = 0; i < NUMOFFEND/2; i++){
!         if (file_log[i].inode != 0){
!             printf ("%6d %6ld   %6ld  %6.2f%% %6.1f",
!                 file_log[i].inode,
!                 file_log[i].total_blocks,
!                 file_log[i].seeks+1,
!                 file_log[i].fragm*100,
!                 file_log[i].rel_cost);
!             if (file_log[i+(NUMOFFEND/2)].inode != 0){
!                 printf (" %6d %6ld   %6ld  %6.2f%%  %6.1f",
!                     file_log[i+(NUMOFFEND/2)].inode,
!                     file_log[i+(NUMOFFEND/2)].total_blocks,
!                     file_log[i+(NUMOFFEND/2)].seeks+1,
!                     file_log[i+(NUMOFFEND/2)].fragm*100,
!                     file_log[i+(NUMOFFEND/2)].rel_cost);
!                 }
!             printf ("\n");
              }
          else break;
          }

--- 272,288 -----
          sparse_files, sparse_p*100);
      printf ("Unused bytes in last blocks = %ld (%.2f%%)\n",
          unuseable, wasted_p*100);
!     if (num_fragmented != 0){
!         printf ("                            %d Most Fragmented Files\n",num_fragmented);
! 
!         if ( show_names ) {
! 	    printstats(NULL);
! 	    printf(" Pathname\n");
! 	    for ( i = 0 ; i < num_fragmented && file_log[i].inode != 0 ; i++ ) {
! 	        printstats(&file_log[i]);
! 	        printf("  %s\n", ( file_log[i].pathname != NULL ?
! 		    file_log[i].pathname : "<unknown>" ) );
! 	        }
              }
          else {
  	    printstats(NULL);
***************
*** 187,193
                  }
              printf ("\n");
              }
!         else break;
          }
      }
  

--- 284,305 -----
  		    file_log[i].pathname : "<unknown>" ) );
  	        }
              }
!         else {
! 	    printstats(NULL);
! 	    putchar(' ');
! 	    printstats(NULL);
! 	    putchar('\n');
! 	    for (i = 0 ; i < (num_fragmented+1)/2; i++){
! 		if (file_log[i].inode != 0){
! 	            printstats(&file_log[i]);
! 		    if ((i + (num_fragmented+1)/2) < num_fragmented && 
! 			file_log[i+(num_fragmented+1)/2].inode != 0){
! 			printf ("  ");
! 	                printstats(&file_log[i+(num_fragmented+1)/2]);
! 	                }
! 	            putchar('\n');
! 		    }
! 	        }
!             }
          }
      }
***************
*** 190,193
          else break;
          }
      }
- 

--- 303,305 -----
              }
          }
      }

Index: stats.c
Prereq: 4.1
*** ../prev/stats.c	Fri Jan 20 10:13:01 1989
--- stats.c	Fri Jan 20 10:14:56 1989
***************
*** 1,4
! static char sccsid[] = "@(#)$Id: stats.c, V4.1 88/11/16 17:31:26 $";
  
  /*
   * stats.c - file system statistics

--- 1,4 -----
! static char sccsid[] = "@(#)$Id: stats.c, V4.2 89/01/20 10:11:44 $";
  
  /*
   * stats.c - file system statistics
***************
*** 2,8
  
  /*
   * stats.c - file system statistics
!  * Version  : 4.1 - 88/11/16 17:31:26
   *
   * Author   : Michael J. Young
   * USmail   : Software Development Technologies, Inc.

--- 2,8 -----
  
  /*
   * stats.c - file system statistics
!  * Version  : 4.2 - 89/01/20 10:11:44
   *
   * Author   : Michael J. Young
   * USmail   : Software Development Technologies, Inc.
***************
*** 33,38
   *
   * Wed Nov 16 11:31:32 EST 1988 - M. Young (mjy at sdti.SDTI.COM),
   *    Placed under SCCS
   */
  
  #include "fsconfig.h"

--- 33,41 -----
   *
   * Wed Nov 16 11:31:32 EST 1988 - M. Young (mjy at sdti.SDTI.COM),
   *    Placed under SCCS
+  *
+  * Tue Jan 10 15:41:38 EST 1989 - M. Young (mjy at sdti.SDTI.COM),
+  *    Support for user-specified number of most-fragmented files to report
   */
  
  #include "fsconfig.h"
***************
*** 71,77
  long unuseable           = 0;           /* unuseable bytes due to external
                                           * fragmentation */
  
! struct file_data file_log[NUMOFFEND] = {0};    /* worst offenders */
  
  /*
   * init_stats : initializes per-file statistics structure

--- 74,80 -----
  long unuseable           = 0;           /* unuseable bytes due to external
                                           * fragmentation */
  
! struct file_data *file_log = NULL;      /* worst offenders */
  
  /*
   * init_stats : initializes per-file statistics structure
***************
*** 124,130
      /*
       * update worst offender array
       */
!     for (i = 0; i < NUMOFFEND; i++){
          if (data->seeks > file_log[i].seeks){
              for (j = NUMOFFEND-1; j > i; j--){
                  file_log[j] = file_log[j-1];

--- 127,133 -----
      /*
       * update worst offender array
       */
!     for (i = 0; i < num_fragmented; i++){
          if (data->seeks > file_log[i].seeks){
              for (j = num_fragmented-1; j > i; j--){
                  file_log[j] = file_log[j-1];
***************
*** 126,132
       */
      for (i = 0; i < NUMOFFEND; i++){
          if (data->seeks > file_log[i].seeks){
!             for (j = NUMOFFEND-1; j > i; j--){
                  file_log[j] = file_log[j-1];
                  }
              file_log[i] = *data;

--- 129,135 -----
       */
      for (i = 0; i < num_fragmented; i++){
          if (data->seeks > file_log[i].seeks){
!             for (j = num_fragmented-1; j > i; j--){
                  file_log[j] = file_log[j-1];
                  }
              file_log[i] = *data;

Index: util.c
Prereq: 4.1.1.1
*** ../prev/util.c	Fri Jan 20 10:14:19 1989
--- util.c	Fri Jan 20 10:14:57 1989
***************
*** 1,4
! static char sccsid[] = "@(#)$Id: util.c, V4.1.1.1 89/01/10 10:49:39 $";
  
  /*
   * util.c - inode utilities

--- 1,4 -----
! static char sccsid[] = "@(#)$Id: util.c, V4.2 89/01/20 10:11:48 $";
  
  /*
   * util.c - inode utilities
***************
*** 2,8
  
  /*
   * util.c - inode utilities
!  * Version  : 4.1.1.1 - 89/01/10 10:49:39
   *
   * Author   : Michael J. Young
   * USmail   : Software Development Technologies, Inc.

--- 2,8 -----
  
  /*
   * util.c - inode utilities
!  * Version  : 4.2 - 89/01/20 10:11:48
   *
   * Author   : Michael J. Young
   * USmail   : Software Development Technologies, Inc.
***************
*** 36,41
   *
   * Thu Jan  5 10:29:19 EST 1989 - Rob McMahon (cudcv at warwick.ac.uk),
   *    Added conditionals for NFS file systems
   */
  
  #include "fsconfig.h"

--- 36,45 -----
   *
   * Thu Jan  5 10:29:19 EST 1989 - Rob McMahon (cudcv at warwick.ac.uk),
   *    Added conditionals for NFS file systems
+  *
+  * Tue Jan 10 14:21:03 EST 1989 - M. Young (mjy at sdti.SDTI.COM),
+  *    Added Srealloc() and Smalloc(), based on code by Chip Rosenthal
+  *    (chip at vector.UUCP)
   */
  
  #include "fsconfig.h"
***************
*** 88,92
              /* NOTREACHED */
              }
          }
      }
  

--- 92,129 -----
              /* NOTREACHED */
              }
          }
+     }
+ 
+ /*
+  * Smalloc : safe malloc()
+  */
+ char *Smalloc(size)
+ int size;
+ {
+     char *s;
+     extern char *malloc(), *realloc();
+ 
+     s = malloc(size);
+     if ( s == NULL ) {
+ 	error (0, "malloc: out of space\n");
+         }
+     return s;
+     }
+ 
+ /*
+  * Srealloc : safe realloc()
+  */
+ char *Srealloc(ptr,size)
+ char *ptr;
+ int size;
+ {
+     char *s;
+     extern char *malloc(), *realloc();
+ 
+     s = ( ptr == NULL ? malloc(size) : realloc(ptr,size) );
+     if ( s == NULL ) {
+ 	error (0, "malloc: out of space\n");
+         }
+     return s;
      }
  
-- 
Mike Young
Software Development Technologies, Inc., Sudbury MA       Tel: +1 508 443 5779
Internet: mjy at sdti.sdti.com                 UUCP: {harvard,mit-eddie}!sdti!mjy



More information about the Comp.sources.bugs mailing list