-/* $OpenBSD: disksubr.c,v 1.100 2017/02/28 10:49:37 natano Exp $ */
+/* $OpenBSD: disksubr.c,v 1.101 2022/10/11 23:39:07 krw Exp $ */
/* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */
/*
if (error)
goto done;
- error = checkdisklabel(bp->b_data + LABELOFFSET, lp, 0,
+ error = checkdisklabel(bp->b_dev, bp->b_data + LABELOFFSET, lp, 0,
DL_GETDSIZE(lp));
if (error == 0)
goto done;
-/* $OpenBSD: disksubr.c,v 1.90 2022/09/01 13:45:26 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.91 2022/10/11 23:39:07 krw Exp $ */
/*
* Copyright (c) 1999 Michael Shalayeff
if (error)
goto done;
- error = checkdisklabel(bp->b_data, lp, openbsdstart, DL_GETDSIZE(lp));
+ error = checkdisklabel(bp->b_dev, bp->b_data, lp, openbsdstart,
+ DL_GETDSIZE(lp));
done:
return (error);
-/* $OpenBSD: disksubr.c,v 1.60 2022/09/01 13:45:26 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.61 2022/10/11 23:39:07 krw Exp $ */
/* $NetBSD: disksubr.c,v 1.12 2002/02/19 17:09:44 wiz Exp $ */
/*
#error "Default value of LABELSECTOR no longer zero?"
#endif
-int disklabel_om_to_bsd(struct sun_disklabel *, struct disklabel *);
+int disklabel_om_to_bsd(dev_t, struct sun_disklabel *, struct disklabel *);
int disklabel_bsd_to_om(struct disklabel *, struct sun_disklabel *);
static __inline u_int sun_extended_sum(struct sun_disklabel *, void *);
slp = (struct sun_disklabel *)bp->b_data;
if (slp->sl_magic == SUN_DKMAGIC) {
- error = disklabel_om_to_bsd(slp, lp);
+ error = disklabel_om_to_bsd(bp->b_dev, slp, lp);
goto done;
}
- error = checkdisklabel(bp->b_data + LABELOFFSET, lp, 0,
+ error = checkdisklabel(bp->b_dev, bp->b_data + LABELOFFSET, lp, 0,
DL_GETDSIZE(lp));
if (error == 0)
goto done;
* The BSD label is cleared out before this is called.
*/
int
-disklabel_om_to_bsd(struct sun_disklabel *sl, struct disklabel *lp)
+disklabel_om_to_bsd(dev_t dev, struct sun_disklabel *sl, struct disklabel *lp)
{
struct partition *npp;
struct sun_dkpart *spp;
lp->d_checksum = 0;
lp->d_checksum = dkcksum(lp);
- return (checkdisklabel(lp, lp, 0, DL_GETDSIZE(lp)));
+ return (checkdisklabel(dev, lp, lp, 0, DL_GETDSIZE(lp)));
}
/*
-/* $OpenBSD: disksubr.c,v 1.82 2017/02/28 10:49:37 natano Exp $ */
+/* $OpenBSD: disksubr.c,v 1.83 2022/10/11 23:39:08 krw Exp $ */
/* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */
/*
if (error)
return (error);
- error = checkdisklabel(bp->b_data + LABELOFFSET, lp, hfspartoff,
- hfspartend);
+ error = checkdisklabel(bp->b_dev, bp->b_data + LABELOFFSET, lp,
+ hfspartoff, hfspartend);
return (error);
}
-/* $OpenBSD: disksubr.c,v 1.73 2022/09/01 13:45:26 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.74 2022/10/11 23:39:08 krw Exp $ */
/* $NetBSD: disksubr.c,v 1.13 2000/12/17 22:39:18 pk Exp $ */
/*
#include "cd.h"
-static int disklabel_sun_to_bsd(struct sun_disklabel *, struct disklabel *);
+static int disklabel_sun_to_bsd(dev_t dev, struct sun_disklabel *,
+ struct disklabel *);
static int disklabel_bsd_to_sun(struct disklabel *, struct sun_disklabel *);
static __inline u_int sun_extended_sum(struct sun_disklabel *, void *);
slp = (struct sun_disklabel *)bp->b_data;
if (slp->sl_magic == SUN_DKMAGIC) {
- error = disklabel_sun_to_bsd(slp, lp);
+ error = disklabel_sun_to_bsd(bp->b_dev, slp, lp);
goto done;
}
- error = checkdisklabel(bp->b_data + LABELOFFSET, lp, 0, DL_GETDSIZE(lp));
+ error = checkdisklabel(bp->b_dev, bp->b_data + LABELOFFSET, lp, 0,
+ DL_GETDSIZE(lp));
if (error == 0)
goto done;
* The BSD label is cleared out before this is called.
*/
static int
-disklabel_sun_to_bsd(struct sun_disklabel *sl, struct disklabel *lp)
+disklabel_sun_to_bsd(dev_t dev, struct sun_disklabel *sl, struct disklabel *lp)
{
struct sun_preamble *preamble = (struct sun_preamble *)sl;
struct sun_partinfo *ppp;
lp->d_checksum = 0;
lp->d_checksum = dkcksum(lp);
- return (checkdisklabel(lp, lp, 0, DL_GETDSIZE(lp)));
+ return (checkdisklabel(dev, lp, lp, 0, DL_GETDSIZE(lp)));
}
/*
-/* $OpenBSD: subr_disk.c,v 1.264 2022/09/23 12:32:50 krw Exp $ */
+/* $OpenBSD: subr_disk.c,v 1.265 2022/10/11 23:39:08 krw Exp $ */
/* $NetBSD: subr_disk.c,v 1.17 1996/03/16 23:17:08 christos Exp $ */
/*
* a newer version if needed, etc etc.
*/
int
-checkdisklabel(void *rlp, struct disklabel *lp, u_int64_t boundstart,
+checkdisklabel(dev_t dev, void *rlp, struct disklabel *lp, u_int64_t boundstart,
u_int64_t boundend)
{
struct disklabel *dlp = rlp;
struct __partitionv0 *v0pp;
struct partition *pp;
+ const char *blkname;
u_int64_t disksize;
int error = 0;
int i;
*lp = *dlp;
if (lp->d_version == 0) {
+ blkname = findblkname(major(dev));
+ if (blkname == NULL)
+ blkname = findblkname(major(chrtoblk(dev)));
+ printf("%s%d has legacy label, please rewrite using "
+ "disklabel(8)\n", blkname, DISKUNIT(dev));
+
lp->d_version = 1;
lp->d_secperunith = 0;
}
rlp = (struct disklabel *)(bp->b_data + DL_BLKOFFSET(lp, partoff));
- error = checkdisklabel(rlp, lp, DL_GETBSTART(rlp), DL_GETBEND(rlp));
+ error = checkdisklabel(bp->b_dev, rlp, lp, DL_GETBSTART(rlp),
+ DL_GETBEND(rlp));
DPRINTF("readdoslabel return: %s, %d, checkdisklabel() of daddr_t "
"%lld %s\n", devname, error, partoff, error ? "failed" : "ok");
-/* $OpenBSD: disklabel.h,v 1.83 2022/10/07 19:34:40 krw Exp $ */
+/* $OpenBSD: disklabel.h,v 1.84 2022/10/11 23:39:08 krw Exp $ */
/* $NetBSD: disklabel.h,v 1.41 1996/05/10 23:07:37 mark Exp $ */
/*
void diskerr(struct buf *, char *, char *, int, int, struct disklabel *);
u_int dkcksum(struct disklabel *);
int initdisklabel(struct disklabel *);
-int checkdisklabel(void *, struct disklabel *, u_int64_t, u_int64_t);
+int checkdisklabel(dev_t, void *, struct disklabel *, u_int64_t, u_int64_t);
int setdisklabel(struct disklabel *, struct disklabel *, u_int);
int readdisklabel(dev_t, void (*)(struct buf *), struct disklabel *, int);
int writedisklabel(dev_t, void (*)(struct buf *), struct disklabel *);