Changeset 107 for trunk/lib


Ignore:
Timestamp:
04/18/08 00:51:21 (16 years ago)
Author:
tim
Message:

removed redundant hbin parsing

added flags parameter to regfi_open

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/regfi.c

    r106 r107  
    883883 * first hbin offset.
    884884 *******************************************************************/
    885 REGF_FILE* regfi_open(const char* filename)
     885REGF_FILE* regfi_open(const char* filename, uint32 flags)
    886886{
    887887  REGF_FILE* rb;
     
    889889  uint32 hbin_off;
    890890  int fd;
    891   int flags = O_RDONLY;
    892   bool rla;
     891  bool rla, save_unalloc = false;
     892
     893  if(flags & REGFI_FLAG_SAVE_UNALLOC)
     894    save_unalloc = true;
    893895
    894896  /* open an existing file */
    895   if ((fd = open(filename, flags)) == -1)
     897  if ((fd = open(filename, O_RDONLY)) == -1)
    896898  {
    897899    /* DEBUG(0,("regfi_open: failure to open %s (%s)\n", filename, strerror(errno)));*/
     
    920922  rla = true;
    921923  hbin_off = REGF_BLOCKSIZE;
    922   hbin = regfi_parse_hbin(rb, hbin_off, true, false);
     924  hbin = regfi_parse_hbin(rb, hbin_off, true, save_unalloc);
    923925  while(hbin && rla)
    924926  {
    925927    hbin_off = hbin->file_off + hbin->block_size;
    926928    rla = range_list_add(rb->hbins, hbin->file_off, hbin->block_size, hbin);
    927     hbin = regfi_parse_hbin(rb, hbin_off, true, false);
     929    hbin = regfi_parse_hbin(rb, hbin_off, true, save_unalloc);
    928930  }
    929931
     
    968970  REGF_NK_REC* nk = NULL;
    969971  REGF_HBIN*   hbin;
    970   uint32       offset = REGF_BLOCKSIZE;
    971   uint32       root_offset;
     972  uint32       root_offset, i, num_hbins;
    972973 
    973974  if(!file)
     
    979980     block (but I'm not assuming that for now) */
    980981
    981   while((hbin = regfi_parse_hbin(file, offset, true, false)))
    982   {
     982  num_hbins = range_list_size(file->hbins);
     983  for(i=0; i < num_hbins; i++)
     984  {
     985    hbin = (REGF_HBIN*)range_list_get(file->hbins, i)->data;
    983986    if(regfi_find_root_nk(file, hbin->file_off+HBIN_HEADER_REC_SIZE,
    984987                          hbin->block_size-HBIN_HEADER_REC_SIZE, &root_offset))
     
    987990      break;
    988991    }
    989 
    990     offset += hbin->block_size;
    991992  }
    992993
Note: See TracChangeset for help on using the changeset viewer.