summaryrefslogtreecommitdiff
path: root/sbin/pdisk
AgeCommit message (Collapse)Author
2016-05-28Remove all the pledge "disklabel" before ioctl DIOCGPDINFO isTheo Buehler
called in order to avoid a pledge crash with 'pdisk /dev/tty'. Only the pledge "stdio" right after the ioctl remains. ok krw
2016-04-27Tweak command line processing vs pledge logic to make things nicer. NoKenneth R Westerback
functional change. Prodded (a while ago) and ok (recently) deraadt@
2016-03-09Accept only character special devices rather than generating a coreKenneth R Westerback
dump on the attempt to get a disklabel from a regular file. Regular files have not been acceptable as the 'disk' for some time, and pledging changed the consequences from a somewhat obscure error message to an abort(). Issue discovered by espie@. ok natano@
2016-02-23A disk name of /dev/wd0c doesn't work. Correct verbiage and example.Kenneth R Westerback
Discovered by rpe@. Tweaked by schwarze@. ok rpe@ schwarze@ jmc@ deraadt@
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-02-02Pledge, based on what's done in fdisk.Kenneth R Westerback
2016-02-01Use printf("%s",prompt) rather than printf(prompt) just for paranoia'sKenneth R Westerback
sake.
2016-02-01Un-shorten some lines that don't need breaking anymore. Remove a couple ofKenneth R Westerback
indent levels by shuffling code bit.
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-31Use delete_entry()/create_entry() in delete_partition_from_map() instead ofKenneth R Westerback
trying to be clever and tweaking the existing entry into a free space entry by manual manipulation of the fields.
2016-01-31Fold add_data_to_map() into create_entry() as the former is always calledKenneth R Westerback
immediately after the latter, manipulating fields in the same structure. Use create_entry() in create_partition() rather than doing the same actions manually.
2016-01-31Don't use add_data_to_map() when reading from disk, since it resets someKenneth R Westerback
of the dpme_ fields, overwriting data from disk. Add some paranoia checks for map limits when reading from disk.
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-30Zap a couple of declarations for non-existant variable and function.Kenneth R Westerback
2016-01-30Another to the attic.Kenneth R Westerback
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-30Refactor add_partition_to_map() to be simpler if perhaps lessKenneth R Westerback
performance optimized. New logic will simplify merging struct dpme into struct entry.
2016-01-30There is not much to do if we run out of memory, so simply exit ifKenneth R Westerback
a malloc() or calloc() fails. Simplifies a bunch of logic, makes add_data_to_map() always succeed or exit, so make it a void.
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-29Add do_dump_map() to make command processing more consistent. PassKenneth R Westerback
1/0 (a.k.a. vverbose/not verbose) do do_dump_map() to differentiate P/p.
2016-01-29Base 10 should be enough for anybody! Allowing hex and octal numberKenneth R Westerback
input for partition id's, partition starting points and partition sizes is silly, especially since we never display anything but base 10 numbers. Also ensure that numbers end with a space, tab or newline.
2016-01-29Warn of partitions extending past the end of the media.Kenneth R Westerback
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-29Conform to Apple Mac OS X's behaviour of setting dpme_flags on freeKenneth R Westerback
partitions to 0, and setting them to VALID | ALLOCATED on the map partition.
2016-01-29Conform to Apple Mac OS X's behaviour of not giving 'Apple_Free'Kenneth R Westerback
partitions a name. Nuke kFreeName.
2016-01-28Flip base_order to a LIST().Kenneth R Westerback
2016-01-28Delete a bunch of Morris dancing in delete_partition_from_map().Kenneth R Westerback
No need to create a new dpme. Just rename/retype the existing and let combine_entry() suck in any surrounding empty space partitions.
2016-01-28Hand rolled lists suck. First, replace disk_order with an LIST.Kenneth R Westerback
2016-01-28Oops. Deleted one too many lines. Need to advance pointer when traversingKenneth R Westerback
list.
2016-01-28When adding a new partition to the map, use only existing mappedKenneth R Westerback
space. Don't try to create new free space partitions to use. If the map does not know about all of the space on the disk, it is broken.
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-28Use consistent 'return' idiom -- no parenthesis since that was the styleKenneth R Westerback
of the existing code.
2016-01-28more tweaks; ok krwJason McIntyre
2016-01-28Tweak verbiage for 'r' (reorder) command.Kenneth R Westerback
2016-01-28Make 'r' (reorder, a.k.a. swap) command work with any two existingKenneth R Westerback
partitions. Do NOT allow partition 1 to be moved!
2016-01-27Traverse next_by_base when checking maps coverage, not next_on_disk!Kenneth R Westerback
2016-01-27No need to copy dmpe_name to a buffer before printing it.Kenneth R Westerback
2016-01-27Clear out some repetitive and pointless verbiage. Shuffle otherKenneth R Westerback
verbiage around to make things clearer.
2016-01-27Tweak some verbiage.Kenneth R Westerback
2016-01-27make sure to check malloc(3) return pointer against NULL.Gleydson Soares
OK krw@
2016-01-27tweak previous; ok krwJason McIntyre
2016-01-27On-disk partition name/types/processorid may or may not be NULKenneth R Westerback
terminated after all. So add an extra byte for a NUL in the in-memory struct's.
2016-01-27Remove some lies and pointless verbiage. Tweak HISTORY.Kenneth R Westerback