Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/dkwedge GPTs are defined in terms of physical blocks.
details: https://anonhg.NetBSD.org/src/rev/a4e44d7fa8cd
branches: trunk
changeset: 751124:a4e44d7fa8cd
user: mlelstv <mlelstv%NetBSD.org@localhost>
date: Mon Jan 25 14:51:03 2010 +0000
description:
GPTs are defined in terms of physical blocks.
- Fix reading of GPT for devices with non-512byte sectors
- Fix bounds check to use DEV_BSIZE units.
diffstat:
sys/dev/dkwedge/dk.c | 12 ++++++++----
sys/dev/dkwedge/dkwedge_gpt.c | 18 ++++++++++--------
2 files changed, 18 insertions(+), 12 deletions(-)
diffs (111 lines):
diff -r 94b2809810b4 -r a4e44d7fa8cd sys/dev/dkwedge/dk.c
--- a/sys/dev/dkwedge/dk.c Mon Jan 25 13:45:16 2010 +0000
+++ b/sys/dev/dkwedge/dk.c Mon Jan 25 14:51:03 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dk.c,v 1.53 2010/01/23 18:31:04 bouyer Exp $ */
+/* $NetBSD: dk.c,v 1.54 2010/01/25 14:51:03 mlelstv Exp $ */
/*-
* Copyright (c) 2004, 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.53 2010/01/23 18:31:04 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.54 2010/01/25 14:51:03 mlelstv Exp $");
#ifdef _KERNEL_OPT
#include "opt_dkwedge.h"
@@ -1098,6 +1098,7 @@
dkstrategy(struct buf *bp)
{
struct dkwedge_softc *sc = dkwedge_lookup(bp->b_dev);
+ uint64_t p_size, p_offset;
int s;
if (sc->sc_state != DKW_STATE_RUNNING) {
@@ -1109,12 +1110,15 @@
if (bp->b_bcount == 0)
goto done;
+ p_offset = sc->sc_offset << sc->sc_parent->dk_blkshift;
+ p_size = sc->sc_size << sc->sc_parent->dk_blkshift;
+
/* Make sure it's in-range. */
- if (bounds_check_with_mediasize(bp, DEV_BSIZE, sc->sc_size) <= 0)
+ if (bounds_check_with_mediasize(bp, DEV_BSIZE, p_size) <= 0)
goto done;
/* Translate it to the parent's raw LBA. */
- bp->b_rawblkno = bp->b_blkno + sc->sc_offset;
+ bp->b_rawblkno = bp->b_blkno + p_offset;
/* Place it in the queue and start I/O on the unit. */
s = splbio();
diff -r 94b2809810b4 -r a4e44d7fa8cd sys/dev/dkwedge/dkwedge_gpt.c
--- a/sys/dev/dkwedge/dkwedge_gpt.c Mon Jan 25 13:45:16 2010 +0000
+++ b/sys/dev/dkwedge/dkwedge_gpt.c Mon Jan 25 14:51:03 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dkwedge_gpt.c,v 1.10 2008/10/23 19:37:40 jakllsch Exp $ */
+/* $NetBSD: dkwedge_gpt.c,v 1.11 2010/01/25 14:51:03 mlelstv Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dkwedge_gpt.c,v 1.10 2008/10/23 19:37:40 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dkwedge_gpt.c,v 1.11 2010/01/25 14:51:03 mlelstv Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -130,6 +130,7 @@
static const char gpt_hdr_sig[] = GPT_HDR_SIG;
struct dkwedge_info dkw;
void *buf;
+ uint32_t secsize;
struct gpt_hdr *hdr;
struct gpt_ent *ent;
uint32_t entries, entsz;
@@ -138,7 +139,8 @@
int error;
u_int i;
- buf = malloc(DEV_BSIZE, M_DEVBUF, M_WAITOK);
+ secsize = DEV_BSIZE << pdk->dk_blkshift;
+ buf = malloc(secsize, M_DEVBUF, M_WAITOK);
/*
* Note: We don't bother with a Legacy or Protective MBR
@@ -147,7 +149,7 @@
*/
/* Read in the GPT Header. */
- error = dkwedge_read(pdk, vp, GPT_HDR_BLKNO, buf, DEV_BSIZE);
+ error = dkwedge_read(pdk, vp, GPT_HDR_BLKNO << pdk->dk_blkshift, buf, secsize);
if (error)
goto out;
hdr = buf;
@@ -163,7 +165,7 @@
error = ESRCH;
goto out;
}
- if (le32toh(hdr->hdr_size) > DEV_BSIZE) {
+ if (le32toh(hdr->hdr_size) > secsize) {
/* XXX Should check at end-of-disk. */
error = ESRCH;
goto out;
@@ -212,9 +214,9 @@
}
free(buf, M_DEVBUF);
- buf = malloc(roundup(entries * entsz, DEV_BSIZE), M_DEVBUF, M_WAITOK);
- error = dkwedge_read(pdk, vp, lba_table, buf,
- roundup(entries * entsz, DEV_BSIZE));
+ buf = malloc(roundup(entries * entsz, secsize), M_DEVBUF, M_WAITOK);
+ error = dkwedge_read(pdk, vp, lba_table << pdk->dk_blkshift, buf,
+ roundup(entries * entsz, secsize));
if (error) {
/* XXX Should check alternate location. */
aprint_error("%s: unable to read GPT partition array, "
Home |
Main Index |
Thread Index |
Old Index