Lines Matching refs:bs

39 fat_boot_sector_read (FatBootSector* bs, const PedGeometry *geom)
41 PED_ASSERT (bs != NULL, return 0);
44 if (!ped_geometry_read (geom, bs, 0, 1))
47 if (PED_LE16_TO_CPU (bs->boot_sign) != 0xAA55) {
54 if (!bs->system_id[0]) {
61 if (!bs->sector_size
62 || PED_LE16_TO_CPU (bs->sector_size) % PED_SECTOR_SIZE_DEFAULT) {
69 if (!bs->cluster_size) {
76 if (!bs->reserved) {
83 if (bs->fats < 1 || bs->fats > 4) {
96 fat_boot_sector_probe_type (const FatBootSector* bs, const PedGeometry* geom)
102 if (!PED_LE16_TO_CPU (bs->dir_entries))
105 logical_sector_size = PED_LE16_TO_CPU (bs->sector_size) / 512;
108 = PED_LE16_TO_CPU (bs->reserved) * logical_sector_size
109 + 2 * PED_LE16_TO_CPU (bs->fat_length) * logical_sector_size
110 + PED_LE16_TO_CPU (bs->dir_entries)
113 / bs->cluster_size / logical_sector_size;
128 fat_boot_sector_analyse (FatBootSector* bs, PedFileSystem* fs)
133 PED_ASSERT (bs != NULL, return 0);
135 if (PED_LE16_TO_CPU (bs->sector_size) != 512) {
142 (int) PED_LE16_TO_CPU (bs->sector_size))
147 fs_info->logical_sector_size = PED_LE16_TO_CPU (bs->sector_size) / 512;
149 fs_info->sectors_per_track = PED_LE16_TO_CPU (bs->secs_track);
150 fs_info->heads = PED_LE16_TO_CPU (bs->heads);
178 bs->secs_track
180 bs->heads = PED_CPU_TO_LE16 (fs_info->heads);
181 if (!fat_boot_sector_write (bs, fs))
196 if (bs->sectors)
197 fs_info->sector_count = PED_LE16_TO_CPU (bs->sectors)
200 fs_info->sector_count = PED_LE32_TO_CPU (bs->sector_count)
203 fs_info->fat_table_count = bs->fats;
204 fs_info->root_dir_entry_count = PED_LE16_TO_CPU (bs->dir_entries);
205 fs_info->fat_offset = PED_LE16_TO_CPU (bs->reserved)
207 fs_info->cluster_sectors = bs->cluster_size
230 fs_info->fat_type = fat_boot_sector_probe_type (bs, fs->geom);
239 fs_info->fat_sectors = PED_LE16_TO_CPU (bs->fat_length)
242 = PED_LE32_TO_CPU (bs->u.fat16.serial_number);
255 fs_info->fat_sectors = PED_LE32_TO_CPU (bs->u.fat32.fat_length)
258 = PED_LE32_TO_CPU (bs->u.fat32.serial_number);
266 = PED_LE32_TO_CPU (bs->u.fat32.root_dir_cluster);
291 fat_boot_sector_set_boot_code (FatBootSector* bs)
293 PED_ASSERT (bs != NULL, return 0);
295 memset (bs, 0, 512);
296 memcpy (bs->boot_jump, FAT_BOOT_JUMP, 3);
297 memcpy (bs->u.fat32.boot_code, FAT_BOOT_CODE, FAT_BOOT_CODE_LENGTH);
302 fat_boot_sector_generate (FatBootSector* bs, const PedFileSystem* fs)
306 PED_ASSERT (bs != NULL, return 0);
308 memcpy (bs->system_id, "MSWIN4.1", 8);
309 bs->sector_size = PED_CPU_TO_LE16 (fs_info->logical_sector_size * 512);
310 bs->cluster_size = fs_info->cluster_sectors
312 bs->reserved = PED_CPU_TO_LE16 (fs_info->fat_offset
314 bs->fats = fs_info->fat_table_count;
316 bs->dir_entries = (fs_info->fat_type == FAT_TYPE_FAT16)
322 bs->sectors = 0;
323 bs->sector_count = PED_CPU_TO_LE32 (fs_info->sector_count
326 bs->sectors = PED_CPU_TO_LE16 (fs_info->sector_count
328 bs->sector_count = 0;
331 bs->media = 0xf8;
333 bs->secs_track = PED_CPU_TO_LE16 (fs_info->sectors_per_track);
334 bs->heads = PED_CPU_TO_LE16 (fs_info->heads);
335 bs->hidden = PED_CPU_TO_LE32 (fs->geom->start);
338 bs->fat_length = 0;
339 bs->u.fat32.fat_length = PED_CPU_TO_LE32 (fs_info->fat_sectors
341 bs->u.fat32.flags = 0; /* FIXME: what the hell are these? */
342 bs->u.fat32.version = 0; /* must be 0, for Win98 bootstrap */
343 bs->u.fat32.root_dir_cluster
345 bs->u.fat32.info_sector
348 bs->u.fat32.backup_sector
352 bs->u.fat32.drive_num = 0x80; /* _ALWAYS_ 0x80. silly DOS */
354 memset (bs->u.fat32.empty_1, 0, 12);
356 bs->u.fat32.ext_signature = 0x29;
357 bs->u.fat32.serial_number
359 memcpy (bs->u.fat32.volume_name, "NO NAME ", 11);
360 memcpy (bs->u.fat32.fat_name, "FAT32 ", 8);
362 bs->fat_length
366 bs->u.fat16.drive_num = 0x80; /* _ALWAYS_ 0x80. silly DOS */
368 bs->u.fat16.ext_signature = 0x29;
369 bs->u.fat16.serial_number
371 memcpy (bs->u.fat16.volume_name, "NO NAME ", 11);
372 memcpy (bs->u.fat16.fat_name, "FAT16 ", 8);
375 bs->boot_sign = PED_CPU_TO_LE16 (0xaa55);
381 fat_boot_sector_write (const FatBootSector* bs, PedFileSystem* fs)
385 PED_ASSERT (bs != NULL, return 0);
387 if (!ped_geometry_write (fs->geom, bs, 0, 1))
390 if (!ped_geometry_write (fs->geom, bs,