ReactOS  0.4.10-dev-348-gbcec1fd
mkdosfs.c File Reference
#include "../version.h"
#include <linux/hdreg.h>
#include <linux/fs.h>
#include <linux/fd.h>
#include <endian.h>
#include <mntent.h>
#include <signal.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>
#include <asm/byteorder.h>
#include <linux/unistd.h>
Include dependency graph for mkdosfs.c:

Go to the source code of this file.

Classes

struct  msdos_volume_info
 
struct  msdos_boot_sector
 
struct  fat32_fsinfo
 
struct  msdos_dir_entry
 

Macros

#define CF_LE_W(v)   ((((v) & 0xff) << 8) | (((v) >> 8) & 0xff))
 
#define CF_LE_L(v)
 
#define CT_LE_W(v)   CF_LE_W(v)
 
#define CT_LE_L(v)   CF_LE_L(v)
 
#define O_NOINHERIT   0
 
#define O_TEMPORARY   0
 
#define O_SHORT_LIVED   0
 
#define O_SEQUENTIAL   0
 
#define O_RANDOM   0
 
#define O_BACKUP   0
 
#define O_SHARED   0
 
#define O_NONE   0
 
#define TRUE   1 /* Boolean constants */
 
#define FALSE   0
 
#define TEST_BUFFER_BLOCKS   16
 
#define HARD_SECTOR_SIZE   512
 
#define SECTORS_PER_BLOCK   ( BLOCK_SIZE / HARD_SECTOR_SIZE )
 
#define die(str)   fatal_error( "%s: " str "\n" )
 
#define mark_sector_bad(sector)   mark_FAT_sector( sector, FAT_BAD )
 
#define ATTR_RO   1 /* read-only */
 
#define ATTR_HIDDEN   2 /* hidden */
 
#define ATTR_SYS   4 /* system */
 
#define ATTR_VOLUME   8 /* volume label */
 
#define ATTR_DIR   16 /* directory */
 
#define ATTR_ARCH   32 /* archived */
 
#define ATTR_NONE   0 /* no attribute bits */
 
#define ATTR_UNUSED   (ATTR_VOLUME | ATTR_ARCH | ATTR_SYS | ATTR_HIDDEN)
 
#define FAT_EOF   (atari_format ? 0x0fffffff : 0x0ffffff8)
 
#define FAT_BAD   0x0ffffff7
 
#define MSDOS_EXT_SIGN   0x29 /* extended boot sector signature */
 
#define MSDOS_FAT12_SIGN   "FAT12 " /* FAT12 filesystem signature */
 
#define MSDOS_FAT16_SIGN   "FAT16 " /* FAT16 filesystem signature */
 
#define MSDOS_FAT32_SIGN   "FAT32 " /* FAT32 filesystem signature */
 
#define BOOT_SIGN   0xAA55 /* Boot sector magic number */
 
#define MAX_CLUST_12   ((1 << 12) - 16)
 
#define MAX_CLUST_16   ((1 << 16) - 16)
 
#define MAX_CLUST_32   ((1 << 28) - 16)
 
#define FAT12_THRESHOLD   4078
 
#define OLDGEMDOS_MAX_SECTORS   32765
 
#define GEMDOS_MAX_SECTORS   65531
 
#define GEMDOS_MAX_SECTOR_SIZE   (16*1024)
 
#define BOOTCODE_SIZE   448
 
#define BOOTCODE_FAT32_SIZE   420
 
#define fat32   fstype._fat32
 
#define oldfat   fstype._oldfat
 
#define MESSAGE_OFFSET   29 /* Offset of message in above code */
 
#define error(str)
 
#define seekto(pos, errstr)
 
#define writebuf(buf, size, errstr)
 

Typedefs

typedef long long ll_t
 

Functions

static _syscall5 (int, _llseek, uint, fd, ulong, hi, ulong, lo, loff_t *, res, uint, wh)
 
static loff_t llseek (int fd, loff_t offset, int whence)
 
int cdiv (int a, int b)
 
struct msdos_volume_info __attribute__ ((packed))
 
static void fatal_error (const char *fmt_string) __attribute__((noreturn))
 
static void mark_FAT_cluster (int cluster, unsigned int value)
 
static void mark_FAT_sector (int sector, unsigned int value)
 
static long do_check (char *buffer, int try, unsigned int current_block)
 
static void alarm_intr (int alnum)
 
static void check_blocks (void)
 
static void get_list_blocks (char *filename)
 
static int valid_offset (int fd, loff_t offset)
 
static int count_blocks (char *filename)
 
static void check_mount (char *device_name)
 
static void establish_params (int device_num, int size)
 
static void setup_tables (void)
 
static void write_tables (void)
 
void usage (void)
 
static void check_atari (void)
 
int main (int argc, char **argv)
 

Variables

__u8 drive_number
 
__u8 RESERVED
 
__u8 ext_boot_sign
 
__u8 volume_id [4]
 
__u8 volume_label [11]
 
__u8 fs_type [8]
 
struct msdos_volume_info vi
 
__u8 boot_code [BOOTCODE_SIZE]
 
__u8 boot_jump [3]
 
__u8 system_id [8]
 
__u8 sector_size [2] = 512
 
__u8 cluster_size
 
__u16 reserved
 
__u8 fats
 
__u8 dir_entries [2]
 
__u8 sectors [2]
 
__u8 media
 
__u16 fat_length
 
__u16 secs_track
 
__u16 heads
 
__u32 hidden
 
__u32 total_sect
 
struct fat32_fsinfo __attribute__
 
char name [8]
 
char ext [3]
 
__u8 attr
 
__u8 lcase
 
__u8 ctime_ms
 
__u16 ctime
 
__u16 cdate
 
__u16 adate
 
__u16 starthi
 
__u16 time
 
__u16 date
 
__u16 start
 
__u32 size
 
char dummy_boot_jump [3] = { 0xeb, 0x3c, 0x90 }
 
char dummy_boot_jump_m68k [2] = { 0x60, 0x1c }
 
char dummy_boot_code [BOOTCODE_SIZE]
 
static charprogram_name = "mkdosfs"
 
static chardevice_name = NULL
 
static int atari_format = 0
 
static int check = FALSE
 
static int verbose = 0
 
static time_t create_time
 
static char volume_name [] = " "
 
static int blocks
 
static int sector_size_set = 0
 
static int backup_boot = 0
 
static int reserved_sectors = 0
 
static int badblocks = 0
 
static int nr_fats = 2
 
static int size_fat = 0
 
static int size_fat_by_user = 0
 
static int dev = -1
 
static int ignore_full_disk = 0
 
static unsigned int currently_testing = 0
 
static struct msdos_boot_sector bs
 
static int start_data_sector
 
static int start_data_block
 
static unsigned charfat
 
static unsigned charinfo_sector
 
static struct msdos_dir_entryroot_dir
 
static int size_root_dir
 
static int sectors_per_cluster = 0
 
static int root_dir_entries = 0
 
static charblank_sector
 

Macro Definition Documentation

#define ATTR_ARCH   32 /* archived */

Definition at line 371 of file mkdosfs.c.

#define ATTR_DIR   16 /* directory */

Definition at line 370 of file mkdosfs.c.

Referenced by add_file(), auto_rename(), check_file(), handle_dot(), rename_file(), and subdirs().

#define ATTR_HIDDEN   2 /* hidden */

Definition at line 367 of file mkdosfs.c.

#define ATTR_NONE   0 /* no attribute bits */

Definition at line 373 of file mkdosfs.c.

#define ATTR_RO   1 /* read-only */

Definition at line 366 of file mkdosfs.c.

#define ATTR_SYS   4 /* system */

Definition at line 368 of file mkdosfs.c.

#define ATTR_UNUSED   (ATTR_VOLUME | ATTR_ARCH | ATTR_SYS | ATTR_HIDDEN)

Definition at line 374 of file mkdosfs.c.

#define ATTR_VOLUME   8 /* volume label */
#define BOOT_SIGN   0xAA55 /* Boot sector magic number */

Definition at line 386 of file mkdosfs.c.

Referenced by setup_tables().

#define BOOTCODE_FAT32_SIZE   420

Definition at line 401 of file mkdosfs.c.

Referenced by setup_tables().

#define BOOTCODE_SIZE   448

Definition at line 400 of file mkdosfs.c.

Referenced by main(), and setup_tables().

#define CF_LE_L (   v)
Value:
(((unsigned)(v)>>24) | (((unsigned)(v)>>8)&0xff00) | \
(((unsigned)(v)<<8)&0xff0000) | ((unsigned)(v)<<24))
const GLdouble * v
Definition: gl.h:2040

Definition at line 95 of file mkdosfs.c.

Referenced by write_tables().

#define CF_LE_W (   v)    ((((v) & 0xff) << 8) | (((v) >> 8) & 0xff))

Definition at line 94 of file mkdosfs.c.

Referenced by establish_params(), setup_tables(), and write_tables().

#define CT_LE_L (   v)    CF_LE_L(v)

Definition at line 98 of file mkdosfs.c.

Referenced by setup_tables().

#define CT_LE_W (   v)    CF_LE_W(v)

Definition at line 97 of file mkdosfs.c.

Referenced by establish_params(), and setup_tables().

#define error (   str)
Value:
do { \
die (str); \
} while(0)
static struct msdos_dir_entry * root_dir
Definition: mkdosfs.c:544
#define free
Definition: debug_ros.c:5
while(1)
Definition: macro.lex.yy.c:743
const WCHAR * str
if(!(yy_init))
Definition: macro.lex.yy.c:717
#define die(str)
Definition: mkdosfs.c:347
static unsigned char * fat
Definition: mkdosfs.c:542

Definition at line 1605 of file mkdosfs.c.

