summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorMarco Peereboom <marco@cvs.openbsd.org>2007-04-22 00:06:10 +0000
committerMarco Peereboom <marco@cvs.openbsd.org>2007-04-22 00:06:10 +0000
commitb49961d0675dc1723df18f2d1b4d119acb1db94f (patch)
treec1ae87f0f5987c69f747921d977dc14f593cc4af /sys/dev
parentb932e5c7a607e76f9eed8c71fc3db6fddf88e10c (diff)
Skip past SBLOCK_UFS1 to make sure that metadata does not destroy anything
filesystem related. pointed out by deraadt
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/softraid.c15
-rw-r--r--sys/dev/softraidvar.h4
2 files changed, 11 insertions, 8 deletions
diff --git a/sys/dev/softraid.c b/sys/dev/softraid.c
index 501fe5a1670..a7f59492ea4 100644
--- a/sys/dev/softraid.c
+++ b/sys/dev/softraid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid.c,v 1.29 2007/04/21 23:50:47 marco Exp $ */
+/* $OpenBSD: softraid.c,v 1.30 2007/04/22 00:06:09 marco Exp $ */
/*
* Copyright (c) 2007 Marco Peereboom <marco@peereboom.us>
*
@@ -1003,7 +1003,8 @@ sr_parse_chunks(struct sr_softc *sc, char *lst, struct sr_chunk_head *cl)
/* get partition size */
ss = name[strlen(name) - 1];
ch_entry->src_meta.scm_size =
- label.d_partitions[ss - 'a'].p_size - SR_META_SIZE;
+ label.d_partitions[ss - 'a'].p_size - SR_META_SIZE -
+ SR_FFS_SKIP;
if (ch_entry->src_meta.scm_size <= 0) {
printf("%s: %s partition size = 0\n",
DEVNAME(sc), name);
@@ -1082,8 +1083,8 @@ sr_raid1_alloc_resources(struct sr_discipline *sd)
sr_alloc_ccb(sd);
/* -2 because that includes mbr and partition table */
- sd->sd_meta = malloc((SR_META_SIZE - 2) * 512 , M_DEVBUF, M_WAITOK);
- bzero(sd->sd_meta, (SR_META_SIZE - 2) * 512);
+ sd->sd_meta = malloc(SR_META_SIZE * 512 , M_DEVBUF, M_WAITOK);
+ bzero(sd->sd_meta, SR_META_SIZE * 512);
rv = 0;
return (rv);
@@ -1304,7 +1305,7 @@ sr_raid1_rw(struct sr_workunit *wu)
else
ios = sd->sd_vol.sv_meta.svm_no_chunk;
- blk += SR_META_SIZE;
+ blk += SR_META_SIZE + SR_FFS_SKIP;
wu->swu_blk_start = blk;
wu->swu_blk_end = blk + xs->datalen - 1;
@@ -1776,7 +1777,7 @@ sr_save_metadata(struct sr_discipline *sd)
struct sr_chunk *src;
struct buf b;
int i, rv = 1;
- size_t sz = (SR_META_SIZE - 2) * 512;
+ size_t sz = SR_META_SIZE * 512;
DNPRINTF(SR_D_META, "%s: sr_save_metadata %s\n",
DEVNAME(sc), sd->sd_vol.sv_meta.svm_devname);
@@ -1852,7 +1853,7 @@ sr_save_metadata(struct sr_discipline *sd)
continue;
b.b_flags = B_WRITE;
- b.b_blkno = 2; /* skip past mbr and partition table */
+ b.b_blkno = SR_FFS_SKIP; /* skip past mbr and partition table */
b.b_bcount = sz;
b.b_bufsize = sz;
b.b_resid = sz;
diff --git a/sys/dev/softraidvar.h b/sys/dev/softraidvar.h
index 7e2e626c189..9805c666b5a 100644
--- a/sys/dev/softraidvar.h
+++ b/sys/dev/softraidvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraidvar.h,v 1.11 2007/04/21 23:39:18 marco Exp $ */
+/* $OpenBSD: softraidvar.h,v 1.12 2007/04/22 00:06:09 marco Exp $ */
/*
* Copyright (c) 2006 Marco Peereboom <sro@peereboom.us>
*
@@ -20,6 +20,7 @@
#include <sys/buf.h>
#include <sys/queue.h>
#include <sys/rwlock.h>
+#include <ufs/ffs/fs.h>
#include <scsi/scsi_all.h>
#include <scsi/scsi_disk.h>
@@ -114,6 +115,7 @@ struct sr_workunit {
TAILQ_HEAD(sr_wu_list, sr_workunit);
#define SR_META_SIZE 32 /* save space at chunk beginning */
+#define SR_FFS_SKIP (SBLOCK_UFS1 >> 9)
#define SR_META_VERSION 2 /* bump when sr_metadata changes */
struct sr_metadata {
/* do not change order of ssd_magic, ssd_version */