Esempio n. 1
0
int
biosdisk_findpartition(int biosdev, daddr_t sector)
{
#if defined(NO_DISKLABEL) && defined(NO_GPT)
	return 0;
#else
	struct biosdisk *d;
	int partition = 0;
#ifdef DISK_DEBUG
	printf("looking for partition device %x, sector %"PRId64"\n", biosdev, sector);
#endif

	/* Look for netbsd partition that is the dos boot one */
	d = alloc_biosdisk(biosdev);
	if (d == NULL)
		return 0;

	if (read_partitions(d) == 0) {
		for (partition = (BIOSDISKNPART-1); --partition;) {
			if (d->part[partition].fstype == FS_UNUSED)
				continue;
			if (d->part[partition].offset == sector)
				break;
		}
	}

	dealloc(d, sizeof(*d));
	return partition;
#endif /* NO_DISKLABEL && NO_GPT */
}
Esempio n. 2
0
void PartitionManager::query_available_partitions(char *script)
{
	FILE *fin = NULL;
	ArgList args;
	priv_state priv;

	/* load a description of the available partitions which could be 
		backed, booted, or generatable. */

	dprintf(D_ALWAYS, "Finding available partitions with: %s\n", script);

	args.AppendArg(script);

	priv = set_root_priv();
	fin = my_popen(args, "r", TRUE);

	if (fin == NULL) {
		EXCEPT("Can't execute %s", script);
	}

	read_partitions(fin);

	my_pclose(fin);
	set_priv(priv);
}
Esempio n. 3
0
static void
uuidcache_init(void)
{
	if (uuidCache)
		return;

#ifdef VG_DIR
	init_lvm();
#endif
	read_evms();
	read_partitions();
}
Esempio n. 4
0
void hd_scan_sysfs_block(hd_data_t *hd_data)
{
  if(!hd_probe_feature(hd_data, pr_block)) return;

  hd_data->module = mod_block;

  /* some clean-up */
  remove_hd_entries(hd_data);

  hd_data->disks = free_str_list(hd_data->disks);
  hd_data->partitions = free_str_list(hd_data->partitions);
  hd_data->cdroms = free_str_list(hd_data->cdroms);

  if(hd_probe_feature(hd_data, pr_block_mods)) {
    PROGRESS(1, 0, "block modules");
    // load_module(hd_data, "ide-cd");
    load_module(hd_data, "ide-cd_mod");
    load_module(hd_data, "ide-disk");
    load_module(hd_data, "sr_mod");
    load_module(hd_data, "sd_mod");
#if !defined(__s390__) && !defined(__s390x__)
    load_module(hd_data, "st");
#endif
  }

  PROGRESS(2, 0, "sysfs drivers");

  hd_sysfs_driver_list(hd_data);

  PROGRESS(3, 0, "cdrom");

  read_cdroms(hd_data);

  PROGRESS(4, 0, "partition");

  read_partitions(hd_data);

  PROGRESS(5, 0, "get sysfs block dev data");

  get_block_devs(hd_data);

  if(hd_data->cdrom) {
    ADD2LOG("oops: cdrom list not empty\n");
  }
}
Esempio n. 5
0
int
disk_open(void)
{
	int di;

	di = get_diskinfo(BDEV(dev,unit));

#ifdef	DEBUG
	if(debug) {
		printf("disk_open()\n");
		printf("diskinfo %x\n", di);
		printf("HS %d %d\n", HEADS(di) ,SPT(di));
	}
#endif
	spc = (spt = SPT(di)) * HEADS(di);
	use_badsect = FALSE;
	if (dev == DEV_FLOPPY) {
		boff = 0;
		part = (spt == 15 ? 3 : 1);
		return 0;
	}
	else {
	  	/*
		 * Usually H=32 S=64 for SCSI
		 * But sometimes we also have H=33 & S=62.
		 * For IDE Apparently H<64 
		 */
		if (spt >= 64 || HEADS(di) > 32) /* scsi */
			dev = DEV_SD;
		if (read_partitions())
			return(1);
#if	DEBUG
	if(debug)
		printf("%d partitions, active is %d\n", 
		       npartitions, active_partition);
#endif
		if (part > npartitions)
			return(1);
		boff = partitions[part].p_start;
	}
	return 0;
}
Esempio n. 6
0
// read the xml file
int read_xml(){
	
	init_config();

	debug_printf ("Reading hardware element...\n");	

	// read the hardaware element
	if (read_hardware() != 0){
		return -1;	
	}
	debug_printf ("OK\n");	

	// read the kernel element	
	if (read_kernel() != 0){
		return -1;	
	}

	// read the ports element
	if (read_ports() != 0){
		return -1;	
	}

	// read the partitions element
	if (read_partitions() != 0){
		return -1;	
	}

	// check if every port has been assigned to a partition
	int i;
	for (i=0; i<nb_ports; i++){
		if (ports[i].partition_id == -1){
			printf("WARNING: port %d has not been assigned to any partition!\n",ports[i].user_port_id);
		}	
	}

	return 0;

} 
Esempio n. 7
0
int
biosdisk_open(struct open_file *f, ...)
/* struct open_file *f, int biosdev, int partition */
{
	va_list ap;
	struct biosdisk *d;
	int biosdev;
	int partition;
	int error = 0;

	va_start(ap, f);
	biosdev = va_arg(ap, int);
	d = alloc_biosdisk(biosdev);
	if (d == NULL) {
		error = ENXIO;
		goto out;
	}

	partition = va_arg(ap, int);
#ifdef _STANDALONE
	bi_disk.biosdev = d->ll.dev;
	bi_disk.partition = partition;
	bi_disk.labelsector = -1;

	bi_wedge.biosdev = d->ll.dev;
	bi_wedge.matchblk = -1;
#endif

#if !defined(NO_DISKLABEL) || !defined(NO_GPT)
	error = read_partitions(d);
	if (error == -1) {
		error = 0;
		goto nolabel;
	}
	if (error)
		goto out;

	if (partition >= BIOSDISKNPART ||
	    d->part[partition].fstype == FS_UNUSED) {
#ifdef DISK_DEBUG
		printf("illegal partition\n");
#endif
		error = EPART;
		goto out;
	}

	d->boff = d->part[partition].offset;

	if (d->part[partition].fstype == FS_RAID)
		d->boff += RF_PROTECTED_SECTORS;

#ifdef _STANDALONE
	bi_wedge.startblk = d->part[partition].offset;
	bi_wedge.nblks = d->part[partition].size;
#endif

nolabel:
#endif
#ifdef DISK_DEBUG
	printf("partition @%"PRId64"\n", d->boff);
#endif

#ifdef _STANDALONE
	add_biosdisk_bootinfo();
#endif

	f->f_devdata = d;
out:
        va_end(ap);
	if (error)
		dealloc(d, sizeof(*d));
	return error;
}
Esempio n. 8
0
void
biosdisk_probe(void)
{
	struct biosdisk d;
	struct biosdisk_extinfo ed;
	uint64_t size;
	int first;
	int i;
#if !defined(NO_DISKLABEL) || !defined(NO_GPT)
	int part;
#endif

	for (i = 0; i < MAX_BIOSDISKS + 2; i++) {
		first = 1;
		memset(&d, 0, sizeof(d));
		memset(&ed, 0, sizeof(ed));
		if (i >= MAX_BIOSDISKS)
			d.ll.dev = 0x00 + i - MAX_BIOSDISKS;	/* fd */
		else
			d.ll.dev = 0x80 + i;			/* hd/cd */
		if (set_geometry(&d.ll, &ed))
			continue;
		printf("disk ");
		switch (d.ll.type) {
		case BIOSDISK_TYPE_CD:
			printf("cd0\n  cd0a\n");
			break;
		case BIOSDISK_TYPE_FD:
			printf("fd%d\n", d.ll.dev & 0x7f);
			printf("  fd%da\n", d.ll.dev & 0x7f);
			break;
		case BIOSDISK_TYPE_HD:
			printf("hd%d", d.ll.dev & 0x7f);
			if (d.ll.flags & BIOSDISK_INT13EXT) {
				printf(" size ");
				size = ed.totsec * ed.sbytes;
				if (size >= (10ULL * 1024 * 1024 * 1024))
					printf("%"PRIu64" GB",
					    size / (1024 * 1024 * 1024));
				else
					printf("%"PRIu64" MB",
					    size / (1024 * 1024));
			}
			printf("\n");
			break;
		}
#if !defined(NO_DISKLABEL) || !defined(NO_GPT)
		if (d.ll.type != BIOSDISK_TYPE_HD)
			continue;

		if (read_partitions(&d) != 0)
			continue;
			
		for (part = 0; part < BIOSDISKNPART; part++) {
			if (d.part[part].size == 0)
				continue;
			if (d.part[part].fstype == FS_UNUSED)
				continue;
			if (first) {
				printf(" ");
				first = 0;
			}
			printf(" hd%d%c(", d.ll.dev & 0x7f, part + 'a');
			if (d.part[part].fstype < FSMAXTYPES)
				printf("%s",
				  fstypenames[d.part[part].fstype]);
			else
				printf("%d", d.part[part].fstype);
			printf(")");
		}
#endif
		if (first == 0)
			printf("\n");
	}
}