コード例 #1
0
ファイル: bios.c プロジェクト: hean01/lxdream
static gboolean bios_load_ipl( cdrom_disc_t disc, cdrom_track_t track, const char *program_name,
                               unsigned char *buffer, gboolean unscramble )
{
    gboolean rv = TRUE;

    IsoImageFilesystem *iso = iso_filesystem_new_from_track( disc, track, NULL );
    if( iso == NULL ) {
        ERROR( "Disc is not bootable (invalid ISO9660 filesystem)" );
        return FALSE;
    }
    IsoFileSource *file = NULL;
    int status = iso->get_by_path(iso, program_name, &file );
    if( status != 1 ) {
        ERROR( "Disc is not bootable (initial program '%s' not found)", program_name );
        iso_filesystem_unref(iso);
        return FALSE;
    }

    struct stat st;
    if( iso_file_source_stat(file, &st) == 1 ) {
        if( st.st_size > (0x8D000000 - BINARY_LOAD_ADDR) ) {
            ERROR( "Disc is not bootable (Initial program is too large to fit into memory)" );
            rv = FALSE;
        } else if( iso_file_source_open(file) == 1 ) {
            size_t len;
            if( unscramble ) {
                char *tmp = g_malloc(st.st_size);
                len = iso_file_source_read(file, tmp, st.st_size);
                bootprogram_unscramble(buffer, tmp, st.st_size);
                g_free(tmp);
            } else {
                len = iso_file_source_read(file, buffer, st.st_size);
            }

            if( len != st.st_size ) {
                ERROR( "Disc is not bootable (Unable to read initial program '%s')", program_name );
                rv = FALSE;
            }
            iso_file_source_close(file);
        }
    } else {
        ERROR( "Disc is not bootable (Unable to get size of initial program '%s')", program_name );
        rv = FALSE;
    }

    iso_file_source_unref(file);
    iso_filesystem_unref(iso);
    return rv;
}
コード例 #2
0
ファイル: cd_reader.c プロジェクト: kallisti5/cd-track-reader
static void create_tree ( IsoFileSource *dir, GtkTreeStore * tree_store,GtkTreeIter parent )
{

	GtkTreeIter  child;
	int ret;
	IsoFileSource *file;
	char tt[96];   // it is a dirty fix because sizeof(struct stat) evaluates 88 or somthing but sizeof(struct stat) realy needed is 96
	struct stat *info=tt;
	ret = iso_file_source_open ( dir );
	if ( ret < 0 )
	{
		printf ( "Can't open dir %d\n", ret );
		show_error("Can't open dir ");
	}
	while ( ( ret = iso_file_source_readdir ( dir, &file ) ) == 1 )
	{


//		struct stat *info;
		char *name;
		iso_file_source_lstat ( file, info );


		name = iso_file_source_get_name ( file );
		//printf ( " %s", name );
		if ( parent.stamp )
			gtk_tree_store_append ( tree_store,&child ,&parent );
		else
			gtk_tree_store_append ( tree_store,&child ,NULL );
		gtk_tree_store_set ( tree_store, &child,0, name, -1 );

		free ( name );
		/*		if ( S_ISLNK ( info.st_mode ) )
				{
					char buf[PATH_MAX];
					iso_file_source_readlink ( file, buf, PATH_MAX );
					printf ( " -> %s\n", buf );
				}
				printf ( "\n" );
		*/


		ret = iso_file_source_lstat ( file, info );
		if ( ret < 0 )
		{
			break;
		}
		if ( S_ISDIR ( info->st_mode ) )
		{

			create_tree ( file,tree_store ,child );
		}
		if ( file )
			iso_file_source_unref ( file );
	}
	iso_file_source_close ( dir );
	if ( ret < 0 )
	{
		printf ( "Can't print dir\n" );
		show_error("Can't print dir ");
	}

}