Пример #1
0
int
dkopen(struct open_file *f, ...)
{
	struct disklabel *lp;
	struct hppa_dev *dp = f->f_devdata;
	const char *st;

#ifdef	DEBUG
	if (debug)
		printf("dkopen(%p)\n", f);
#endif

	if (!(dp->pz_dev = pdc_findev(-1, PCL_RANDOM)))
		return ENXIO;

	lp = dp->label;
	st = NULL;

#ifdef DEBUG
	if (debug)
		printf ("disklabel\n");
#endif

	if ((st = dk_disklabel(dp, lp)) != NULL) {
#ifdef DEBUG
		if (debug)
			printf ("dkopen: %s\n", st);
#endif
		/* we do not know if it's a disk or net, but do not fail */
	} else {
		u_int i;

		i = B_PARTITION(dp->bootdev);
		if (i >= lp->d_npartitions || !lp->d_partitions[i].p_size)
			return (EPART);

		dp->fsoff = lp->d_partitions[i].p_offset;
	}

#ifdef DEBUGBUG
	if (debug)
		printf ("dkopen() ret\n");
#endif
	return (0);
}
Пример #2
0
Файл: dk.c Проект: MarginC/kame
int
dkopen(struct open_file *f, ...)
{
	struct disklabel *lp;
	struct hppa_dev *dp = f->f_devdata;
	const char *st;
	u_int i;

#ifdef	DEBUG
	if (debug)
		printf("dkopen(%p)\n", f);
#endif

	if (!(dp->pz_dev = pdc_findev(-1, PCL_RANDOM)))
		return ENXIO;

	lp = dp->label;
	st = NULL;
#ifdef DEBUG
	if (debug)
		printf ("disklabel\n");
#endif
	if ((st = dk_disklabel(dp, lp)) != NULL) {
#ifdef DEBUG
		if (debug)
			printf ("dkopen: %s\n", st);
#endif
		return ERDLAB;
	} else {
		i = B_PARTITION(dp->bootdev);
#ifdef DEBUG
		if (debug)
			printf("bootdev 0x%x, partition %u\n", dp->bootdev, i);
#endif
		if (i >= lp->d_npartitions || !lp->d_partitions[i].p_size) {
			return (EPART);
		}
	}
#ifdef DEBUGBUG
	if (debug)
		printf ("dkopen() ret\n");
#endif
	return (0);
}
Пример #3
0
int
dkopen(struct open_file *f, ...)
{
	struct disklabel dkl;
	struct hppa_dev *dp = f->f_devdata;
	const char *st;
	u_int i;

#ifdef	DEBUG
	if (debug)
		printf("dkopen(%p)\n", f);
#endif

	if (!(dp->pz_dev = pdc_findev(-1, PCL_RANDOM)))
		return ENXIO;

	dp->part_off = 0;
	st = NULL;
#ifdef DEBUG
	if (debug)
		printf ("disklabel\n");
#endif
	if ((st = dk_disklabel(dp, &dkl)) != NULL) {
#ifdef DEBUG
		if (debug)
			printf ("dkopen: %s\n", st);
#endif
	/*
	 * Ignore disklabel errors for this two reasons:
	 * 1. It is possible to dd(1) a LIF image containing the bootloader
	 * and a kernel with attached RAM disk to disk and boot it. That way
	 * the netboot installation LIF image is also usable as disk boot 
	 * image.
	 * 2. Some old 700 machines report a wrong device class in 
	 * PAGE0->mem_boot.pz_class when net booting. (PCL_RANDOM instead 
	 * PCL_NET_MASK|PCL_SEQU) So the bootloader thinks it is booting 
	 * from disk when it is actually net booting. The net boot LIF image 
	 * contains no disklabel so the test for the disklabel will fail. 
	 * If the device open fails if there is no disklabel we are not able
	 * to netboot those machines. 
	 * Therefore the error is ignored. The bootloader will fall back to 
	 * LIF later when there is no disklabel / FFS partition.
	 * At the moment it doesn't matter that the wrong device type ("dk"
	 * instead "lf") is used, as all I/O is abstracted by the firmware.
	 * To get the correct device type it would be necessary to add a 
	 * quirk table to the switch() in dev_hppa.c:devboot().
	 */
	} else {
		i = B_PARTITION(dp->bootdev);
#ifdef DEBUG
		if (debug)
			printf("bootdev 0x%x, partition %u\n", dp->bootdev, i);
#endif
		if (i >= dkl.d_npartitions || !dkl.d_partitions[i].p_size) {
			return (EPART);
		}
		dp->part_off = dkl.d_partitions[i].p_offset * dkl.d_secsize;
	}
#ifdef DEBUGBUG
	if (debug)
		printf ("dkopen() ret\n");
#endif
	return (0);
}