diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2016-01-17 23:18:20 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2016-01-17 23:18:20 +0000 |
commit | 01308218db84dbe39d40e0a68e9051070079e552 (patch) | |
tree | bb4e53b36a7f77b5c7400b0f2c0e2232a94fe266 | |
parent | 6a8ab3d78c1ca5638191dddc702dca808451f029 (diff) |
Change "//" comments to "/**/". Nuke really stupid ones.
-rw-r--r-- | sbin/pdisk/convert.c | 32 | ||||
-rw-r--r-- | sbin/pdisk/convert.h | 20 | ||||
-rw-r--r-- | sbin/pdisk/dpme.h | 46 | ||||
-rw-r--r-- | sbin/pdisk/dump.c | 16 | ||||
-rw-r--r-- | sbin/pdisk/dump.h | 12 | ||||
-rw-r--r-- | sbin/pdisk/file_media.c | 3 | ||||
-rw-r--r-- | sbin/pdisk/io.c | 36 | ||||
-rw-r--r-- | sbin/pdisk/io.h | 12 | ||||
-rw-r--r-- | sbin/pdisk/partition_map.c | 97 | ||||
-rw-r--r-- | sbin/pdisk/partition_map.h | 26 | ||||
-rw-r--r-- | sbin/pdisk/pdisk.c | 43 | ||||
-rw-r--r-- | sbin/pdisk/validate.c | 74 | ||||
-rw-r--r-- | sbin/pdisk/validate.h | 12 |
13 files changed, 207 insertions, 222 deletions
diff --git a/sbin/pdisk/convert.c b/sbin/pdisk/convert.c index 78f9bcbe6e6..2e440493170 100644 --- a/sbin/pdisk/convert.c +++ b/sbin/pdisk/convert.c @@ -1,12 +1,12 @@ -/* $OpenBSD: convert.c,v 1.16 2016/01/17 19:39:20 krw Exp $ */ +/* $OpenBSD: convert.c,v 1.17 2016/01/17 23:18:19 krw Exp $ */ -// -// convert.c - Little-endian conversion -// -// Written by Eryk Vershen -// -// See comments in convert.h -// +/* + * convert.c - Little-endian conversion + * + * Written by Eryk Vershen + * + * See comments in convert.h + */ /* * Copyright 1996,1997,1998 by Apple Computer, Inc. @@ -41,8 +41,10 @@ int convert_dpme(struct dpme *data, int to_cpu_form) { #if BYTE_ORDER == LITTLE_ENDIAN - // Since we will toss the block if the signature doesn't match - // we don't need to check the signature down here. + /* + * Since we will toss the block if the signature doesn't match + * we don't need to check the signature down here. + */ reverse2((uint8_t *)&data->dpme_signature); reverse2((uint8_t *)&data->dpme_reserved_1); reverse4((uint8_t *)&data->dpme_map_entries); @@ -71,10 +73,12 @@ convert_block0(struct block0 *data, int to_cpu_form) uint16_t count; int i; - // Since this data is optional we do not want to convert willy-nilly. - // We use the flag to determine whether to check for the signature - // before or after we flip the bytes and to determine which form of - // the count to use. + /* + * Since this data is optional we do not want to convert willy-nilly. + * We use the flag to determine whether to check for the signature + * before or after we flip the bytes and to determine which form of + * the count to use. + */ if (to_cpu_form) { reverse2((uint8_t *)&data->sbSig); if (data->sbSig != BLOCK0_SIGNATURE) { diff --git a/sbin/pdisk/convert.h b/sbin/pdisk/convert.h index d6395133ac6..3b7ef46a9d1 100644 --- a/sbin/pdisk/convert.h +++ b/sbin/pdisk/convert.h @@ -1,14 +1,14 @@ -/* $OpenBSD: convert.h,v 1.9 2016/01/17 19:39:20 krw Exp $ */ +/* $OpenBSD: convert.h,v 1.10 2016/01/17 23:18:19 krw Exp $ */ -// -// convert.h - Little-endian conversion -// -// Written by Eryk Vershen -// -// The approach taken to conversion is fairly simply. -// Keep the in-memory copy in the machine's normal form and -// Convert as necessary when reading and writing. -// +/* + * convert.h - Little-endian conversion + * + * Written by Eryk Vershen + * + * The approach taken to conversion is fairly simply. + * Keep the in-memory copy in the machine's normal form and + * Convert as necessary when reading and writing. + */ /* * Copyright 1996,1998 by Apple Computer, Inc. diff --git a/sbin/pdisk/dpme.h b/sbin/pdisk/dpme.h index 63ab6cf7da6..090ecd8ba1a 100644 --- a/sbin/pdisk/dpme.h +++ b/sbin/pdisk/dpme.h @@ -1,23 +1,23 @@ -/* $OpenBSD: dpme.h,v 1.15 2016/01/17 19:15:55 krw Exp $ */ +/* $OpenBSD: dpme.h,v 1.16 2016/01/17 23:18:19 krw Exp $ */ -// -// dpme.h - Disk Partition Map Entry (dpme) -// -// Written by Eryk Vershen -// -// This file describes structures and values related to the standard -// Apple SCSI disk partitioning scheme. -// -// Each entry is (and shall remain) 512 bytes long. -// -// For more information see: -// "Inside Macintosh: Devices" pages 3-12 to 3-15. -// "Inside Macintosh - Volume V" pages V-576 to V-582 -// "Inside Macintosh - Volume IV" page IV-292 -// -// There is a kernel file with much of the same info (under different names): -// /usr/src/mklinux-1.0DR2/osfmk/src/mach_kernel/ppc/POWERMAC/mac_label.h -// +/* + * dpme.h - Disk Partition Map Entry (dpme) + * + * Written by Eryk Vershen + * + * This file describes structures and values related to the standard + * Apple SCSI disk partitioning scheme. + * + * Each entry is (and shall remain) 512 bytes long. + * + * For more information see: + * "Inside Macintosh: Devices" pages 3-12 to 3-15. + * "Inside Macintosh - Volume V" pages V-576 to V-582 + * "Inside Macintosh - Volume IV" page IV-292 + * + * There is a kernel file with much of the same info (under different names): + * /usr/src/mklinux-1.0DR2/osfmk/src/mach_kernel/ppc/POWERMAC/mac_label.h + */ /* * Copyright 1996 by Apple Computer, Inc. @@ -58,8 +58,10 @@ struct block0 { uint16_t sbMap[247]; /* descriptor map */ }; -// Where &sbMap[0] is actually an array struct ddmap[sbDrvrCount] -// kludge to get around alignment junk +/* + * Where &sbMap[0] is actually an array struct ddmap[sbDrvrCount] + * kludge to get around alignment junk + */ struct ddmap { uint32_t ddBlock; /* 1st driver's starting block (in sbBlkSize blocks!) */ uint16_t ddSize; /* size of 1st driver (512-byte blks) */ @@ -67,7 +69,7 @@ struct ddmap { }; -// Each partition map entry (blocks 1 through n) has this format +/* Each partition map entry (blocks 1 through n) has this format */ struct dpme { uint16_t dpme_signature ; uint16_t dpme_reserved_1 ; diff --git a/sbin/pdisk/dump.c b/sbin/pdisk/dump.c index cc7f16887ed..ea766a8f2be 100644 --- a/sbin/pdisk/dump.c +++ b/sbin/pdisk/dump.c @@ -1,10 +1,10 @@ -/* $OpenBSD: dump.c,v 1.33 2016/01/17 19:39:20 krw Exp $ */ +/* $OpenBSD: dump.c,v 1.34 2016/01/17 23:18:19 krw Exp $ */ -// -// dump.c - dumping partition maps -// -// Written by Eryk Vershen -// +/* + * dump.c - dumping partition maps + * + * Written by Eryk Vershen + */ /* * Copyright 1996,1997,1998 by Apple Computer, Inc. @@ -57,8 +57,8 @@ struct patchdescriptor { }; struct patchlist { - unsigned short numPatchBlocks; // number of disk blocks to hold the patch list - unsigned short numPatches; // number of patches in list + unsigned short numPatchBlocks; /* number of disk blocks to hold the patch list */ + unsigned short numPatches; /* number of patches in list */ struct patchdescriptor thePatch[1]; }; diff --git a/sbin/pdisk/dump.h b/sbin/pdisk/dump.h index 62b9d3899cd..c87602573ae 100644 --- a/sbin/pdisk/dump.h +++ b/sbin/pdisk/dump.h @@ -1,10 +1,10 @@ -/* $OpenBSD: dump.h,v 1.9 2016/01/17 19:39:20 krw Exp $ */ +/* $OpenBSD: dump.h,v 1.10 2016/01/17 23:18:19 krw Exp $ */ -// -// dump.h - dumping partition maps -// -// Written by Eryk Vershen -// +/* + * dump.h - dumping partition maps + * + * Written by Eryk Vershen + */ /* * Copyright 1996,1997 by Apple Computer, Inc. diff --git a/sbin/pdisk/file_media.c b/sbin/pdisk/file_media.c index d71a4bc38d7..610faf1246c 100644 --- a/sbin/pdisk/file_media.c +++ b/sbin/pdisk/file_media.c @@ -1,4 +1,4 @@ -/* $OpenBSD: file_media.c,v 1.29 2016/01/17 19:39:20 krw Exp $ */ +/* $OpenBSD: file_media.c,v 1.30 2016/01/17 23:18:19 krw Exp $ */ /* * file_media.c - @@ -97,7 +97,6 @@ open_file_as_media(char *file, int oflag) if (a != 0) { compute_block_size(fd, file); off = lseek(fd, 0, SEEK_END); /* seek to end of media */ - //printf("file size = %Ld\n", off); a->size_in_bytes = (long long) off; a->fd = fd; a->regular_file = 0; diff --git a/sbin/pdisk/io.c b/sbin/pdisk/io.c index 1a15e353e02..dec1950fb6b 100644 --- a/sbin/pdisk/io.c +++ b/sbin/pdisk/io.c @@ -1,10 +1,10 @@ -/* $OpenBSD: io.c,v 1.15 2016/01/17 19:39:20 krw Exp $ */ +/* $OpenBSD: io.c,v 1.16 2016/01/17 23:18:19 krw Exp $ */ -// -// io.c - simple io and input parsing routines -// -// Written by Eryk Vershen -// +/* + * io.c - simple io and input parsing routines + * + * Written by Eryk Vershen + */ /* * Copyright 1996,1997,1998 by Apple Computer, Inc. @@ -66,8 +66,10 @@ my_getch() void my_ungetch(int c) { - // In practice there is never more than one character in - // the unget_buf, but what's a little overkill among friends? + /* + * In practice there is never more than one character in + * the unget_buf, but what's a little overkill among friends? + */ if (unget_count < UNGET_MAX_COUNT) { unget_buf[unget_count++] = c; @@ -92,7 +94,7 @@ flush_to_newline(int keep_newline) } break; } else { - // skip + /* skip */ } } return; @@ -113,7 +115,7 @@ get_okay(const char *prompt, int default_value) if (c <= 0) { break; } else if (c == ' ' || c == '\t') { - // skip blanks and tabs + /* skip blanks and tabs */ } else if (c == '\n') { my_ungetch(c); return default_value; @@ -143,7 +145,7 @@ get_command(const char *prompt, int promptBeforeGet, int *command) if (c <= 0) { break; } else if (c == ' ' || c == '\t') { - // skip blanks and tabs + /* skip blanks and tabs */ } else if (c == '\n') { printf(prompt); } else { @@ -166,7 +168,7 @@ get_number_argument(const char *prompt, long *number, long default_value) if (c <= 0) { break; } else if (c == ' ' || c == '\t') { - // skip blanks and tabs + /* skip blanks and tabs */ } else if (c == '\n') { if (default_value == kDefault) { printf(prompt); @@ -244,7 +246,7 @@ get_string_argument(const char *prompt, char **string, int reprompt) if (c <= 0) { break; } else if (c == ' ' || c == '\t') { - // skip blanks and tabs + /* skip blanks and tabs */ } else if (c == '\n') { if (reprompt) { printf(prompt); @@ -293,7 +295,7 @@ get_string(int eos) c = my_getch(); for (s = ret_value; ; c = my_getch()) { if (s >= limit) { - // expand string + /* expand string */ limit = malloc(length+STRING_CHUNK); if (limit == NULL) { warn("can't allocate memory for string buffer"); @@ -399,9 +401,9 @@ number_of_digits(unsigned long value) } -// -// Print a message on standard error & flush the input. -// +/* + * Print a message on standard error & flush the input. + */ void bad_input(const char *fmt, ...) { diff --git a/sbin/pdisk/io.h b/sbin/pdisk/io.h index 35421787a04..417a129f518 100644 --- a/sbin/pdisk/io.h +++ b/sbin/pdisk/io.h @@ -1,10 +1,10 @@ -/* $OpenBSD: io.h,v 1.6 2016/01/17 19:39:20 krw Exp $ */ +/* $OpenBSD: io.h,v 1.7 2016/01/17 23:18:19 krw Exp $ */ -// -// io.h - simple io and input parsing routines -// -// Written by Eryk Vershen -// +/* + * io.h - simple io and input parsing routines + * + * Written by Eryk Vershen + */ /* * Copyright 1996,1997,1998 by Apple Computer, Inc. diff --git a/sbin/pdisk/partition_map.c b/sbin/pdisk/partition_map.c index 2965c2f8405..75fa944ad3e 100644 --- a/sbin/pdisk/partition_map.c +++ b/sbin/pdisk/partition_map.c @@ -1,10 +1,10 @@ -/* $OpenBSD: partition_map.c,v 1.35 2016/01/17 19:39:20 krw Exp $ */ +/* $OpenBSD: partition_map.c,v 1.36 2016/01/17 23:18:19 krw Exp $ */ -// -// partition_map.c - partition map routines -// -// Written by Eryk Vershen -// +/* + * partition_map.c - partition map routines + * + * Written by Eryk Vershen + */ /* * Copyright 1996,1997,1998 by Apple Computer, Inc. @@ -130,13 +130,11 @@ open_partition_map(char *name, int *valid_file) } else if (read_file_media(map->m, (long long) 0, DEV_BSIZE, (char *)map->misc) == 0 || convert_block0(map->misc, 1) || coerce_block0(map)) { - // if I can't read block 0 I might as well give up warnx("Can't read block 0 from '%s'", name); close_partition_map(map); return NULL; } map->physical_block = map->misc->sbBlkSize; - //printf("physical block size is %d\n", map->physical_block); map->logical_block = DEV_BSIZE; @@ -152,10 +150,9 @@ open_partition_map(char *name, int *valid_file) sync_device_size(map); if (read_partition_map(map) < 0) { - // some sort of failure reading the map + /* some sort of failure reading the map */ } else { - // got it! - ; + /* got it! */ return map; } close_partition_map(map); @@ -194,8 +191,6 @@ read_partition_map(struct partition_map_header *map) int old_logical; double d; -//printf("called read_partition_map\n"); -//printf("logical = %d, physical = %d\n", map->logical_block, map->physical_block); data = malloc(DEV_BSIZE); if (data == NULL) { warn("can't allocate memory for disk buffers"); @@ -229,7 +224,6 @@ read_partition_map(struct partition_map_header *map) return -1; } } -//printf("logical = %d, physical = %d\n", map->logical_block, map->physical_block); limit = data->dpme_map_entries; ix = 1; @@ -310,7 +304,6 @@ add_data_to_map(struct dpme *data, long ix, struct partition_map_header *map) { struct partition_map *entry; -//printf("add data %d to map\n", ix); entry = malloc(sizeof(struct partition_map)); if (entry == NULL) { warn("can't allocate memory for map entries"); @@ -400,7 +393,6 @@ create_partition_map(char *name, struct partition_map_header *oldmap) map->physical_block = MAXIOSIZE; } map->physical_block = size; - // printf("block size is %d\n", map->physical_block); if (oldmap != NULL) { size = oldmap->logical_block; @@ -420,7 +412,6 @@ create_partition_map(char *name, struct partition_map_header *oldmap) if (map->misc == NULL) { warn("can't allocate memory for block zero buffer"); } else { - // got it! coerce_block0(map); sync_device_size(map); @@ -428,7 +419,6 @@ create_partition_map(char *name, struct partition_map_header *oldmap) if (data == NULL) { warn("can't allocate memory for disk buffers"); } else { - // set data into entry data->dpme_signature = DPME_SIGNATURE; data->dpme_map_entries = 1; data->dpme_pblock_start = 1; @@ -473,7 +463,7 @@ coerce_block0(struct partition_map_header *map) p->sbData = 0; p->sbDrvrCount = 0; } - return 0; // we do this simply to make it easier to call this function + return 0; } @@ -490,7 +480,7 @@ add_partition_to_map(const char *name, const char *dptype, uint32_t base, uint32 uint32_t new_base = 0; uint32_t new_length = 0; - // find a block that starts includes base and length + /* find a block that starts includes base and length */ cur = map->base_order; while (cur != NULL) { if (cur->data->dpme_pblock_start <= base @@ -498,17 +488,17 @@ add_partition_to_map(const char *name, const char *dptype, uint32_t base, uint32 (cur->data->dpme_pblock_start + cur->data->dpme_pblocks)) { break; } else { - // check if request is past end of existing partitions, but on disk + /* check if request is past end of existing partitions, but on disk */ if ((cur->next_by_base == NULL) && (base + length <= map->media_size)) { - // Expand final free partition + /* Expand final free partition */ if ((strncasecmp(cur->data->dpme_type, kFreeType, DPISTRLEN) == 0) && base >= cur->data->dpme_pblock_start) { cur->data->dpme_pblocks = map->media_size - cur->data->dpme_pblock_start; break; } - // create an extra free partition + /* create an extra free partition */ if (base >= cur->data->dpme_pblock_start + cur->data->dpme_pblocks) { if (map->maximum_in_map < 0) { limit = map->media_size; @@ -532,17 +522,17 @@ add_partition_to_map(const char *name, const char *dptype, uint32_t base, uint32 cur = cur->next_by_base; } } - // if it is not Extra then punt + /* if it is not Extra then punt */ if (cur == NULL || strncasecmp(cur->data->dpme_type, kFreeType, DPISTRLEN) != 0) { printf("requested base and length is not " "within an existing free partition\n"); return 0; } - // figure out what to do and sizes + /* figure out what to do and sizes */ data = cur->data; if (data->dpme_pblock_start == base) { - // replace or add + /* replace or add */ if (data->dpme_pblocks == length) { act = kReplace; } else { @@ -551,7 +541,7 @@ add_partition_to_map(const char *name, const char *dptype, uint32_t base, uint32 adjusted_length = data->dpme_pblocks - length; } } else { - // split or add + /* split or add */ if (data->dpme_pblock_start + data->dpme_pblocks == base + length) { act = kAdd; adjusted_base = data->dpme_pblock_start; @@ -564,7 +554,7 @@ add_partition_to_map(const char *name, const char *dptype, uint32_t base, uint32 adjusted_length = data->dpme_pblocks - (length + new_length); } } - // if the map will overflow then punt + /* if the map will overflow then punt */ if (map->maximum_in_map < 0) { limit = map->media_size; } else { @@ -583,26 +573,24 @@ add_partition_to_map(const char *name, const char *dptype, uint32_t base, uint32 free(cur->data); cur->data = data; } else { - // adjust this block's size + /* adjust this block's size */ cur->data->dpme_pblock_start = adjusted_base; cur->data->dpme_pblocks = adjusted_length; cur->data->dpme_lblocks = adjusted_length; - // insert new with block address equal to this one + /* insert new with block address equal to this one */ if (add_data_to_map(data, cur->disk_address, map) == 0) { free(data); } else if (act == kSplit) { data = create_data(kFreeName, kFreeType, new_base, new_length); if (data != NULL) { - // insert new with block address equal to this one + /* insert new with block address equal to this one */ if (add_data_to_map(data, cur->disk_address, map) == 0) { free(data); } } } } - // renumber disk addresses renumber_disk_addresses(map); - // mark changed map->changed = 1; return 1; } @@ -617,7 +605,6 @@ create_data(const char *name, const char *dptype, uint32_t base, uint32_t length if (data == NULL) { warn("can't allocate memory for disk buffers"); } else { - // set data into entry data->dpme_signature = DPME_SIGNATURE; data->dpme_map_entries = 1; data->dpme_pblock_start = base; @@ -650,7 +637,7 @@ renumber_disk_addresses(struct partition_map_header *map) struct partition_map * cur; long ix; - // reset disk addresses + /* reset disk addresses */ cur = map->disk_order; ix = 1; while (cur != NULL) { @@ -724,16 +711,16 @@ delete_partition_from_map(struct partition_map *entry) return; } } - // if past end of disk, delete it completely + /* if past end of disk, delete it completely */ if (entry->next_by_base == NULL && entry->data->dpme_pblock_start >= entry->the_map->media_size) { if (entry->contains_driver) { - remove_driver(entry); // update block0 if necessary + remove_driver(entry); /* update block0 if necessary */ } delete_entry(entry); return; } - // If at end of disk, incorporate extra disk space to partition + /* If at end of disk, incorporate extra disk space to partition */ if (entry->next_by_base == NULL) { entry->data->dpme_pblocks = entry->the_map->media_size - entry->data->dpme_pblock_start; @@ -744,7 +731,7 @@ delete_partition_from_map(struct partition_map *entry) return; } if (entry->contains_driver) { - remove_driver(entry); // update block0 if necessary + remove_driver(entry); /* update block0 if necessary */ } free(entry->data); entry->HFS_kind = kHFS_not; @@ -808,13 +795,13 @@ combine_entry(struct partition_map *entry) if (entry->next_by_base != NULL) { p = entry->next_by_base; if (strncasecmp(p->data->dpme_type, kFreeType, DPISTRLEN) != 0) { - // next is not free + /* next is not free */ } else if (entry->data->dpme_pblock_start + entry->data->dpme_pblocks != p->data->dpme_pblock_start) { - // next is not contiguous (XXX this is bad) + /* next is not contiguous (XXX this is bad) */ printf("next entry is not contiguous\n"); - // start is already minimum - // new end is maximum of two ends + /* start is already minimum */ + /* new end is maximum of two ends */ end = p->data->dpme_pblock_start + p->data->dpme_pblocks; if (end > entry->data->dpme_pblock_start + entry->data->dpme_pblocks) { entry->data->dpme_pblocks = end - entry->data->dpme_pblock_start; @@ -830,18 +817,18 @@ combine_entry(struct partition_map *entry) if (entry->prev_by_base != NULL) { p = entry->prev_by_base; if (strncasecmp(p->data->dpme_type, kFreeType, DPISTRLEN) != 0) { - // previous is not free + /* previous is not free */ } else if (p->data->dpme_pblock_start + p->data->dpme_pblocks != entry->data->dpme_pblock_start) { - // previous is not contiguous (XXX this is bad) + /* previous is not contiguous (XXX this is bad) */ printf("previous entry is not contiguous\n"); - // new end is maximum of two ends + /* new end is maximum of two ends */ end = p->data->dpme_pblock_start + p->data->dpme_pblocks; if (end < entry->data->dpme_pblock_start + entry->data->dpme_pblocks) { end = entry->data->dpme_pblock_start + entry->data->dpme_pblocks; } entry->data->dpme_pblocks = end - p->data->dpme_pblock_start; - // new start is previous entry's start + /* new start is previous entry's start */ entry->data->dpme_pblock_start = p->data->dpme_pblock_start; entry->data->dpme_lblocks = entry->data->dpme_pblocks; delete_entry(p); @@ -976,7 +963,7 @@ insert_in_disk_order(struct partition_map *entry) struct partition_map_header *map; struct partition_map * cur; - // find position in disk list & insert + /* find position in disk list & insert */ map = entry->the_map; cur = map->disk_order; if (cur == NULL || entry->disk_address <= cur->disk_address) { @@ -1010,7 +997,7 @@ insert_in_base_order(struct partition_map *entry) struct partition_map_header *map; struct partition_map * cur; - // find position in base list & insert + /* find position in base list & insert */ map = entry->the_map; cur = map->base_order; if (cur == NULL @@ -1047,7 +1034,6 @@ resize_map(long new_size, struct partition_map_header *map) struct partition_map * next; int incr; - // find map entry entry = find_entry_by_type(kMapType, map); if (entry == NULL) { @@ -1056,13 +1042,11 @@ resize_map(long new_size, struct partition_map_header *map) } next = entry->next_by_base; - // same size if (new_size == entry->data->dpme_pblocks) { - // do nothing return; } - // make it smaller + /* make it smaller */ if (new_size < entry->data->dpme_pblocks) { if (next == NULL || strncasecmp(next->data->dpme_type, kFreeType, DPISTRLEN) != 0) { @@ -1077,7 +1061,7 @@ resize_map(long new_size, struct partition_map_header *map) goto doit; } - // make it larger + /* make it larger */ if (next == NULL || strncasecmp(next->data->dpme_type, kFreeType, DPISTRLEN) != 0) { printf("No free space to expand into\n"); @@ -1139,8 +1123,8 @@ remove_driver(struct partition_map *entry) && f*(start + m[i].ddSize) <= (entry->data->dpme_pblock_start + entry->data->dpme_pblocks)) { - // delete this driver - // by copying down later ones and zapping the last + /* delete this driver */ + /* by copying down later ones and zapping the last */ for (j = i+1; j < p->sbDrvrCount; j++, i++) { put_align_long(get_align_long(&m[j].ddBlock), &m[i].ddBlock); m[i].ddSize = m[j].ddSize; @@ -1159,7 +1143,6 @@ remove_driver(struct partition_map *entry) int read_block(struct partition_map_header *map, unsigned long num, char *buf) { -//printf("read block %d\n", num); return read_file_media(map->m, ((long long) num) * map->logical_block, DEV_BSIZE, (void *)buf); } diff --git a/sbin/pdisk/partition_map.h b/sbin/pdisk/partition_map.h index 6cad03f4e0a..4207811beac 100644 --- a/sbin/pdisk/partition_map.h +++ b/sbin/pdisk/partition_map.h @@ -1,10 +1,10 @@ -/* $OpenBSD: partition_map.h,v 1.16 2016/01/17 19:39:20 krw Exp $ */ +/* $OpenBSD: partition_map.h,v 1.17 2016/01/17 23:18:19 krw Exp $ */ -// -// partition_map.h - partition map routines -// -// Written by Eryk Vershen -// +/* + * partition_map.h - partition map routines + * + * Written by Eryk Vershen + */ /* * Copyright 1996,1998 by Apple Computer, Inc. @@ -42,11 +42,11 @@ struct partition_map_header { int writable; int changed; int written; - int physical_block; // must be == sbBlockSize - int logical_block; // must be <= physical_block + int physical_block; /* must be == sbBlockSize */ + int logical_block; /* must be <= physical_block */ int blocks_in_map; int maximum_in_map; - unsigned long media_size; // in logical_blocks + unsigned long media_size; /* in logical_blocks */ }; struct partition_map { @@ -63,10 +63,10 @@ struct partition_map { /* Identifies the HFS kind. */ enum { - kHFS_not = 0, // ' ' - kHFS_std = 1, // 'h' - kHFS_embed = 2, // 'e' - kHFS_plus = 3 // '+' + kHFS_not = 0, /* ' ' */ + kHFS_std = 1, /* 'h' */ + kHFS_embed = 2, /* 'e' */ + kHFS_plus = 3 /* '+' */ }; extern const char * kFreeType; diff --git a/sbin/pdisk/pdisk.c b/sbin/pdisk/pdisk.c index a30d2a36cb4..56ac2fd1c4a 100644 --- a/sbin/pdisk/pdisk.c +++ b/sbin/pdisk/pdisk.c @@ -1,12 +1,12 @@ -/* $OpenBSD: pdisk.c,v 1.43 2016/01/17 19:39:20 krw Exp $ */ +/* $OpenBSD: pdisk.c,v 1.44 2016/01/17 23:18:19 krw Exp $ */ -// -// pdisk - an editor for Apple format partition tables -// -// Written by Eryk Vershen -// -// Still under development (as of 15 January 1998) -// +/* + * pdisk - an editor for Apple format partition tables + * + * Written by Eryk Vershen + * + * Still under development (as of 15 January 1998) + */ /* * Copyright 1996,1997,1998 by Apple Computer, Inc. @@ -134,7 +134,7 @@ get_options(int argc, char **argv) dflag = DFLAG_DEFAULT; rflag = RFLAG_DEFAULT; - optind = 1; // reset option scanner logic + optind = 1; /* reset option scanner logic */ while ((c = getopt(argc, argv, "ldr")) != -1) { switch (c) { case 'l': @@ -170,9 +170,9 @@ print_edit_notes() } -// -// Edit the file -// +/* + * Edit the file + */ void edit(char *name) { @@ -197,7 +197,7 @@ edit(char *name) switch (command) { case '?': print_edit_notes(); - // fall through + /* fall through */ case 'H': case 'h': printf("Commands are:\n"); @@ -222,7 +222,7 @@ edit(char *name) break; case 'P': order = 0; - // fall through + /* fall through */ case 'p': dump_partition_map(map, order); break; @@ -242,7 +242,7 @@ edit(char *name) break; case 'C': get_type = 1; - // fall through + /* fall through */ case 'c': do_create_partition(map, get_type); break; @@ -309,7 +309,6 @@ do_create_partition(struct partition_map_header *map, int get_type) if (!rflag && map->writable == 0) { printf("The map is not writable.\n"); } -// XXX add help feature (i.e. '?' in any argument routine prints help string) if (get_base_argument(&base, map) == 0) { return; } @@ -424,12 +423,12 @@ do_rename_partition(struct partition_map_header *map) return; } - // find partition and change it + /* find partition and change it */ entry = find_entry_by_disk_address(ix, map); if (entry == NULL) { printf("No such partition\n"); } else { - // stuff name into partition map entry data + /* stuff name into partition map entry data */ strncpy(entry->data->dpme_name, name, DPISTRLEN); map->changed = 1; } @@ -498,7 +497,7 @@ do_delete_partition(struct partition_map_header *map) return; } - // find partition and delete it + /* find partition and delete it */ cur = find_entry_by_disk_address(ix, map); if (cur == NULL) { printf("No such partition\n"); @@ -558,8 +557,6 @@ do_write_partition_map(struct partition_map_header *map) map->changed = 0; map->written = 1; - - // exit(0); } @@ -585,7 +582,7 @@ do_expert(struct partition_map_header *map, char *name) switch (command) { case '?': print_expert_notes(); - // fall through + /* fall through */ case 'H': case 'h': printf("Commands are:\n"); @@ -619,7 +616,7 @@ do_expert(struct partition_map_header *map, char *name) show_data_structures(map); break; } - // fall through + /* fall through */ case 'p': dump_partition_map(map, 1); break; diff --git a/sbin/pdisk/validate.c b/sbin/pdisk/validate.c index ff6eec9419a..369a7e222a8 100644 --- a/sbin/pdisk/validate.c +++ b/sbin/pdisk/validate.c @@ -1,10 +1,10 @@ -/* $OpenBSD: validate.c,v 1.24 2016/01/17 19:39:20 krw Exp $ */ +/* $OpenBSD: validate.c,v 1.25 2016/01/17 23:18:19 krw Exp $ */ -// -// validate.c - -// -// Written by Eryk Vershen -// +/* + * validate.c - + * + * Written by Eryk Vershen + */ /* * Copyright 1997,1998 by Apple Computer, Inc. @@ -270,8 +270,6 @@ print_range_list(struct range_list *list) break; case kAllocated: continue; - //s = "allocated"; - //break; case kMultiplyAllocated: s = "multiply allocated"; break; @@ -282,8 +280,6 @@ print_range_list(struct range_list *list) switch (cur->state) { case kUnallocated: continue; - //s = "unallocated"; - //break; case kAllocated: s = "allocated"; break; @@ -310,8 +306,6 @@ validate_map(struct partition_map_header *map) uint32_t limit; int printed; - //printf("Validation not implemented yet.\n"); - if (map == NULL) { the_map = 0; if (get_string_argument("Name of device: ", &name, 1) == 0) { @@ -340,20 +334,22 @@ validate_map(struct partition_map_header *map) initialize_list(&list); - // get block 0 if (get_block_zero() == 0) { printf("unable to read block 0\n"); goto check_map; } - // XXX signature valid - // XXX size & count match DeviceCapacity - // XXX number of descriptors matches array size - // XXX each descriptor wholly contained in a partition - // XXX the range below here is in physical blocks but the map is in logical blocks!!! + /* + * XXX signature valid + * XXX size & count match DeviceCapacity + * XXX number of descriptors matches array size + * XXX each descriptor wholly contained in a partition + * XXX the range below here is in physical blocks but the map is + * in logical blocks!!! + */ add_range(&list, 1, b0->sbBlkCount-1, 0); /* subtract one since args are base & len */ check_map: - // compute size of map + /* compute size of map */ if (map != NULL) { limit = the_map->blocks_in_map; } else { @@ -369,7 +365,7 @@ check_map: } } - // for each entry + /* for each entry */ for (i = 1; ; i++) { if (limit < 0) { /* XXX what to use for end of list? */ @@ -382,24 +378,24 @@ check_map: printf("block %d:\n", i); - // get entry + /* get entry */ if (get_block_n(i) == 0) { printf("\tunable to get\n"); goto post_processing; } printed = 0; - // signature matches + /* signature matches */ if (mb->dpme_signature != DPME_SIGNATURE) { printed = 1; printf("\tsignature is 0x%x, should be 0x%x\n", mb->dpme_signature, DPME_SIGNATURE); } - // reserved1 == 0 + /* reserved1 == 0 */ if (mb->dpme_reserved_1 != 0) { printed = 1; printf("\treserved word is 0x%x, should be 0\n", mb->dpme_reserved_1); } - // entry count matches + /* entry count matches */ if (limit < 0) { printed = 1; printf("\tentry count is 0x%x, real value unknown\n", mb->dpme_map_entries); @@ -407,38 +403,40 @@ check_map: printed = 1; printf("\tentry count is 0x%x, should be %u\n", mb->dpme_map_entries, limit); } - // lblocks contained within physical + /* lblocks contained within physical */ if (mb->dpme_lblock_start >= mb->dpme_pblocks || mb->dpme_lblocks > mb->dpme_pblocks - mb->dpme_lblock_start) { printed = 1; printf("\tlogical blocks (%u for %u) not within physical size (%u)\n", mb->dpme_lblock_start, mb->dpme_lblocks, mb->dpme_pblocks); } - // remember stuff for post processing + /* remember stuff for post processing */ add_range(&list, mb->dpme_pblock_start, mb->dpme_pblocks, 1); - // XXX type is known type? - // XXX no unknown flags? - // XXX boot blocks either within or outside of logical - // XXX checksum matches contents - // XXX other fields zero if boot_bytes is zero - // XXX processor id is known value? - // XXX no data in reserved3 + /* + * XXX type is known type? + * XXX no unknown flags? + * XXX boot blocks either within or outside of logical + * XXX checksum matches contents + * XXX other fields zero if boot_bytes is zero + * XXX processor id is known value? + * XXX no data in reserved3 + */ if (printed == 0) { printf("\tokay\n"); } } post_processing: - // properties of whole map + /* properties of whole map */ - // every block on disk in one & only one partition + /* every block on disk in one & only one partition */ coalesce_list(list); print_range_list(list); - // there is a partition for the map - // map fits within partition that contains it + /* there is a partition for the map */ + /* map fits within partition that contains it */ - // try to detect 512/2048 mixed partition map? + /* try to detect 512/2048 mixed partition map? */ done: if (map == NULL) { diff --git a/sbin/pdisk/validate.h b/sbin/pdisk/validate.h index 44997f98112..463939645d7 100644 --- a/sbin/pdisk/validate.h +++ b/sbin/pdisk/validate.h @@ -1,10 +1,10 @@ -/* $OpenBSD: validate.h,v 1.7 2016/01/17 19:39:20 krw Exp $ */ +/* $OpenBSD: validate.h,v 1.8 2016/01/17 23:18:19 krw Exp $ */ -// -// validate.h - -// -// Written by Eryk Vershen -// +/* + * validate.h - + * + * Written by Eryk Vershen + */ /* * Copyright 1997,1998 by Apple Computer, Inc. |