dosfstools  4.2
About: dosfstools are utilities to create, check and label (MS-DOS) FAT filesystems.
  Fossies Dox: dosfstools-4.2.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

boot.c File Reference
#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"
Include dependency graph for boot.c:

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 []
 

Macro Definition Documentation

◆ FAT12_THRESHOLD

#define FAT12_THRESHOLD   4085

Definition at line 49 of file boot.c.

◆ FAT16_THRESHOLD

#define FAT16_THRESHOLD   65525

Definition at line 50 of file boot.c.

◆ GET_UNALIGNED_W

#define GET_UNALIGNED_W (   f)     ( (uint16_t)f[0] | ((uint16_t)f[1]<<8) )

Definition at line 195 of file boot.c.

◆ ROUND_TO_MULTIPLE

#define ROUND_TO_MULTIPLE (   n,
 
)    ((n) && (m) ? (n)+(m)-1-((n)-1)%(m) : 0)

Definition at line 45 of file boot.c.

Function Documentation

◆ alloc_rootdir_entry()

◆ check_backup_boot()

static void check_backup_boot ( DOS_FS fs,
struct boot_sector b,
unsigned int  lss 
)
static

◆ dump_boot()

◆ find_volume_de()

◆ get_media_descr()

static const char* get_media_descr ( unsigned char  media)
static

Definition at line 198 of file boot.c.

References descr, media, and mediabytes.

Referenced by dump_boot().

◆ init_fsinfo_except_reserved()

static void init_fsinfo_except_reserved ( struct info_sector i)
static

◆ pretty_label()

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().

◆ read_boot()

◆ read_fsinfo()

◆ remove_label()

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().

◆ write_boot_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().

◆ write_boot_label_or_serial()

static void write_boot_label_or_serial ( int  label_mode,
DOS_FS fs,
const char *  label,
uint32_t  serial 
)
static

◆ write_label()

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().

◆ write_serial()

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().

◆ write_volume_label()

Variable Documentation

◆ descr

const char* descr

Definition at line 180 of file boot.c.

Referenced by get_media_descr().

◆ media

uint8_t media

Definition at line 179 of file boot.c.

Referenced by establish_params(), and get_media_descr().

◆ 

struct { ... } mediabytes[]
Initial value:
= {
{
0xf0, "5.25\" or 3.5\" HD floppy"}, {
0xf8, "hard disk"}, {
0xf9, "3,5\" 720k floppy 2s/80tr/9sec or "
"5.25\" 1.2M floppy 2s/80tr/15sec"}, {
0xfa, "5.25\" 320k floppy 1s/80tr/8sec"}, {
0xfb, "3.5\" 640k floppy 2s/80tr/8sec"}, {
0xfc, "5.25\" 180k floppy 1s/40tr/9sec"}, {
0xfd, "5.25\" 360k floppy 2s/40tr/9sec"}, {
0xfe, "5.25\" 160k floppy 1s/40tr/8sec"}, {
0xff, "5.25\" 320k floppy 2s/40tr/8sec"},}

Referenced by get_media_descr().