summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/cam/scsi/scsi_cd.c6
-rw-r--r--sys/kern/subr_diskslice.c22
-rw-r--r--sys/sys/diskslice.h1
3 files changed, 26 insertions, 3 deletions
diff --git a/sys/cam/scsi/scsi_cd.c b/sys/cam/scsi/scsi_cd.c
index a972e84..8025560 100644
--- a/sys/cam/scsi/scsi_cd.c
+++ b/sys/cam/scsi/scsi_cd.c
@@ -254,7 +254,7 @@ static struct cdevsw cd_cdevsw = {
/* open */ cdopen,
/* close */ cdclose,
/* read */ physread,
- /* write */ nowrite,
+ /* write */ physwrite,
/* ioctl */ cdioctl,
/* poll */ nopoll,
/* mmap */ nommap,
@@ -628,7 +628,7 @@ cdregister(struct cam_periph *periph, void *arg)
DEVSTAT_TYPE_CDROM | DEVSTAT_TYPE_IF_SCSI,
DEVSTAT_PRIORITY_CD);
disk_create(periph->unit_number, &softc->disk,
- DSO_NOLABELS | DSO_ONESLICE,
+ DSO_ONESLICE | DSO_COMPATLABEL,
&cd_cdevsw, &cddisk_cdevsw);
/*
@@ -727,6 +727,7 @@ cdregister(struct cam_periph *periph, void *arg)
STAILQ_INSERT_TAIL(&nchanger->chluns,
nsoftc,changer_links);
}
+ xpt_free_path(path);
} else if (status == CAM_REQ_CMP)
xpt_free_path(path);
else {
@@ -833,6 +834,7 @@ cdregister(struct cam_periph *periph, void *arg)
STAILQ_INSERT_TAIL(&nchanger->chluns,
nsoftc, changer_links);
+ xpt_free_path(path);
} else if (status == CAM_REQ_CMP)
xpt_free_path(path);
else {
diff --git a/sys/kern/subr_diskslice.c b/sys/kern/subr_diskslice.c
index 25a88be..c4ecdc5 100644
--- a/sys/kern/subr_diskslice.c
+++ b/sys/kern/subr_diskslice.c
@@ -706,8 +706,28 @@ dsopen(dev, mode, flags, sspp, lp)
TRACE(("readdisklabel\n"));
if (flags & DSO_NOLABELS)
msg = NULL;
- else
+ else {
msg = readdisklabel(dev1, lp1);
+
+ /*
+ * readdisklabel() returns NULL for success, and an
+ * error string for failure.
+ *
+ * If there isn't a label on the disk, and if the
+ * DSO_COMPATLABEL is set, we want to use the
+ * faked-up label provided by the caller.
+ *
+ * So we set msg to NULL to indicate that there is
+ * no failure (since we have a faked-up label),
+ * free lp1, and then clone it again from lp.
+ * (In case readdisklabel() modified lp1.)
+ */
+ if (msg != NULL && (flags & DSO_COMPATLABEL)) {
+ msg = NULL;
+ free(lp1, M_DEVBUF);
+ lp1 = clone_label(lp);
+ }
+ }
if (msg == NULL)
msg = fixlabel(sname, sp, lp1, FALSE);
if (msg == NULL && lp1->d_secsize != ssp->dss_secsize)
diff --git a/sys/sys/diskslice.h b/sys/sys/diskslice.h
index f4289ce..c2dcb4c 100644
--- a/sys/sys/diskslice.h
+++ b/sys/sys/diskslice.h
@@ -71,6 +71,7 @@ struct diskslices {
/* Flags for dsopen(). */
#define DSO_NOLABELS 1
#define DSO_ONESLICE 2
+#define DSO_COMPATLABEL 4
#define dsgetlabel(dev, ssp) (ssp->dss_slices[dkslice(dev)].ds_label)
OpenPOWER on IntegriCloud