summaryrefslogtreecommitdiff
path: root/sbin/pdisk/dump.c
AgeCommit message (Collapse)Author
2016-02-23Fix display of pdisk partition sizes by casting the 32-bit numberKenneth R Westerback
of blocks to (long long) before multiplying by 512 and passing the value to fmt_scaled(). Discovered and fix tested by rpe@. ok rpe@ deraadt@
2016-01-31Nuke pointless map field 'physical_block' and just use 'sbBlkSize' which isKenneth R Westerback
set to the same value.
2016-01-31Nuke djust_value_and_compute_prefix() and use fmt_scaled() to displayKenneth R Westerback
human readable sizes.
2016-01-31Just call contains_driver() when you need to know rather than carrying aKenneth R Westerback
flag around. More obviously current data. Nuke unnecessary variables when displaying a partition.
2016-01-31Move dump_block() declaration from io.h to io.c since it is notKenneth R Westerback
used anywhere else. Remove declarations of non-existant kPatchType and init_partition_map().
2016-01-31Apple sets lblock_start and lblocks to 0 in free space entries. DoKenneth R Westerback
the same. Don't use lblock_start or lblocks in calculation for length@base display. We no longer display lblock info there.
2016-01-30Move last three lines (#define's) from dpme.h to partition_map.h andKenneth R Westerback
tweak #include's as necessary.
2016-01-30Fold struct dpme into struct entry. Same reasons as for foldingKenneth R Westerback
struct block0 into struct partition_map. Easier to read code.
2016-01-29Fold struct block0 into struct partition map. There can be only oneKenneth R Westerback
and read/write_block0() can move the data from/to disk to/from appropriate fields anywhere. Removes a bunch of dereferencing, malloc'ing and pointer checking.
2016-01-29Tweak printing of partitions. Always show the pblock info in theKenneth R Westerback
'p' command output. And always show the lblock info in the 'P' command. Showing sometimes one and sometimes another with a subtle extra character to indicate which is being shown is error prone.
2016-01-29Shorter names means a few whitespace adjustments.Kenneth R Westerback
2016-01-29Rename struct partition_map_header to struct partition_map. No change toKenneth R Westerback
.o files.
2016-01-29Rename struct partition_map to struct entry. No change to .o files.Kenneth R Westerback
2016-01-28Hand rolled lists suck. First, replace disk_order with an LIST.Kenneth R Westerback
2016-01-28Since we don't allow maps to be created or opened with an invalidKenneth R Westerback
block0, there is no point in checking later if block0 has magically become invalid.
2016-01-27No need to copy dmpe_name to a buffer before printing it.Kenneth R Westerback
2016-01-27make sure to check malloc(3) return pointer against NULL.Gleydson Soares
OK krw@
2016-01-27We do not support logical_block != physical_block. Remove logical_blockKenneth R Westerback
field and left over code that checks for logical != physical. Removes confusion with dmpe fields lblock_start and lblocks, which have nothing to do with block sizes! lblock_start is the block offset within the partition where the data actually starts. and lblocks is the number of blocks of data within the partition. Both are in units of *physical blocks*, a.k.a. disk sectors.
2016-01-27Nuke another (and I hope final) batch of superfluous '{}' around singleKenneth R Westerback
statements.
2016-01-26dpme_name and dpme_type are NUL-terminated in Apple code, so useKenneth R Westerback
strlcpy() to fill them. They are also supposed to be NUL-padded so zap previous contents before copying in possibly shorter new values.
2016-01-26Whitespace, line wrapping fixes. Nuke many superfluous '{}' around singleKenneth R Westerback
statements. 0 -> NULL for pointer checks.
2016-01-26Whitespace, line wrapping fixes.Kenneth R Westerback
2016-01-25Use new read/write_block0 and read/write_dpme which handle anyKenneth R Westerback
endian or alignment issues forcefully. Removes need for convert_* functions so unhook convert.c from build. read/write_block become static functions inside file_media.c. Tweak struct block0 to stop trying to handle alignment issues by clever declaration. Rely on the new functions to accurately translate between on-disk and in-memory layouts. Enables pdisk to work on amd64 and likely other architectures if it's ever desirable. Does bring back DEV_BSIZE to pdisk.c since the in-memory structure will *not* be 512 bytes on other archs.
2016-01-25Tweak fields in struct dpme to be more consistent with Apple's info.Kenneth R Westerback
Better comments, make all reserved fields uint8_t arrays, don't claim uint32_t fields are actually pointers.
2016-01-25remove some uneeded includesJonathan Gray
ok krw@
2016-01-24Whitespace.Kenneth R Westerback
2016-01-24Nuke get_align_long() and put_align_long() #define's. They don't doKenneth R Westerback
anything according to gcc & cmp. cmp suggested by & ok stefan@.
2016-01-24Whitespace fixes.Kenneth R Westerback
2016-01-23Nuke unused kPatchType. Nuke kStringNot and use " not' where needed.Kenneth R Westerback
Nuke kStringEmpty and use "" where needed. Nuke unused static 'g'. Eliminate #include's in *.h files. Some whitespace fixes.
2016-01-23Flip read_block() and write_block() back to taking sector addressesKenneth R Westerback
instead of off_t values. Do the DEV_BSIZE multiplication in these two functions. Easier to read code and kills two #include <sys/param.h>. Kill unused label.
2016-01-23map->block0 is always allocated or the map is discarded.Kenneth R Westerback
So stop checking for NULL. Nuke get_block_zero() and just use map->block0.
2016-01-22Change partition map field 'data' to 'dmpe'. Change 'create_data'Kenneth R Westerback
to 'create_dmpe'. Sweep up some 'struct dpme *data' to struct dpme *dpme'.
2016-01-22Rename map field 'misc' to 'block0' since that's what it is.Kenneth R Westerback
2016-01-22In the "why use two variables when one would do" category, eliminateKenneth R Westerback
the 'written' field and just use the 'changed' field to mediate when it is appropriate to ask whether changes should be discarded.
2016-01-22Nuke 'expert' mode and the enabling, undocumented, '-d' flag byKenneth R Westerback
just making all the commands available all the time. Document the newly available commands. Remove the former 'P' command (list partitions in base address order) and use 'P' from expert mode (show map data structures). Stop accepting uppercase aliases for commands documented as lower case. Bring the 'h' help text and man pages into agreement. ok jasper@ millert@
2016-01-21Hoist all file opening and ioctl calls into main(), passing a pointer toKenneth R Westerback
a valid map to edit(). Should enable pledging a la fdisk at some point. Since edit() always gets a valid map (and maintains its validity even when 'I'nitializing a new one) many checks for (map == NULL) are junked. Remove some dances around block sizes by using DEV_BSIZE everywhere since we don't support non-DEV_BSIZE (a.k.a. 512-byte) sectors. Remove many superfluous #include statements.
2016-01-21Nuke 'writable' field now that it is always in sync with 'rflag'. SinceKenneth R Westerback
(!rflag && writable == 0) can't be true remove those warning blocks and simply leave the not-writable warning when attempting to write the map. Always show 'w' in the help and rely on the check and warning in do_write_partition_map() so the user always gets a message.
2016-01-19Bring code into line with man page and usage() by only allowing oneKenneth R Westerback
disk to be specified on the command line. Nuke dump() function and hoist its few lines into main() as a result.
2016-01-18The contents of the Apple_Patches partition is none of our business.Kenneth R Westerback
Stop pretending we care or know what's in there. Remove 'debugging' mode command to examine the partition contents and the supporting code. ok deraadt@ jasper@
2016-01-18struct file_media had 1 field left. And one place where structKenneth R Westerback
file_media was actually stored. So move the last field (fd) into the place formerly used to store pointer to the instance. As a result we can just pass fd's around rather than pointers to a struct containing a fd. close_file_media() becomes empty but for a close(). So just use close() and nuke close_file_media().
2016-01-18Run indent(1) over it and tweak the results a bit manually to look moreKenneth R Westerback
KNF'ish.
2016-01-17Change "//" comments to "/**/". Nuke really stupid ones.Kenneth R Westerback
2016-01-17Reduce namespace pollution by eliminating parameter names from forwardKenneth R Westerback
declarations.
2016-01-17Kill leading, imbedded, trailing whitespace.Kenneth R Westerback
2016-01-17Remove a bunch of ridiculous and uninformative comments like "// Defines".Kenneth R Westerback
2016-01-17The great de-typedef'ification concludes with u32 -> uint32_t. And aKenneth R Westerback
bunch of consequent printf() format corrections.
2016-01-17The great de-typedef'ification continues.Kenneth R Westerback
partition_map -> struct partition_map partition_map_header -> struct partition_map_header
2016-01-17The great de-typedef'ification continues.Kenneth R Westerback
PatchList -> struct patchlist Nuke PatchListPtr PatchListDescriptor -> struct patchlistdescriptor Nuke PatchListDescriptorPtr
2016-01-17The great de-typedef'ification continues. OSType -> unsigned long.Kenneth R Westerback
Nuke names/NAMES as the only use was in an unused array of abbreviations which also goes.
2016-01-17The great de-typedef'ification continues. DDMap -> struct ddmap.Kenneth R Westerback