Example #1
0
errno_t fs_probe_phantom(phantom_disk_partition_t *p)
{
    char buf[PAGE_SIZE];
    phantom_disk_superblock *sb = (phantom_disk_superblock *)&buf;

    int i;
    for( i = 0; i < nsbpos; i++ )
    {
        if( phantom_sync_read_block( p, buf, sbpos[i], 1 ) )
            continue;
        if( phantom_calc_sb_checksum( sb ) )
        {
            p->flags |= PART_FLAG_IS_PHANTOM_FSSB;
            return 0;
        }
    }

    return EINVAL;
}
void
phantom_disk_format( phantom_disk_superblock *sb, unsigned int n_pages, const char *sysname )
{

    memset( sb, 0, sizeof(*sb) );

    sb->version = DISK_STRUCT_VERSION;
    sb->magic   = DISK_STRUCT_MAGIC_SUPERBLOCK;
    sb->magic2  = DISK_STRUCT_MAGIC_SUPER_2;
    sb->blocksize = 4096;

    sb->sb2_addr = sb->sb3_addr = 0; // No copies of superblock

    sb->disk_start_page = PHANTOM_DEFAULT_DISK_START;
    sb->disk_page_count = n_pages;

    sb->free_start = 1; // Next block after super is free.
    sb->free_list = 0;  // No free list yet.
    sb->fs_is_clean = 0xFF;

    strlcpy( sb->sys_name, sysname, sizeof(sb->sys_name) );

    phantom_calc_sb_checksum( sb );
}