Referenced by __nc_error(), __rpc_get_time_offset(), __rpcb_findaddr_timed(), _bdf_add_comment(), _bdf_add_property(), _bdf_list_ensure(), _bdf_list_split(), _bdf_parse_glyphs(), _bdf_parse_properties(), _bdf_parse_start(), _bdf_readstream(), _bdf_set_default_spacing(), basic_filebuf< _CharT, _Traits >::_M_underflow_aux(), basic_filebuf< _CharT, _Traits >::_M_unshift(), _mesa_record_error(), _SHGetUserProfilePath(), _test_flush_async(), _test_overlapped_failure(), _test_security_info(), _tpopen(), ACMWrapper_Receive(), acpi_bus_match(), AdapterDiscoveryThread(), add_coclass_typeinfo(), add_enum_typeinfo(), add_field_from_token(), add_func_desc(), add_impl_type(), add_interface_typeinfo(), add_module_typeinfo(), add_protocol(), add_statement(), add_timeout(), add_type_typeinfo(), add_union_typeinfo(), add_var_desc(), af_autofitter_load_glyph(), af_axis_hints_new_edge(), af_axis_hints_new_segment(), af_dummy_hints_apply(), af_face_globals_compute_style_coverage(), af_face_globals_get_metrics(), af_face_globals_new(), af_glyph_hints_reload(), af_latin_hints_apply(), af_latin_hints_compute_edges(), af_latin_hints_compute_segments(), af_latin_hints_detect_features(), af_latin_metrics_init_blues(), af_latin_metrics_init_widths(), af_loader_embolden_glyph_in_slot(), af_loader_load_glyph(), af_loader_reset(), af_property_get(), af_property_get_face_globals(), af_property_set(), af_shaper_buf_create(), afm_parse_kern_data(), afm_parse_kern_pairs(), afm_parse_track_kern(), afm_parser_init(), afm_parser_parse(), afm_parser_read_vals(), AtapiInterrupt(), AtapiInterrupt__(), AVIDec_Receive(), AVISaveA(), AVISaveVW(), AVISaveW(), bdf_create_property(), BDF_Face_Init(), BDF_Glyph_Load(), bdf_interpret_style(), bdf_load_font(), BDF_Size_Request(), ber_parse_header(), bindresvport_sa(), buffer_create_buffer_object(), buffered_fullread(), Bus_PDO_Power(), cache_container_lock_index(), cache_get_bitmap(), cache_get_brush_data(), cache_get_cursor(), cache_get_desktop(), cache_get_font(), cache_put_bitmap(), cache_put_brush_data(), cache_put_cursor(), cache_put_desktop(), cache_put_font(), cache_rebuild_bmpcache_linked_list(), callback_child(), cdf_callback(), CertDllVerifyRevocation(), CertViewPropertiesA(), cf2_arrstack_init(), cf2_builder_cubeTo(), cf2_builder_lineTo(), cf2_getSeacComponent(), cf2_getT1SeacComponent(), cf2_hintmask_init(), cf2_outline_init(), cff_blend_build_vector(), cff_blend_doBlend(), cff_builder_add_contour(), cff_builder_add_point1(), cff_builder_start_point(), cff_charset_compute_cids(), cff_charset_load(), cff_decoder_prepare(), cff_encoding_load(), cff_face_init(), cff_font_load(), cff_get_glyph_data(), cff_index_access_element(), cff_index_get_name(), cff_index_get_pointers(), cff_index_init(), cff_index_load_offsets(), cff_index_read_offset(), CFF_Load_FD_Select(), cff_load_private_dict(), cff_parse_blend(), cff_parse_cid_ros(), cff_parse_font_bbox(), cff_parse_font_matrix(), cff_parse_maxstack(), cff_parse_multiple_master(), cff_parse_private_dict(), cff_parse_vsindex(), cff_parser_init(), cff_parser_run(), cff_size_init(), cff_slot_load(), cff_strcpy(), cff_subfont_load(), cff_vstore_load(), channel_register(), check_balloc(), check_table_dir(), check_type1_format(), cid_face_init(), cid_face_open(), cid_get_cid_from_glyph_index(), cid_get_is_cid(), cid_hex_to_binary(), cid_load_glyph(), cid_load_keyword(), cid_parser_new(), cid_read_subrs(), cid_size_init(), cid_slot_load_glyph(), classic_kern_validate(), clnt_create_vers_timed(), COMBO_GetText(), COMBO_GetTextA(), COMBO_GetTextW(), COMDLG32_FR_DoFindReplace(), CommonInstall(), compare_export_(), compute_glyph_metrics(), cons(), convert_hex_to_dword(), create_copy_error(), create_directdraw(), create_signature_columns_and_data(), create_temp_binary(), create_tmp_ini_file(), CreateHiddenConsoleProcess(), CreateLobbyMessageReceptionThread(), createtestfilter(), CRYPT_LoadProvider(), CRYPT_LoadSIP(), CRYPT_VerifyChainRevocation(), CryptAcquireContextW(), CryptCATEnumerateMember(), CryptUIDlgViewCertificateA(), CURSORICON_GetCursorDataFromANI(), d3dx9_mesh_CloneMesh(), d3dx_include_from_file_open(), D3DXCreateSkinInfo(), D3DXCreateTextW(), D3DXGetShaderConstantTableEx(), D3DXLoadSurfaceFromMemory(), D3DXOptimizeFaces(), dbgstr_event_seq_result(), dde_connect(), decode_header(), decode_update(), decompress_file_lz(), default_init(), DeleteUrlCacheEntryA(), disk_create(), display_network_error(), DnsRecordCopyEx(), DnsRecordSetCompare(), do_import(), do_layer1(), do_layer3(), do_readahead(), download_url(), encode_type(), enter_dns_host(), escstrcpy(), fi_resize(), fill_source_list(), FilterGraph2_AddSourceFilter(), FilterGraph2_Connect(), FilterGraph2_Render(), find_dectype(), find_file_hash(), find_or_create_directory(), fnt_face_get_dll_font(), FNT_Face_Init(), fnt_font_load(), FNT_Load_Glyph(), FNT_Size_Request(), ForF(), frame_cpu_opt(), frame_offset(), FT_Add_Default_Modules(), FT_Add_Module(), ft_add_renderer(), FT_Attach_Stream(), ft_bitmap_assure_buffer(), FT_Bitmap_Convert(), FT_Bitmap_Copy(), FT_Bitmap_Embolden(), ft_bitmap_glyph_init(), ft_black_new(), FT_ClassicKern_Validate(), FT_CMap_Done(), FT_CMap_New(), FT_DEFINE_GLYPH(), FT_DEFINE_OUTLINE_FUNCS(), FT_Done_Face(), FT_Done_Size(), ft_face_get_mm_service(), ft_face_get_mvar_service(), FT_Face_Properties(), FT_Get_Advance(), FT_Get_Advances(), FT_Get_BDF_Charset_ID(), FT_Get_BDF_Property(), FT_Get_CID_From_Glyph_Index(), FT_Get_CID_Is_Internally_CID_Keyed(), FT_Get_CID_Registry_Ordering_Supplement(), FT_Get_Glyph(), FT_Get_Glyph_Name(), FT_Get_Kerning(), FT_Get_MM_Blend_Coordinates(), FT_Get_MM_Var(), FT_Get_Multi_Master(), FT_Get_PFR_Advance(), FT_Get_PFR_Kerning(), FT_Get_PFR_Metrics(), FT_Get_PS_Font_Info(), FT_Get_PS_Font_Private(), FT_Get_SubGlyph_Info(), FT_Get_Track_Kerning(), FT_Get_Var_Blend_Coordinates(), FT_Get_Var_Design_Coordinates(), FT_Get_WinFNT_Header(), FT_Glyph_Copy(), FT_Glyph_Stroke(), FT_Glyph_StrokeBorder(), FT_Glyph_To_Bitmap(), FT_Glyph_Transform(), FT_GlyphLoader_CheckPoints(), FT_GlyphLoader_CheckSubGlyphs(), FT_GlyphLoader_CopyPoints(), FT_GlyphLoader_CreateExtra(), FT_GlyphLoader_New(), ft_glyphslot_alloc_bitmap(), FT_GlyphSlot_Embolden(), ft_glyphslot_init(), FT_GlyphSlot_Own_Bitmap(), FT_Init_FreeType(), FT_List_Iterate(), FT_Load_Glyph(), ft_lzwstate_prefix_grow(), ft_lzwstate_stack_grow(), ft_mem_alloc(), ft_mem_dup(), ft_mem_qalloc(), ft_mem_qrealloc(), ft_mem_realloc(), FT_New_GlyphSlot(), FT_New_Library(), FT_New_Size(), ft_open_face_internal(), FT_OpenType_Validate(), FT_Outline_Decompose(), ft_outline_glyph_copy(), FT_Outline_New_Internal(), FT_Outline_Render(), FT_Raccess_Get_DataOffsets(), FT_Raccess_Get_HeaderInfo(), ft_raster1_render(), ft_raster1_transform(), FT_Render_Glyph_Internal(), FT_Request_Size(), FT_Select_Size(), FT_Set_MM_Blend_Coordinates(), FT_Set_MM_Design_Coordinates(), FT_Set_Named_Instance(), FT_Set_Renderer(), FT_Set_Var_Blend_Coordinates(), FT_Set_Var_Design_Coordinates(), ft_smooth_render_generic(), ft_smooth_transform(), FT_Stream_EnterFrame(), FT_Stream_ExtractFrame(), FT_Stream_New(), FT_Stream_ReadAt(), FT_Stream_ReadFields(), FT_Stream_Seek(), ft_stroke_border_arcto(), ft_stroke_border_conicto(), ft_stroke_border_cubicto(), ft_stroke_border_get_counts(), ft_stroke_border_grow(), ft_stroke_border_lineto(), ft_stroker_add_reverse_left(), ft_stroker_arcto(), ft_stroker_cap(), FT_Stroker_ConicTo(), FT_Stroker_CubicTo(), FT_Stroker_EndSubPath(), FT_Stroker_GetBorderCounts(), FT_Stroker_GetCounts(), ft_stroker_inside(), FT_Stroker_LineTo(), FT_Stroker_New(), ft_stroker_outside(), FT_Stroker_ParseOutline(), ft_stroker_process_corner(), ft_stroker_subpath_start(), FT_TrueTypeGX_Validate(), ft_validator_error(), ftc_basic_family_get_count(), ftc_basic_family_load_bitmap(), ftc_basic_family_load_glyph(), ftc_cache_init(), FTC_Cache_NewNode(), ftc_cache_resize(), ftc_cmap_node_new(), FTC_CMapCache_Lookup(), ftc_face_node_init(), ftc_gcache_init(), FTC_ImageCache_Lookup(), FTC_ImageCache_LookupScaler(), FTC_INode_New(), FTC_Manager_LookupFace(), FTC_Manager_LookupSize(), FTC_Manager_New(), FTC_Manager_RegisterCache(), FTC_MruList_New(), ftc_sbit_copy_bitmap(), FTC_SBitCache_Lookup(), FTC_SBitCache_LookupScaler(), ftc_scaler_lookup_size(), ftc_snode_compare(), ftc_snode_load(), FTC_SNode_New(), ftGdiGetGlyphOutline(), ftGdiGlyphCacheSet(), ftGdiGlyphSet(), FTPFILE_ReadFile(), get_context_handle_offset(), get_data_from_stream(), get_element_size(), get_fd_set(), get_file_version(), get_generic_handle_offset(), get_graft(), get_required_buffer_size_type(), get_size_is_expr(), get_type_vt(), GetCurrencyFormatW(), utf_converter::getError(), GetNumberFormatW(), getpeereid(), GetShellSecurityDescriptor(), GetWinMetaFileBits(), gray_convert_glyph(), gray_raster_new(), GreExtTextOutW(), guess_freeformat_framesize(), gxv_ctlPoint_validate(), gxv_load_table(), gxv_prop_zero_advance_validate(), gxv_validate(), handle_apetag(), hash_init(), hash_insert(), hash_rehash(), HttpProtocol_open_request(), HTTPREQ_QueryDataAvailable(), HTTPREQ_QueryOption(), HTTPREQ_ReadFile(), HttpSendRequestEx_test(), ICSeqCompressFrameStart(), icy_fullread(), IDirectMusicInstrumentImpl_CustomLoad(), IDirectXFileEnumObjectImpl_GetNextDataObject(), IDirectXFileImpl_CreateEnumObject(), if(), III_get_side_info(), ImageRemoveCertificate(), inf_load(), init_client(), init_proxy(), init_server(), initialize_universes(), InitProcessCallback(), InitThreadCallback(), InitWebBrowser(), InstallLiveCD(), InternetCrackUrlW_test(), InternetTimeFromSystemTimeA_test(), InternetTimeFromSystemTimeW_test(), iso9660_file_length(), iso_connect(), iso_reconnect(), iso_recv(), iso_recv_msg(), KmtCloseDriver(), KmtOpenDriver(), KmtRunKernelTest(), KmtServiceCleanup(), KmtServiceInit(), LIBXML_ATTR_FORMAT(), licence_parse_authreq(), licence_parse_platform_challenge(), load_ciffile(), load_truetype_glyph(), log_device_error(), lspci_process_line(), main(), make_conv16to8_table(), match_allows_spec_alpha(), match_event_sequence(), mcs_connect(), mcs_connect_finalize(), mcs_reconnect(), mcs_recv(), mcs_recv_aucf(), mcs_recv_cjcf(), mcs_recv_connect_response(), merge_isofs(), mp_prime_random_ex(), mpg123_info(), mpg123_init(), msi_download_file(), NetBTRecv(), NEtoSW(), new_index_name(), NWtoSE(), ODBC_LoadDriverManager(), open_face(), open_feed(), option_as_string(), otv_load_table(), otv_validate(), OutputResult(), basic_filebuf< _CharT, _Traits >::overflow(), parse_afm(), parse_assembly_elem(), parse_assembly_identity_elem(), parse_binding_redirect_elem(), parse_blend_axis_types(), parse_blend_design_map(), parse_blend_design_positions(), parse_charstrings(), parse_clr_class_elem(), parse_clr_surrogate_elem(), parse_com_class_elem(), parse_com_interface_external_proxy_stub_elem(), parse_cominterface_proxy_stub_elem(), parse_ctab_constant_type(), parse_dependency_elem(), parse_encoding(), parse_expect_no_attr(), parse_fd_array(), parse_file_elem(), parse_new_id3(), parse_option_buffer(), parse_requested_execution_level_elem(), parse_subrs(), parse_supportedos_elem(), parse_transform_desc(), parse_typelib_elem(), parse_typelib_version(), parse_unknown_elem(), parse_version(), parse_weight_vector(), parse_window_class_elem(), PCF_Face_Init(), pcf_get_accel(), pcf_get_bitmaps(), pcf_get_encodings(), pcf_get_metric(), pcf_get_metrics(), pcf_get_properties(), PCF_Glyph_Load(), pcf_interpret_style(), pcf_load_font(), pcf_property_get(), pcf_property_set(), pcf_read_TOC(), pcf_seek_to_table_type(), PCF_Size_Request(), pe_map_file(), PerformSampleRateConversion(), pfr_aux_name_load(), pfr_cmap_init(), pfr_extra_item_load_bitmap_info(), pfr_extra_item_load_font_id(), pfr_extra_item_load_kerning_pairs(), pfr_extra_item_load_stem_snaps(), pfr_extra_items_parse(), pfr_face_get_kerning(), pfr_face_init(), pfr_get_advance(), pfr_glyph_curve_to(), pfr_glyph_line_to(), pfr_glyph_load_compound(), pfr_glyph_load_rec(), pfr_glyph_load_simple(), pfr_glyph_move_to(), pfr_header_load(), pfr_load_bitmap_bits(), pfr_load_bitmap_metrics(), pfr_log_font_count(), pfr_log_font_load(), pfr_phy_font_load(), pfr_slot_load(), pfr_slot_load_bitmap(), pp_add_define(), prbytes(), pretty_print_option(), print_phase_basetype(), printasc(), process_comment(), process_component(), process_data_pdu(), process_extra(), process_group(), process_line(), process_orders(), process_picture(), process_polygon(), process_polygon2(), process_polyline(), process_redirect_pdu(), process_switches(), process_text(), ps_builder_add_contour(), ps_builder_add_point1(), ps_builder_start_point(), ps_dimension_add_counter(), ps_dimension_add_t1stem(), ps_dimension_set_mask_bits(), ps_hint_table_alloc(), ps_hint_table_ensure(), ps_hints_apply(), ps_hints_close(), ps_hints_stem(), ps_hints_t1reset(), ps_hints_t1stem3(), ps_hints_t2counter(), ps_hints_t2mask(), ps_mask_ensure(), ps_mask_set_bit(), ps_mask_table_alloc(), ps_mask_table_ensure(), ps_mask_table_last(), ps_mask_table_merge(), ps_mask_table_merge_all(), ps_mask_table_set_bits(), ps_parser_load_field(), ps_parser_load_field_table(), ps_parser_to_bytes(), ps_property_get(), ps_property_set(), ps_table_add(), ps_table_done(), ps_table_new(), psh_globals_new(), psh_glyph_init(), psh_glyph_interpolate_normal_points(), psh_hint_table_init(), rdp2vnc_connect(), rdp5_process(), rdpdr_process_irp(), rdpsnd_process(), rdssl_cert_read(), rdssl_cert_to_rkey(), rdssl_certs_ok(), rdssl_hash_clear(), rdssl_hash_complete(), rdssl_hash_info_create(), rdssl_hash_transform(), rdssl_hmac_md5(), rdssl_rc4_crypt(), rdssl_rc4_info_create(), rdssl_rc4_info_delete(), rdssl_rc4_set_key(), rdssl_rkey_free(), rdssl_rkey_get_exp_mod(), XMLStorage::XMLReaderBase::read(), read_importlib(), read_merging_directory(), read_pfb_tag(), read_pipe(), read_urls(), reallocate_t1_table(), reg_export(), reg_import(), reg_unreg_wine_test_class(), Render_Glyph(), request_receive(), request_send(), rewrite_client_leases(), rpcb_rmtcall(), RpcQualityOfService_Create(), rsa_exptmod(), rsa_make_key(), RtlCreateActivationContext(), ScriptStringAnalyse(), sec_parse_crypt_info(), sec_parse_public_key(), sec_parse_x509_key(), select_visual(), send_discover(), send_request_complete(), set_error(), set_synth_functions(), set_target(), tinyxml2::XMLDocument::SetError(), SEtoNW(), setup_brush(), SetupGetFileCompressionInfoA(), SetupGetFileCompressionInfoW(), SetUrlCacheEntryInfoA(), sfnt_init_face(), sfnt_load_face(), sfnt_open_font(), ShowTcpTable(), ShowUdpTable(), skip_literal_string(), SlWriteBytecode(), SnmpExtensionQuery(), SOFTPUB_DecodeInnerContent(), SOFTPUB_LoadCatalogMessage(), SOFTPUB_LoadFileMessage(), sort_n_finish(), src_callback_read(), src_process(), src_simple(), start_installation(), START_TEST(), store_id3_text(), stream_initialize_from_filehandle(), string_of_type(), surface_cpu_blt(), susage(), SWtoNE(), synth_ntom_set_step(), t1_allocate_blend(), t1_builder_add_contour(), t1_builder_add_point1(), t1_builder_start_point(), T1_Compute_Max_Advance(), T1_Face_Init(), T1_Get_Advances(), T1_Get_MM_Var(), T1_Get_Multi_Master(), T1_Get_Private_Dict(), T1_Load_Glyph(), t1_load_keyword(), T1_New_Parser(), T1_Open_Face(), T1_Parse_Glyph(), T1_Parse_Glyph_And_Get_Char_String(), T1_Read_Metrics(), T1_Read_PFM(), T1_Set_MM_Blend(), T1_Set_MM_Design(), T1_Size_Init(), T42_Face_Init(), T42_GlyphSlot_Init(), T42_GlyphSlot_Load(), t42_load_keyword(), T42_Open_Face(), t42_parse_charstrings(), t42_parse_encoding(), t42_parse_sfnts(), t42_parser_init(), T42_Size_Init(), T42_Size_Request(), T42_Size_Select(), tcp_connect(), tcp_recv(), tcp_send(), test_admin(), test_adminimage(), test_adminprops(), test_allusers_prop(), test_appsearch_complocator(), test_appsearch_drlocator(), test_appsearch_inilocator(), test_AssociateColorProfileWithDeviceA(), test_async_HttpSendRequestEx(), test_basic_authentication(), test_basic_request(), test_bogus_accept_types_array(), test_cabisextracted(), test_caborder(), test_CanUserWritePwrScheme(), test_command(), test_concurrentinstall(), test_connection_failure(), test_connection_info(), test_continuouscabs(), test_cookie_header(), test_create_remove_folder(), test_create_remove_shortcut(), test_CreateDirectoryA(), test_CreateFile(), test_CreateIconFromResource(), test_CreateThread_basic(), test_CreateThread_suspended(), test_CreateWellKnownSid(), test_credentials(), test_CredMarshalCredentialA(), test_CredUnmarshalCredentialA(), test_CryptCATAdminAddRemoveCatalog(), test_currentworkingdir(), test_customaction51(), test_dbtopackage(), test_decodeOctets(), test_default_service_port(), test_deferred_action(), test_delete_services(), test_DestroyCursor(), test_directory(), test_dispex(), test_domdoc(), test_duplicate_files(), test_envvar(), test_feature_override(), test_file_in_use(), test_file_in_use_cab(), test_find_first_file(), test_find_related_products(), test_get_user_profile_dir(), test_GetComputerName(), test_GetComputerNameExA(), test_GetComputerNameExW(), test_GetDiskInfoA(), test_GetICMProfileA(), test_GetICMProfileW(), test_GetNamedSecurityInfoA(), test_GetSetConsoleInputExeName(), test_GetSetStdHandle(), test_GetThreadTimes(), test_GetVolumePathNameA(), test_GetVolumePathNamesForVolumeNameA(), test_GetVolumePathNamesForVolumeNameW(), test_GlobalAlloc(), test_hashes(), test_HeapCreate(), test_HttpOptions(), test_HttpQueryInfo(), test_HttpSendRequestW(), test_IDirectDrawStreamSample(), test_ImpersonateNamedPipeClient(), test_impersonation_level(), test_initial_cursor(), test_install_remove_odbc(), test_install_services(), test_installed_prop(), test_installstate(), test_InternetErrorDlg(), test_lastusedsource(), test_LoadImage(), test_LoadImageFile(), test_LocalAlloc(), test_LookupAccountSid(), test_message_from_hmodule(), test_message_from_string_wide(), test_message_null_buffer(), test_message_null_buffer_wide(), test_missingcab(), test_missingcomponent(), test_mixed_package(), test_mixedmedia(), test_move_files(), test_MsiConfigureProductEx(), test_MsiDatabaseCommit(), test_MsiEnumComponentCosts(), test_MsiEnumPatchesEx_userunmanaged(), test_MsiInstallProduct(), test_MsiQueryComponentState(), test_MsiQueryFeatureState(), test_MsiQueryProductState(), test_MsiSetComponentState(), test_MsiSetExternalUI(), test_no_headers(), test_open_url_async(), test_openfile(), test_opengl3(), test_options(), test_package_validation(), test_parseerror(), test_parser(), test_preselected(), test_process_components(), test_progman_dde(), test_progman_dde2(), test_propcase(), test_proxy_direct(), test_publish(), test_publish_components(), test_publish_features(), test_publish_product(), test_publish_sourcelist(), test_rc2(), test_readonlyfile(), test_readonlyfile_cab(), Test_References(), test_reg_open_key(), test_register_class_info(), test_register_extension_info(), test_register_font(), test_register_mime_info(), test_register_product(), test_register_progid_info(), test_register_typelib(), test_register_user(), test_remove_duplicate_files(), test_remove_env_strings(), test_remove_existing_products(), test_remove_files(), test_remove_ini_values(), test_remove_registry_values(), test_renderfile(), test_request_parameter_defaults(), test_samesequence(), test_self_registration(), test_send(), test_sendto(), test_sequence(), test_SetCursor(), test_setdirproperty(), test_SetFileValidData(), test_SetICMProfileA(), test_SetICMProfileW(), test_setpropertyfolder(), test_SetupDiCreateDeviceInfoListEx(), test_SetupGetSourceFileLocation(), test_SetupLogError(), test_shell_window(), test_shortcut(), test_sioAddressListChange(), test_sourcedir(), test_sourcedirprop(), test_sourcefolder(), test_SuspendThread(), test_transformprop(), test_try_transform(), test_uiLevelFlags(), test_validate_product_id(), test_VerifyConsoleIoHandle(), test_WinHttpDetectAutoProxyConfigUrl(), test_WinHttpGetIEProxyConfigForCurrentUser(), test_WinHttpGetProxyForUrl(), test_WithWSAStartup(), test_write_registry_values(), test_WSAEnumNameSpaceProvidersA(), test_WSAEnumNameSpaceProvidersW(), test_WSAEnumProtocolsA(), test_WSAEnumProtocolsW(), test_WSALookupService(), TestEnumFontFamilies(), testGetModuleHandleEx(), testIcmpSendEcho(), testQuery(), testSAX(), testScreenBuffer(), teximage(), texstorage(), TextIntGetTextExtentPoint(), TextIntUpdateSize(), texture2d_read_from_framebuffer(), tlb_lseek(), tlb_read(), tree_concat(), tree_const(), tree_host_lookup(), TRIO_ARGS2(), TT_Access_Glyph_Frame(), tt_check_single_notdef(), tt_face_get_metrics(), tt_face_get_name(), tt_face_goto_table(), tt_face_init(), tt_face_load_any(), tt_face_load_cmap(), tt_face_load_cvt(), tt_face_load_font_dir(), tt_face_load_fpgm(), tt_face_load_gasp(), tt_face_load_generic_header(), tt_face_load_hdmx(), tt_face_load_hhea(), tt_face_load_hmtx(), tt_face_load_kern(), tt_face_load_loca(), tt_face_load_maxp(), tt_face_load_name(), tt_face_load_os2(), tt_face_load_pclt(), tt_face_load_post(), tt_face_load_prep(), tt_get_metrics(), tt_glyph_load(), TT_Hint_Glyph(), TT_Load_Composite_Glyph(), TT_Load_Glyph(), TT_Load_Simple_Glyph(), tt_loader_init(), TT_Process_Composite_Glyph(), TT_Process_Simple_Glyph(), tt_property_get(), tt_property_set(), tt_size_init(), tt_size_request(), tt_synth_sfnt_checksum(), type_buffer_alignment(), type_memsize_and_alignment(), ui_create_cursor(), ui_draw_text(), ui_init(), ui_select(), UnlockUrlCacheEntryFileA(), urlcache_create_hash_table(), urlcache_entry_commit(), urlcache_entry_create(), urlcache_entry_get_file(), urlcache_find_next_entry(), urlcache_get_entry_info(), urlcache_hash_entry_create(), user_type_offset(), verify_cert_revocation(), verify_cert_revocation_from_aia_ext(), verify_cert_revocation_from_dist_points_ext(), verify_cert_revocation_with_crl_offline(), verify_cert_revocation_with_crl_online(), vgaNEtoSW(), vgaNWtoSE(), vgaSEtoNW(), vgaSWtoNE(), vncNewCursor(), wait_for_completion(), wave_out_write(), wctomb(), wetwork(), wglUseFontOutlines_common(), WHERE_sort(), win32_error_file_func(), wined3d_cs_exec_blt_sub_resource(), winhttp_request_Open(), WinHttpCrackUrl_test(), WINTRUST_CertVerify(), WINTRUST_CertVerifyObjTrust(), WINTRUST_DefaultVerify(), WINTRUST_GetSignedMsgFromPEFile(), WINTRUST_TrustStatusToError(), woff_open_font(), wpp_open_mem(), wrap_lseek(), wrap_read(), write_branch_type(), write_client_lease(), write_conf_or_var_desc(), write_conformant_array_pointer_descriptions(), write_dlldata(), write_dlldata_list(), write_endpoints(), write_header(), write_id_data(), write_ip_tfs(), write_local_stubs(), write_member_type(), write_pointer_description_offsets(), write_regscript(), write_remoting_arg(), write_simple_pointer(), write_string_tfs(), write_struct_members(), write_struct_tfs(), write_type_tfs(), write_union_tfs(), write_var_desc(), write_varying_array_pointer_descriptions(), WSAEnumProtocolsA(), WSAEnumProtocolsW(), WSPSocket(), xfwrite(), xkeymap_read(), xkeymap_send_keys(), xmlGetUTF8Char(), xmlMemFree(), xmlMemStrdupLoc(), xmlReallocLoc(), xsltAddKey(), xsltApplySequenceConstructor(), xsltApplyStylesheetInternal(), xsltApplyTemplates(), xsltAttribute(), xsltAttrListTemplateProcess(), xsltChoose(), xsltCompileAttr(), xsltCompilePatternInternal(), xsltCompileRelativePathPattern(), xsltCompileStepPattern(), xsltDocumentComp(), xsltDocumentElem(), xsltElement(), xsltElementComp(), xsltEvalGlobalVariable(), xsltEvalVariable(), xsltForEach(), xsltGetUTF8Char(), xsltIf(), xsltInitCtxtKey(), xsltKeyFunction(), xsltMessage(), xsltNamespaceAlias(), xsltParseStylesheetImport(), xsltParseStylesheetInclude(), xsltParseStylesheetKey(), xsltParseStylesheetTemplate(), xsltPrintErrorContext(), xsltProcessingInstruction(), xsltTransformError(), xsltValueOf(), and xwin_process_events().

