int netopen(struct open_file *f, ...) { char *path; long fd; int rc; va_list ap; va_start(ap, f); path = va_arg(ap, char *); va_end(ap); /* to match netfs.c filename buffers... */ if (strlen(path) > 128 - 1) return ENAMETOOLONG; rc = Bios_Open(path, 0, &fd); if (rc != 0) { switch (rc) { case arc_EACCES: return EACCES; case arc_EISDIR: return EISDIR; case arc_ENOENT: return ENOENT; default: return ENXIO; } } f->f_devdata = (void *)fd; return 0; }
int dioopen(struct open_file *f, ...) { char *ctlr; int partition; struct dio_softc *sc; struct disklabel *lp; int i, fd; char *msg = NULL; char buf[DEV_BSIZE]; int cnt; daddr_t labelsector; va_list ap; va_start(ap, f); ctlr = va_arg(ap, char *); partition = va_arg(ap, int); if (partition >= MAXPARTITIONS) return (ENXIO); if (Bios_Open(ctlr, 0, &fd) < 0) return (ENXIO); sc = alloc(sizeof(struct dio_softc)); bzero(sc, sizeof(struct dio_softc)); f->f_devdata = (void *)sc; sc->sc_fd = fd; sc->sc_part = partition; lp = &sc->sc_label; lp->d_secsize = DEV_BSIZE; lp->d_secpercyl = 1; lp->d_npartitions = MAXPARTITIONS; lp->d_partitions[partition].p_offset = 0; lp->d_partitions[0].p_size = 0x7fff0000; labelsector = LABELSECTOR; #if 0 /* try to read disk label and partition table information */ i = diostrategy(sc, F_READ, (daddr_t)labelsector, DEV_BSIZE, buf, &cnt); if (i == 0 && cnt == DEV_BSIZE) msg = getdisklabel(buf, lp); else msg = "rd err"; if (msg) { printf("%s: %s\n", ctlr, msg); return ENXIO; } #endif return 0; }