Esempio n. 1
0
/* ( -- success? ) */
static void
grubfs_files_open( grubfs_info_t *mi )
{
	int fd, i;
	char *path = my_args_copy();
	char *s;

	fd = open_ih( my_parent() );
	if ( fd == -1 ) {
		free( path );
		RET( 0 );
	}

	mi->gfs = &dummy_fs;

	for (i = 0; i < sizeof(fsys_table)/sizeof(fsys_table[0]); i++) {
#ifdef CONFIG_DEBUG_FS
		printk("Trying %s\n", fsys_table[i].name);
#endif
		if (fsys_table[i].mount_func()) {
			const fsys_entry_t *fsys = &fsys_table[i];
#ifdef CONFIG_DEBUG_FS
			printk("Mounted %s\n", fsys->name);
#endif
			mi->gfs = malloc(sizeof(grubfs_t));
			mi->gfs->fsys = fsys;
			mi->gfs->dev_fd = fd;
			mi->gfs->offset = 0;

			s = path;
			while (*s) {
				if(*s=='\\') *s='/';
				s++;
			}
#ifdef CONFIG_DEBUG_FS
			printk("Path=%s\n",path);
#endif
			if (!mi->gfs->fsys->dir_func((char *) path)) {
				forth_printf("File not found\n");
				RET( 0 );
			}

			mi->gfs->fd = malloc(sizeof(grubfile_t));
			mi->gfs->fd->pos = filepos;
			mi->gfs->fd->len = filemax;
			mi->gfs->fd->path = strdup(path);

			RET( -1 );
		}
	}
#ifdef CONFIG_DEBUG_FS
	printk("Unknown filesystem type\n");
#endif

	RET( 0 );
}
Esempio n. 2
0
int
_parword( const char *method, xt_t *cache_xt )
{
	if( !*cache_xt )
		*cache_xt = find_ih_method( method, my_parent() );
	if( *cache_xt ) {
		enterforth( *cache_xt );
		return 0;
	}
	return -1;
}
Esempio n. 3
0
/* ( -- success? ) */
static void
hfsp_files_open( hfsp_info_t *mi )
{
	int fd;
	char *path = my_args_copy();

	if ( ! path )
		RET( 0 );

	fd = open_ih( my_parent() );
	if ( fd == -1 ) {
		free( path );
		RET( 0 );
	}

	mi->vol = malloc( sizeof(volume) );
	if (volume_open(mi->vol, fd)) {
		free( path );
		close_io( fd );
		RET( 0 );
	}

	mi->hfspfile = malloc( sizeof(hfsp_file_t) );
	
	/* Leading \\ means system folder. The finder info block has
	 * the following meaning.
	 *
	 *  [0] Prefered boot directory ID
	 *  [3] MacOS 9 boot directory ID
	 *  [5] MacOS X boot directory ID
	 */
	if( !strncmp(path, "\\\\", 2) ) {
		int *p = (int*)&(mi->vol)->vol.finder_info[0];
		int cnid = p[0];
		/* printk(" p[0] = %x, p[3] = %x, p[5] = %x\n", p[0], p[3], p[5] ); */
		if( p[0] == p[5] && p[3] )
			cnid = p[3];
		if( record_init_cnid(&(mi->hfspfile->rec), &(mi->vol)->catalog, cnid) )
			RET ( 0 );
		path += 2;
	} else {
		record_init_root( &(mi->hfspfile->rec), &(mi->vol)->catalog );
	}

	if( !search_files(&(mi->hfspfile->rec), 0, match_path, path, mi->hfspfile ) )
		RET ( -1 );
	
	RET ( -1 );
}
Esempio n. 4
0
/* ( -- success? ) */
static void
dlabel_open( dlabel_info_t *di )
{
	char *path;
	char block0[512];
	phandle_t ph;
	int success=0;
	cell status;

	path = my_args_copy();

	DPRINTF("dlabel-open '%s'\n", path );

	di->part_ih = 0;

	/* Find parent methods */
	di->filesystem_ph = 0;
	di->parent_seek_xt = find_parent_method("seek");
	di->parent_tell_xt = find_parent_method("tell");
	di->parent_read_xt = find_parent_method("read");

	/* If arguments have been passed, determine the partition/filesystem type */
	if (path && strlen(path)) {

		/* Read first block from parent device */
		DPUSH(0);
		call_package(di->parent_seek_xt, my_parent());
		POP();

		PUSH(pointer2cell(block0));
		PUSH(sizeof(block0));
		call_package(di->parent_read_xt, my_parent());
		status = POP();
		if (status != sizeof(block0))
			goto out;

		/* Find partition handler */
		PUSH( pointer2cell(block0) );
		selfword("find-part-handler");
		ph = POP_ph();
		if( ph ) {
			/* We found a suitable partition handler, so interpose it */
			DPRINTF("Partition found on disk - scheduling interpose with ph " FMT_ucellx "\n", ph);

			push_str(path);
			PUSH_ph(ph);
			fword("interpose");	

			success = 1;
		} else {
			/* unknown (or missing) partition map,
			* try the whole disk
			*/

			DPRINTF("Unknown or missing partition map; trying whole disk\n");

			/* Probe for filesystem from start of device */
			DPUSH ( 0 );	
			PUSH_ih( my_self() );
			selfword("find-filesystem");
			ph = POP_ph();
			if( ph ) {
				/* If we have been asked to open a particular file, interpose the filesystem package with the passed filename as an argument */
				di->filesystem_ph = ph;

				DPRINTF("Located filesystem with ph " FMT_ucellx "\n", ph);
				DPRINTF("path: %s length: %d\n", path, strlen(path));

				if (path && strlen(path)) {
					DPRINTF("INTERPOSE!\n");

					push_str( path );
					PUSH_ph( ph );
					fword("interpose");
				}
			} else if (path && strcmp(path, "%BOOT") != 0) {
				goto out;
			}

			success = 1;
		}
	} else {
		/* No arguments were passed, so we just use the parent raw device directly */
		success = 1;
	}

out:
	if( path )
		free( path );
	if( !success ) {
		dlabel_close( di );
		RET(0);
	}
	PUSH(-1);
}
Esempio n. 5
0
/* ( -- filepos.d ) */
static void
dlabel_tell( dlabel_info_t *di )
{
	/* Call back up to parent */
	call_package(di->parent_tell_xt, my_parent());
}