#define FALSE   0

Definition at line 336 of file mkdosfs.c.

Referenced by valid_offset().

#define FAT12_THRESHOLD   4078

Definition at line 394 of file mkdosfs.c.

Referenced by setup_tables().

#define fat32   fstype._fat32

Definition at line 454 of file mkdosfs.c.

#define FAT_BAD   0x0ffffff7

Definition at line 379 of file mkdosfs.c.

Referenced by set_fat().

#define FAT_EOF   (atari_format ? 0x0fffffff : 0x0ffffff8)

Definition at line 378 of file mkdosfs.c.

Referenced by set_fat(), and setup_tables().

#define GEMDOS_MAX_SECTOR_SIZE   (16*1024)

Definition at line 398 of file mkdosfs.c.

Referenced by setup_tables().

#define GEMDOS_MAX_SECTORS   65531

Definition at line 397 of file mkdosfs.c.

Referenced by setup_tables().

#define HARD_SECTOR_SIZE   512

Definition at line 339 of file mkdosfs.c.

Referenced by mark_FAT_sector(), and setup_tables().

#define mark_sector_bad (   sector)    mark_FAT_sector( sector, FAT_BAD )

Definition at line 352 of file mkdosfs.c.

Referenced by check_blocks(), and get_list_blocks().

#define MAX_CLUST_12   ((1 << 12) - 16)

Definition at line 388 of file mkdosfs.c.

Referenced by setup_tables().

#define MAX_CLUST_16   ((1 << 16) - 16)

Definition at line 389 of file mkdosfs.c.

Referenced by setup_tables().

#define MAX_CLUST_32   ((1 << 28) - 16)

Definition at line 392 of file mkdosfs.c.

Referenced by setup_tables().

#define MESSAGE_OFFSET   29 /* Offset of message in above code */

Definition at line 515 of file mkdosfs.c.

Referenced by main().

#define MSDOS_EXT_SIGN   0x29 /* extended boot sector signature */

Definition at line 381 of file mkdosfs.c.

Referenced by setup_tables().

#define MSDOS_FAT12_SIGN   "FAT12 " /* FAT12 filesystem signature */

Definition at line 382 of file mkdosfs.c.

Referenced by setup_tables().

#define MSDOS_FAT16_SIGN   "FAT16 " /* FAT16 filesystem signature */

Definition at line 383 of file mkdosfs.c.

Referenced by setup_tables().

#define MSDOS_FAT32_SIGN   "FAT32 " /* FAT32 filesystem signature */

Definition at line 384 of file mkdosfs.c.

Referenced by setup_tables().

#define O_BACKUP   0

Definition at line 299 of file mkdosfs.c.

#define O_NOINHERIT   0

Definition at line 294 of file mkdosfs.c.

Referenced by test_file_inherit().

#define O_NONE   0

Definition at line 302 of file mkdosfs.c.

#define O_RANDOM   0

Definition at line 298 of file mkdosfs.c.

#define O_SEQUENTIAL   0

Definition at line 297 of file mkdosfs.c.

#define O_SHARED   0

Definition at line 300 of file mkdosfs.c.

#define O_SHORT_LIVED   0

Definition at line 296 of file mkdosfs.c.

#define O_TEMPORARY   0

Definition at line 295 of file mkdosfs.c.

#define oldfat   fstype._oldfat

Definition at line 455 of file mkdosfs.c.

#define OLDGEMDOS_MAX_SECTORS   32765

Definition at line 396 of file mkdosfs.c.

Referenced by setup_tables().

#define SECTORS_PER_BLOCK   ( BLOCK_SIZE / HARD_SECTOR_SIZE )

Definition at line 340 of file mkdosfs.c.

Referenced by check_blocks(), establish_params(), get_list_blocks(), and setup_tables().

#define seekto (   pos,
  errstr 
)
Value:
do { \
loff_t __pos = (pos); \
if (llseek (dev, __pos, SEEK_SET) != __pos) \
error ("seek to " errstr " failed whilst writing tables"); \
} while(0)
#define error(str)
Definition: mkdosfs.c:1605
#define SEEK_SET
Definition: jmemansi.c:26
if(!(yy_init))
Definition: macro.lex.yy.c:717
unsigned __int64 loff_t
Definition: types.h:80
static loff_t llseek(int fd, loff_t offset, int whence)
Definition: mkdosfs.c:321
const char * errstr(int errcode)

Definition at line 1613 of file mkdosfs.c.

Referenced by _marshal_interface(), _unmarshal_interface(), CoMarshalInterThreadInterfaceInStream(), ide_seek(), local_server_thread(), RPC_GetLocalClassObject(), test_empty_image(), test_empty_image_2(), test_pic(), and write_tables().

#define TEST_BUFFER_BLOCKS   16

Definition at line 338 of file mkdosfs.c.

Referenced by check_blocks().

#define TRUE   1 /* Boolean constants */

Definition at line 335 of file mkdosfs.c.

Referenced by main(), and valid_offset().

#define writebuf (   buf,
  size,
  errstr 
)
Value:
do { \
int __size = (size); \
if (write (dev, buf, __size) != __size) \
error ("failed whilst writing " errstr); \
} while(0)
#define error(str)
Definition: mkdosfs.c:1605
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
__u32 size
Definition: mkdosfs.c:367
#define write
Definition: acwin.h:73
if(!(yy_init))
Definition: macro.lex.yy.c:717
const char * errstr(int errcode)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:29

Definition at line 1620 of file mkdosfs.c.

Referenced by write_tables().

Typedef Documentation

typedef long long ll_t

Definition at line 305 of file mkdosfs.c.

Function Documentation

Definition at line 52 of file framebased-gcchack.c.

57 {
58  return trampoline_->STR_MovEcx == 0xb9 && trampoline_->STR_Jmp == 0xe9;
59 }
static _syscall5 ( int  ,
_llseek  ,
uint  ,
fd  ,
ulong  ,
hi  ,
ulong  ,
lo  ,
loff_t ,
res  ,
uint  ,
wh   
)
static
static void alarm_intr ( int  alnum)
static

Definition at line 668 of file mkdosfs.c.

Referenced by check_blocks().

669 {
670  if (currently_testing >= blocks)
671  return;
672 
673  signal (SIGALRM, alarm_intr);
674  alarm (5);
675  if (!currently_testing)
676  return;
677 
678  printf ("%d... ", currently_testing);
679  fflush (stdout);
680 }
FILE * stdout
static int blocks
Definition: mkdosfs.c:527
int signal
Definition: xcptfil.c:12
static unsigned int currently_testing
Definition: mkdosfs.c:538
static void alarm_intr(int alnum)
Definition: mkdosfs.c:668
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
#define printf
Definition: config.h:203
int cdiv ( int  a,
int  b 
)
inline

Definition at line 357 of file mkdosfs.c.

Referenced by setup_tables().

358 {
359  return (a + b - 1) / b;
360 }
#define b
Definition: ke_i.h:79
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
static void check_atari ( void  )
static

Definition at line 1700 of file mkdosfs.c.

Referenced by main().

1701 {
1702 #ifdef __mc68000__
1703  FILE *f;
1704  char line[128], *p;
1705 
1706  if (!(f = fopen( "/proc/hardware", "r" ))) {
1707  perror( "/proc/hardware" );
1708  return;
1709  }
1710 
1711  while( fgets( line, sizeof(line), f ) ) {
1712  if (strncmp( line, "Model:", 6 ) == 0) {
1713  p = line + 6;
1714  p += strspn( p, " \t" );
1715  if (strncmp( p, "Atari ", 6 ) == 0)
1716  atari_format = 1;
1717  break;
1718  }
1719  }
1720  fclose( f );
1721 #endif
1722 }
_Check_return_ _CRTIMP size_t __cdecl strspn(_In_z_ const char *_Str, _In_z_ const char *_Control)
static int atari_format
Definition: mkdosfs.c:521
_CRTIMP void __cdecl perror(_In_opt_z_ const char *_ErrMsg)
Definition: parser.c:48
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_opt_ _CRTIMP char *__cdecl fgets(_Out_writes_z_(_MaxCount) char *_Buf, _In_ int _MaxCount, _Inout_ FILE *_File)
#define f
Definition: ke_i.h:83
GLfloat GLfloat p
Definition: glext.h:8902
static void check_blocks ( void  )
static

Definition at line 684 of file mkdosfs.c.

Referenced by main().

685 {
686  int try, got;
687  int i;
688  static char blkbuf[BLOCK_SIZE * TEST_BUFFER_BLOCKS];
689 
690  if (verbose)
691  {
692  printf ("Searching for bad blocks ");
693  fflush (stdout);
694  }
695  currently_testing = 0;
696 #ifndef _WIN32
697  if (verbose)
698  {
699  signal (SIGALRM, alarm_intr);
700  alarm (5);
701  }
702 #endif
703  try = TEST_BUFFER_BLOCKS;
704  while (currently_testing < blocks)
705  {
706  if (currently_testing + try > blocks)
707  try = blocks - currently_testing;
708  got = do_check (blkbuf, try, currently_testing);
709  currently_testing += got;
710  if (got == try)
711  {
712  try = TEST_BUFFER_BLOCKS;
713  continue;
714  }
715  else
716  try = 1;
717  if (currently_testing < start_data_block)
718  die ("bad blocks before data-area: cannot make fs");
719 
720  for (i = 0; i < SECTORS_PER_BLOCK; i++) /* Mark all of the sectors in the block as bad */
721  mark_sector_bad (currently_testing * SECTORS_PER_BLOCK + i);
722  badblocks++;
723  currently_testing++;
724  }
725 
726  if (verbose)
727  printf ("\n");
728 
729  if (badblocks)
730  printf ("%d bad block%s\n", badblocks,
731  (badblocks > 1) ? "s" : "");
732 }
static int start_data_block
Definition: mkdosfs.c:541
static int badblocks
Definition: mkdosfs.c:532
static long do_check(char *buffer, int try, unsigned int current_block)
Definition: mkdosfs.c:644
FILE * stdout
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define mark_sector_bad(sector)
Definition: mkdosfs.c:352
static int blocks
Definition: mkdosfs.c:527
#define BLOCK_SIZE
Definition: dlist.c:321
#define SECTORS_PER_BLOCK
Definition: mkdosfs.c:340
int signal
Definition: xcptfil.c:12
static unsigned int currently_testing
Definition: mkdosfs.c:538
static void alarm_intr(int alnum)
Definition: mkdosfs.c:668
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
#define die(str)
Definition: mkdosfs.c:347
static int verbose
Definition: mkdosfs.c:523
#define TEST_BUFFER_BLOCKS
Definition: mkdosfs.c:338
#define printf
Definition: config.h:203
static void check_mount ( char device_name)
static

Definition at line 847 of file mkdosfs.c.

Referenced by main().

848 {
849 #ifndef _WIN32
850  FILE *f;
851  struct mntent *mnt;
852 
853  if ((f = setmntent (MOUNTED, "r")) == NULL)
854  return;
855  while ((mnt = getmntent (f)) != NULL)
856  if (strcmp (device_name, mnt->mnt_fsname) == 0)
857  die ("%s contains a mounted file system.");
858  endmntent (f);
859 #endif
860 }
static char * device_name
Definition: mkdosfs.c:520
smooth NULL
Definition: ftsmooth.c:416
#define f
Definition: ke_i.h:83
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define die(str)
Definition: mkdosfs.c:347
static int count_blocks ( char filename)
static

Definition at line 782 of file mkdosfs.c.

Referenced by main().

783 {
784 #ifdef _WIN32
785  int fd;
786  DISK_GEOMETRY geom;
788  DWORD ret;
789  loff_t len = 0;
790 
791  if ((fd = open(filename, O_RDONLY)) < 0) {
792  perror(filename);
793  exit(1);
794  }
795  /*
796  * This should probably use IOCTL_DISK_GET_LENGTH_INFO here, but
797  * this ioctl is only available in XP and up.
798  */
799  if (is_device) {
800  if (!DeviceIoControl((HANDLE)fd, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, &geom, sizeof(geom), &ret, NULL)) {
801  errno = GetLastError();
802  die("unable to get length for '%s'");
803  }
805  } else {
806  if (!GetFileInformationByHandle((HANDLE)fd, &hinfo)) {
807  errno = GetLastError();
808  die("unable to get length for '%s'");
809  }
810  len = ((loff_t)hinfo.nFileSizeHigh << 32) | (loff_t)hinfo.nFileSizeLow;
811  }
812  close(fd);
813  return len/BLOCK_SIZE;
814 #else
815  loff_t high, low;
816  int fd;
817 
818  if ((fd = open (filename, O_RDONLY)) < 0)
819  {
820  perror (filename);
821  exit (1);
822  }
823  low = 0;
824 
825  for (high = 1; valid_offset (fd, high); high *= 2)
826  low = high;
827  while (low < high - 1)
828  {
829  const loff_t mid = (low + high) / 2;
830 
831  if (valid_offset (fd, mid))
832  low = mid;
833  else
834  high = mid;
835  }
836  valid_offset (fd, 0);
837  close (fd);
838 
839  return (low + 1) / BLOCK_SIZE;
840 #endif
841 }
#define open
Definition: acwin.h:71
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1056
static int fd
Definition: io.c:51
ULONG TracksPerCylinder
Definition: ntdddisk.h:371
int errno
const char * filename
Definition: ioapi.h:135
DWORD DWORD
Definition: winlogon.h:75
_CRTIMP void __cdecl perror(_In_opt_z_ const char *_ErrMsg)
smooth NULL
Definition: ftsmooth.c:416
#define BLOCK_SIZE
Definition: dlist.c:321
BOOL WINAPI GetFileInformationByHandle(HANDLE hFile, LPBY_HANDLE_FILE_INFORMATION lpFileInformation)
Definition: fileinfo.c:608
LARGE_INTEGER Cylinders
Definition: ntdddisk.h:369
ULONG SectorsPerTrack
Definition: ntdddisk.h:372
unsigned __int64 loff_t
Definition: types.h:80
int ret
GLenum GLsizei len
Definition: glext.h:6722
#define close
Definition: acwin.h:74
static int valid_offset(int fd, loff_t offset)
Definition: mkdosfs.c:766
DWORD *typedef HANDLE
Definition: winlogon.h:52
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
#define die(str)
Definition: mkdosfs.c:347
void exit(int exitcode)
Definition: _exit.c:33
#define IOCTL_DISK_GET_DRIVE_GEOMETRY
Definition: cdrw_usr.h:169
LONGLONG QuadPart
Definition: typedefs.h:112
#define O_RDONLY
Definition: acwin.h:82
static long do_check ( char buffer,
int  try,
unsigned int  current_block 
)
static

