summaryrefslogtreecommitdiff
path: root/sbin/fdisk
AgeCommit message (Collapse)Author
2015-07-09Nuke unused variable.Kenneth R Westerback
2015-07-08Do not attempt to read a disk sector worth of data from the fileKenneth R Westerback
containing the MBR template. Most especially don't get upset when the 512-byte file does not contain a full 4096 byte disk sector. Allows 4096-byte disks to be fdisk'ed once more. Problem reported and fix tested by Gerald Hanuer via bugs@. ok deraadt@
2015-04-02Don't printf("offset: ...) before every call to MBR_print(). Do itKenneth R Westerback
once inside MBR_print().
2015-03-30Even better -- readsector() and writesector() become DISK_readsector() andKenneth R Westerback
DISK_writesector() and live in disk.[ch].
2015-03-30Nuke declaration of unused and non-existant function MBR_print_disk().Kenneth R Westerback
2015-03-29Rename MBR_readsector() and MBR_writesector() to just readsector()Kenneth R Westerback
and writesector(). Move them to misc.[ch]. Soon to be used for more than MBR reading/writing. No intentional functional change.
2015-03-29A couple of letoh64() to make GPTSIGNATURE test work better onKenneth R Westerback
non-amd64 boxen.
2015-03-28Add a simple crc32() implmentation to avoid pulling in libz, whichKenneth R Westerback
would complicate install media. Will be used by GPT support.
2015-03-27Wrap some annoying long lines.Kenneth R Westerback
2015-03-27Use DOSACTIVE define instead of magic number 0x80.Kenneth R Westerback
2015-03-26Adapt ask_string() from disklabel's getstring(). It will be usedKenneth R Westerback
to obtain GPT partition names. Tweak ask_pid() to take low/high bounds so it can handle 1-ff (MBR) or 1000-ffff (GPT) partition pids as required. A pid of '0' is still special and disables the partition. No visible or intentional functional change.
2015-03-26Allow input/printing/conversion of terabyte sizes. Which GPT partitonsKenneth R Westerback
will eventually be able to use.
2015-03-26Expand internal representation of partition starting LBA and sizeKenneth R Westerback
to 64 bits, adjusting printf()'s, etc. as required. Preparing for GPT partitions. Add 't' size unit. No other intentional functional change.
2015-03-19When zapping the GPT at the end of the disk, don't use disk.sizeKenneth R Westerback
to get the location. disk.size is a 32 bit value for MBR use. Use DL_GETDSIZE(&dl) to get the real location even on 'big' disks.
2015-03-19Nuke now unused variable.Kenneth R Westerback
2015-03-18Stop passing around little used 'struct mbr tt' parameter. JustKenneth R Westerback
make the initial mbr that tt pointed at a global that can be directly accessed in the couple of places it is needed. Fewer parameters, less confusion, no functional change.
2015-03-17Stop passing around little used and superfluous 'offset' parameter.Kenneth R Westerback
Just use the offset recorded/parsed in the struct mbr being used. Can still traverse/edit extended MBRs so offset really wasn't needed. Fewer parameters, less confusion, no functional change.
2015-03-16Stop passing around a pointer to the stack variable 'disk' in main().Kenneth R Westerback
There is only one disk being worked on, so just make it a global. Fewer parameters, less confusion, no functional change.
2015-03-16Document that -i/-u are mutually exclusive and clean up the relatedKenneth R Westerback
code a bit. ok deraadt@ igor@ (with suggested tweak that is coming)
2015-03-14Whitespace & KNF tweaks. Change functions whose return values areKenneth R Westerback
not checked to void. Use continue inside a do loop instead of a goto to the top. Move a #define/#undef more local to use. Eliminate some lint. General cleanup of things noticed preparing the big churn. No intentional functional change.
2015-03-14Zap unused variable.Kenneth R Westerback
Diff from chl@. Committing now so it doesn't get lost in upcoming megachurn.
2015-03-14Switch all the license blocks to the standard OpenBSD/ISC license.Kenneth R Westerback
With the permission of Toby. ok deraadt@
2015-02-10If 'write' is issued after a 'reinit' command, and the MBR to beKenneth R Westerback
written does not contain an EFI partition, zap any GPT signature found on the 2nd (LBA 1) and last sectors on the disk. The install script uses this sequence. This is a temporary workaround until more GPT support is imported post-5.7. Should fix at least some machines who insist on using the GPT even after we have overritten the 'protective' MBR. ok deraadt@ tedu@ beck@ millert@
2015-02-09Rename 'm_flag' to 'e_flag' since it's '-e' that sets it. RenameKenneth R Westerback
'User_modify' to 'USER_edit' for the same reason.
2015-01-16Replace <sys/param.h> with <limits.h> and other less dirty headers whereTheo de Raadt
possible. Annotate <sys/param.h> lines with their current reasons. Switch to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where sensible to avoid pulling in the pollution. These are the files confirmed through binary verification. ok guenther, millert, doug (helped with the verification protocol)
2015-01-03Add support for creating a protective MBR for GPT.Joel Sing
Part of a diff by Markus Mueller, which was derived from Bitrig during Google Summer of Code, with further tweaks by me. ok krw@ miod@
2014-05-21Fix 'fdisk -u', a.k.a. MBR_pcopy(), on sparc64 and possibly others.Kenneth R Westerback
gcc's built-in/in-lined memcpy() can't copy elements of a struct dos_partiton array from inside the __packed struct dos_mbr into an 'unpacked' local variable. But copying the whole array works fine. Be consistant and use the same idiom in both places the partition table is parsed. Leave the landisk workaround/hack in place until it can be confirmed it is no longer needed. ok martynas@ after many alternatives crashed and burned.
2014-05-05Ugly workaround for an overoptimistic alignment expectation of dos_partitionMiod Vallat
fields, found the hard way on landisk, to allow the tree to build until a proper fix is devised. ok deraadt@
2014-04-13At some point, we are going to switch the mandoc(1) defaultIngo Schwarze
from -Tascii to -Tlocale, even though not quite yet because there are more important things to do first. But let's already make -Tascii explicit in the build system right now, it is safer anyway.
2014-03-31Use return value constants to make effects clearer than the useKenneth R Westerback
of an intermediate variable. No intended functional change.
2014-03-31Whitespace rectification.Kenneth R Westerback
2014-03-31Nuke [get|put][short|long] and just use letoh[16|32] andKenneth R Westerback
htole[16|32]. This is made possible by a) copying unaligned data (struct dos_partition's) into properly aligned structs and accessing the fields of the same; and b) realizing that gcc is smart enough to access fields in packed struct's *if* it knows it is accessing a packed struct. Even sparc64 finally gave a thumbs up. After several attempts and feedback from deraadt@ and dlg@, it looks good to deraadt@.
2014-03-25Use 'struct dos_partition' variable to access 'struct dos_partition'Kenneth R Westerback
data. Since all the fields but 2 that are specially handled are u_int8_t's there should be no danger from alignment issues. ok dlg@
2014-03-23Change struct mbr signature field type from 'unsigned short' toKenneth R Westerback
'u_int16_t' to be consistant with disklabel.h's struct dos_mbr.
2014-03-22warn() -> warnx() when errno is irrelevant.Kenneth R Westerback
2014-03-20Simplify a bit of code to make sure even -Wall can see the variablesKenneth R Westerback
are not used uninitialized. As a bonus, make variables the same type as the data they are trying to preserve.
2014-03-20Add back various #includes of err.h, unistd.h, ctype.h, ioctl.h toKenneth R Westerback
eliminate multiple 'implicit' declarations introduced by the previous over-zealous #include cleanup. Thanks to to tedu@ for pointing out how -Wall reveals all.
2014-03-20Add back #include <stdlib.h> so strtod() works better. Fixes fdisk onKenneth R Westerback
sparc64 at least. Found when deraadt@ complained about loongson miniroot blowing up.
2014-03-18Sync built-in MBR with current (a.k.a. '2004 Version') ofKenneth R Westerback
/usr/mdec/mbr. Only one instruction changes, a 'cli' becomes 'sti'. ok deraadt@ tedu@
2014-03-17Nuke pointless blank lines, defines, comments and casts. EliminateKenneth R Westerback
#include in *.h files in favour of listing them as required in the *.c files. Fix error message to correctly state that 64 is the minimum value for -l. Use errx() where errno is not relevant. Use 'continue' rather than a label to go back to start of a loop. No intentional functional change.
2014-03-17Un-revert, being careful to not break snap building. Add paranoia checkKenneth R Westerback
for any missing geometry.
2014-03-14Revert last -- broke building snaps.Kenneth R Westerback
2014-03-13Remove some lint -- ARGSUSED.Kenneth R Westerback
Inspired by guenther@.
2014-03-13Merge 'struct DISK_metrics' and 'struct disk' into one, since we don'tKenneth R Westerback
need to record two sets of metric/geometry data. Use 'geometry' instead of 'metrics' in names and comments. Eliminate DISK_getmetrics(). While here, make 64 the minimal valid value for '-l' instead of 1. This avoids the possibility of having 0 cylinders. No intentional functional change. Feedback & tweak from chris@
2014-03-10No need to pass the name of the command to the function that isKenneth R Westerback
implementing that command, a pointer to the command arguments is the only thing needed. No need to have a pointer to the command table in every command, since there is only one table. No need for shiney new stack space for every command name and arguments parsed, since we don't recurse we can just use static memory. No intentional functional change.
2014-03-09Instead of passing around 'char buf[DEV_BSIZE]' buffers, pass aroundKenneth R Westerback
'struct dos_mbr' variables, since that is what the buffers were used for. Removes need to know about DEV_BSIZE and thus include param.h from all files but one so move the param.h #include to that file (mbr.c). Nuke a bunch of local MBR #defines in favour of the disklabel.h ones. Remove a bunch of unneeded #includes, replace the odd malloc/bzero with calloc, replace equally odd bcopy's with memcpy, remove a stray duplicate MBR parsing in MBR_pcopy(). No intentional functional change.
2014-03-08It's silly to check at compile time for DEV_BSIZE == 512.Kenneth R Westerback
ok deraadt@ with gritted teeth on keeping <sys/param.h> for now.
2014-03-07Relieve the code of an overburden of unnecessary typedefKenneth R Westerback
abstraction. Call a 'struct' a 'struct' and not a pony. No functional change. idea ok deraadt@
2014-03-06tweak previous;Jason McIntyre
2014-03-02-l disksize code, to force LBA mode. code by chris, after I suggestedTheo de Raadt
wrapping rows of echo's via fdisk was silly. ok kettenis krw