summaryrefslogtreecommitdiffstats
path: root/sbin/pdisk (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Allow sbBlkCount to be less than the number of physical sectors on thekrw2019-07-311-4/+4
| | | | | | | | | | disk. Fixes dealing with MacOS 9.2.2 formatted disk, allowing dual boot again. Problem reported and fix tested by Donovan Watteau on his B&W G3. Thanks!
* use $OpenBSD markertedu2019-01-171-1/+1
|
* Remove all the pledge "disklabel" before ioctl DIOCGPDINFO istb2016-05-281-11/+1
| | | | | | | called in order to avoid a pledge crash with 'pdisk /dev/tty'. Only the pledge "stdio" right after the ioctl remains. ok krw
* Tweak command line processing vs pledge logic to make things nicer. Nokrw2016-04-271-4/+6
| | | | | | functional change. Prodded (a while ago) and ok (recently) deraadt@
* Accept only character special devices rather than generating a corekrw2016-03-091-4/+3
| | | | | | | | | | | | 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@
* A disk name of /dev/wd0c doesn't work. Correct verbiage and example.krw2016-02-231-7/+7
| | | | | | Discovered by rpe@. Tweaked by schwarze@. ok rpe@ schwarze@ jmc@ deraadt@
* Fix display of pdisk partition sizes by casting the 32-bit numberkrw2016-02-231-4/+4
| | | | | | | | | 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@
* Pledge, based on what's done in fdisk.krw2016-02-021-2/+18
|
* Use printf("%s",prompt) rather than printf(prompt) just for paranoia'skrw2016-02-011-7/+7
| | | | sake.
* Un-shorten some lines that don't need breaking anymore. Remove a couple ofkrw2016-02-011-50/+42
| | | | indent levels by shuffling code bit.
* Nuke pointless map field 'physical_block' and just use 'sbBlkSize' which iskrw2016-01-314-13/+9
| | | | set to the same value.
* Nuke djust_value_and_compute_prefix() and use fmt_scaled() to displaykrw2016-01-311-50/+19
| | | | human readable sizes.
* Use delete_entry()/create_entry() in delete_partition_from_map() instead ofkrw2016-01-311-7/+10
| | | | | trying to be clever and tweaking the existing entry into a free space entry by manual manipulation of the fields.
* Fold add_data_to_map() into create_entry() as the former is always calledkrw2016-01-311-37/+24
| | | | | | | immediately after the latter, manipulating fields in the same structure. Use create_entry() in create_partition() rather than doing the same actions manually.
* Don't use add_data_to_map() when reading from disk, since it resets somekrw2016-01-311-5/+22
| | | | | | of the dpme_ fields, overwriting data from disk. Add some paranoia checks for map limits when reading from disk.
* Just call contains_driver() when you need to know rather than carrying akrw2016-01-313-14/+9
| | | | | flag around. More obviously current data. Nuke unnecessary variables when displaying a partition.
* Move dump_block() declaration from io.h to io.c since it is notkrw2016-01-313-6/+4
| | | | | | used anywhere else. Remove declarations of non-existant kPatchType and init_partition_map().
* Apple sets lblock_start and lblocks to 0 in free space entries. Dokrw2016-01-312-19/+11
| | | | | | | the same. Don't use lblock_start or lblocks in calculation for length@base display. We no longer display lblock info there.
* Zap a couple of declarations for non-existant variable and function.krw2016-01-301-3/+1
|
* Another to the attic.krw2016-01-301-50/+0
|
* Move last three lines (#define's) from dpme.h to partition_map.h andkrw2016-01-306-12/+15
| | | | tweak #include's as necessary.
* Fold struct dpme into struct entry. Same reasons as for foldingkrw2016-01-307-352/+324
| | | | struct block0 into struct partition_map. Easier to read code.
* Refactor add_partition_to_map() to be simpler if perhaps lesskrw2016-01-301-71/+60
| | | | | performance optimized. New logic will simplify merging struct dpme into struct entry.
* There is not much to do if we run out of memory, so simply exit ifkrw2016-01-302-68/+49
| | | | | a malloc() or calloc() fails. Simplifies a bunch of logic, makes add_data_to_map() always succeed or exit, so make it a void.
* Fold struct block0 into struct partition map. There can be only onekrw2016-01-296-184/+140
| | | | | | 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.
* Add do_dump_map() to make command processing more consistent. Passkrw2016-01-291-3/+12
| | | | | 1/0 (a.k.a. vverbose/not verbose) do do_dump_map() to differentiate P/p.
* Base 10 should be enough for anybody! Allowing hex and octal numberkrw2016-01-291-37/+21
| | | | | | | | 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.
* Warn of partitions extending past the end of the media.krw2016-01-291-1/+7
|
* Tweak printing of partitions. Always show the pblock info in thekrw2016-01-291-25/+7
| | | | | | '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.
* Shorter names means a few whitespace adjustments.krw2016-01-293-23/+18
|
* Rename struct partition_map_header to struct partition_map. No change tokrw2016-01-295-92/+92
| | | | .o files.
* Rename struct partition_map to struct entry. No change to .o files.krw2016-01-293-61/+61
|
* Conform to Apple Mac OS X's behaviour of setting dpme_flags on freekrw2016-01-291-9/+9
| | | | | partitions to 0, and setting them to VALID | ALLOCATED on the map partition.
* Conform to Apple Mac OS X's behaviour of not giving 'Apple_Free'krw2016-01-291-8/+2
| | | | partitions a name. Nuke kFreeName.
* Flip base_order to a LIST().krw2016-01-282-62/+41
|
* Delete a bunch of Morris dancing in delete_partition_from_map().krw2016-01-281-27/+16
| | | | | No need to create a new dpme. Just rename/retype the existing and let combine_entry() suck in any surrounding empty space partitions.
* Hand rolled lists suck. First, replace disk_order with an LIST.krw2016-01-284-80/+43
|
* Oops. Deleted one too many lines. Need to advance pointer when traversingkrw2016-01-281-1/+2
| | | | list.
* When adding a new partition to the map, use only existing mappedkrw2016-01-281-47/+2
| | | | | 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.
* Since we don't allow maps to be created or opened with an invalidkrw2016-01-282-17/+5
| | | | | block0, there is no point in checking later if block0 has magically become invalid.
* Use consistent 'return' idiom -- no parenthesis since that was the stylekrw2016-01-284-14/+14
| | | | of the existing code.
* more tweaks; ok krwjmc2016-01-281-4/+7
|
* Tweak verbiage for 'r' (reorder) command.krw2016-01-282-5/+6
|
* Make 'r' (reorder, a.k.a. swap) command work with any two existingkrw2016-01-281-12/+31
| | | | partitions. Do NOT allow partition 1 to be moved!
* Traverse next_by_base when checking maps coverage, not next_on_disk!krw2016-01-271-4/+4
|
* No need to copy dmpe_name to a buffer before printing it.krw2016-01-271-10/+3
|
* Clear out some repetitive and pointless verbiage. Shuffle otherkrw2016-01-271-41/+22
| | | | verbiage around to make things clearer.
* Tweak some verbiage.krw2016-01-272-10/+10
|
* make sure to check malloc(3) return pointer against NULL.gsoares2016-01-271-1/+3
| | | | OK krw@
* tweak previous; ok krwjmc2016-01-271-1/+2
|