Definition at line 644 of file mkdosfs.c.

Referenced by check_blocks().

645 {
646  long got;
647 
648  if (llseek (dev, (loff_t)current_block * BLOCK_SIZE, SEEK_SET) /* Seek to the correct location */
649  != (loff_t)current_block * BLOCK_SIZE)
650  die ("seek failed during testing for blocks");
651 
652  got = read (dev, buffer, try * BLOCK_SIZE); /* Try reading! */
653  if (got < 0)
654  got = 0;
655 
656  if (got & (BLOCK_SIZE - 1))
657  printf ("Unexpected values in do_check: probably bugs\n");
658  got /= BLOCK_SIZE;
659 
660  return got;
661 }
GLuint buffer
Definition: glext.h:5915
#define SEEK_SET
Definition: jmemansi.c:26
#define BLOCK_SIZE
Definition: dlist.c:321
unsigned __int64 loff_t
Definition: types.h:80
static loff_t llseek(int fd, loff_t offset, int whence)
Definition: mkdosfs.c:321
#define die(str)
Definition: mkdosfs.c:347
_CRTIMP int __cdecl read(_In_ int _FileHandle, _Out_writes_bytes_(_MaxCharCount) void *_DstBuf, _In_ unsigned int _MaxCharCount)
#define printf
Definition: config.h:203
static void establish_params ( int  device_num,
int  size 
)
static

Definition at line 924 of file mkdosfs.c.

Referenced by main().

925 {
926  long loop_size;
927  struct hd_geometry geometry;
928  struct floppy_struct param;
929 
930  if ((0 == device_num) || ((device_num & 0xff00) == 0x0200))
931  /* file image or floppy disk */
932  {
933  if (0 == device_num)
934  {
935  param.size = size/512;
936  switch(param.size)
937  {
938  case 720:
939  param.sect = 9 ;
940  param.head = 2;
941  break;
942  case 1440:
943  param.sect = 9;
944  param.head = 2;
945  break;
946  case 2400:
947  param.sect = 15;
948  param.head = 2;
949  break;
950  case 2880:
951  param.sect = 18;
952  param.head = 2;
953  break;
954  case 5760:
955  param.sect = 36;
956  param.head = 2;
957  break;
958  default:
959  /* fake values */
960  param.sect = 32;
961  param.head = 64;
962  break;
963  }
964 
965  }
966  else /* is a floppy diskette */
967  {
968  if (ioctl (dev, FDGETPRM, &param)) /* Can we get the diskette geometry? */
969  die ("unable to get diskette geometry for '%s'");
970  }
971  bs.secs_track = CT_LE_W(param.sect); /* Set up the geometry information */
972  bs.heads = CT_LE_W(param.head);
973  switch (param.size) /* Set up the media descriptor byte */
974  {
975  case 720: /* 5.25", 2, 9, 40 - 360K */
976  bs.media = (char) 0xfd;
977  bs.cluster_size = (char) 2;
978  bs.dir_entries[0] = (char) 112;
979  bs.dir_entries[1] = (char) 0;
980  break;
981 
982  case 1440: /* 3.5", 2, 9, 80 - 720K */
983  bs.media = (char) 0xf9;
984  bs.cluster_size = (char) 2;
985  bs.dir_entries[0] = (char) 112;
986  bs.dir_entries[1] = (char) 0;
987  break;
988 
989  case 2400: /* 5.25", 2, 15, 80 - 1200K */
990  bs.media = (char) 0xf9;
991  bs.cluster_size = (char)(atari_format ? 2 : 1);
992  bs.dir_entries[0] = (char) 224;
993  bs.dir_entries[1] = (char) 0;
994  break;
995 
996  case 5760: /* 3.5", 2, 36, 80 - 2880K */
997  bs.media = (char) 0xf0;
998  bs.cluster_size = (char) 2;
999  bs.dir_entries[0] = (char) 224;
1000  bs.dir_entries[1] = (char) 0;
1001  break;
1002 
1003  case 2880: /* 3.5", 2, 18, 80 - 1440K */
1004  floppy_default:
1005  bs.media = (char) 0xf0;
1006  bs.cluster_size = (char)(atari_format ? 2 : 1);
1007  bs.dir_entries[0] = (char) 224;
1008  bs.dir_entries[1] = (char) 0;
1009  break;
1010 
1011  default: /* Anything else */
1012  if (0 == device_num)
1013  goto def_hd_params;
1014  else
1015  goto floppy_default;
1016  }
1017  }
1018  else if ((device_num & 0xff00) == 0x0700) /* This is a loop device */
1019  {
1020  /* Can we get the loop geometry? This is in 512 byte blocks, always? */
1021  if (ioctl (dev, BLKGETSIZE, &loop_size))
1022  die ("unable to get loop geometry for '%s'");
1023  loop_size = loop_size >> 1;
1024 
1025  switch (loop_size) /* Assuming the loop device -> floppy later */
1026  {
1027  case 720: /* 5.25", 2, 9, 40 - 360K */
1028  bs.secs_track = CF_LE_W(9);
1029  bs.heads = CF_LE_W(2);
1030  bs.media = (char) 0xfd;
1031  bs.cluster_size = (char) 2;
1032  bs.dir_entries[0] = (char) 112;
1033  bs.dir_entries[1] = (char) 0;
1034  break;
1035 
1036  case 1440: /* 3.5", 2, 9, 80 - 720K */
1037  bs.secs_track = CF_LE_W(9);
1038  bs.heads = CF_LE_W(2);
1039  bs.media = (char) 0xf9;
1040  bs.cluster_size = (char) 2;
1041  bs.dir_entries[0] = (char) 112;
1042  bs.dir_entries[1] = (char) 0;
1043  break;
1044 
1045  case 2400: /* 5.25", 2, 15, 80 - 1200K */
1046  bs.secs_track = CF_LE_W(15);
1047  bs.heads = CF_LE_W(2);
1048  bs.media = (char) 0xf9;
1049  bs.cluster_size = (char)(atari_format ? 2 : 1);
1050  bs.dir_entries[0] = (char) 224;
1051  bs.dir_entries[1] = (char) 0;
1052  break;
1053 
1054  case 5760: /* 3.5", 2, 36, 80 - 2880K */
1055  bs.secs_track = CF_LE_W(36);
1056  bs.heads = CF_LE_W(2);
1057  bs.media = (char) 0xf0;
1058  bs.cluster_size = (char) 2;
1059  bs.dir_entries[0] = (char) 224;
1060  bs.dir_entries[1] = (char) 0;
1061  break;
1062 
1063  case 2880: /* 3.5", 2, 18, 80 - 1440K */
1064  bs.secs_track = CF_LE_W(18);
1065  bs.heads = CF_LE_W(2);
1066  bs.media = (char) 0xf0;
1067  bs.cluster_size = (char)(atari_format ? 2 : 1);
1068  bs.dir_entries[0] = (char) 224;
1069  bs.dir_entries[1] = (char) 0;
1070  break;
1071 
1072  default: /* Anything else: default hd setup */
1073  printf("Loop device does not match a floppy size, using "
1074  "default hd params\n");
1075  bs.secs_track = CT_LE_W(32); /* these are fake values... */
1076  bs.heads = CT_LE_W(64);
1077  goto def_hd_params;
1078  }
1079  }
1080  else
1081  /* Must be a hard disk then! */
1082  {
1083  /* Can we get the drive geometry? (Note I'm not too sure about */
1084  /* whether to use HDIO_GETGEO or HDIO_REQ) */
1085  if (ioctl (dev, HDIO_GETGEO, &geometry))
1086  die ("unable to get drive geometry for '%s'");
1087  bs.secs_track = CT_LE_W(geometry.sectors); /* Set up the geometry information */
1088  bs.heads = CT_LE_W(geometry.heads);
1089  def_hd_params:
1090  bs.media = (char) 0xf8; /* Set up the media descriptor for a hard drive */
1091  bs.dir_entries[0] = (char) 0; /* Default to 512 entries */
1092  bs.dir_entries[1] = (char) 2;
1093  /* For FAT32, use 4k clusters on sufficiently large file systems,
1094  * otherwise 1 sector per cluster. This is also what M$'s format
1095  * command does for FAT32. */
1096  bs.cluster_size = (char)
1097  (size_fat == 32 ?
1098  ((ll_t)blocks*SECTORS_PER_BLOCK >= 512*1024 ? 8 : 1) :
1099  4); /* FAT12 and FAT16: start at 4 sectors per cluster */
1100  }
1101 }
long long ll_t
Definition: mkdosfs.c:305
static int size_fat
Definition: mkdosfs.c:534
static int atari_format
Definition: mkdosfs.c:521
#define ioctl
Definition: wintirpc.h:60
unsigned char
Definition: typeof.h:27
static int blocks
Definition: mkdosfs.c:527
GLsizeiptr size
Definition: glext.h:5919
#define SECTORS_PER_BLOCK
Definition: mkdosfs.c:340
GLfloat param
Definition: glext.h:5796
#define CF_LE_W(v)
Definition: mkdosfs.c:94
#define CT_LE_W(v)
Definition: mkdosfs.c:97
#define die(str)
Definition: mkdosfs.c:347
static struct msdos_boot_sector bs
Definition: mkdosfs.c:539
#define printf
Definition: config.h:203
static void fatal_error ( const char fmt_string)
static

Definition at line 577 of file mkdosfs.c.

Referenced by usage().

578 {
579  fprintf (stderr, fmt_string, program_name, device_name);
580  exit (1); /* The error exit code is 1! */
581 }
static char * program_name
Definition: mkdosfs.c:519
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
static char * device_name
Definition: mkdosfs.c:520
FILE * stderr
void exit(int exitcode)
Definition: _exit.c:33
static void get_list_blocks ( char filename)
static

Definition at line 736 of file mkdosfs.c.

Referenced by main().

737 {
738  int i;
739  FILE *listfile;
740  unsigned long blockno;
741 
742  listfile = fopen (filename, "r");
743  if (listfile == (FILE *) NULL)
744  die ("Can't open file of bad blocks");
745 
746  while (!feof (listfile))
747  {
748  fscanf (listfile, "%ld\n", &blockno);
749  for (i = 0; i < SECTORS_PER_BLOCK; i++) /* Mark all of the sectors in the block as bad */
750  mark_sector_bad (blockno * SECTORS_PER_BLOCK + i);
751  badblocks++;
752  }
753  fclose (listfile);
754 
755  if (badblocks)
756  printf ("%d bad block%s\n", badblocks,
757  (badblocks > 1) ? "s" : "");
758 }
_Check_return_ _CRTIMP int __cdecl fscanf(_Inout_ FILE *_File, _In_z_ _Scanf_format_string_ const char *_Format,...)
static int badblocks
Definition: mkdosfs.c:532
const char * filename
Definition: ioapi.h:135
GLenum GLclampf GLint i
Definition: glfuncs.h:14
smooth NULL
Definition: ftsmooth.c:416
#define mark_sector_bad(sector)
Definition: mkdosfs.c:352
_Check_return_ _CRTIMP int __cdecl feof(_In_ FILE *_File)
#define SECTORS_PER_BLOCK
Definition: mkdosfs.c:340
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
#define die(str)
Definition: mkdosfs.c:347
#define printf
Definition: config.h:203
static loff_t llseek ( int  fd,
loff_t  offset,
int  whence 
)
static

Definition at line 321 of file mkdosfs.c.

Referenced by do_check(), main(), and valid_offset().

322 {
323  loff_t actual;
324 
325  if (_llseek(fd, offset>>32, offset&0xffffffff, &actual, whence) != 0)
326  return (loff_t)-1;
327  return actual;
328 }
LONG WINAPI _llseek(HFILE hFile, LONG lOffset, int iOrigin)
Definition: lfile.c:149
GLintptr offset
Definition: glext.h:5920
static int fd
Definition: io.c:51
unsigned __int64 loff_t
Definition: types.h:80
int main ( int argc  ,
char **  argv 
)

Definition at line 1728 of file mkdosfs.c.

