From 3888db5b76ec0c80dae00e944842b3cef9d743f5 Mon Sep 17 00:00:00 2001 From: Michael Shalayeff Date: Tue, 29 Sep 1998 07:31:00 +0000 Subject: sync; fixes; cleanup get rid of those obscuring commands use device finger/mapper, thus rewrite devopen --- sys/arch/hppa/stand/libsa/dev_hppa.c | 62 ++++++++++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 14 deletions(-) (limited to 'sys/arch/hppa/stand/libsa/dev_hppa.c') diff --git a/sys/arch/hppa/stand/libsa/dev_hppa.c b/sys/arch/hppa/stand/libsa/dev_hppa.c index 8f7583bb257..faee0acd16b 100644 --- a/sys/arch/hppa/stand/libsa/dev_hppa.c +++ b/sys/arch/hppa/stand/libsa/dev_hppa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dev_hppa.c,v 1.1 1998/06/23 18:46:42 mickey Exp $ */ +/* $OpenBSD: dev_hppa.c,v 1.2 1998/09/29 07:30:59 mickey Exp $ */ /* $NOWHERE: dev_hppa.c,v 2.1 1998/06/17 20:51:54 mickey Exp $ */ /* @@ -39,9 +39,9 @@ #include #include -#include "dev_hppa.h" +#include -struct pz_device ctdev; /* cartridge tape (boot) device path */ +#include "dev_hppa.h" extern int debug; @@ -56,11 +56,12 @@ const struct pdc_devs { int dev_type; } pdc_devs[] = { { "ct", 0 }, + { "sd", 1 }, + { "lf", 2 }, { "", -1 }, { "rd", -1 }, { "sw", -1 }, - { "fl", 1 }, - { "sd", 1 }, + { "fl", -1 }, }; /* pass dev_t to the open routines */ @@ -73,37 +74,70 @@ devopen(f, fname, file) register const struct pdc_devs *dp = pdc_devs; register int rc = 1; - *file = (char *)fname; + if (!(*file = strchr(fname, ':'))) + return ENODEV; + else + (*file)++; #ifdef DEBUG if (debug) - printf("devopen:"); + printf("devopen: "); #endif for (dp = pdc_devs; dp < &pdc_devs[NENTS(pdc_devs)]; dp++) - if (strncmp(fname, dp->name, sizeof(dp->name)-1)) + if (!strncmp(fname, dp->name, sizeof(dp->name)-1)) break; if (dp >= &pdc_devs[NENTS(pdc_devs)] || dp->dev_type < 0) return ENODEV; +#ifdef DEBUG + if (debug) + printf("%s\n", dp->name); +#endif if ((rc = (*devsw[dp->dev_type].dv_open)(f, file)) == 0) { f->f_dev = &devsw[dp->dev_type]; return 0; } - if ((f->f_flags & F_NODEV) == 0) + if (!(f->f_flags & F_NODEV)) f->f_dev = &devsw[dp->dev_type]; + if (!f->f_devdata) + *file = NULL; + return rc; } void -devboot(bootdev, p) - dev_t bootdev; +devboot(dev, p) + dev_t dev; char *p; { register const char *q; + if (!dev) { + int type, unit; + + switch (PAGE0->mem_boot.pz_class) { + case PCL_RANDOM: + type = 0; + unit = PAGE0->mem_boot.pz_layers[0]; + break; + case PCL_SEQU: + type = 1; + unit = PAGE0->mem_boot.pz_layers[0]; + break; + case PCL_NET_MASK|PCL_SEQU: + type = 2; + unit = 0; + break; + default: + type = 0; + unit = 0; + break; + } + dev = bootdev = MAKEBOOTDEV(type, 0, 0, unit, 0); + } #ifdef _TEST *p++ = '/'; *p++ = 'd'; @@ -113,9 +147,9 @@ devboot(bootdev, p) *p++ = 'r'; #endif /* quick copy device name */ - for (q = pdc_devs[B_TYPE(bootdev)].name; (*p++ = *q++);); - *p++ = '0' + B_UNIT(bootdev); - *p++ = 'a' + B_PARTITION(bootdev); + for (q = pdc_devs[B_TYPE(dev)].name; (*p++ = *q++);); + p[-1] = '0' + B_UNIT(dev); + *p++ = 'a' + B_PARTITION(dev); *p = '\0'; } -- cgit v1.2.3