Beispiel #1
0
int file_cvt(unsigned char *name,unsigned char *fixed)
{
    unsigned char c;
    int size,ext,cnt;

    size = 8;
    ext = 0;
    while (*name) {
	c = *name;
	if (c < ' ' || c > 0x7e || strchr("*?<>|\"/",c)) {
	    VfatPrint("Invalid character in name. Use \\ooo for special "
	      "characters.\n");
	    return 0;
	}
	if (c == '.') {
	    if (ext) {
		VfatPrint("Duplicate dots in name.\n");
		return 0;
	    }
	    while (size--) *fixed++ = ' ';
	    size = 3;
	    ext = 1;
	    name++;
	    continue;
	}
	if (c == '\\') {
	    c = 0;
	    for (cnt = 3; cnt; cnt--) {
		if (*name < '0' || *name > '7') {
		    VfatPrint("Invalid octal character.\n");
		    return 0;
		}
		c = c*8+*name++-'0';
	    }
	    if (cnt < 4) {
		VfatPrint("Expected three octal digits.\n");
		return 0;
	    }
	    name += 3;
	}
	if (islower(c)) c = toupper(c);
	if (size) {
	    *fixed++ = c;
	    size--;
	}
	name++;
    }
    if (*name || size == 8) return 0;
    if (!ext) {
	while (size--) *fixed++ = ' ';
	size = 3;
    }
    while (size--) *fixed++ = ' ';
    return 1;
}
Beispiel #2
0
void file_modify(FDSC **curr,unsigned char *fixed)
{
    FDSC **this,*next;

    if (!(this = file_find(curr,(char *)fixed)))
	die("Internal error: file_find failed");
    switch ((*this)->type) {
	case fdt_drop:
	    VfatPrint("Dropping %s\n",file_name(fixed));
	    *fixed = DELETED_FLAG;
	    break;
	case fdt_undelete:
	    *fixed = *(*this)->name;
	    VfatPrint("Undeleting %s\n",file_name(fixed));
	    break;
	default:
	    die("Internal error: file_modify");
    }
    next = (*this)->next;
    vffree(*this);
    *this = next;
}
Beispiel #3
0
NTSTATUS
WINAPI
VfatChkdsk(IN PUNICODE_STRING DriveRoot,
           IN BOOLEAN FixErrors,
           IN BOOLEAN Verbose,
           IN BOOLEAN CheckOnlyIfDirty,
           IN BOOLEAN ScanDrive,
           IN PFMIFSCALLBACK Callback)
{
#if 0
    BOOLEAN verify;
    BOOLEAN salvage_files;
#endif
    //ULONG free_clusters;
    //DOS_FS fs;

    /* Store callback pointer */
    ChkdskCallback = Callback;
    FsCheckMemQueue = NULL;

    /* Set parameters */
    FsCheckFlags = 0;
    if (Verbose)
        FsCheckFlags |= FSCHECK_VERBOSE;

    FsCheckTotalFiles = 0;

#if 0
    verify = TRUE;
    salvage_files = TRUE;

    /* Open filesystem */
    fs_open(DriveRoot,FixErrors);

    if (CheckOnlyIfDirty && !fs_isdirty())
    {
        /* No need to check FS */
        return fs_close(FALSE);
    }

    read_boot(&fs);
    if (verify)
        VfatPrint("Starting check/repair pass.\n");

    while (read_fat(&fs), scan_root(&fs))
        qfree(&FsCheckMemQueue);

    if (ScanDrive)
        fix_bad(&fs);

    if (salvage_files)
        reclaim_file(&fs);
    else
        reclaim_free(&fs);

    free_clusters = update_free(&fs);
    file_unused();
    qfree(&FsCheckMemQueue);
    if (verify)
    {
        VfatPrint("Starting verification pass.\n");
        read_fat(&fs);
        scan_root(&fs);
        reclaim_free(&fs);
        qfree(&FsCheckMemQueue);
    }

    if (fs_changed())
    {
        if (FixErrors)
        {
            if (FsCheckFlags & FSCHECK_INTERACTIVE)
                FixErrors = get_key("yn","Perform changes ? (y/n)") == 'y';
            else
                VfatPrint("Performing changes.\n");
        }
        else
        {
            VfatPrint("Leaving file system unchanged.\n");
        }
    }

    VfatPrint("%wZ: %u files, %lu/%lu clusters\n", DriveRoot,
        FsCheckTotalFiles, fs.clusters - free_clusters, fs.clusters );

    if (FixErrors)
    {
        /* Dismount the volume */
        fs_dismount();

        /* Unlock the volume */
        fs_lock(FALSE);
    }

    /* Close the volume */
    return fs_close(FixErrors) ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL;
#else
    return STATUS_SUCCESS;
#endif
}