diff options
Diffstat (limited to 'sys/kern/subr_diskslice.c')
-rw-r--r-- | sys/kern/subr_diskslice.c | 22 |
1 files changed, 21 insertions, 1 deletions
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) |