Exemple #1
0
static int xfs_open(struct boot_file_t *file, const char *dev_name, struct partition_t *part, const char *file_name)
{
	char buffer[1024];

	DEBUG_ENTER;
	DEBUG_OPEN;

	DEBUG_F("Determining offset for partition %d\n", part->part_number);
	partition_offset = ((u64) part->part_start) * part->blocksize;
	DEBUG_F("%Lu = %lu * %hu\n", partition_offset, part->part_start, part->blocksize);

	sprintf(buffer, "%s:0", dev_name);	/* 0 is full disk in OF */
	DEBUG_F("Trying to open dev_name=%s; filename=%s; partition offset=%Lu\n", buffer, file_name, partition_offset);
	file->of_device = prom_open(buffer);

	if (file->of_device == PROM_INVALID_HANDLE || file->of_device == NULL) {
		DEBUG_F("Can't open device %p\n", file->of_device);
		DEBUG_LEAVE(FILE_ERR_BADDEV);
		return FILE_ERR_BADDEV;
	}

	DEBUG_F("%p was successfully opened\n", file->of_device);

	xfs_file = file;

	if (xfs_mount() != 1) {
		DEBUG_F("Couldn't open XFS @ %s/%Lu\n", buffer, partition_offset);
		prom_close(file->of_device);
		DEBUG_LEAVE(FILE_ERR_BAD_FSYS);
		DEBUG_SLEEP;
		return FILE_ERR_BAD_FSYS;
	}

	DEBUG_F("Attempting to open %s\n", file_name);
	strcpy(buffer, file_name);	/* xfs_dir modifies argument */
	if (!xfs_dir(buffer)) {
		DEBUG_F("xfs_dir() failed. errnum = %d\n", errnum);
		prom_close(file->of_device);
		DEBUG_LEAVE_F(errnum);
		DEBUG_SLEEP;
		return errnum;
	}

	DEBUG_F("Successfully opened %s\n", file_name);

	DEBUG_LEAVE(FILE_ERR_OK);
	return FILE_ERR_OK;
}
Exemple #2
0
/*
 * Unmount root
 */
int
cb_unmountroot()
{
	(void) prom_close(cb_rih);
	cb_rih = OBP_BADNODE;
	return (0);
}
Exemple #3
0
int
cpr_statefile_close(int fd)
{
	if (statefile_special) {
		statefile_special = 0;
		return (prom_close(fd));
	} else
		return (cpr_fs_close(fd));
}
Exemple #4
0
static int xfs_close(struct boot_file_t *file)
{
	if (file->of_device) {
		prom_close(file->of_device);
		file->of_device = 0;
		DEBUG_F("xfs_close called\n");
	}
	return FILE_ERR_OK;
}
Exemple #5
0
static int 
bd_close(struct open_file *f)
{
    struct open_disk	*od = f->f_devdata;

    (void)prom_close(od->od_fd);

    free(od);
    f->f_devdata = NULL;
    return(0);
}
Exemple #6
0
/*
 * Closes the prom interface
 */
static void
todds1307_rele_prom()
{
    (void) prom_close(todds1307_ihandle);
}
Exemple #7
0
int close(int fd) {
	prom_close((void *)fd);
	return 0;
}
Exemple #8
0
static int
promfs_unmountroot(void)
{
	(void) prom_close(fsih);
	return (0);
}
Exemple #9
0
static int
reiserfs_open( struct boot_file_t *file, const char *dev_name,
               struct partition_t *part, const char *file_name )
{
     static char buffer[1024];

     DEBUG_ENTER;
     DEBUG_OPEN;

     memset( INFO, 0, sizeof(struct reiserfs_state) );
     INFO->file = file;

     if (part)
     {
	  DEBUG_F( "Determining offset for partition %d\n", part->part_number );
	  INFO->partition_offset = ((uint64_t)part->part_start) * part->blocksize;
	  DEBUG_F( "%Lu = %lu * %hu\n", INFO->partition_offset,
		   part->part_start,
		   part->blocksize );
     }
     else
	  INFO->partition_offset = 0;

     strncpy(buffer, dev_name, 1020);
     if (_machine != _MACH_bplan)
	  strcat(buffer, ":0");  /* 0 is full disk in (non-buggy) OF */

     file->of_device = prom_open( buffer );
     DEBUG_F( "Trying to open dev_name=%s; filename=%s; partition offset=%Lu\n",
	      buffer, file_name, INFO->partition_offset );

     if ( file->of_device == PROM_INVALID_HANDLE || file->of_device == NULL )
     {
	  DEBUG_F( "Can't open device %p\n", file->of_device );
	  DEBUG_LEAVE(FILE_ERR_BADDEV);
	  return FILE_ERR_BADDEV;
     }

     DEBUG_F("%p was successfully opened\n", file->of_device);

     if ( reiserfs_read_super() != 1 )
     {
	  DEBUG_F( "Couldn't open ReiserFS @ %s/%Lu\n", buffer, INFO->partition_offset );
	  prom_close( file->of_device );
	  DEBUG_LEAVE(FILE_ERR_BAD_FSYS);
	  return FILE_ERR_BAD_FSYS;
     }

     DEBUG_F( "Attempting to open %s\n", file_name );
     strcpy(buffer, file_name); /* reiserfs_open_file modifies argument */
     if (reiserfs_open_file(buffer) == 0)
     {
	  DEBUG_F( "reiserfs_open_file failed. errnum = %d\n", errnum );
	  prom_close( file->of_device );
	  DEBUG_LEAVE_F(errnum);
	  return errnum;
     }

     DEBUG_F( "Successfully opened %s\n", file_name );

     DEBUG_LEAVE(FILE_ERR_OK);
     DEBUG_SLEEP;
     return FILE_ERR_OK;
}