FAT16 format troubles

Discussion in 'Windows Vista Drivers' started by Mike, Oct 14, 2004.

  1. Mike

    Mike Guest

    Hello,

    my storage device driver connects the file system (mountmgr) with the
    pcmcia bus driver. It is used to read and write data from/to pcmcia flash
    cards. The pcmcia flash cards are FAT16 formatted by an other operating
    system. So far everything works well.

    The problems arise as soon as i try to format a pcmcia card, because
    windows has the habbit to raise the cluster (allocation unit) size and
    change the file system from FAT16 to FAT12.
    Now the question is: How can a driver force windows to format a partition
    with FAT16 instead of FAT12? Or how can a driver specify the allocation unit
    (cluster) size?


    The driver receives (and handles) the following IOCTLs after a format
    command has been entered: (In ther same order as they are listed)

    IOCTL_DISK_CHECK_VERIFY
    IOCTL_DISK_IS_WRITEABLE
    IOCTL_DISK_GET_DRIVE_GEOMETRY
    DiskGeometry.Cylinders.QuadPart = PartitionSize/512;
    DiskGeometry.MediaType = FixedMedia;
    DiskGeometry.TracksPerCylinder = 1;
    DiskGeometry.SectorsPerTrack = 1;
    DiskGeometry.BytesPerSector = 512;
    IOCTL_DISK_GET_LENGTH_INFO
    IOCTL_DISK_GET_PARTITION_INFO_EX
    The parameter PARTITION_INFORMATION_EX.Mbr.PartitionType is set
    to PARTITION_FAT16 but the value seems to be ignored.
    IOCTL_STORAGE_GET_DEVICE_NUMBER
    IOCTL_DISK_GET_DRIVE_LAYOUT_EX
    PDRIVE_LAYOUT_INFORMATION_EX.PartitionCount = 4;
    Type of first partition is PARTITION_FAT_16, the three remaining
    partitions are set to PARTITION_ENTRY_UNUSED.
    IOCTL_MOUNTDEV_QUERY_DEVICE_NAME
    IOCTL_DISK_CHECK_VERIFY
    IOCTL_DISK_VERIFY
    Returns STATUS_SUCCESS without any futher action.
    This should be ok, because the formating should only erase/reset
    the file system.
    IOCTL_DISK_GET_DRIVE_GEOMETRY
    IOCTL_DISK_GET_PARTITION_INFO_EX
    *** The boot sector is written here, but all previously supplied
    file system parameters will be ignored! Why?!?
    IOCTL_DISK_SET_PARTITION_INFO:
    tries to write the type of the first partition to fat12. Which is
    ignored because FAT12 should not be supported!

    Non of the above ioctls allows a driver to change the cluster size. So
    i suppose there's an other way to adjust the file system parameters.
    Please let me know if you have any ideas how to ensure a partition will
    be formatted with FAT16.
    Thanks in advance,
    Mike
     
    Mike, Oct 14, 2004
    #1
    1. Advertisements

  2. Write your own format utility.
     
    David J. Craig, Oct 14, 2004
    #2
    1. Advertisements

  3. Mike

    Mike Guest

    Hi David,

    thanks for your advice, but writing a format utility is only an option
    if there is a way to prevent the usage of all other (windows supplied)
    format programs.
    Is this somehow possible?

    I've got an other idea how to fix the fat12 problem and would
    appreciate
    your advice:
    IOCTL_DISK_SET_PARTITION_INFO is a certain indicator that the
    partition/drive has just been formatted. Would it be valid to use
    IOCTL_DISK_SET_PARTITION_INFO to overwrite the FAT12 boot sector by a
    FAT16 boot sector? If the driver also ignores the request to set the
    partition type to FAT12, the result would be a FAT16 boot sector on a
    FAT16 partition On an empty file system...
    But is this a save way to convert (hack) the file system from fat12 to
    fat16?

    I somehow can't belief that there's no way to specify the file system
    parameters. Unfortunatly there's not much information about
    fat12/fat16 in the ddk docs, so please let me know if you have any
    information.
    Thanks and advance,
    Mike
     
    Mike, Oct 15, 2004
    #3
  4. There is a FAT doc on the Microsoft site that covers how the rules work for
    all FAT types. You need to read and understand it before your questions
    will be answered. It is fatgen103.doc. It is somewhere under the hardware
    capability labs area.

    I did write my own format utility for SmartMedia and to allow hard drive
    partitions larger than 32GB to be formatted as FAT32.
     
    David J. Craig, Oct 16, 2004
    #4
  5. Try blocking MJ_CREATE for DASD mode (for zero length or absent
    FileObject->FileName).
    This will block format and chkdsk.
     
    Maxim S. Shatskih, Oct 18, 2004
    #5
  6. Mike

    Mike Guest

    Hello together,
    thanks for the information.
    I currently try to 'mistreat' IOCTL_DISK_SET_PARTITION_INFO to
    overwrite the partition table, boot sector and fat structures after
    the drive has been formatted. It looks like the only way to force a
    fat16 format on a drive with less than or equal 32 MB capacity. But
    i'm still uncertain...

    Thanks again,
    Mike
     
    Mike, Oct 19, 2004
    #6
  7. Mike

    Mike Guest

    Hi Maxim,
    thanks for the hint but i have some more questions about blocking
    format and chkdisk.
    What is DASD mode? And how can it be enabled?
    The driver receives a lot of IRP_MJ_CREATE requests. But all with
    pIrpStack->FileObject->FileName.Length set to zero!
    Of course, dropping them all blocks any calls to format/chkdisk, but
    unfortunatly also limits the access to 'unaccessible'. :)

    Anyway, the only difference between the various MJ_CREATEs appears at
    the
    following two data fields:
    pIrpStack->Parameters.Create.ShareAccess
    pIrpStack->Parameters.Create.Options
    Now i wonder if there's a way to determine the source of an
    IRP_MJ_CREATE based on the values of .Create.ShareAccess and
    ..Create.Options. Or maybe there's an other way?

    Please let me know if you have any ideas how to block format/chkdsk.
    Thanks in advance,
    Mike
     
    Mike, Oct 21, 2004
    #7
  8. DASD is direct access storage device (or maybe direct access to storage
    device) - it's a way of opening the entire volume for block-level access
    rather than any particular stream on the volume (including directory
    streams).

    opening c:\ is opening the root directory stream in the volume. opening c:
    (note - no trailing slash) is a DASD open of the volume.

    with disks you can open partitions (\\.\c:) or you can use the PhysicalDrive
    links (or the PNP device interface names) to get DASD access to the entire
    drive.

    -p
     
    Peter Wieland [MSFT], Oct 21, 2004
    #8
  9. What is DASD mode? And how can it be enabled?

    DASD = Direct Access Storage Device. Blockwise disk.

    To open the volume in DASD mode in Windows, use pathname like "\\.\C:".

    This translates to kernel pathname of "\??\C:", without appending the current
    directory. Trying to open "C:" will append the current directory for drive C.
    The \\.\ prefix blocks it.

    From the FSD's point of view, the DASD CREATE is CREATE with empty filename.
    This means that the user wants to work with the disk blockwise. The FSD creates
    a special file object which stupidly passes all reads/writes down to the disk,
    and supports NtQueryVolumeInformationFile so you can get the disk sizes from
    Win32 API.

    Now note Raw FS. It only supports DASD mode, and nothing else. It is mounted
    only if the user wants to open a DASD filename AND no other FS have recognized
    the metadata. So, its only purpose is to support NtQueryVolumeInformationFile
    on unformatted disk with no valid FS metadata.

    Now note CHKDSK and FORMAT. They use the DASD open to access the disk.
    At least block them with write desired access.
     
    Maxim S. Shatskih, Oct 22, 2004
    #9
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.