[comp.sys.att] Patch #1 to bf

brant@manta.pha.pa.us (Brant Cheikes) (05/24/89)

Peter Fales (psfales@ihlpb.att.com) found and fixed a bug in bf, the
block->inode mapping utility that I posted some months back.  Herewith
is a patch file correcting that bug and making a few other minor
source tweaks.

*** bf.c-old	Tue May 23 20:38:27 1989
--- bf.c	Wed May 24 00:54:34 1989
***************
*** 1,5
  /*
!  * bf.c 1.0
   * Search filesystem for particular blocks, returning corresponding inodes.
   *
   * Brant Cheikes

--- 1,5 -----
  /*
!  * bf.c 1.1
   * Search filesystem for particular blocks, returning corresponding inodes.
   *
   * Brant Cheikes
***************
*** 6,12
   * University of Pennsylvania, Department of Computer and Information Science
   * brant@manta.pha.pa.us, brant@linc.cis.upenn.edu, bpa!manta!brant
   *
!  * Copyright (C) 1989 Brant A. Cheikes.  All rights reserved.
   *
   * bf is distributed in the hope that it will be useful, but WITHOUT ANY
   * WARRANTY.  No author or distributor accepts responsibility to anyone

--- 6,12 -----
   * University of Pennsylvania, Department of Computer and Information Science
   * brant@manta.pha.pa.us, brant@linc.cis.upenn.edu, bpa!manta!brant
   *
!  * Copyright (c) 1989 Brant A. Cheikes.  All rights reserved.
   *
   * bf is distributed in the hope that it will be useful, but WITHOUT ANY
   * WARRANTY.  No author or distributor accepts responsibility to anyone
***************
*** 17,22
   * but only under the conditions described in the GNU General Public License.
   * Among other things, the copyright notice and this notice must be preserved
   * on all copies.
   */
  
  #define KERNEL

--- 17,29 -----
   * but only under the conditions described in the GNU General Public License.
   * Among other things, the copyright notice and this notice must be preserved
   * on all copies.
+  *
+  * Modification History:
+  *  1.1		Tue May 23 20:40:03 EDT 1989
+  *	Peter Fales (att!ihlpb!psfales, psfales@ihlpb.att.com)
+  *	reported a bug in which the first three blocks in the
+  *	filesystem were incorrectly treated as part of the i-list.
+  *	Some other minor fixups too, while I'm at it.
   */
  
  #define KERNEL
***************
*** 98,104
      } else if (blk == 1) {
        (void) puts("block 1 reserved");
        --nblk;
!     } else if (blk < superblk.s_isize+3) {
        (void) printf("block %ld in i-list\n",blk);
        --nblk;
      } else if (blk > superblk.s_fsize) {

--- 105,111 -----
      } else if (blk == 1) {
        (void) puts("block 1 reserved");
        --nblk;
!     } else if (blk < superblk.s_isize) {
        (void) printf("block %ld in i-list\n",blk);
        --nblk;
      } else if (blk > superblk.s_fsize) {
***************
*** 102,108
        (void) printf("block %ld in i-list\n",blk);
        --nblk;
      } else if (blk > superblk.s_fsize) {
!       (void) printf("block %ld outside fs\n",blk);
        --nblk;
      } else
        /*

--- 109,115 -----
        (void) printf("block %ld in i-list\n",blk);
        --nblk;
      } else if (blk > superblk.s_fsize) {
!       (void) printf("block %ld outside file system\n",blk);
        --nblk;
      } else
        /*
***************
*** 112,118
    }
  
    /*
!    * Verify that we still have blocks to look for.
     */
    if (nblk == 0)
      barf("feh! no blocks",0);

--- 119,125 -----
    }
  
    /*
!    * Look for all blocks that remain.
     */
    if (nblk)
      (void) done(scan_ilist(fsdev,&superblk,nblk,bitmap));
***************
*** 114,126
    /*
     * Verify that we still have blocks to look for.
     */
!   if (nblk == 0)
!     barf("feh! no blocks",0);
! 
!   /*
!    * Scan the allocated block list.
!    */
!   (void) done(scan_ilist(fsdev,&superblk,nblk,bitmap));
  }
  
  /*

--- 121,128 -----
    /*
     * Look for all blocks that remain.
     */
!   if (nblk)
!     (void) done(scan_ilist(fsdev,&superblk,nblk,bitmap));
  }
  
  /*
***************
*** 340,346
    if (s > 0)
      (void) perror(msg);
    else
!     (void) fprintf(stderr,"%s\n",msg);
    done(s);
  }
  

--- 342,348 -----
    if (s > 0)
      (void) perror(msg);
    else
!     (void) fprintf(stderr,"internal error: %s\n",msg);
    done(s);
  }
  
-- 
Brant Cheikes
University of Pennsylvania, Department of Computer and Information Science
brant@manta.pha.pa.us, brant@linc.cis.upenn.edu, bpa!manta!brant

kevin@kosman.UUCP (Kevin O'Gorman) (06/02/89)

In article <479@manta.pha.pa.us>, brant@manta.pha.pa.us (Brant Cheikes) writes:
> Peter Fales (psfales@ihlpb.att.com) found and fixed a bug in bf, the
> block->inode mapping utility that I posted some months back.  Herewith
> is a patch file correcting that bug and making a few other minor
> source tweaks.

I have bf, archived back in February.  I tried applying the patch, and only
part of it took.  Some with big offsets and fuzz factors

> 
> *** bf.c-old	Tue May 23 20:38:27 1989
> --- bf.c	Wed May 24 00:54:34 1989

The last two hunks fail completely

> ***************
> *** 114,126
>     /*
>      * Verify that we still have blocks to look for.
>      */
> !   if (nblk == 0)
> !     barf("feh! no blocks",0);
> ! 
> !   /*
> !    * Scan the allocated block list.
> !    */
> !   (void) done(scan_ilist(fsdev,&superblk,nblk,bitmap));
>   }
>   
>   /*
> 
> --- 121,128 -----
>     /*
>      * Look for all blocks that remain.
>      */
> !   if (nblk)
> !     (void) done(scan_ilist(fsdev,&superblk,nblk,bitmap));
>   }
>   
>   /*

<This tries to match up with the original:
<
<  /*
<   * Verify that we still have blocks to look for.
<   */
<  if (nblk == 0) {
<    (void) puts("feh! no blocks");
<    exit(0);
<  }
<
<  /*
<   * Scan the allocated block list.
<   */
<  return(scan_ilist(fsdev,&superblk,nblk,bitmap));
<}

Were there two copies of the original posted?  The header I have looks like
this:

<Path: kosman!srhqla!denwa!gryphon!lll-winken!uunet!xanth!nic.MR.NET!csd4.milw.wisc.edu!mailrus!rutgers!bpa!manta!brant
<From: brant@manta.pha.pa.us (Brant Cheikes)
<Newsgroups: unix-pc.sources
<Subject: bf: find blocks in inodes
<Keywords: blocks inodes files
<Message-ID: <466@manta.pha.pa.us>
<Date: 13 Feb 89 19:15:05 GMT
<Reply-To: brant@manta.pha.pa.us (Brant Cheikes)
<Distribution: unix-pc
<Organization: Soul of the Gnu Machine, Philadelphia
<Lines: 365