diff options
author | phk <phk@FreeBSD.org> | 2002-09-27 21:19:47 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2002-09-27 21:19:47 +0000 |
commit | 891aee9210e2346ce041cc4b765cf88a923d7c2f (patch) | |
tree | b64beaa7560b5a80ee84f92ca0bd6ed31f74dbe0 /sys | |
parent | 3a17cc7881e25a35f83573bd5088037483956909 (diff) | |
download | FreeBSD-src-891aee9210e2346ce041cc4b765cf88a923d7c2f.zip FreeBSD-src-891aee9210e2346ce041cc4b765cf88a923d7c2f.tar.gz |
Correctly en/decode MAXPARTITIONS partitions.
Sponsored by: DARPA & NAI Labs.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/geom/geom_bsd.c | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/sys/geom/geom_bsd.c b/sys/geom/geom_bsd.c index 61eaaf3..6155d42 100644 --- a/sys/geom/geom_bsd.c +++ b/sys/geom/geom_bsd.c @@ -80,6 +80,8 @@ g_bsd_ledec_partition(u_char *ptr, struct partition *d) static void g_bsd_ledec_disklabel(u_char *ptr, struct disklabel *d) { + int i; + d->d_magic = g_dec_le4(ptr + 0); d->d_type = g_dec_le2(ptr + 4); d->d_subtype = g_dec_le2(ptr + 6); @@ -116,14 +118,8 @@ g_bsd_ledec_disklabel(u_char *ptr, struct disklabel *d) d->d_npartitions = g_dec_le2(ptr + 138); d->d_bbsize = g_dec_le4(ptr + 140); d->d_sbsize = g_dec_le4(ptr + 144); - g_bsd_ledec_partition(ptr + 148, &d->d_partitions[0]); - g_bsd_ledec_partition(ptr + 164, &d->d_partitions[1]); - g_bsd_ledec_partition(ptr + 180, &d->d_partitions[2]); - g_bsd_ledec_partition(ptr + 196, &d->d_partitions[3]); - g_bsd_ledec_partition(ptr + 212, &d->d_partitions[4]); - g_bsd_ledec_partition(ptr + 228, &d->d_partitions[5]); - g_bsd_ledec_partition(ptr + 244, &d->d_partitions[6]); - g_bsd_ledec_partition(ptr + 260, &d->d_partitions[7]); + for (i = 0; i < MAXPARTITIONS; i++) + g_bsd_ledec_partition(ptr + 148 + 16 * i, &d->d_partitions[i]); } #if 0 @@ -141,6 +137,8 @@ g_bsd_leenc_partition(u_char *ptr, struct partition *d) static void g_bsd_leenc_disklabel(u_char *ptr, struct disklabel *d) { + int i; + g_enc_le4(ptr + 0, d->d_magic); g_enc_le2(ptr + 4, d->d_type); g_enc_le2(ptr + 6, d->d_subtype); @@ -177,14 +175,8 @@ g_bsd_leenc_disklabel(u_char *ptr, struct disklabel *d) g_enc_le2(ptr + 138, d->d_npartitions); g_enc_le4(ptr + 140, d->d_bbsize); g_enc_le4(ptr + 144, d->d_sbsize); - g_bsd_leenc_partition(ptr + 148, &d->d_partitions[0]); - g_bsd_leenc_partition(ptr + 164, &d->d_partitions[1]); - g_bsd_leenc_partition(ptr + 180, &d->d_partitions[2]); - g_bsd_leenc_partition(ptr + 196, &d->d_partitions[3]); - g_bsd_leenc_partition(ptr + 212, &d->d_partitions[4]); - g_bsd_leenc_partition(ptr + 228, &d->d_partitions[5]); - g_bsd_leenc_partition(ptr + 244, &d->d_partitions[6]); - g_bsd_leenc_partition(ptr + 260, &d->d_partitions[7]); + for (i = 0; i < MAXPARTITIONS; i++) + g_bsd_leenc_partition(ptr + 148 + 16 * i, &d->d_partitions[i]); } #endif |