1729 {
1730  int c;
1731  char *tmp;
1732  char *listfile = NULL;
1733  FILE *msgfile;
1734 #ifdef _WIN32
1735  static char dev_buf[] = "\\\\.\\X:";
1736 #else
1737  struct stat statbuf;
1738 #endif
1739  int i = 0, pos, ch;
1740  int create = 0;
1741 
1742  if (argc && *argv) { /* What's the program name? */
1743  char *p;
1744  program_name = *argv;
1745 #ifdef _WIN32
1746  if ((p = strrchr( program_name, '\\' )))
1747 #else
1748  if ((p = strrchr( program_name, '/' )))
1749 #endif
1750  program_name = p+1;
1751  }
1752 
1753  time(&create_time);
1754  volume_id = (long)create_time; /* Default volume ID = creation time */
1755  check_atari();
1756 
1757  printf ("%s " VERSION " (" VERSION_DATE ")\n"
1758 #ifdef _WIN32
1759  "Win32 port by Jens-Uwe Mager <jum@anubis.han.de>\n"
1760 #endif
1761  , program_name);
1762 
1763  while ((c = getopt (argc, argv, "AcCf:F:Ii:l:m:n:r:R:s:S:v")) != EOF)
1764  /* Scan the command line for options */
1765  switch (c)
1766  {
1767  case 'A': /* toggle Atari format */
1769  break;
1770 
1771  case 'b': /* b : location of backup boot sector */
1772  backup_boot = (int) strtol (optarg, &tmp, 0);
1773  if (*tmp || backup_boot < 2 || backup_boot > 0xffff)
1774  {
1775  printf ("Bad location for backup boot sector : %s\n", optarg);
1776  usage ();
1777  }
1778  break;
1779 
1780  case 'c': /* c : Check FS as we build it */
1781  check = TRUE;
1782  break;
1783 
1784  case 'C': /* C : Create a new file */
1785  create = TRUE;
1786  break;
1787 
1788  case 'f': /* f : Choose number of FATs */
1789  nr_fats = (int) strtol (optarg, &tmp, 0);
1790  if (*tmp || nr_fats < 1 || nr_fats > 4)
1791  {
1792  printf ("Bad number of FATs : %s\n", optarg);
1793  usage ();
1794  }
1795  break;
1796 
1797  case 'F': /* F : Choose FAT size */
1798  size_fat = (int) strtol (optarg, &tmp, 0);
1799  if (*tmp || (size_fat != 12 && size_fat != 16 && size_fat != 32))
1800  {
1801  printf ("Bad FAT type : %s\n", optarg);
1802  usage ();
1803  }
1804  size_fat_by_user = 1;
1805  break;
1806 
1807  case 'I':
1808  ignore_full_disk = 1;
1809  break;
1810 
1811  case 'i': /* i : specify volume ID */
1812  volume_id = strtol(optarg, &tmp, 16);
1813  if ( *tmp )
1814  {
1815  printf("Volume ID must be a hexadecimal number\n");
1816  usage();
1817  }
1818  break;
1819 
1820  case 'l': /* l : Bad block filename */
1821  listfile = optarg;
1822  break;
1823 
1824  case 'm': /* m : Set boot message */
1825  if ( strcmp(optarg, "-") )
1826  {
1827  msgfile = fopen(optarg, "r");
1828  if ( !msgfile )
1829  perror(optarg);
1830  }
1831  else
1832  msgfile = stdin;
1833 
1834  if ( msgfile )
1835  {
1836  /* The boot code ends at offset 448 and needs a null terminator */
1837  i = MESSAGE_OFFSET;
1838  pos = 0; /* We are at beginning of line */
1839  do
1840  {
1841  ch = getc(msgfile);
1842  switch (ch)
1843  {
1844  case '\r': /* Ignore CRs */
1845  case '\0': /* and nulls */
1846  break;
1847 
1848  case '\n': /* LF -> CR+LF if necessary */
1849  if ( pos ) /* If not at beginning of line */
1850  {
1851  dummy_boot_code[i++] = '\r';
1852  pos = 0;
1853  }
1854  dummy_boot_code[i++] = '\n';
1855  break;
1856 
1857  case '\t': /* Expand tabs */
1858  do
1859  {
1860  dummy_boot_code[i++] = ' ';
1861  pos++;
1862  }
1863  while ( pos % 8 && i < BOOTCODE_SIZE-1 );
1864  break;
1865 
1866  case EOF:
1867  dummy_boot_code[i++] = '\0'; /* Null terminator */
1868  break;
1869 
1870  default:
1871  dummy_boot_code[i++] = ch; /* Store character */
1872  pos++; /* Advance position */
1873  break;
1874  }
1875  }
1876  while ( ch != EOF && i < BOOTCODE_SIZE-1 );
1877 
1878  /* Fill up with zeros */
1879  while( i < BOOTCODE_SIZE-1 )
1880  dummy_boot_code[i++] = '\0';
1881  dummy_boot_code[BOOTCODE_SIZE-1] = '\0'; /* Just in case */
1882 
1883  if ( ch != EOF )
1884  printf ("Warning: message too long; truncated\n");
1885 
1886  if ( msgfile != stdin )
1887  fclose(msgfile);
1888  }
1889  break;
1890 
1891  case 'n': /* n : Volume name */
1892  sprintf(volume_name, "%-11.11s", optarg);
1893  break;
1894 
1895  case 'r': /* r : Root directory entries */
1896  root_dir_entries = (int) strtol (optarg, &tmp, 0);
1897  if (*tmp || root_dir_entries < 16 || root_dir_entries > 32768)
1898  {
1899  printf ("Bad number of root directory entries : %s\n", optarg);
1900  usage ();
1901  }
1902  break;
1903 
1904  case 'R': /* R : number of reserved sectors */
1905  reserved_sectors = (int) strtol (optarg, &tmp, 0);
1906  if (*tmp || reserved_sectors < 1 || reserved_sectors > 0xffff)
1907  {
1908  printf ("Bad number of reserved sectors : %s\n", optarg);
1909  usage ();
1910  }
1911  break;
1912 
1913  case 's': /* s : Sectors per cluster */
1914  sectors_per_cluster = (int) strtol (optarg, &tmp, 0);
1915  if (*tmp || (sectors_per_cluster != 1 && sectors_per_cluster != 2
1917  && sectors_per_cluster != 16 && sectors_per_cluster != 32
1918  && sectors_per_cluster != 64 && sectors_per_cluster != 128))
1919  {
1920  printf ("Bad number of sectors per cluster : %s\n", optarg);
1921  usage ();
1922  }
1923  break;
1924 
1925  case 'S': /* S : Sector size */
1926  sector_size = (int) strtol (optarg, &tmp, 0);
1927  if (*tmp || (sector_size != 512 && sector_size != 1024 &&
1928  sector_size != 2048 && sector_size != 4096 &&
1929  sector_size != 8192 && sector_size != 16384 &&
1930  sector_size != 32768))
1931  {
1932  printf ("Bad logical sector size : %s\n", optarg);
1933  usage ();
1934  }
1935  sector_size_set = 1;
1936  break;
1937 
1938  case 'v': /* v : Verbose execution */
1939  ++verbose;
1940  break;
1941 
1942  default:
1943  printf( "Unknown option: %c\n", c );
1944  usage ();
1945  }
1946 
1947  if (optind >= argc)
1948  usage();
1949  device_name = argv[optind]; /* Determine the number of blocks in the FS */
1950 #ifdef _WIN32
1951  if (device_name[1] == ':' && device_name[2] == '\0') {
1952  dev_buf[4] = device_name[0];
1953  device_name = dev_buf;
1954  is_device = 1;
1955  }
1956 #endif
1957  if (!create)
1958  i = count_blocks (device_name); /* Have a look and see! */
1959  if (optind == argc - 2) /* Either check the user specified number */
1960  {
1961  blocks = (int) strtol (argv[optind + 1], &tmp, 0);
1962  if (!create && blocks != i)
1963  {
1964  fprintf (stderr, "Warning: block count mismatch: ");
1965  fprintf (stderr, "found %d but assuming %d.\n",i,blocks);
1966  }
1967  }
1968  else if (optind == argc - 1) /* Or use value found */
1969  {
1970  if (create)
1971  die( "Need intended size with -C." );
1972  blocks = i;
1973  tmp = "";
1974  }
1975  else
1976  usage ();
1977  if (*tmp)
1978  {
1979  printf ("Bad block count : %s\n", argv[optind + 1]);
1980  usage ();
1981  }
1982 
1983  if (check && listfile) /* Auto and specified bad block handling are mutually */
1984  die ("-c and -l are incompatible"); /* exclusive of each other! */
1985 
1986  if (!create) {
1987  check_mount (device_name); /* Is the device already mounted? */
1988  dev = open (device_name, O_RDWR|O_SHARED); /* Is it a suitable device to build the FS on? */
1989  if (dev < 0)
1990  die ("unable to open %s");
1991 #ifdef _WIN32
1992  if (is_device) {
1993  if (fsctl(dev, FSCTL_LOCK_VOLUME) == -1)
1994  die("unable to lock %s");
1995  }
1996 #endif
1997  }
1998  else {
2000  char null = 0;
2001  /* create the file */
2002  dev = open( device_name, O_RDWR|O_CREAT|O_TRUNC, 0775 );
2003  if (dev < 0)
2004  die("unable to create %s");
2005  /* seek to the intended end-1, and write one byte. this creates a
2006  * sparse-as-possible file of appropriate size. */
2007  if (llseek( dev, offset, SEEK_SET ) != offset)
2008  die( "seek failed" );
2009  if (write( dev, &null, 1 ) < 0)
2010  die( "write failed" );
2011  if (llseek( dev, 0, SEEK_SET ) != 0)
2012  die( "seek failed" );
2013  }
2014 
2015 #ifdef _WIN32
2016  if (!is_device)
2017  check = 0;
2018  establish_params();
2019 #else
2020  if (fstat (dev, &statbuf) < 0)
2021  die ("unable to stat %s");
2022  if (!S_ISBLK (statbuf.st_mode)) {
2023  statbuf.st_rdev = 0;
2024  check = 0;
2025  }
2026  else
2027  /*
2028  * Ignore any 'full' fixed disk devices, if -I is not given.
2029  * On a MO-disk one doesn't need partitions. The filesytem can go
2030  * directly to the whole disk. Under other OSes this is known as
2031  * the 'superfloppy' format. As I don't know how to find out if
2032  * this is a MO disk I introduce a -I (ignore) switch. -Joey
2033  */
2034  if (!ignore_full_disk && (
2035  (statbuf.st_rdev & 0xff3f) == 0x0300 || /* hda, hdb */
2036  (statbuf.st_rdev & 0xff0f) == 0x0800 || /* sd */
2037  (statbuf.st_rdev & 0xff3f) == 0x0d00 || /* xd */
2038  (statbuf.st_rdev & 0xff3f) == 0x1600 ) /* hdc, hdd */
2039  )
2040  die ("Will not try to make filesystem on '%s'");
2041 
2042  establish_params (statbuf.st_rdev,statbuf.st_size);
2043  /* Establish the media parameters */
2044 #endif
2045 
2046  setup_tables (); /* Establish the file system tables */
2047 
2048  if (check) /* Determine any bad block locations and mark them */
2049  check_blocks ();
2050  else if (listfile)
2051  get_list_blocks (listfile);
2052 
2053  write_tables (); /* Write the file system tables away! */
2054 
2055 #ifdef _WIN32
2056  if (is_device) {
2057  if (fsctl(dev, FSCTL_DISMOUNT_VOLUME) == -1)
2058  die("unable to dismount %s");
2059  if (fsctl(dev, FSCTL_UNLOCK_VOLUME) == -1)
2060  die("unable to unlock %s");
2061  }
2062 #endif
2063  exit (0); /* Terminate with no errors! */
2064 }
static int sectors_per_cluster
Definition: mkdosfs.c:546
static int ignore_full_disk
Definition: mkdosfs.c:537
static int argc
Definition: ServiceArgs.c:12
#define FSCTL_UNLOCK_VOLUME
Definition: nt_native.h:833
void usage(void)
Definition: mkdosfs.c:1686
#define S_ISBLK(m)
Definition: ext2fs.h:370
static void establish_params(int device_num, int size)
Definition: mkdosfs.c:924
#define open
Definition: acwin.h:71
static char * program_name
Definition: mkdosfs.c:519
int optind
Definition: getopt.c:47
static int size_fat_by_user
Definition: mkdosfs.c:535
static time_t create_time
Definition: mkdosfs.c:525
static void write_tables(void)
Definition: mkdosfs.c:1629
GLintptr offset
Definition: glext.h:5920
_Check_return_ _CRTIMP int __cdecl getc(_Inout_ FILE *_File)
static void check_mount(char *device_name)
Definition: mkdosfs.c:847
FILE * stdin
static int sector_size_set
Definition: mkdosfs.c:529
static int size_fat
Definition: mkdosfs.c:534
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
__u16 time
Definition: mkdosfs.c:366
static void check_atari(void)
Definition: mkdosfs.c:1700
static char ** argv
Definition: ServiceArgs.c:11
static int atari_format
Definition: mkdosfs.c:521
#define sprintf(buf, format,...)
Definition: sprintf.c:55
static void check_blocks(void)
Definition: mkdosfs.c:684
#define write
Definition: acwin.h:73
GLenum GLclampf GLint i
Definition: glfuncs.h:14
_CRTIMP void __cdecl perror(_In_opt_z_ const char *_ErrMsg)
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
static char * device_name
Definition: mkdosfs.c:520
__u8 volume_id[4]
Definition: mkdosfs.c:361
static int count_blocks(char *filename)
Definition: mkdosfs.c:782
smooth NULL
Definition: ftsmooth.c:416
char dummy_boot_code[BOOTCODE_SIZE]
Definition: mkdosfs.c:491
static int blocks
Definition: mkdosfs.c:527
#define O_SHARED
Definition: mkdosfs.c:300
#define FSCTL_DISMOUNT_VOLUME
Definition: nt_native.h:834
static void get_list_blocks(char *filename)
Definition: mkdosfs.c:736
#define SEEK_SET
Definition: jmemansi.c:26
#define BLOCK_SIZE
Definition: dlist.c:321
static void setup_tables(void)
Definition: mkdosfs.c:1108
unsigned long
Definition: typeof.h:99
#define MESSAGE_OFFSET
Definition: mkdosfs.c:515
int getopt(int nargc, char *const *nargv, const char *ostr)
Definition: getopt.c:55
int null(void)
Definition: ftp.c:1794
unsigned __int64 loff_t
Definition: types.h:80
Definition: stat.h:55
static int backup_boot
Definition: mkdosfs.c:530
#define O_TRUNC
Definition: acwin.h:86
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
static int reserved_sectors
Definition: mkdosfs.c:531
__u8 sector_size[2]
Definition: mkdosfs.c:361
static char volume_name[]
Definition: mkdosfs.c:526
#define O_RDWR
Definition: fcntl.h:36
const char * optarg
Definition: getopt.c:49
static loff_t llseek(int fd, loff_t offset, int whence)
Definition: mkdosfs.c:321
static int check
Definition: mkdosfs.c:522
#define EOF
Definition: stdio.h:24
_Check_return_ long __cdecl strtol(_In_z_ const char *_Str, _Out_opt_ _Deref_post_z_ char **_EndPtr, _In_ int _Radix)
#define FSCTL_LOCK_VOLUME
Definition: nt_native.h:832
_CRTIMP int __cdecl fstat(int _Desc, struct stat *_Stat)
Definition: stat.h:341
#define c
Definition: ke_i.h:80
FILE * stderr
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define die(str)
Definition: mkdosfs.c:347
void exit(int exitcode)
Definition: _exit.c:33
GLfloat GLfloat p
Definition: glext.h:8902
static int verbose
Definition: mkdosfs.c:523
#define BOOTCODE_SIZE
Definition: mkdosfs.c:400
static const struct access_res create[16]
Definition: package.c:7720
#define O_CREAT
Definition: acwin.h:84
static int nr_fats
Definition: mkdosfs.c:533
#define VERSION
Definition: rdesktop.h:45
#define TRUE
Definition: mkdosfs.c:335
static int root_dir_entries
Definition: mkdosfs.c:547
#define printf
Definition: config.h:203
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:29
static void mark_FAT_cluster ( int  cluster,
unsigned int  value 
)
static

Definition at line 587 of file mkdosfs.c.

Referenced by mark_FAT_sector(), and setup_tables().

588 {
589  switch( size_fat ) {
590  case 12:
591  value &= 0x0fff;
592  if (((cluster * 3) & 0x1) == 0)
593  {
594  fat[3 * cluster / 2] = (unsigned char) (value & 0x00ff);
595  fat[(3 * cluster / 2) + 1] = (unsigned char) ((fat[(3 * cluster / 2) + 1] & 0x00f0)
596  | ((value & 0x0f00) >> 8));
597  }
598  else
599  {
600  fat[3 * cluster / 2] = (unsigned char) ((fat[3 * cluster / 2] & 0x000f) | ((value & 0x000f) << 4));
601  fat[(3 * cluster / 2) + 1] = (unsigned char) ((value & 0x0ff0) >> 4);
602  }
603  break;
604 
605  case 16:
606  value &= 0xffff;
607  fat[2 * cluster] = (unsigned char) (value & 0x00ff);
608  fat[(2 * cluster) + 1] = (unsigned char) (value >> 8);
609  break;
610 
611  case 32:
612  value &= 0xfffffff;
613  fat[4 * cluster] = (unsigned char) (value & 0x000000ff);
614  fat[(4 * cluster) + 1] = (unsigned char) ((value & 0x0000ff00) >> 8);
615  fat[(4 * cluster) + 2] = (unsigned char) ((value & 0x00ff0000) >> 16);
616  fat[(4 * cluster) + 3] = (unsigned char) ((value & 0xff000000) >> 24);
617  break;
618 
619  default:
620  die("Bad FAT size (not 12, 16, or 32)");
621  }
622 }
Definition: get.c:139
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3706
static int size_fat
Definition: mkdosfs.c:534
unsigned char
Definition: typeof.h:27
#define die(str)
Definition: mkdosfs.c:347
static unsigned char * fat
Definition: mkdosfs.c:542
static void mark_FAT_sector ( int  sector,
unsigned int  value 
)
static

Definition at line 628 of file mkdosfs.c.

629 {
630  int cluster;
631 
632  cluster = (sector - start_data_sector) / (int) (bs.cluster_size) /
634  if (cluster < 0)
635  die ("Invalid cluster number in mark_FAT_sector: probably bug!");
636 
637  mark_FAT_cluster (cluster, value);
638 }
static int start_data_sector
Definition: mkdosfs.c:540
Definition: get.c:139
uint8_t sector
Definition: isohybrid.c:61
static void mark_FAT_cluster(int cluster, unsigned int value)
Definition: mkdosfs.c:587
__u8 sector_size[2]
Definition: mkdosfs.c:361
#define die(str)
Definition: mkdosfs.c:347
static struct msdos_boot_sector bs
Definition: mkdosfs.c:539
#define HARD_SECTOR_SIZE
Definition: mkdosfs.c:339
static void setup_tables ( void  )
static

Definition at line 1108 of file mkdosfs.c.

Referenced by main().

