summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2016-01-15 16:39:21 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2016-01-15 16:39:21 +0000
commitf88347846e7a8f9ba5ff8c37ce15575d9f4fff08 (patch)
tree7593ca87ed0ccd0e2873a6c357c6cfc3cad3f3a9 /sbin
parentabd48148ace0480aeaa124b3e057cb90f230040c (diff)
Replace bitfield_get() and bitfield_set() abstraction with simple masking
operations since all the uses but 1 are for 1 bit fields. No functional change intended. Unhook bitfield.c from build.
Diffstat (limited to 'sbin')
-rw-r--r--sbin/pdisk/Makefile4
-rw-r--r--sbin/pdisk/dpme.h55
-rw-r--r--sbin/pdisk/dump.c70
-rw-r--r--sbin/pdisk/partition_map.c26
4 files changed, 64 insertions, 91 deletions
diff --git a/sbin/pdisk/Makefile b/sbin/pdisk/Makefile
index e6c91c2e463..8fa9556998a 100644
--- a/sbin/pdisk/Makefile
+++ b/sbin/pdisk/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.16 2016/01/14 04:17:40 krw Exp $
+# $Id: Makefile,v 1.17 2016/01/15 16:39:20 krw Exp $
.if ${MACHINE} == "macppc"
PROG= pdisk
@@ -6,7 +6,7 @@ LDADD= -lutil
DPADD= ${LIBUTIL}
CFLAGS+=-Wall
-SRCS= bitfield.c convert.c deblock_media.c dump.c \
+SRCS= convert.c deblock_media.c dump.c \
file_media.c io.c media.c partition_map.c \
pdisk.c validate.c
diff --git a/sbin/pdisk/dpme.h b/sbin/pdisk/dpme.h
index 456c51a2a97..c8a9889b60f 100644
--- a/sbin/pdisk/dpme.h
+++ b/sbin/pdisk/dpme.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dpme.h,v 1.5 2016/01/11 17:55:45 jasper Exp $ */
+/* $OpenBSD: dpme.h,v 1.6 2016/01/15 16:39:20 krw Exp $ */
//
// dpme.h - Disk Partition Map Entry (dpme)
@@ -42,8 +42,6 @@
#ifndef __dpme__
#define __dpme__
-#include "bitfield.h"
-
//
// Defines
//
@@ -102,7 +100,18 @@ struct dpme {
char dpme_type[DPISTRLEN] ; /* type of partition */
u32 dpme_lblock_start ;
u32 dpme_lblocks ;
- u32 dpme_flags;
+ u32 dpme_flags ;
+#define DPME_DISKDRIVER (1<<9)
+#define DPME_CHAINABLE (1<<8)
+#define DPME_OS_SPECIFIC_1 (1<<8)
+#define DPME_OS_SPECIFIC_2 (1<<7)
+#define DPME_OS_PIC_CODE (1<<6)
+#define DPME_WRITABLE (1<<5)
+#define DPME_READABLE (1<<4)
+#define DPME_BOOTABLE (1<<3)
+#define DPME_IN_USE (1<<2)
+#define DPME_ALLOCATED (1<<1)
+#define DPME_VALID (1<<0)
u32 dpme_boot_block ;
u32 dpme_boot_bytes ;
u8 *dpme_load_addr ;
@@ -116,31 +125,6 @@ struct dpme {
};
typedef struct dpme DPME;
-#define dpme_diskdriver_set(p, v) bitfield_set(&p->dpme_flags, 9, 1, v)
-#define dpme_chainable_set(p, v) bitfield_set(&p->dpme_flags, 8, 1, v)
-
-#define dpme_os_specific_1_set(p, v) bitfield_set(&p->dpme_flags, 8, 1, v)
-#define dpme_os_specific_2_set(p, v) bitfield_set(&p->dpme_flags, 7, 1, v)
-#define dpme_os_pic_code_set(p, v) bitfield_set(&p->dpme_flags, 6, 1, v)
-#define dpme_writable_set(p, v) bitfield_set(&p->dpme_flags, 5, 1, v)
-#define dpme_readable_set(p, v) bitfield_set(&p->dpme_flags, 4, 1, v)
-#define dpme_bootable_set(p, v) bitfield_set(&p->dpme_flags, 3, 1, v)
-#define dpme_in_use_set(p, v) bitfield_set(&p->dpme_flags, 2, 1, v)
-#define dpme_allocated_set(p, v) bitfield_set(&p->dpme_flags, 1, 1, v)
-#define dpme_valid_set(p, v) bitfield_set(&p->dpme_flags, 0, 1, v)
-
-#define dpme_diskdriver_get(p) bitfield_get(p->dpme_flags, 9, 1)
-#define dpme_chainable_get(p) bitfield_get(p->dpme_flags, 8, 1)
-
-#define dpme_os_specific_1_get(p) bitfield_get(p->dpme_flags, 8, 1)
-#define dpme_os_specific_2_get(p) bitfield_get(p->dpme_flags, 7, 1)
-#define dpme_os_pic_code_get(p) bitfield_get(p->dpme_flags, 6, 1)
-#define dpme_writable_get(p) bitfield_get(p->dpme_flags, 5, 1)
-#define dpme_readable_get(p) bitfield_get(p->dpme_flags, 4, 1)
-#define dpme_bootable_get(p) bitfield_get(p->dpme_flags, 3, 1)
-#define dpme_in_use_get(p) bitfield_get(p->dpme_flags, 2, 1)
-#define dpme_allocated_get(p) bitfield_get(p->dpme_flags, 1, 1)
-#define dpme_valid_get(p) bitfield_get(p->dpme_flags, 0, 1)
// A/UX only data structures (sentimental reasons?)
@@ -155,6 +139,11 @@ struct bzb /* block zero block format */
u8 bzb_type; /* FS type */
u16 bzb_inode; /* bad block inode number */
u32 bzb_flags;
+#define BZB_ROOT (1<<31)
+#define BZB_USR (1<<30)
+#define BZB_CRIT (1<<29)
+#define BZB_SLICE_SHIFT 16
+#define BZB_SLICE_MASK 0x1f
u32 bzb_tmade; /* time of FS creation */
u32 bzb_tmount; /* time of last mount */
u32 bzb_tumount; /* time of last umount */
@@ -163,15 +152,7 @@ struct bzb /* block zero block format */
};
typedef struct bzb BZB;
-#define bzb_root_set(p, v) bitfield_set(&p->bzb_flags, 31, 1, v)
-#define bzb_usr_set(p, v) bitfield_set(&p->bzb_flags, 30, 1, v)
-#define bzb_crit_set(p, v) bitfield_set(&p->bzb_flags, 29, 1, v)
-#define bzb_slice_set(p, v) bitfield_set(&p->bzb_flags, 20, 5, v)
-#define bzb_root_get(p) bitfield_get(p->bzb_flags, 31, 1)
-#define bzb_usr_get(p) bitfield_get(p->bzb_flags, 30, 1)
-#define bzb_crit_get(p) bitfield_get(p->bzb_flags, 29, 1)
-#define bzb_slice_get(p) bitfield_get(p->bzb_flags, 20, 5)
//
diff --git a/sbin/pdisk/dump.c b/sbin/pdisk/dump.c
index 7c54083d196..12b6bbda00c 100644
--- a/sbin/pdisk/dump.c
+++ b/sbin/pdisk/dump.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dump.c,v 1.16 2016/01/14 04:02:05 krw Exp $ */
+/* $OpenBSD: dump.c,v 1.17 2016/01/15 16:39:20 krw Exp $ */
//
// dump.c - dumping partition maps
@@ -247,7 +247,7 @@ dump_partition_entry(partition_map *entry, int type_length, int name_length, int
const char *s;
u32 size;
double bytes;
- int driver;
+ int driver, slice;
// int kind;
char *buf;
#if 1
@@ -312,14 +312,14 @@ dump_partition_entry(partition_map *entry, int type_length, int name_length, int
break;
case FST:
default:
- if (bzb_root_get(bp) != 0) {
- if (bzb_usr_get(bp) != 0) {
+ if ((bp->bzb_flags & BZB_ROOT) != 0) {
+ if ((bp->bzb_flags & BZB_USR) != 0) {
s = "RUFS";
} else {
s = "RFS";
}
j = 0;
- } else if (bzb_usr_get(bp) != 0) {
+ } else if ((bp->bzb_flags & BZB_USR) != 0) {
s = "UFS";
j = 2;
} else {
@@ -327,14 +327,15 @@ dump_partition_entry(partition_map *entry, int type_length, int name_length, int
}
break;
}
- if (bzb_slice_get(bp) != 0) {
- printf(" s%1ld %4s", bzb_slice_get(bp)-1, s);
+ slice = ((bp->bzb_flags >> BZB_SLICE_SHIFT) & BZB_SLICE_MASK);
+ if (slice != 0) {
+ printf(" s%1d %4s", slice - 1, s);
} else if (j >= 0) {
printf(" S%1d %4s", j, s);
} else {
printf(" %4s", s);
}
- if (bzb_crit_get(bp) != 0) {
+ if ((bp->bzb_flags & BZB_CRIT) != 0) {
printf(" K%1d", bp->bzb_cluster);
} else if (j < 0) {
printf(" ");
@@ -356,7 +357,7 @@ show_data_structures(partition_map_header *map)
Block0 *zp;
DDMap *m;
int i;
- int j;
+ int j, slice;
partition_map * entry;
DPME *p;
BZB *bp;
@@ -418,18 +419,18 @@ u32 dpme_reserved_3[62] ;
entry->disk_address, p->dpme_type);
printf("%7lu @ %-7lu ", p->dpme_pblocks, p->dpme_pblock_start);
printf("%c%c%c%c%c%c%c%c%c%c%c%c ",
- (dpme_valid_get(p))?'V':'.',
- (dpme_allocated_get(p))?'A':'.',
- (dpme_in_use_get(p))?'I':'.',
- (dpme_bootable_get(p))?'B':'.',
- (dpme_readable_get(p))?'R':'.',
- (dpme_writable_get(p))?'W':'.',
- (dpme_os_pic_code_get(p))?'P':'.',
- (dpme_os_specific_2_get(p))?'2':'.',
- (dpme_chainable_get(p))?'C':'.',
- (dpme_diskdriver_get(p))?'D':'.',
- (bitfield_get(p->dpme_flags, 30, 1))?'M':'.',
- (bitfield_get(p->dpme_flags, 31, 1))?'X':'.');
+ (p->dpme_flags & DPME_VALID)?'V':'.',
+ (p->dpme_flags & DPME_ALLOCATED)?'A':'.',
+ (p->dpme_flags & DPME_IN_USE)?'I':'.',
+ (p->dpme_flags & DPME_BOOTABLE)?'B':'.',
+ (p->dpme_flags & DPME_READABLE)?'R':'.',
+ (p->dpme_flags & DPME_WRITABLE)?'W':'.',
+ (p->dpme_flags & DPME_OS_PIC_CODE)?'P':'.',
+ (p->dpme_flags & DPME_OS_SPECIFIC_2)?'2':'.',
+ (p->dpme_flags & DPME_CHAINABLE)?'C':'.',
+ (p->dpme_flags & DPME_DISKDRIVER)?'D':'.',
+ (p->dpme_flags & (1<<30))?'M':'.',
+ (p->dpme_flags & (1<<31))?'X':'.');
if (p->dpme_lblock_start != 0 || p->dpme_pblocks != p->dpme_lblocks) {
printf("(%lu @ %lu)", p->dpme_lblocks, p->dpme_lblock_start);
}
@@ -474,19 +475,20 @@ xx: cccc RU *dd s...
case FST:
default:
s = "fsys";
- if (bzb_root_get(bp) != 0) {
+ if ((bp->bzb_flags & BZB_ROOT) != 0) {
j = 0;
- } else if (bzb_usr_get(bp) != 0) {
+ } else if ((bp->bzb_flags & BZB_USR) != 0) {
j = 2;
}
break;
}
printf("%4s ", s);
printf("%c%c ",
- (bzb_root_get(bp))?'R':' ',
- (bzb_usr_get(bp))?'U':' ');
- if (bzb_slice_get(bp) != 0) {
- printf(" %2ld", bzb_slice_get(bp)-1);
+ (bp->bzb_flags & BZB_ROOT)?'R':' ',
+ (bp->bzb_flags & BZB_USR)?'U':' ');
+ slice = ((bp->bzb_flags >> BZB_SLICE_SHIFT) & BZB_SLICE_MASK);
+ if (slice != 0) {
+ printf(" %2d", slice);
} else if (j >= 0) {
printf(" *%2d", j);
} else {
@@ -524,13 +526,13 @@ full_dump_partition_entry(partition_map_header *map, int ix)
printf(" flags: 0x%lx\n", (u32)p->dpme_flags);
printf(" ");
- if (dpme_valid_get(p)) printf("valid ");
- if (dpme_allocated_get(p)) printf("alloc ");
- if (dpme_in_use_get(p)) printf("in-use ");
- if (dpme_bootable_get(p)) printf("boot ");
- if (dpme_readable_get(p)) printf("read ");
- if (dpme_writable_get(p)) printf("write ");
- if (dpme_os_pic_code_get(p)) printf("pic ");
+ if (p->dpme_flags & DPME_VALID) printf("valid ");
+ if (p->dpme_flags & DPME_ALLOCATED) printf("alloc ");
+ if (p->dpme_flags & DPME_IN_USE) printf("in-use ");
+ if (p->dpme_flags & DPME_BOOTABLE) printf("boot ");
+ if (p->dpme_flags & DPME_READABLE) printf("read ");
+ if (p->dpme_flags & DPME_WRITABLE) printf("write ");
+ if (p->dpme_flags & DPME_OS_PIC_CODE) printf("pic ");
t = p->dpme_flags >> 7;
for (i = 7; i <= 31; i++) {
if (t & 0x1) {
diff --git a/sbin/pdisk/partition_map.c b/sbin/pdisk/partition_map.c
index 0fdc011639a..a643c2ec3e4 100644
--- a/sbin/pdisk/partition_map.c
+++ b/sbin/pdisk/partition_map.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: partition_map.c,v 1.18 2016/01/14 04:22:25 krw Exp $ */
+/* $OpenBSD: partition_map.c,v 1.19 2016/01/15 16:39:20 krw Exp $ */
//
// partition_map.c - partition map routines
@@ -472,12 +472,7 @@ create_partition_map(char *name, partition_map_header *oldmap)
strncpy(data->dpme_type, kFreeType, DPISTRLEN);
data->dpme_lblock_start = 0;
data->dpme_lblocks = data->dpme_pblocks;
- dpme_writable_set(data, 1);
- dpme_readable_set(data, 1);
- dpme_bootable_set(data, 0);
- dpme_in_use_set(data, 0);
- dpme_allocated_set(data, 0);
- dpme_valid_set(data, 1);
+ data->dpme_flags = DPME_WRITABLE | DPME_READABLE | DPME_VALID;
if (add_data_to_map(data, 1, map) == 0) {
free(data);
@@ -679,12 +674,8 @@ dpme_init_flags(DPME *data)
data->dpme_flags = APPLE_HFS_FLAGS_VALUE;
}
else {
- dpme_writable_set(data, 1);
- dpme_readable_set(data, 1);
- dpme_bootable_set(data, 0);
- dpme_in_use_set(data, 0);
- dpme_allocated_set(data, 1);
- dpme_valid_set(data, 1);
+ data->dpme_flags = DPME_WRITABLE | DPME_READABLE | DPME_ALLOCATED |
+ DPME_VALID;
}
}
@@ -711,8 +702,7 @@ bzb_init_slice(BZB *bp, int slice)
bp->bzb_type = FST;
strlcpy(bp->bzb_mount_point, "/", sizeof(bp->bzb_mount_point));
bp->bzb_inode = 1;
- bzb_root_set(bp,1);
- bzb_usr_set(bp,1);
+ bp->bzb_flags = BZB_ROOT | BZB_USR;
break;
case 'b':
bp->bzb_type = FSTSFS;
@@ -724,11 +714,11 @@ bzb_init_slice(BZB *bp, int slice)
default:
bp->bzb_type = FST;
bp->bzb_inode = 1;
- bzb_usr_set(bp,1);
+ bp->bzb_flags = BZB_USR;
break;
}
- bzb_slice_set(bp,0); // XXX OpenBSD disksubr.c ignores slice
- // bzb_slice_set(bp,slice-'a'+1);
+ // XXX OpenBSD disksubr.c ignores slice
+ // bp->bzb_flags |= (slice-'a'+1) << BZB_SLICE_SHIFT;
bp->bzb_magic = BZBMAGIC;
}