fatformat.h 1.2 KB

1234567891011121314151617181920212223242526272829
  1. /* Create a fresh FAT filesystem on a block device (floppy = FAT12 superfloppy,
  2. * IDE = MBR + single FAT16/32 partition). */
  3. #ifndef FATFORMAT_H
  4. #define FATFORMAT_H
  5. #include "blkdev.h"
  6. /* Format device d. Returns 0 on success, -1 on error. `limit_sectors`
  7. * (0 = the whole device) caps the partition size; useful for testing or for
  8. * reserving part of a large disk for another filesystem. */
  9. int fat_format(blk_dev_t *d);
  10. int fat_format_limited(blk_dev_t *d, unsigned int limit_sectors);
  11. /* Format one partition region without touching the MBR. `label` is an
  12. * 11-byte FAT volume label (NULL keeps it blank); `type_out` receives the
  13. * chosen FAT type (12/16/32) so the caller can build the MBR entry. */
  14. int fat_format_partition(blk_dev_t *d, unsigned int part_lba,
  15. unsigned int sectors, const char *label,
  16. unsigned int *type_out);
  17. /* Decimal helper for the format messages (terminal + netlog mirror). */
  18. void format_putdec(unsigned int v);
  19. /* Set while a destructive format owns the disks. Filesystem syscalls wait
  20. * for it instead of touching a half-written FAT; the owner is exempt. */
  21. extern volatile int format_busy;
  22. extern volatile unsigned int format_owner_pid;
  23. #endif