1109 {
1110  unsigned num_sectors;
1111  unsigned cluster_count = 0, fat_length;
1112  unsigned fatdata; /* Sectors for FATs + data area */
1113  struct tm *ctime;
1114  struct msdos_volume_info *vi = (size_fat == 32 ? &bs.fat32.vi : &bs.oldfat.vi);
1115 
1116  if (atari_format)
1117  /* On Atari, the first few bytes of the boot sector are assigned
1118  * differently: The jump code is only 2 bytes (and m68k machine code
1119  * :-), then 6 bytes filler (ignored), then 3 byte serial number. */
1120  strncpy( bs.system_id-1, "mkdosf", 6 );
1121  else
1122  strcpy (bs.system_id, "mkdosfs");
1123  if (sectors_per_cluster)
1124  bs.cluster_size = (char) sectors_per_cluster;
1125  if (size_fat == 32)
1126  {
1127  /* Under FAT32, the root dir is in a cluster chain, and this is
1128  * signalled by bs.dir_entries being 0. */
1129  bs.dir_entries[0] = bs.dir_entries[1] = (char) 0;
1130  root_dir_entries = 0;
1131  }
1132  else if (root_dir_entries)
1133  {
1134  /* Override default from establish_params() */
1135  bs.dir_entries[0] = (char) (root_dir_entries & 0x00ff);
1136  bs.dir_entries[1] = (char) ((root_dir_entries & 0xff00) >> 8);
1137  }
1138  else
1139  root_dir_entries = bs.dir_entries[0] + (bs.dir_entries[1] << 8);
1140 
1141  if (atari_format) {
1142  bs.system_id[5] = (unsigned char) (volume_id & 0x000000ff);
1143  bs.system_id[6] = (unsigned char) ((volume_id & 0x0000ff00) >> 8);
1144  bs.system_id[7] = (unsigned char) ((volume_id & 0x00ff0000) >> 16);
1145  }
1146  else {
1147  vi->volume_id[0] = (unsigned char) (volume_id & 0x000000ff);
1148  vi->volume_id[1] = (unsigned char) ((volume_id & 0x0000ff00) >> 8);
1149  vi->volume_id[2] = (unsigned char) ((volume_id & 0x00ff0000) >> 16);
1150  vi->volume_id[3] = (unsigned char) (volume_id >> 24);
1151  }
1152 
1153  if (!atari_format) {
1154  memcpy(vi->volume_label, volume_name, 11);
1155 
1156  memcpy(bs.boot_jump, dummy_boot_jump, 3);
1157  /* Patch in the correct offset to the boot code */
1158  bs.boot_jump[1] = ((size_fat == 32 ?
1159  (char *)&bs.fat32.boot_code :
1160  (char *)&bs.oldfat.boot_code) -
1161  (char *)&bs) - 2;
1162 
1163  if (size_fat == 32) {
1165  printf ("Warning: message too long; truncated\n");
1167  memcpy(bs.fat32.boot_code, dummy_boot_code, BOOTCODE_FAT32_SIZE);
1168  }
1169  else {
1170  memcpy(bs.oldfat.boot_code, dummy_boot_code, BOOTCODE_SIZE);
1171  }
1172  bs.boot_sign = CT_LE_W(BOOT_SIGN);
1173  }
1174  else {
1175  memcpy(bs.boot_jump, dummy_boot_jump_m68k, 2);
1176  }
1177  if (verbose >= 2)
1178  printf( "Boot jump code is %02x %02x\n",
1179  bs.boot_jump[0], bs.boot_jump[1] );
1180 
1181  if (!reserved_sectors)
1182  reserved_sectors = (size_fat == 32) ? 32 : 1;
1183  else {
1184  if (size_fat == 32 && reserved_sectors < 2)
1185  die("On FAT32 at least 2 reserved sectors are needed.");
1186  }
1187  bs.reserved = CT_LE_W(reserved_sectors);
1188  if (verbose >= 2)
1189  printf( "Using %d reserved sectors\n", reserved_sectors );
1190  bs.fats = (char) nr_fats;
1191  if (!atari_format || size_fat == 32)
1192  bs.hidden = CT_LE_L(0);
1193  else
1194  /* In Atari format, hidden is a 16 bit field */
1195  memset( &bs.hidden, 0, 2 );
1196 
1197  num_sectors = (ll_t)blocks*BLOCK_SIZE/sector_size;
1198  if (!atari_format) {
1199  unsigned fatlength12, fatlength16, fatlength32;
1200  unsigned maxclust12, maxclust16, maxclust32;
1201  unsigned clust12, clust16, clust32;
1202  int maxclustsize;
1203 
1204  fatdata = num_sectors - cdiv (root_dir_entries * 32, sector_size) -
1206 
1207  if (sectors_per_cluster)
1208  bs.cluster_size = maxclustsize = sectors_per_cluster;
1209  else
1210  /* An initial guess for bs.cluster_size should already be set */
1211  maxclustsize = 128;
1212 
1213  if (verbose >= 2)
1214  printf( "%d sectors for FAT+data, starting with %d sectors/cluster\n",
1215  fatdata, bs.cluster_size );
1216  do {
1217  if (verbose >= 2)
1218  printf( "Trying with %d sectors/cluster:\n", bs.cluster_size );
1219 
1220  /* The factor 2 below avoids cut-off errors for nr_fats == 1.
1221  * The "nr_fats*3" is for the reserved first two FAT entries */
1222  clust12 = 2*((ll_t) fatdata *sector_size + nr_fats*3) /
1223  (2*(int) bs.cluster_size * sector_size + nr_fats*3);
1224  fatlength12 = cdiv (((clust12+2) * 3 + 1) >> 1, sector_size);
1225  /* Need to recalculate number of clusters, since the unused parts of the
1226  * FATS and data area together could make up space for an additional,
1227  * not really present cluster. */
1228  clust12 = (fatdata - nr_fats*fatlength12)/bs.cluster_size;
1229  maxclust12 = (fatlength12 * 2 * sector_size) / 3;
1230  if (maxclust12 > MAX_CLUST_12)
1231  maxclust12 = MAX_CLUST_12;
1232  if (verbose >= 2)
1233  printf( "FAT12: #clu=%u, fatlen=%u, maxclu=%u, limit=%u\n",
1234  clust12, fatlength12, maxclust12, MAX_CLUST_12 );
1235  if (clust12 > maxclust12-2) {
1236  clust12 = 0;
1237  if (verbose >= 2)
1238  printf( "FAT12: too much clusters\n" );
1239  }
1240 
1241  clust16 = ((ll_t) fatdata *sector_size + nr_fats*4) /
1242  ((int) bs.cluster_size * sector_size + nr_fats*2);
1243  fatlength16 = cdiv ((clust16+2) * 2, sector_size);
1244  /* Need to recalculate number of clusters, since the unused parts of the
1245  * FATS and data area together could make up space for an additional,
1246  * not really present cluster. */
1247  clust16 = (fatdata - nr_fats*fatlength16)/bs.cluster_size;
1248  maxclust16 = (fatlength16 * sector_size) / 2;
1249  if (maxclust16 > MAX_CLUST_16)
1250  maxclust16 = MAX_CLUST_16;
1251  if (verbose >= 2)
1252  printf( "FAT16: #clu=%u, fatlen=%u, maxclu=%u, limit=%u\n",
1253  clust16, fatlength16, maxclust16, MAX_CLUST_16 );
1254  if (clust16 > maxclust16-2) {
1255  if (verbose >= 2)
1256  printf( "FAT16: too much clusters\n" );
1257  clust16 = 0;
1258  }
1259  /* The < 4078 avoids that the filesystem will be misdetected as having a
1260  * 12 bit FAT. */
1261  if (clust16 < FAT12_THRESHOLD && !(size_fat_by_user && size_fat == 16)) {
1262  if (verbose >= 2)
1263  printf( clust16 < FAT12_THRESHOLD ?
1264  "FAT16: would be misdetected as FAT12\n" :
1265  "FAT16: too much clusters\n" );
1266  clust16 = 0;
1267  }
1268 
1269  clust32 = ((ll_t) fatdata *sector_size + nr_fats*8) /
1270  ((int) bs.cluster_size * sector_size + nr_fats*4);
1271  fatlength32 = cdiv ((clust32+2) * 4, sector_size);
1272  /* Need to recalculate number of clusters, since the unused parts of the
1273  * FATS and data area together could make up space for an additional,
1274  * not really present cluster. */
1275  clust32 = (fatdata - nr_fats*fatlength32)/bs.cluster_size;
1276  maxclust32 = (fatlength32 * sector_size) / 4;
1277  if (maxclust32 > MAX_CLUST_32)
1278  maxclust32 = MAX_CLUST_32;
1279  if (verbose >= 2)
1280  printf( "FAT32: #clu=%u, fatlen=%u, maxclu=%u, limit=%u\n",
1281  clust32, fatlength32, maxclust32, MAX_CLUST_32 );
1282  if (clust32 > maxclust32) {
1283  clust32 = 0;
1284  if (verbose >= 2)
1285  printf( "FAT32: too much clusters\n" );
1286  }
1287 
1288  if ((clust12 && (size_fat == 0 || size_fat == 12)) ||
1289  (clust16 && (size_fat == 0 || size_fat == 16)) ||
1290  (clust32 && size_fat == 32))
1291  break;
1292 
1293  bs.cluster_size <<= 1;
1294  } while (bs.cluster_size && bs.cluster_size <= maxclustsize);
1295 
1296  /* Use the optimal FAT size if not specified;
1297  * FAT32 is (not yet) choosen automatically */
1298  if (!size_fat) {
1299  size_fat = (clust16 > clust12) ? 16 : 12;
1300  if (verbose >= 2)
1301  printf( "Choosing %d bits for FAT\n", size_fat );
1302  }
1303 
1304  switch (size_fat) {
1305  case 12:
1306  cluster_count = clust12;
1307  fat_length = fatlength12;
1308  bs.fat_length = CT_LE_W(fatlength12);
1309  memcpy(vi->fs_type, MSDOS_FAT12_SIGN, 8);
1310  break;
1311 
1312  case 16:
1313  if (clust16 < FAT12_THRESHOLD) {
1314  if (size_fat_by_user) {
1315  fprintf( stderr, "WARNING: Not enough clusters for a "
1316  "16 bit FAT! The filesystem will be\n"
1317  "misinterpreted as having a 12 bit FAT without "
1318  "mount option \"fat=16\".\n" );
1319  }
1320  else {
1321  fprintf( stderr, "This filesystem has an unfortunate size. "
1322  "A 12 bit FAT cannot provide\n"
1323  "enough clusters, but a 16 bit FAT takes up a little "
1324  "bit more space so that\n"
1325  "the total number of clusters becomes less than the "
1326  "threshold value for\n"
1327  "distinction between 12 and 16 bit FATs.\n" );
1328  die( "Make the file system a bit smaller manually." );
1329  }
1330  }
1331  cluster_count = clust16;
1332  fat_length = fatlength16;
1333  bs.fat_length = CT_LE_W(fatlength16);
1334  memcpy(vi->fs_type, MSDOS_FAT16_SIGN, 8);
1335  break;
1336 
1337  case 32:
1338  cluster_count = clust32;
1339  fat_length = fatlength32;
1340  bs.fat_length = CT_LE_W(0);
1341  bs.fat32.fat32_length = CT_LE_L(fatlength32);
1342  memcpy(vi->fs_type, MSDOS_FAT32_SIGN, 8);
1343  break;
1344 
1345  default:
1346  die("FAT not 12, 16 or 32 bits");
1347  }
1348  }
1349  else {
1350  unsigned clusters, maxclust;
1351 
1352  /* GEMDOS always uses a 12 bit FAT on floppies, and always a 16 bit FAT on
1353  * hard disks. So use 12 bit if the size of the file system suggests that
1354  * this fs is for a floppy disk, if the user hasn't explicitly requested a
1355  * size.
1356  */
1357  if (!size_fat)
1358  size_fat = (num_sectors == 1440 || num_sectors == 2400 ||
1359  num_sectors == 2880 || num_sectors == 5760) ? 12 : 16;
1360  if (verbose >= 2)
1361  printf( "Choosing %d bits for FAT\n", size_fat );
1362 
1363  /* Atari format: cluster size should be 2, except explicitly requested by
1364  * the user, since GEMDOS doesn't like other cluster sizes very much.
1365  * Instead, tune the sector size for the FS to fit.
1366  */
1367  bs.cluster_size = sectors_per_cluster ? sectors_per_cluster : 2;
1368  if (!sector_size_set) {
1369  while( num_sectors > GEMDOS_MAX_SECTORS ) {
1370  num_sectors >>= 1;
1371  sector_size <<= 1;
1372  }
1373  }
1374  if (verbose >= 2)
1375  printf( "Sector size must be %d to have less than %d log. sectors\n",
1376  sector_size, GEMDOS_MAX_SECTORS );
1377 
1378  /* Check if there are enough FAT indices for how much clusters we have */
1379  do {
1380  fatdata = num_sectors - cdiv (root_dir_entries * 32, sector_size) -
1382  /* The factor 2 below avoids cut-off errors for nr_fats == 1 and
1383  * size_fat == 12
1384  * The "2*nr_fats*size_fat/8" is for the reserved first two FAT entries
1385  */
1386  clusters = (2*((ll_t)fatdata*sector_size - 2*nr_fats*size_fat/8)) /
1387  (2*((int)bs.cluster_size*sector_size + nr_fats*size_fat/8));
1388  fat_length = cdiv( (clusters+2)*size_fat/8, sector_size );
1389  /* Need to recalculate number of clusters, since the unused parts of the
1390  * FATS and data area together could make up space for an additional,
1391  * not really present cluster. */
1392  clusters = (fatdata - nr_fats*fat_length)/bs.cluster_size;
1393  maxclust = (fat_length*sector_size*8)/size_fat;
1394  if (verbose >= 2)
1395  printf( "ss=%d: #clu=%d, fat_len=%d, maxclu=%d\n",
1396  sector_size, clusters, fat_length, maxclust );
1397 
1398  /* last 10 cluster numbers are special (except FAT32: 4 high bits rsvd);
1399  * first two numbers are reserved */
1400  if (maxclust <= (size_fat == 32 ? MAX_CLUST_32 : (1<<size_fat)-0x10) &&
1401  clusters <= maxclust-2)
1402  break;
1403  if (verbose >= 2)
1404  printf( clusters > maxclust-2 ?
1405  "Too many clusters\n" : "FAT too big\n" );
1406 
1407  /* need to increment sector_size once more to */
1408  if (sector_size_set)
1409  die( "With this sector size, the maximum number of FAT entries "
1410  "would be exceeded." );
1411  num_sectors >>= 1;
1412  sector_size <<= 1;
1413  } while( sector_size <= GEMDOS_MAX_SECTOR_SIZE );
1414 
1415  if (sector_size > GEMDOS_MAX_SECTOR_SIZE)
1416  die( "Would need a sector size > 16k, which GEMDOS can't work with");
1417 
1418  cluster_count = clusters;
1419  if (size_fat != 32)
1420  bs.fat_length = CT_LE_W(fat_length);
1421  else {
1422  bs.fat_length = 0;
1423  bs.fat32.fat32_length = CT_LE_L(fat_length);
1424  }
1425  }
1426 
1427  bs.sector_size[0] = (char) (sector_size & 0x00ff);
1428  bs.sector_size[1] = (char) ((sector_size & 0xff00) >> 8);
1429 
1430  if (size_fat == 32)
1431  {
1432  /* set up additional FAT32 fields */
1433  bs.fat32.flags = CT_LE_W(0);
1434  bs.fat32.version[0] = 0;
1435  bs.fat32.version[1] = 0;
1436  bs.fat32.root_cluster = CT_LE_L(2);
1437  bs.fat32.info_sector = CT_LE_W(1);
1438  if (!backup_boot)
1439  backup_boot = (reserved_sectors >= 7) ? 6 :
1440  (reserved_sectors >= 2) ? reserved_sectors-1 : 0;
1441  else
1442  {
1443  if (backup_boot == 1)
1444  die("Backup boot sector must be after sector 1");
1445  else if (backup_boot >= reserved_sectors)
1446  die("Backup boot sector must be a reserved sector");
1447  }
1448  if (verbose >= 2)
1449  printf( "Using sector %d as backup boot sector (0 = none)\n",
1450  backup_boot );
1451  bs.fat32.backup_boot = CT_LE_W(backup_boot);
1452  memset( &bs.fat32.reserved2, 0, sizeof(bs.fat32.reserved2) );
1453  }
1454 
1455  if (atari_format) {
1456  /* Just some consistency checks */
1457  if (num_sectors >= GEMDOS_MAX_SECTORS)
1458  die( "GEMDOS can't handle more than 65531 sectors" );
1459  else if (num_sectors >= OLDGEMDOS_MAX_SECTORS)
1460  printf( "Warning: More than 32765 sector need TOS 1.04 "
1461  "or higher.\n" );
1462  }
1463  if (num_sectors >= 65536)
1464  {
1465  bs.sectors[0] = (char) 0;
1466  bs.sectors[1] = (char) 0;
1467  bs.total_sect = CT_LE_L(num_sectors);
1468  }
1469  else
1470  {
1471  bs.sectors[0] = (char) (num_sectors & 0x00ff);
1472  bs.sectors[1] = (char) ((num_sectors & 0xff00) >> 8);
1473  if (!atari_format)
1474  bs.total_sect = CT_LE_L(0);
1475  }
1476 
1477  if (!atari_format)
1479 
1480  if (!cluster_count)
1481  {
1482  if (sectors_per_cluster) /* If yes, die if we'd spec'd sectors per cluster */
1483  die ("Too many clusters for file system - try more sectors per cluster");
1484  else
1485  die ("Attempting to create a too large file system");
1486  }
1487 
1488 
1489  /* The two following vars are in hard sectors, i.e. 512 byte sectors! */
1490  start_data_sector = (reserved_sectors + nr_fats * fat_length) *
1491  (sector_size/HARD_SECTOR_SIZE);
1494 
1495  if (blocks < start_data_block + 32) /* Arbitrary undersize file system! */
1496  die ("Too few blocks for viable file system");
1497 
1498  if (verbose)
1499  {
1500  printf("%s has %d head%s and %d sector%s per track,\n",
1501  device_name, CF_LE_W(bs.heads), (CF_LE_W(bs.heads) != 1) ? "s" : "",
1502  CF_LE_W(bs.secs_track), (CF_LE_W(bs.secs_track) != 1) ? "s" : "");
1503  printf("logical sector size is %d,\n",sector_size);
1504  printf("using 0x%02x media descriptor, with %d sectors;\n",
1505  (int) (bs.media), num_sectors);
1506  printf("file system has %d %d-bit FAT%s and %d sector%s per cluster.\n",
1507  (int) (bs.fats), size_fat, (bs.fats != 1) ? "s" : "",
1508  (int) (bs.cluster_size), (bs.cluster_size != 1) ? "s" : "");
1509  printf ("FAT size is %d sector%s, and provides %d cluster%s.\n",
1510  fat_length, (fat_length != 1) ? "s" : "",
1511  cluster_count, (cluster_count != 1) ? "s" : "");
1512  if (size_fat != 32)
1513  printf ("Root directory contains %d slots.\n",
1514  (int) (bs.dir_entries[0]) + (int) (bs.dir_entries[1]) * 256);
1515  printf ("Volume ID is %08lx, ", volume_id &
1516  (atari_format ? 0x00ffffff : 0xffffffff));
1517  if ( strcmp(volume_name, " ") )
1518  printf("volume label %s.\n", volume_name);
1519  else
1520  printf("no volume label.\n");
1521  }
1522 
1523  /* Make the file allocation tables! */
1524 
1525  if ((fat = (unsigned char *) malloc (fat_length * sector_size)) == NULL)
1526  die ("unable to allocate space for FAT image in memory");
1527 
1528  memset( fat, 0, fat_length * sector_size );
1529 
1530  mark_FAT_cluster (0, 0xffffffff); /* Initial fat entries */
1531  mark_FAT_cluster (1, 0xffffffff);
1532  fat[0] = (unsigned char) bs.media; /* Put media type in first byte! */
1533  if (size_fat == 32) {
1534  /* Mark cluster 2 as EOF (used for root dir) */
1536  }
1537 
1538  /* Make the root directory entries */
1539 
1540  size_root_dir = (size_fat == 32) ?
1541  bs.cluster_size*sector_size :
1542  (((int)bs.dir_entries[1]*256+(int)bs.dir_entries[0]) *
1543  sizeof (struct msdos_dir_entry));
1544  if ((root_dir = (struct msdos_dir_entry *) malloc (size_root_dir)) == NULL)
1545  {
1546  free (fat); /* Tidy up before we die! */
1547  die ("unable to allocate space for root directory in memory");
1548  }
1549 
1551  if ( memcmp(volume_name, " ", 11) )
1552  {
1553  struct msdos_dir_entry *de = &root_dir[0];
1554  memcpy(de->name, volume_name, 11);
1555  de->attr = ATTR_VOLUME;
1556  ctime = localtime(&create_time);
1557  de->time = CT_LE_W((unsigned short)((ctime->tm_sec >> 1) +
1558  (ctime->tm_min << 5) + (ctime->tm_hour << 11)));
1559  de->date = CT_LE_W((unsigned short)(ctime->tm_mday +
1560  ((ctime->tm_mon+1) << 5) +
1561  ((ctime->tm_year-80) << 9)));
1562  de->ctime_ms = 0;
1563  de->ctime = de->time;
1564  de->cdate = de->date;
1565  de->adate = de->date;
1566  de->starthi = CT_LE_W(0);
1567  de->start = CT_LE_W(0);
1568  de->size = CT_LE_L(0);
1569  }
1570 
1571  if (size_fat == 32) {
1572  /* For FAT32, create an info sector */
1573  struct fat32_fsinfo *info;
1574 
1575  if (!(info_sector = malloc( sector_size )))
1576  die("Out of memory");
1577  memset(info_sector, 0, sector_size);
1578  /* fsinfo structure is at offset 0x1e0 in info sector by observation */
1579  info = (struct fat32_fsinfo *)(info_sector + 0x1e0);
1580 
1581  /* Info sector magic */
1582  info_sector[0] = 'R';
1583  info_sector[1] = 'R';
1584  info_sector[2] = 'a';
1585  info_sector[3] = 'A';
1586 
1587  /* Magic for fsinfo structure */
1588  info->signature = CT_LE_L(0x61417272);
1589  /* We've allocated cluster 2 for the root dir. */
1590  info->free_clusters = CT_LE_L(cluster_count - 1);
1591  info->next_cluster = CT_LE_L(2);
1592 
1593  /* Info sector also must have boot sign */
1594  *(__u16 *)(info_sector + 0x1fe) = CT_LE_W(BOOT_SIGN);
1595  }
1596 
1597  if (!(blank_sector = malloc( sector_size )))
1598  die( "Out of memory" );
1599  memset(blank_sector, 0, sector_size);
1600 }
static int sectors_per_cluster
Definition: mkdosfs.c:546
static struct msdos_dir_entry * root_dir
Definition: mkdosfs.c:544
long long ll_t
Definition: mkdosfs.c:305
static int start_data_sector
Definition: mkdosfs.c:540
__u32 size
Definition: mkdosfs.c:477
int tm_min
Definition: time.h:78
#define MAX_CLUST_32
Definition: mkdosfs.c:392
char dummy_boot_jump[3]
Definition: mkdosfs.c:487
#define ATTR_VOLUME
Definition: mkdosfs.c:369
static int start_data_block
Definition: mkdosfs.c:541
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
__u32 signature
Definition: mkdosfs.c:459
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
#define free
Definition: debug_ros.c:5
static int size_fat_by_user
Definition: mkdosfs.c:535
static time_t create_time
Definition: mkdosfs.c:525
int cdiv(int a, int b)
Definition: mkdosfs.c:357
int tm_mday
Definition: time.h:80
__u8 ctime_ms
Definition: mkdosfs.c:471
static char * blank_sector
Definition: mkdosfs.c:548
char dummy_boot_jump_m68k[2]
Definition: mkdosfs.c:489
struct msdos_volume_info vi
Definition: mkdosfs.c:435
static int sector_size_set
Definition: mkdosfs.c:529
#define BOOT_SIGN
Definition: mkdosfs.c:386
int tm_year
Definition: time.h:82
static int size_fat
Definition: mkdosfs.c:534
__u16 fat_length
Definition: mkdosfs.c:368
__u16 cdate
Definition: mkdosfs.c:473
#define FAT12_THRESHOLD
Definition: mkdosfs.c:394
#define MSDOS_FAT16_SIGN
Definition: mkdosfs.c:383
static int atari_format
Definition: mkdosfs.c:521
__u8 attr
Definition: mkdosfs.c:469
#define MSDOS_FAT32_SIGN
Definition: mkdosfs.c:384
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
static void mark_FAT_cluster(int cluster, unsigned int value)
Definition: mkdosfs.c:587
static char * device_name
Definition: mkdosfs.c:520
__u8 volume_id[4]
Definition: mkdosfs.c:361
#define CT_LE_L(v)
Definition: mkdosfs.c:98
smooth NULL
Definition: ftsmooth.c:416
unsigned char
Definition: typeof.h:27
char dummy_boot_code[BOOTCODE_SIZE]
Definition: mkdosfs.c:491
#define OLDGEMDOS_MAX_SECTORS
Definition: mkdosfs.c:396
int tm_mon
Definition: time.h:81
static int blocks
Definition: mkdosfs.c:527
__u16 ctime
Definition: mkdosfs.c:472
__u16 ctime
Definition: mkdosfs.c:362
#define BLOCK_SIZE
Definition: dlist.c:321
unsigned short __u16
Definition: compat.h:89
#define SECTORS_PER_BLOCK
Definition: mkdosfs.c:340
if(!(yy_init))
Definition: macro.lex.yy.c:717
#define FAT_EOF
Definition: mkdosfs.c:378
Definition: mkdosfs.c:466
__u16 adate
Definition: mkdosfs.c:474
#define MAX_CLUST_16
Definition: mkdosfs.c:389
__u8 volume_id[4]
Definition: mkdosfs.c:413
__u16 starthi
Definition: mkdosfs.c:475
static int backup_boot
Definition: mkdosfs.c:530
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define MSDOS_EXT_SIGN
Definition: mkdosfs.c:381
Definition: time.h:76
_CRTIMP struct tm *__cdecl localtime(const time_t *_Time)
Definition: time.h:426
static int reserved_sectors
Definition: mkdosfs.c:531
#define CF_LE_W(v)
Definition: mkdosfs.c:94
__u8 ext_boot_sign
Definition: mkdosfs.c:412
__u8 volume_label[11]
Definition: mkdosfs.c:414
__u8 sector_size[2]
Definition: mkdosfs.c:361
__u16 date
Definition: mkdosfs.c:476
static char volume_name[]
Definition: mkdosfs.c:526
const XML_Char XML_Encoding * info
Definition: expat.h:530
__u32 next_cluster
Definition: mkdosfs.c:461
__u8 fs_type[8]
Definition: mkdosfs.c:415
#define MAX_CLUST_12
Definition: mkdosfs.c:388
int tm_sec
Definition: time.h:77
#define BOOTCODE_FAT32_SIZE
Definition: mkdosfs.c:401
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
int tm_hour
Definition: time.h:79
FILE * stderr
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
char name[8]
Definition: mkdosfs.c:468
__u32 free_clusters
Definition: mkdosfs.c:460
#define CT_LE_W(v)
Definition: mkdosfs.c:97
#define malloc
Definition: debug_ros.c:4
#define die(str)
Definition: mkdosfs.c:347
__u16 time
Definition: mkdosfs.c:476
#define GEMDOS_MAX_SECTORS
Definition: mkdosfs.c:397
static int size_root_dir
Definition: mkdosfs.c:545
static int verbose
Definition: mkdosfs.c:523
static struct msdos_boot_sector bs
Definition: mkdosfs.c:539
#define BOOTCODE_SIZE
Definition: mkdosfs.c:400
#define memset(x, y, z)
Definition: compat.h:39
#define MSDOS_FAT12_SIGN
Definition: mkdosfs.c:382
static unsigned char * fat
Definition: mkdosfs.c:542
static int nr_fats
Definition: mkdosfs.c:533
static int root_dir_entries
Definition: mkdosfs.c:547
#define HARD_SECTOR_SIZE
Definition: mkdosfs.c:339
#define printf
Definition: config.h:203
__u16 start
Definition: mkdosfs.c:476
#define GEMDOS_MAX_SECTOR_SIZE
Definition: mkdosfs.c:398
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:29
void usage ( void  )

