int open(const char *path, int flags) { const char *filepath; BVRef bvr; // Resolve the boot volume from the file spec. if ((bvr = getBootVolumeRef(path, &filepath)) != NULL) { return open_bvr(bvr, filepath, flags); } return -1; }
int open_bvdev(const char *bvd, const char *path, int flags) { const struct devsw *dp; const char *cp; BVRef bvr; int i; int len; int unit; int partition; if ((i = open(path, flags)) >= 0) { return i; } if (bvd == NULL || (len = strlen(bvd)) < 2) { return -1; } for (dp=devsw; dp->name; dp++) { if (bvd[0] == dp->name[0] && bvd[1] == dp->name[1]) { unit = 0; partition = 0; /* get optional unit and partition */ if (len >= 5 && bvd[2] == '(') { /* min must be present xx(0) */ cp = &bvd[3]; i = 0; while ((cp - path) < len && isdigit(*cp)) { i = i * 10 + *cp++ - '0'; unit = i; } if (*cp++ == ',') { i = 0; while ((cp - path) < len && isdigit(*cp)) { i = i * 10 + *cp++ - '0'; partition = i; } } } // turbo - bt(0,0) hook if ((dp->biosdev + unit) == 0x101) { // zef - use the ramdisk if available and the alias is active. if (gRAMDiskVolume != NULL && gRAMDiskBTAliased) { bvr = gRAMDiskVolume; } else { bvr = gBIOSBootVolume; } } else { bvr = newBootVolumeRef(dp->biosdev + unit, partition); } return open_bvr(bvr, path, flags); } } return -1; }
int open_bvdev(const char *bvd, const char *path, int flags) { const struct devsw *dp; const char *cp; BVRef bvr; int i; int len; int unit; int partition; if ((i = open(path, flags)) >= 0) { return i; } if (bvd == NULL || (len = strlen(bvd)) < 2) { return -1; } for (dp=devsw; dp->name; dp++) { if (bvd[0] == dp->name[0] && bvd[1] == dp->name[1]) { unit = 0; partition = 0; /* get optional unit and partition */ if (len >= 5 && bvd[2] == '(') { /* min must be present xx(0) */ cp = &bvd[3]; i = 0; while ((cp - path) < len && isdigit(*cp)) { i = i * 10 + *cp++ - '0'; unit = i; } if (*cp++ == ',') { i = 0; while ((cp - path) < len && isdigit(*cp)) { i = i * 10 + *cp++ - '0'; partition = i; } } } bvr = newBootVolumeRef(dp->biosdev + unit, partition); return open_bvr(bvr, path, flags); } } return -1; }