diff options
| author | Kenneth D. Merry <ken@FreeBSD.org> | 2000-10-30 07:03:00 +0000 |
|---|---|---|
| committer | Kenneth D. Merry <ken@FreeBSD.org> | 2000-10-30 07:03:00 +0000 |
| commit | 2906da29dc6c172a8a117b55053c829959fbe960 (patch) | |
| tree | 05b1cb99bf53256cd501ee53ce53dba764bc5a1a /sys/kern/subr_diskslice.c | |
| parent | f3b7b7b4ae9a2e05097f6b726de350abbf6025a9 (diff) | |
Notes
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 25a88be6c112..c4ecdc54e271 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) |