Definition at line 1686 of file mkdosfs.c.

Referenced by main().

1687 {
1688  fatal_error("\
1689 Usage: mkdosfs [-A] [-c] [-C] [-v] [-I] [-l bad-block-file] [-b backup-boot-sector]\n\
1690  [-m boot-msg-file] [-n volume-name] [-i volume-id]\n\
1691  [-s sectors-per-cluster] [-S logical-sector-size] [-f number-of-FATs]\n\
1692  [-F fat-size] [-r root-dir-entries] [-R reserved-sectors]\n\
1693  /dev/name [blocks]\n");
1694 }
static void fatal_error(const char *fmt_string) __attribute__((noreturn))
Definition: mkdosfs.c:577
static int valid_offset ( int  fd,
loff_t  offset 
)
static

Definition at line 766 of file mkdosfs.c.

Referenced by count_blocks().

767 {
768  char ch;
769 
770  if (llseek (fd, offset, SEEK_SET) < 0)
771  return FALSE;
772  if (read (fd, &ch, 1) < 1)
773  return FALSE;
774  return TRUE;
775 }
GLintptr offset
Definition: glext.h:5920
static int fd
Definition: io.c:51
#define FALSE
Definition: mkdosfs.c:336
#define SEEK_SET
Definition: jmemansi.c:26
static loff_t llseek(int fd, loff_t offset, int whence)
Definition: mkdosfs.c:321
#define TRUE
Definition: mkdosfs.c:335
_CRTIMP int __cdecl read(_In_ int _FileHandle, _Out_writes_bytes_(_MaxCharCount) void *_DstBuf, _In_ unsigned int _MaxCharCount)
static void write_tables ( void  )
static

Definition at line 1629 of file mkdosfs.c.

Referenced by main().

1630 {
1631  int x;
1632  int fat_length;
1633 #ifdef _WIN32
1634  int blk;
1635 #endif
1636 
1637  fat_length = (size_fat == 32) ?
1638  CF_LE_L(bs.fat32.fat32_length) : CF_LE_W(bs.fat_length);
1639 
1640  seekto( 0, "start of device" );
1641  /* clear all reserved sectors */
1642  for( x = 0; x < reserved_sectors; ++x )
1643  writebuf( blank_sector, sector_size, "reserved sector" );
1644  /* seek back to sector 0 and write the boot sector */
1645  seekto( 0, "boot sector" );
1646  writebuf( (char *) &bs, sizeof (struct msdos_boot_sector), "boot sector" );
1647  /* on FAT32, write the info sector and backup boot sector */
1648  if (size_fat == 32)
1649  {
1650  seekto( CF_LE_W(bs.fat32.info_sector)*sector_size, "info sector" );
1651  writebuf( info_sector, 512, "info sector" );
1652  if (backup_boot != 0)
1653  {
1654  seekto( backup_boot*sector_size, "backup boot sector" );
1655  writebuf( (char *) &bs, sizeof (struct msdos_boot_sector),
1656  "backup boot sector" );
1657  }
1658  }
1659  /* seek to start of FATS and write them all */
1660  seekto( reserved_sectors*sector_size, "first FAT" );
1661  for (x = 1; x <= nr_fats; x++)
1662 #ifdef _WIN32
1663  /*
1664  * WIN32 appearently has problems writing very large chunks directly
1665  * to disk devices. To not produce errors because of resource shortages
1666  * split up the write in sector size chunks.
1667  */
1668  for (blk = 0; blk < fat_length; blk++)
1669  writebuf(fat+blk*sector_size, sector_size, "FAT");
1670 #else
1671  writebuf( fat, fat_length * sector_size, "FAT" );
1672 #endif
1673  /* Write the root directory directly after the last FAT. This is the root
1674  * dir area on FAT12/16, and the first cluster on FAT32. */
1675  writebuf( (char *) root_dir, size_root_dir, "root directory" );
1676 
1677  if (info_sector) free( info_sector );
1678  free (root_dir); /* Free up the root directory space from setup_tables */
1679  free (fat); /* Free up the fat table space reserved during setup_tables */
1680 }
static struct msdos_dir_entry * root_dir
Definition: mkdosfs.c:544
#define free
Definition: debug_ros.c:5
static char * blank_sector
Definition: mkdosfs.c:548
static int size_fat
Definition: mkdosfs.c:534
__u16 fat_length
Definition: mkdosfs.c:368
#define writebuf(buf, size, errstr)
Definition: mkdosfs.c:1620
#define seekto(pos, errstr)
Definition: mkdosfs.c:1613
static int backup_boot
Definition: mkdosfs.c:530
#define blk
Definition: linetest.c:70
static int reserved_sectors
Definition: mkdosfs.c:531
#define CF_LE_W(v)
Definition: mkdosfs.c:94
__u8 sector_size[2]
Definition: mkdosfs.c:361
#define CF_LE_L(v)
Definition: mkdosfs.c:95
static int size_root_dir
Definition: mkdosfs.c:545
static struct msdos_boot_sector bs
Definition: mkdosfs.c:539
static unsigned char * fat
Definition: mkdosfs.c:542
static int nr_fats
Definition: mkdosfs.c:533
INT x
Definition: msvc.h:62

Variable Documentation

__u16 adate

Definition at line 364 of file mkdosfs.c.

int atari_format = 0
static

Definition at line 521 of file mkdosfs.c.

Referenced by main().

Definition at line 359 of file mkdosfs.c.

Referenced by _get_elem_attr_node(), _mesa_free_attrib_data(), _swrast_span_default_attribs(), _test_comment_attrs(), _test_provideclassinfo(), ACTION_AppSearchComponents(), ACTION_AppSearchDr(), ACTION_SearchDirectory(), add_coclass_typeinfo(), add_func_desc(), add_var_desc(), BtrfsDeviceAdd::AddDevice(), app_search_file(), ATL::AtlComModuleUnregisterServer(), AtlGetObjectSourceInterface(), check_arg_attrs(), check_coclass_attrs(), check_dispiface_attrs(), check_enum_attrs(), check_field_attrs(), check_function_attrs(), check_iface_attrs(), check_library_attrs(), check_module_attrs(), check_struct_attrs(), check_typedef_attrs(), check_union_attrs(), clear_active_eval1(), clear_active_eval2(), contentHandler_putDocumentLocator(), contentHandler_startElement(), create_classes_key(), create_classes_root_hkey(), create_file_test(), create_msft_typeinfo(), create_registry_key(), CRYPT_AsnDecodePKCSAttribute(), CRYPT_CopyKeyIdAsIssuerAndSerial(), CRYPT_SizeOfKeyIdAsIssuerAndSerial(), delete_file_test(), dir_exists(), dupattrs(), dwarf2_read_one_debug_info(), Exist(), fill_filename_from_selection(), find_devices(), find_matching_domain_component(), for(), FormatEx2(), GdipCreateStringFormat(), get_attribute_value(), get_attrp(), get_attrv(), get_base_dir(), get_default_source(), get_dispids(), get_func_flags(), get_funcdesc(), get_manifest_in_manifest_file(), get_manifest_in_pe_file(), get_param_flags(), HandleDumpAttributes(), HTMLAttributeCollection2_getNamedItem(), HTMLAttributeCollection3_item(), HTMLAttributeCollection_get_dispid(), HTMLAttributeCollection_item(), HTMLDocument5_createAttribute(), HTMLElement_destructor(), HTMLElement_populate_props(), ICommDlgBrowser3_fnIncludeObject(), ICreateTypeInfo2_fnLayOut(), if(), init_library(), interpolate_active_attribs(), interpolate_texcoords(), is_attr(), is_correct_dir(), is_object(), keyed_event_thread(), line(), loadabbrevs(), LoadRegTypeLib(), lookup_winsxs(), move_attr(), msi_dialog_radiogroup_control(), MXAttributes_addAttribute(), MXAttributes_setLocalName(), MXAttributes_setQName(), MXAttributes_setURI(), MXAttributes_setValue(), NAME(), NLS_RegOpenKey(), nt_mailslot_test(), num_of_funcs(), open_classes_key(), open_file_test(), open_nt_file(), parse_attr(), parseabbrevs(), plot(), BtrfsDeviceAdd::populate_device_tree(), prepare_materials(), query_headers(), reader_add_attr(), reader_clear_attrs(), reader_set_current_attribute(), RegisterTypeLib(), run_client(), run_server(), sample_lambda_2d_aniso(), SdbpCreate(), search_absolute_directory(), set_active_eval1(), set_active_eval2(), set_cookies(), set_lib_flags(), SetUserGeoID(), SHAddToRecentDocs(), sprite_point(), START_TEST(), test__lcreat(), test_attr(), test_attr_collection(), test_attr_collection_disp(), test_case_sensitive(), test_catalog_properties(), test_cloneNode(), test_cp855(), test_cp932(), test_create_elems(), test_create_typelib_lcid(), test_CreateDirectoryA(), test_decodePKCSAttribute(), test_directory(), test_directory_sort(), test_empty_image(), test_encodePKCSAttributes(), test_encodePKCSSignerInfo(), test_event(), test_FillConsoleOutputAttribute(), test_get_Attributes(), test_get_attributes(), test_get_ownerDocument(), test_get_xml(), test_getAttributeNode(), test_GetDisplayName(), test_GetLibAttr(), test_insertBefore(), test_InstallAssembly(), test_keyed_events(), test_LoadRegTypeLib(), test_mutant(), test_name_collisions(), test_name_limits(), test_namespace_pipe(), test_namespaces_basic(), test_NtCreateFile(), test_NtQueryDirectoryFile(), test_NtQueryDirectoryFile_case(), test_null_auth_data(), test_null_device(), test_pic_with_stream(), test_put_nodeValue(), test_query_attribute_information_file(), test_query_object(), test_query_volume_information_file(), test_ReadConsoleOutputAttribute(), test_readonly(), test_recinfo(), test_register_typelib(), test_setAttributeNode(), test_setpropertyfolder(), test_ShellItemArrayGetAttributes(), test_signed_msg_encoding(), test_symboliclink(), test_type_mismatch(), test_TypeInfo(), test_WriteConsoleOutputAttribute(), test_XPath(), testIsRDNAttrsInCertificateName(), testWriteNotWrappedProcessed(), testWriteWrappedProcessed(), TLB_get_size_from_hreftype(), Typelib_EnumResNameProc(), UDFAttributesToUDF(), urlcache_delete_file(), vbo_exec_do_EvalCoord1f(), vbo_exec_do_EvalCoord2f(), vbo_exec_eval_update(), vbo_exec_fixup_vertex(), vbo_exec_wrap_upgrade_vertex(), VerInstallFileA(), xmlAddID(), xmlAddRef(), xmlreader_MoveToAttributeByName(), xmlRemoveRef(), xmlSAX2AttributeDecl(), xsltAttribute(), xsltAttrListTemplateProcess(), xsltGetTemplate(), and xsltNewAttrElem().

