diff options
author | grog <grog@FreeBSD.org> | 2000-08-16 04:31:37 +0000 |
---|---|---|
committer | grog <grog@FreeBSD.org> | 2000-08-16 04:31:37 +0000 |
commit | 5b09de97953ed09ac63da21661895834c1016cdd (patch) | |
tree | 338454e6a0c45fe834fa5374d377d4e539ca3e0f /sys/dev/vinum | |
parent | c4b3a3ad9214309fd9dc378a78cd3e5aedbbdf3f (diff) | |
download | FreeBSD-src-5b09de97953ed09ac63da21661895834c1016cdd.zip FreeBSD-src-5b09de97953ed09ac63da21661895834c1016cdd.tar.gz |
open_drive:
Add support for AMD RAID controllers as "disks".
Requested-by: Marius Bendiksen <mbendiks@eunet.no>
Remove potential panic when attempting to open non-existent drivers.
init_drive: Return error codes correctly. Previously it would
occasionally return 0. The error was redetected
elsewhere, but this was causing a number of confusing
error messages.
Diffstat (limited to 'sys/dev/vinum')
-rw-r--r-- | sys/dev/vinum/vinumio.c | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/sys/dev/vinum/vinumio.c b/sys/dev/vinum/vinumio.c index 95d717c..1b9ad98 100644 --- a/sys/dev/vinum/vinumio.c +++ b/sys/dev/vinum/vinumio.c @@ -55,6 +55,7 @@ open_drive(struct drive *drive, struct proc *p, int verbose) int devminor; /* minor devs for disk device */ int unit; char *dname; + struct cdevsw *dsw; /* pointer to cdevsw entry */ if (bcmp(drive->devicename, "/dev/", 5)) /* device name doesn't start with /dev */ return ENOENT; /* give up */ @@ -83,7 +84,10 @@ open_drive(struct drive *drive, struct proc *p, int verbose) devmajor = 43; else if (bcmp(dname, "md", 2) == 0) devmajor = 95; - else + else if (bcmp(dname, "amrd", 4) == 0) { + devmajor = 133; + dname += 2; + } else return ENODEV; dname += 2; /* point past */ @@ -121,7 +125,11 @@ open_drive(struct drive *drive, struct proc *p, int verbose) return ENODEV; drive->dev->si_iosize_max = DFLTPHYS; - drive->lasterror = (*devsw(drive->dev)->d_open) (drive->dev, FWRITE, 0, NULL); + dsw = devsw(drive->dev); + if (dsw == NULL) + drive->lasterror = ENOENT; + else + drive->lasterror = (dsw->d_open) (drive->dev, FWRITE, 0, NULL); if (drive->lasterror != 0) { /* failed */ drive->state = drive_down; /* just force it down */ @@ -190,31 +198,28 @@ set_drive_parms(struct drive *drive) int init_drive(struct drive *drive, int verbose) { - int error; - if (drive->devicename[0] != '/') { drive->lasterror = EINVAL; log(LOG_ERR, "vinum: Can't open drive without drive name\n"); return EINVAL; } - error = open_drive(drive, curproc, verbose); /* open the drive */ - if (error) - return error; + drive->lasterror = open_drive(drive, curproc, verbose); /* open the drive */ + if (drive->lasterror) + return drive->lasterror; - error = (*devsw(drive->dev)->d_ioctl) (drive->dev, + drive->lasterror = (*devsw(drive->dev)->d_ioctl) (drive->dev, DIOCGPART, (caddr_t) & drive->partinfo, FREAD, curproc); - if (error) { + if (drive->lasterror) { if (verbose) log(LOG_WARNING, - "vinum open_drive %s: Can't get partition information, error %d\n", + "vinum open_drive %s: Can't get partition information, drive->lasterror %d\n", drive->devicename, - error); + drive->lasterror); close_drive(drive); - drive->lasterror = error; - return error; + return drive->lasterror; } if (drive->partinfo.part->p_fstype != FS_VINUM) { /* not Vinum */ drive->lasterror = EFTYPE; @@ -357,16 +362,16 @@ read_drive_label(struct drive *drive, int verbose) vhdr = (struct vinum_hdr *) Malloc(VINUMHEADERLEN); /* allocate buffers */ CHECKALLOC(vhdr, "Can't allocate memory"); + drive->state = drive_up; /* be optimistic */ error = read_drive(drive, (void *) vhdr, VINUMHEADERLEN, VINUM_LABEL_OFFSET); if (vhdr->magic == VINUM_MAGIC) { /* ours! */ if (drive->label.name[0] /* we have a name for this drive */ &&(strcmp(drive->label.name, vhdr->label.name))) { /* but it doesn't match the real name */ drive->lasterror = EINVAL; result = DL_WRONG_DRIVE; /* it's the wrong drive */ - } else { - drive->state = drive_up; /* it's OK by us */ + drive->state = drive_unallocated; /* put it back, it's not ours */ + } else result = DL_OURS; - } /* * We copy the drive anyway so that we have * the correct name in the drive info. This |