static errno_t cd_read_sectors( cdfs_t *impl, void *buf, int cd_sector, size_t nsectors ) { phantom_disk_partition_t *p = impl->p; SHOW_FLOW( 10, "CDFS disk read @ sect %d, nsect %d", cd_sector * 4, nsectors * 4 ); #if CD_CACHE if( impl->cache ) { if( 0 == cache_get_multiple( impl->cache, cd_sector, nsectors, buf ) ) return 0; } errno_t rc = phantom_sync_read_sector( p, buf, cd_sector * 4, nsectors * 4 ); if( impl->cache && !rc ) cache_put_multiple( impl->cache, cd_sector, nsectors, buf ); return rc; #else return phantom_sync_read_sector( p, buf, cd_sector * 4, nsectors * 4 ); #endif }
errno_t fs_probe_cd(phantom_disk_partition_t *p) { char buf[PAGE_SIZE]; //phantom_disk_superblock *sb = (phantom_disk_superblock *)&buf; int cd_sector = 16; // Have some limit while(cd_sector < 64) { if( phantom_sync_read_sector( p, buf, cd_sector * 4, 4 ) ) return EINVAL; if( strncmp( buf, cd_marker, 7 ) || (buf[7] != 0) ) return EINVAL; SHOW_FLOW( 3, "CDFS marker found @ sector %d", cd_sector ); return 0; } return EINVAL; }
static void lookup_old_pc_partitions(phantom_disk_partition_t *p) { unsigned char buf[512]; int lookAt = (p->flags & PART_FLAG_IS_WHOLE_DISK) || (p->type == 0x05) || (p->type == 0x0F) || (p->type == 0x85); if(!lookAt ) return; //p->syncRead( p, buf, 0, 1 ); if( phantom_sync_read_sector( p, buf, 0, 1 )) return; //hexdump(buf, 512, "", 0); //SHOW_FLOW0( 1, "Got block 0" ); if( debug_level_flow > 10) hexdump( buf, sizeof(buf), "", 0); if( (buf[0x1FE] != 0x55) || (buf[0x1FF] != 0xAA) ) { SHOW_ERROR0( 1, "No part table magic" ); return; } SHOW_FLOW0( 1, "Has part table magic!" ); p->flags |= PART_FLAG_IS_DIVIDED; int i; int pno = 0; for( i = 0x1BE; i <= 0x1EE; i += 16, pno++ ) { struct pc_partition *pp = (struct pc_partition *)(buf+i); SHOW_FLOW( 2, "Check partition %d, start %d, size %d, type 0x%02X", pno, pp->start, pp->size, pp->type ); if(pp->size == 0) continue; // break? phantom_disk_partition_t * newp = phantom_create_partition_struct( p, pp->start, pp->size ); newp->type = pp->type; if(newp->type == PHANTOM_PARTITION_TYPE_ID) { printf("!! Phantom Partition found !!\n"); p->flags |= PART_FLAG_IS_PHANTOM_TYPE; } char pn[4] = "PC0"; //pn[2] += pno++; pn[2] += pno; strncpy(newp->name, pn, PARTITION_NAME_LEN-1); register_partition( newp ); } }