int backup_boot = 0
static

Definition at line 530 of file mkdosfs.c.

int badblocks = 0
static

Definition at line 532 of file mkdosfs.c.

char* blank_sector
static

Definition at line 548 of file mkdosfs.c.

__u8 boot_code

Definition at line 436 of file mkdosfs.c.

__u8 boot_jump[3]

Definition at line 358 of file mkdosfs.c.

__u16 cdate

Definition at line 363 of file mkdosfs.c.

int check = FALSE
static

Definition at line 522 of file mkdosfs.c.

uint8_t cluster_size

Definition at line 362 of file mkdosfs.c.

Referenced by read_boot(), ScriptXtoCP(), and test_GetDiskInfoA().

time_t create_time
static

Definition at line 525 of file mkdosfs.c.

Referenced by alloc_cookie().

__u8 ctime_ms

Definition at line 361 of file mkdosfs.c.

unsigned int currently_testing = 0
static

Definition at line 538 of file mkdosfs.c.

Referenced by check_blocks().

__u16 date

Definition at line 366 of file mkdosfs.c.

Referenced by _strdate(), _wstrdate(), add_cert_to_view(), add_date_string_to_control(), create_date(), create_date_constr(), create_utc_string(), Date_getDate(), Date_getDay(), Date_getFullYear(), Date_getHours(), Date_getMilliseconds(), Date_getMinutes(), Date_getMonth(), Date_getSeconds(), Date_getTime(), Date_getTimezoneOffset(), Date_getUTCDate(), Date_getUTCDay(), Date_getUTCFullYear(), Date_getUTCHours(), Date_getUTCMilliseconds(), Date_getUTCMinutes(), Date_getUTCMonth(), Date_getUTCSeconds(), Date_getYear(), Date_setDate(), Date_setFullYear(), Date_setHours(), Date_setMilliseconds(), Date_setMinutes(), Date_setMonth(), Date_setSeconds(), Date_setTime(), Date_setUTCDate(), Date_setUTCFullYear(), Date_setUTCHours(), Date_setUTCMilliseconds(), Date_setUTCMinutes(), Date_setUTCMonth(), Date_setUTCSeconds(), Date_setYear(), Date_toDateString(), Date_toISOString(), Date_toLocaleDateString(), Date_toLocaleString(), Date_toLocaleTimeString(), Date_toString(), Date_toTimeString(), Date_valueOf(), DateConstr_value(), DATETIME_ApplySelectedField(), DATETIME_IncreaseField(), DATETIME_ReturnTxt(), ExtCabCallback(), file_stat(), filetime_to_str(), Global_Date(), Global_Now(), InternetTimeFromSystemTimeW(), MONTHCAL_PaintCalendar(), MONTHCAL_PaintWeeknumbers(), msi_publish_install_properties(), CAttributesDialog::OnInitDialog(), return_date(), SHFormatDateTimeW(), summaryinfo_invoke(), test_GetFile(), test_hash_value(), test_IWinHttpRequest(), test_publish(), test_register_product(), test_strdate(), test_VarFormatFromTokens(), test_wstrdate(), urlcache_delete_file(), VarBstrFromDate(), and VARIANT_FormatDate().

char* device_name = NULL
static

Definition at line 520 of file mkdosfs.c.

uint8_t dir_entries

Definition at line 365 of file mkdosfs.c.

uint8_t drive_number

Definition at line 358 of file mkdosfs.c.

char dummy_boot_code[BOOTCODE_SIZE]
Initial value:
=
"\x0e"
"\x1f"
"\xbe\x5b\x7c"
"\xac"
"\x22\xc0"
"\x74\x0b"
"\x56"
"\xb4\x0e"
"\xbb\x07\x00"
"\xcd\x10"
"\x5e"
"\xeb\xf0"
"\x32\xe4"
"\xcd\x16"
"\xcd\x19"
"\xeb\xfe"
"This is not a bootable disk. Please insert a bootable floppy and\r\n"
"press any key to try again ... \r\n"

Definition at line 491 of file mkdosfs.c.

char dummy_boot_jump[3] = { 0xeb, 0x3c, 0x90 }

Definition at line 487 of file mkdosfs.c.

char dummy_boot_jump_m68k[2] = { 0x60, 0x1c }

Definition at line 489 of file mkdosfs.c.

char ext[3]

Definition at line 358 of file mkdosfs.c.

Referenced by _tstat64(), ACTION_RegisterExtensionInfo(), ACTION_UnregisterExtensionInfo(), add_ext_holes(), add_extent(), add_extent_to_fcb(), add_insert_extent_rollback(), alloc_child_window(), allocate_cache_chunk(), assign_file_addresses(), AX_ConvertDialogTemplate(), bad_name(), balance_data_chunk(), cert_find_alt_name_entry(), CertContext_GetProperty(), CertGetEnhancedKeyUsage(), CertGetIntendedKeyUsage(), CertIsValidCRLForCertificate(), compare_crl_issued_by(), create_snapshot(), CreateUrlCacheEntryW(), CRYPT_AsnDecodeExtension(), CRYPT_CheckNameConstraints(), CRYPT_CheckUsages(), CRYPT_DecodeBasicConstraints(), CRYPT_FileNameOpenStoreW(), CRYPT_GetIssuer(), CRYPT_GetNameConstraints(), CRYPT_GetPolicies(), CRYPT_GetUrlFromCertificateCRLDistPoint(), CRYPT_GetUrlFromCertificateIssuer(), CRYPT_IsCertificateSelfSigned(), CRYPT_KeyUsageValid(), do_create_snapshot(), do_write_file(), duplicate_extents(), duplicate_fcb(), excise_extents(), extend_file(), fcb_is_inline(), field_format_detailed_extension(), file_cvt(), FILEDLG95_OnOpen(), FileProtocol_StartEx(), find_cert_by_issuer(), find_mime_from_url(), flush_fcb(), format_enhanced_key_usage_value(), free_fcb(), free_package_structures(), get_extension_override(), get_file_type(), get_first_ext_from_spec(), get_inode_info(), get_subject_alt_name_ext(), GPOS_apply_lookup(), GPOS_get_subtable(), GSUB_apply_lookup(), GSUB_get_subtable(), handle_WM_KEY(), BookmarkList::import_IE_favorites(), install_file(), is_ca_cert(), is_valid_file(), iterate_all_extensions(), key_event(), load_extension(), load_given_extension(), load_gl_funcs(), make_number(), MMIO_ParseExtA(), move_across_subvols(), nsURL_GetFileBaseName(), on_command_filetype(), on_default_action(), PathYetAnotherMakeUniqueName(), print_version(), prompt_target(), query_ranges(), rationalize_extents(), ShellDirectory::read_directory(), read_file(), BtrfsContextMenu::reflink_copy(), remove_fcb_extent(), run_script(), savedc_emf_enum_proc(), FileTypeManager::set_type(), set_zero_data(), CFSFolder::SetNameOf(), SHAddToRecentDocs(), SHELL32_GetFSItemAttributes(), SHELL_FS_HideExtension(), ShellExecute_GetClassKey(), show_frame(), SplitFileSysURL(), START_TEST(), test_decodeExtensions(), test_DeviceCapabilities(), test_encodeCertToBeSigned(), test_findExtension(), test_GetExtensionName(), test_PathFindExtensionA(), test_splitpath(), test_SplitShortPathA(), testIntendedKeyUsage(), TrustIsCertificateSelfSigned(), try_extend_data(), try_find_new_name(), UDFDOSName100(), UDFDOSName200(), UDFDOSName201(), update_chunks(), URLDownloadToCacheFileW(), verify_cert_revocation(), vol_get_disk_extents(), wWinMain(), XCOPY_ProcessDestParm(), xsltExtModuleElementLookup(), xsltExtModuleElementPreComputeLookup(), xsltPreComputeExtModuleElement(), and xsltRegisterExtModuleElement().

__u8 ext_boot_sign

Definition at line 360 of file mkdosfs.c.

unsigned char* fat
static

Definition at line 542 of file mkdosfs.c.

Referenced by EndLog(), f_getfree(), FatGetFatEntry(), and FormatBufferFat().

uint16_t fat_length

Definition at line 368 of file mkdosfs.c.

Referenced by read_boot().

uint8_t fats

Definition at line 364 of file mkdosfs.c.

uint8_t fs_type

Definition at line 363 of file mkdosfs.c.

uint16_t heads

Definition at line 370 of file mkdosfs.c.

int ignore_full_disk = 0
static

Definition at line 537 of file mkdosfs.c.

unsigned char* info_sector
static

Definition at line 543 of file mkdosfs.c.

__u8 lcase

Definition at line 360 of file mkdosfs.c.

char name[8]

Definition at line 358 of file mkdosfs.c.

int nr_fats = 2
static

Definition at line 533 of file mkdosfs.c.

Referenced by write_tables().

char* program_name = "mkdosfs"
static

Definition at line 519 of file mkdosfs.c.

Referenced by susage(), and usage().

__u8 RESERVED

Definition at line 359 of file mkdosfs.c.

Referenced by MiniportSend(), NICPrepareForTransmit(), and vtstr().

__u16 reserved

Definition at line 363 of file mkdosfs.c.

int reserved_sectors = 0
static

Definition at line 531 of file mkdosfs.c.

Referenced by setup_tables(), and write_tables().

struct msdos_dir_entry* root_dir
static

Definition at line 544 of file mkdosfs.c.

Referenced by fnt_face_get_dll_font().

int root_dir_entries = 0
static

Definition at line 547 of file mkdosfs.c.

uint16_t secs_track

Definition at line 369 of file mkdosfs.c.

int sector_size_set = 0
static

Definition at line 529 of file mkdosfs.c.

int sectors_per_cluster = 0
static

Definition at line 546 of file mkdosfs.c.

Referenced by setup_tables(), test_GetDiskFreeSpaceA(), and test_GetDiskFreeSpaceW().

Definition at line 367 of file mkdosfs.c.

int size_fat = 0
static

Definition at line 534 of file mkdosfs.c.

Referenced by setup_tables().

int size_fat_by_user = 0
static

Definition at line 535 of file mkdosfs.c.

int size_root_dir
static

Definition at line 545 of file mkdosfs.c.

Definition at line 366 of file mkdosfs.c.

int start_data_block
static

Definition at line 541 of file mkdosfs.c.

int start_data_sector
static

Definition at line 540 of file mkdosfs.c.

Referenced by mark_FAT_sector().

__u16 starthi

Definition at line 365 of file mkdosfs.c.

__CRT_INLINE time_t __cdecl time

Definition at line 366 of file mkdosfs.c.

Referenced by __xmlInitializeDict(), ATL::_ATL_MSG::_ATL_MSG(), _Dispatch_type_(), _Function_class_(), _gmtime32_s(), _gmtime64_s(), _ILGetFileDate(), _mkgmtime(), _mkgmtime32(), _mktime32(), _Stl_loc_combine_names_aux(), _strtime(), _time(), _wstrtime(), ACTION_AppSearchGetSignature(), add_special_defines(), AtapiQueueTimerDpc(), AtapiTimerDpc(), attr_cache_entry_expired(), attr_cache_update(), AVIStreamSampleToTime(), bind_lease(), clnt_vc_call(), CloseTrace(), BtrfsRecv::cmd_utimes(), collect_query_data(), CommandShell(), convert_time(), create_date(), create_directory_fcb(), create_msft_typelib(), create_snapshot(), create_stream(), create_subvol(), ATL::CTime::CTime(), ATL::CTimeSpan::CTimeSpan(), d3drm_animation2_AddPositionKey(), d3drm_animation2_AddRotateKey(), d3drm_animation2_AddScaleKey(), Date_getFullYear(), date_now(), Date_toTimeString(), dateobj_to_date_string(), dateobj_to_string(), DaytimeHandler(), DECLARE_INTERFACE_(), delete_fileref(), delete_reparse_point(), dhcpack(), dhcpoffer(), DirectSoundDevice_Initialize(), dispatch(), do_create_snapshot(), DoOpen(), DoOutput(), duplicate_extents(), empty_message_queue(), entry_invis(), EnumEventsThread(), ExtCabCallback(), Fbt_CreateFiber(), file_create2(), fill_in_file_basic_information(), fill_in_file_network_open_information(), FillBookmarkInfo(), FillBuffer(), flush_events(), ATL::CTimeSpan::Format(), ATL::CTime::Format(), FormatDateTime(), ATL::CTime::FormatGmt(), FTP_SendData(), FTPGetOneF(), FTPOpenHost(), FTPOpenHostNoLogin(), FTPUpdateIOTimer(), FTPUtime(), generate_reloc_directory(), get_fattime(), get_test_year(), get_volume_size_info(), ATL::CTime::GetCurrentTime(), GetStartSpoolDate(), locale::global(), Global_Time(), handle_button_event(), idmap_lookup_group(), idmap_lookup_user(), init(), init_fs_tree(), InitGL(), InitLsMonths(), initrand(), InternetTimeFromSystemTimeA_test(), InternetTimeFromSystemTimeW_test(), InternetTimeToSystemTimeA_test(), InternetTimeToSystemTimeW_test(), IrotRegister(), keep_responsive(), load_persistent_cookie(), locale::locale(), localtime(), LogErrorConsole(), LogInfoConsole(), logMess(), LogMessage(), LogOpen(), LogWarningConsole(), look_for_roots(), LsCacheAdd(), LsCacheLookup(), LsL(), main(), make_date(), make_day(), MediaSeeking_GetCurrentPosition(), MediaSeeking_GetPositions(), MediaSeeking_GetStopPosition(), MiniDumpWriteDump(), mknod(), mktime(), mktime_worker(), move_across_subvols(), msi_create_empty_local_file(), MSVCRT__create_locale(), name_cache_entry_updated(), nfs41_create_session(), nfs41_open(), OnCreate(), open_file(), OpenTrace(), ATL::CTime::operator!=(), ATL::CTime::operator-(), ATL::CTime::operator<(), ATL::CTime::operator<=(), ATL::CTime::operator=(), ATL::CTime::operator==(), ATL::CTime::operator>(), ATL::CTime::operator>=(), pause_scrub(), PerfDataGetText(), PlaceMines(), print_ttl(), process_pdu_logon(), processPendingMessages(), processRequest(), PROPVAR_ConvertFILETIME(), query_dir_item(), query_scrub(), queue_add_timer(), queue_event(), queue_get_timeout(), rdp_send_logon_info(), recover_delegation_open(), recvd_subvol(), ATL::CRegObject::RegDeleteTreeX(), RendererPosPassThru_EOS(), reset_modifier_keys(), rpcb_gettime(), SampleGrabber_callback(), save_persistent_cookie(), SClose(), ScmAcquireServiceStartLock(), ScmQueryServiceLockStatusA(), ScmQueryServiceLockStatusW(), send_discover(), send_request(), SendRun(), set_basic_information(), set_end_of_file_information(), set_file_security(), set_link_information(), set_rename_information(), set_reparse_point(), set_symlink(), set_valid_data_length_information(), set_zero_data(), SetInstallationCompleted(), SHFormatDateTimeW(), sleep(), SpoolName(), SRead(), SRecv(), SRecvfrom(), SSend(), SSendto(), SSendtoByName(), START_TEST(), state_bound(), state_init(), state_reboot(), state_selecting(), stream_set_end_of_file_information(), SWaitUntilReadyForReading(), SWaitUntilReadyForWriting(), swapchain_gdi_present(), swapchain_gl_present(), SWrite(), SynthPortImpl_IDirectMusicPort_PlayBuffer(), SystemFunction036(), TaskTriggerConstructor(), test__hwrite(), test__lwrite(), Test_ctime(), test_dbcs_wm_char(), test_FileTimeToLocalFileTime(), test_FileTimeToSystemTime(), test_localtime32_s(), test_localtime64_s(), test_PdhCollectQueryDataWithTime(), test_RealizationInfo(), test_SetTrigger_GetTrigger(), test_strtime(), test_supported_locale(), test_verifyRevocation(), test_WinHttpTimeFromSystemTime(), test_WinHttpTimeToSystemTime(), test_wm_set_get_text(), test_wstrtime(), LocaleTest::time_by_name(), Database::toSdb(), Trace(), TruncBatchLog(), UDFEjectReqWaiter(), UnDate(), uninit(), UnLslR(), UnMDTMDate(), upcall_parse(), update_chunk_caches(), urlcache_delete_file(), urlcache_hash_entry_is_locked(), urlcache_rate_entry(), UuidCreateSequential(), VarBstrFromDate(), verify_cert_revocation_from_dist_points_ext(), vncKey(), vncMouse(), wait_move_event(), WINTRUST_GetTimeFromSigner(), write_btrfs(), write_file2(), write_one_file(), write_volume_label(), WriteDefaultFirewallPrefs(), xmlMemDisplay(), xsltGetProfileInformation(), xsltSaveProfiling(), and xwin_process_events().

uint32_t total_sect

Definition at line 372 of file mkdosfs.c.

int verbose = 0
static

Definition at line 523 of file mkdosfs.c.

Referenced by main().

Definition at line 435 of file mkdosfs.c.

Referenced by getline().

static long volume_id

Definition at line 361 of file mkdosfs.c.

Referenced by pvd_write().

__u8 volume_label[11]

Definition at line 362 of file mkdosfs.c.

char volume_name[] = " "
static

Definition at line 526 of file mkdosfs.c.

Referenced by source_matches_volume().