ReactOS Fundraising Campaign 2012
 
€ 3,873 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

Definition at line 260 of file fat.c.

Referenced by VfatChkdsk().

{
    DOS_FILE dummy;
    int reclaimed,files,changed;
    unsigned long i,next,walk;

    if (FsCheckFlags & FSCHECK_VERBOSE)
    VfatPrint("Reclaiming unconnected clusters.\n");
    for (i = 2; i < fs->clusters+2; i++) fs->fat[i].prev = 0;
    for (i = 2; i < fs->clusters+2; i++) {
    next = fs->fat[i].value;
    if (!get_owner(fs,i) && next && next < fs->clusters+2) {
        if (get_owner(fs,next) || !fs->fat[next].value ||
        FAT_IS_BAD(fs,fs->fat[next].value)) set_fat(fs,i,-1);
        else fs->fat[next].prev++;
    }
    }
    do {
    tag_free(fs,&dummy);
    changed = 0;
    for (i = 2; i < fs->clusters+2; i++)
        if (fs->fat[i].value && !FAT_IS_BAD(fs,fs->fat[i].value) &&
        !get_owner(fs, i)) {
        if (!fs->fat[fs->fat[i].value].prev--)
            die("Internal error: prev going below zero");
        set_fat(fs,i,-1);
        changed = 1;
        VfatPrint("Broke cycle at cluster %lu in free chain.\n",i);
        break;
        }
    }
    while (changed);
    files = reclaimed = 0;
    for (i = 2; i < fs->clusters+2; i++)
    if (get_owner(fs,i) == &dummy && !fs->fat[i].prev) {
        DIR_ENT de;
        loff_t offset;
        files++;
        offset = alloc_rootdir_entry(fs,&de,"FSCK%04dREC");
        de.start = CT_LE_W(i&0xffff);
        if (fs->fat_bits == 32)
        de.starthi = CT_LE_W(i>>16);
        for (walk = i; walk > 0 && walk != -1;
         walk = next_cluster(fs,walk)) {
        de.size = CT_LE_L(CF_LE_L(de.size)+fs->cluster_size);
        reclaimed++;
        }
        fs_write(offset,sizeof(DIR_ENT),&de);
    }
    if (reclaimed)
    VfatPrint("Reclaimed %d unused cluster%s (%d bytes) in %d chain%s.\n",
      reclaimed,reclaimed == 1 ? "" : "s",reclaimed*fs->cluster_size,files,
      files == 1 ? "" : "s");
}

Generated on Sat May 19 2012 04:45:30 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.