<< Previous | Next >>

fat_FormatDevice

int fat_FormatDevice( mbr_dev *dev, int mode );

Description

Formats a device. The device will have a DOS master boot record (MBR) written to it. Existing partitions are left alone if the device was previously formatted. The formatted device will be registered with the write-back cache for use with the FAT library. The one partition mode will instruct the routine to create a partition table, with one partition using the entire device. This mode only works if the device is currently unformatted or has no partitions.

If needed (i.e., there is no MBR on the device), this function is called by fat_AutoMount() if its flags parameter allows it.

Parameters

dev
Pointer to the data structure for the device to format.

mode
Mode:

0 = normal (use the partition table in the device structure)

1 = one partition using the entire device (errors occur if there are already partitions in the device structure)

3 = force one partition for the entire device (overwrites values already in the device structure)

Return

0: success.
-EIO: error trying to read the device or structure.
-EINVAL: device structure is invalid or does not exist.
-ENOMEM: memory for page buffer/RJ is not available.
-EEXIST: the device is already formatted.
-EPERM: the device already has mounted partition(s).
-EBUSY: the device is busy. (Only if non-blocking.)

Library

FAT.LIB

See Also

fat_AutoMount, fat_Init, fat_EnumDevice, fat_PartitionDevice, fat_FormatPartition


Dynamic C Functions << Previous | Next >> rabbit.com