dosfstools
4.2
About: dosfstools are utilities to create, check and label (MS-DOS) FAT filesystems.
![]() ![]() |
#include <limits.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <time.h>
#include "common.h"
#include "fsck.fat.h"
#include "fat.h"
#include "io.h"
#include "boot.h"
#include "check.h"
#include "charconv.h"
Go to the source code of this file.
Macros | |
#define | ROUND_TO_MULTIPLE(n, m) ((n) && (m) ? (n)+(m)-1-((n)-1)%(m) : 0) |
#define | FAT12_THRESHOLD 4085 |
#define | FAT16_THRESHOLD 65525 |
#define | GET_UNALIGNED_W(f) ( (uint16_t)f[0] | ((uint16_t)f[1]<<8) ) |
Functions | |
off_t | alloc_rootdir_entry (DOS_FS *fs, DIR_ENT *de, const char *pattern, int gen_name) |
static const char * | get_media_descr (unsigned char media) |
static void | dump_boot (DOS_FS *fs, struct boot_sector *b, unsigned lss) |
static void | check_backup_boot (DOS_FS *fs, struct boot_sector *b, unsigned int lss) |
static void | init_fsinfo_except_reserved (struct info_sector *i) |
static void | read_fsinfo (DOS_FS *fs, struct boot_sector *b, unsigned int lss) |
void | read_boot (DOS_FS *fs) |
static void | write_boot_label_or_serial (int label_mode, DOS_FS *fs, const char *label, uint32_t serial) |
void | write_boot_label (DOS_FS *fs, const char *label) |
void | write_serial (DOS_FS *fs, uint32_t serial) |
off_t | find_volume_de (DOS_FS *fs, DIR_ENT *de) |
void | write_volume_label (DOS_FS *fs, char *label) |
void | write_label (DOS_FS *fs, char *label) |
void | remove_label (DOS_FS *fs) |
const char * | pretty_label (const char *label) |
Variables | |
struct { | |
uint8_t media | |
const char * descr | |
} | mediabytes [] |
#define GET_UNALIGNED_W | ( | f | ) | ( (uint16_t)f[0] | ((uint16_t)f[1]<<8) ) |
#define ROUND_TO_MULTIPLE | ( | n, | |
m | |||
) | ((n) && (m) ? (n)+(m)-1-((n)-1)%(m) : 0) |
Definition at line 52 of file boot.c.
References alloc(), DIR_ENT::attr, DOS_FS::cluster_size, cluster_start(), DOS_FS::data_clusters, die(), DOS_FS::fat, fs_read(), fs_write(), get_fat(), get_owner(), IS_FREE, MSDOS_NAME, n_files, DIR_ENT::name, next_cluster(), root, DOS_FS::root_cluster, DOS_FS::root_entries, DOS_FS::root_start, set_fat(), set_owner(), FAT_ENTRY::value, and VFAT_LN_ATTR.
Referenced by reclaim_file(), and write_volume_label().
|
static |
Definition at line 262 of file boot.c.
References boot_sector::backup_boot, backup_boot, DOS_FS::backupboot_start, fs_read(), fs_write(), get_choice(), boot_sector::info_sector, and boot_sector::reserved.
Referenced by read_boot().
|
static |
Definition at line 209 of file boot.c.
References atari_format, DOS_FS::cluster_size, DOS_FS::data_clusters, DOS_FS::data_start, DOS_FS::fat_bits, DOS_FS::fat_size, DOS_FS::fat_start, boot_sector::fats, get_media_descr(), GET_UNALIGNED_W, boot_sector::heads, boot_sector::hidden, boot_sector::media, boot_sector::reserved, DOS_FS::root_cluster, DOS_FS::root_entries, DOS_FS::root_start, boot_sector::secs_track, boot_sector::sector_size, boot_sector::sectors, boot_sector::system_id, and boot_sector::total_sect.
Referenced by read_boot().
Definition at line 629 of file boot.c.
References DIR_ENT::attr, ATTR_VOLUME, DOS_FS::cluster_size, cluster_start(), fs_read(), IS_FREE, DIR_ENT::name, next_cluster(), DOS_FS::root_cluster, DOS_FS::root_entries, DOS_FS::root_start, and VFAT_LN_ATTR.
Referenced by check_label(), handle_label(), remove_label(), and write_volume_label().
|
static |
Definition at line 198 of file boot.c.
References descr, media, and mediabytes.
Referenced by dump_boot().
|
static |
Definition at line 338 of file boot.c.
References info_sector::boot_sign, info_sector::free_clusters, info_sector::magic, info_sector::next_cluster, and info_sector::signature.
Referenced by read_fsinfo().
const char* pretty_label | ( | const char * | label | ) |
Definition at line 747 of file boot.c.
References dos_char_to_printable(), and last.
Referenced by check_boot_label(), check_label(), and handle_label().
void read_boot | ( | DOS_FS * | fs | ) |
Definition at line 415 of file boot.c.
References atari_format, boot_sector::backup_boot, DOS_FS::backupboot_start, check_backup_boot(), boot_sector::cluster_size, DOS_FS::cluster_size, DOS_FS::data_clusters, DOS_FS::data_start, die(), boot_sector::dir_entries, dump_boot(), DOS_FS::eff_fat_bits, boot_sector::extended_sig, boot_sector_16::extended_sig, FAT12_THRESHOLD, FAT16_THRESHOLD, boot_sector::fat32_length, DOS_FS::fat_bits, boot_sector::fat_length, DOS_FS::fat_size, DOS_FS::fat_start, boot_sector::fats, DOS_FS::free_clusters, fs_read(), fs_test(), DOS_FS::fsinfo_start, GET_UNALIGNED_W, boot_sector::heads, boot_sector::label, boot_sector_16::label, DOS_FS::label, MSDOS_DIR_BITS, MSDOS_DPS, DOS_FS::nfats, OFF_MAX, read_fsinfo(), boot_sector::reserved, boot_sector::root_cluster, DOS_FS::root_cluster, DOS_FS::root_entries, DOS_FS::root_start, ROUND_TO_MULTIPLE, boot_sector::secs_track, boot_sector::sector_size, SECTOR_SIZE, boot_sector::sectors, boot_sector::serial, boot_sector_16::serial, DOS_FS::serial, boot_sector::total_sect, and verbose.
Referenced by handle_label(), handle_volid(), and main().
|
static |
Definition at line 347 of file boot.c.
References boot_sector::backup_boot, DOS_FS::backupboot_start, info_sector::boot_sign, info_sector::free_clusters, DOS_FS::free_clusters, fs_read(), fs_write(), DOS_FS::fsinfo_start, get_choice(), boot_sector::info_sector, init_fsinfo_except_reserved(), info_sector::magic, boot_sector::reserved, and info_sector::signature.
Referenced by read_boot().
void remove_label | ( | DOS_FS * | fs | ) |
Definition at line 729 of file boot.c.
References DIR_ENT::attr, find_volume_de(), fs_write(), DIR_ENT::name, and write_boot_label().
Referenced by check_label(), and handle_label().
void write_boot_label | ( | DOS_FS * | fs, |
const char * | label | ||
) |
Definition at line 619 of file boot.c.
References boot_sector::label, and write_boot_label_or_serial().
Referenced by check_boot_label(), check_label(), remove_label(), and write_label().
|
static |
Definition at line 576 of file boot.c.
References DOS_FS::backupboot_start, boot_sector::extended_sig, boot_sector_16::extended_sig, DOS_FS::fat_bits, fs_read(), boot_sector::fs_type, boot_sector_16::fs_type, fs_write(), boot_sector::label, boot_sector_16::label, boot_sector::serial, and boot_sector_16::serial.
Referenced by write_boot_label(), and write_serial().
void write_label | ( | DOS_FS * | fs, |
char * | label | ||
) |
Definition at line 718 of file boot.c.
References write_boot_label(), and write_volume_label().
Referenced by check_label(), and handle_label().
void write_serial | ( | DOS_FS * | fs, |
uint32_t | serial | ||
) |
Definition at line 624 of file boot.c.
References boot_sector::serial, and write_boot_label_or_serial().
Referenced by handle_volid().
void write_volume_label | ( | DOS_FS * | fs, |
char * | label | ||
) |
Definition at line 671 of file boot.c.
References DIR_ENT::adate, alloc_rootdir_entry(), DIR_ENT::attr, ATTR_VOLUME, DIR_ENT::cdate, DIR_ENT::ctime, DIR_ENT::ctime_ms, DIR_ENT::date, find_volume_de(), fs_write(), DIR_ENT::name, DIR_ENT::size, DIR_ENT::start, DIR_ENT::starthi, and DIR_ENT::time.
Referenced by check_label(), and write_label().
const char* descr |
Definition at line 180 of file boot.c.
Referenced by get_media_descr().
uint8_t media |
Definition at line 179 of file boot.c.
Referenced by establish_params(), and get_media_descr().
struct { ... } mediabytes[] |
Referenced by get_media_descr().