summaryrefslogtreecommitdiff
path: root/sys/kern/subr_disk.c
AgeCommit message (Collapse)Author
2015-09-25Don't immediately try to checksum the GPT header using the sizeKenneth R Westerback
field from the GPT header being checksum'd. First make sure the size is in a valid range. In particular ensure it won't cause crc32() to run off the end of the GPT header being checksum'd. Also check GPT signature and version first. These checks were inadvertantly moved after the checksumming. This should fix the system crash reported by Ze Loff on bugs@.
2015-09-24Move declaration of readdisksector() to disklabel.h. This makes itKenneth R Westerback
available to other areas of the kernel suffering from an overburden of buf tweaking to read a disk sector. ok mpi@
2015-09-24A couple of missing letoh32() conversions of GPT header fields inKenneth R Westerback
gpt_chk_hdr() and gpt_chk_parts(). Spotted when investigating zeloff's GPT bug report.
2015-09-15Unbeak boot from GPT partition. Reported by Henrik Friedrichsen.YASUOKA Masahiko
ok krw
2015-09-13Move prototype for spoofgptlabel() from disklabel.h to subr_disk.c.Kenneth R Westerback
It's a helper function for readdoslabel(). Not something called outside of subr_disk.c.
2015-09-13Rename readgptlabel() to spoofgptlabel() because that's what weKenneth R Westerback
really want it to do. Handle all the actual disklabel reading in readdoslabel(). Makes the code much simpler to understand. ok deraadt@
2015-09-11Hoist all the GPT header checks into gpt_chk_header(). Tweak remainingKenneth R Westerback
logic a bit so that an invalid primary header/partition entries table does not cause readgptlabel() to exit before the secondary header is tried.
2015-09-11Move all prototypes of gpt helper functions to top of file. RenameKenneth R Westerback
get_fstype() to gpt_get_fstype() as it moves.
2015-09-11Shuffle some variables around, add a couple, and eliminate hordesKenneth R Westerback
of repeated lehto32() and lehtoh64() in readgptlabel() to make code more readable.
2015-09-11Move initialization of count of spoofed GPT partitions closerKenneth R Westerback
to use.
2015-09-11GPT partitions cannot start at offset 0. Eliminate the variableKenneth R Westerback
tracking our discovery of the first OpenBSD partition (ourpart) and just use the variable holding the offset of the first OpenBSD partition (gptpartoff). Move initialization of gptpartoff and gptpartend closer to their use and set them when the first OpenBSD partition is found. Thus eliminating a later 'if' statement.
2015-09-11KNF shuffling of local declarations in readgptlabel().Kenneth R Westerback
2015-09-11readgptlabel() is called from readdoslabel() so there is no needKenneth R Westerback
for readgptlable() to re-check that the label d_secpercyl and d_secsize are not 0.
2015-09-11Spoof EFI SYSTEM GPT partitions as MSDOS partitions. As is doneKenneth R Westerback
with MBR EFI SYSTEM partitions.
2015-09-11Eliminate use-once variable in readgptlabel() and just use theKenneth R Westerback
function value the variable was being set to.
2015-09-11Don't spoof GPT OpenBSD partitions. Simply record and use the first oneKenneth R Westerback
found, as is done in MBR processing.
2015-09-10Now that the GPT code tries really hard not to get in the way andKenneth R Westerback
accidentally capture disks ... Eliminate kernel option GPT and associated #ifdef GPT/#endif. Let everybody get on the GPT bandwagon and we'll see what wheels fly off. Requested by & ok deraadt@
2015-09-10Call readgptlabel() from readdoslabel() instead of MD readdisklabel().Kenneth R Westerback
Call it if and only if there is an MBR on sector 0 that contains 1 and only 1 partition; that partition is an EFI partition; and it covers the entire disk or as much of the disk as can be covered in an MBR partition. Be paranoid about restoring any possible tweaks to the label being built in the case that readgptlabel() fails, and in that case return to the readdoslabel() code. ok deraadt@
2015-09-10Don't stop spoofing GPT partitions when the OpenBSD partition isKenneth R Westerback
found. Keep going until we spoof 8 or run out of partitions needing spoofing.
2015-09-09No need to set d_npartitions in readdoslabel() or readgptlabel().Kenneth R Westerback
It has already been initialized in the MD readdisklabel() routines when they call initdisklabel(). ok deraadt@
2015-09-01a white space krw could not seeTheo de Raadt
2015-09-01'bogous' is bogus spelling of 'bogus' in debug message.Kenneth R Westerback
2015-09-01Missing letoh64() when checking value of gh_lba_alt.Kenneth R Westerback
2015-08-31Abstract 5 identical code blocks into a readdisksector() function.Kenneth R Westerback
Cleaner, clearer and less error prone. Tested by bmercer@ as part of a larger diff, of which this is the last part. reads ok to jsing@ kettenis@. ok deraadt@.
2015-08-31Rejig the the expression calculating of the address of the diskKenneth R Westerback
sector containing the disklabel, eliminating an unnecessary " * DL_BLKSPERSEC()". Tested by bmercer@ as part of larger diff. Idea from & reads ok to jsing@. ok kettenis@.
2015-08-30In readgptlabel() avoid pointless conversions from sector countsKenneth R Westerback
to daddr_t counts and back again. And rename 'part_blkno' to 'sector' to mirror readdoslabel() changes and make code clearer. Reads ok to jsing@ and kettenis@. Tested by bmercer@ as part of larger diff.
2015-08-30Eliminate a couple of extraneous DL_SECTOBLK() calls.Kenneth R Westerback
The disklabel is either 0 bytes into a 512-byte disk sector, or 512 bytes into a larger disk sector. The address of the disk sector read is irrelevant. Pointed out by jsing@ I think. ok deraadt@
2015-08-29In readgptlabel() the block offsets of the GPT header and GPT partitionKenneth R Westerback
entries within a disk sector are always 0. i.e. both must start on a sector boundary. So stop calculating the offset value and adding it to b_data when pulling data out of the buf. Part of larger refactoring, eyed by jsing@, tested by bmercer@ as part of that larger diff.
2015-08-28Move label 'offset' calculation out of the buf setup logic andKenneth R Westerback
closer to where it is used. It isn't part of the setup and we want to abstract the setup. ok deraadt@
2015-08-28Rename 'part_blkno' to 'sector' as it has not held DEV_BSIZE values inKenneth R Westerback
some time. ok deraadt@
2015-08-26Enhance setdisklabel() to ensure that the disk size and 'C'Kenneth R Westerback
partition information of the in-memory disklabel remains correct. ok deraadt@
2015-08-24Fix GPT code to work with non-DEV_BSIZE disks.Kenneth R Westerback
Part of GPT refactoring that was backed out at c2k15. ok deraadt@
2015-08-12Remove last two 'uses' of d_subtype in tree. No point in settingKenneth R Westerback
it to 0 immediately after a bzero() of the entire label. Nor in swapping endianness since nobody looks at it. Don't touch the actual field in disklabel. Yet. ok deraadt@ as part of larger diff that needs splitting up.
2015-07-29Zap a couple of extra blank lines that keep showing up in diffs I'mKenneth R Westerback
trying to build.
2015-07-28Convert sectors to DEV_BSIZE block values were necessary to find,Kenneth R Westerback
read and validate disklabels on GPT partitioned disks. Makes it much more likely GPT partitioned disks with non-512-byte sectors will work. Part of the larger reverted GPT work. ok deraadt@
2015-07-26Always initialize the b_error field and B_ERROR flag before usingKenneth R Westerback
a buf. Otherwise stale data might cause a successful I/O to be seen as a failed I/O. ok tedu@
2015-07-23Revert attempted GPT code cleanup. Too much code, too little testing.Kenneth R Westerback
Requested by deraadt@
2015-05-09Cleanup/rejig GPT code to be more readable, support different endianKenneth R Westerback
archs and different sized disk sectors. Make MBR have higher priority than GPT. Add many paranoia checks and associated DPRINTF's to make further development easier. Keep everything hidden behind #ifdef GPT. Tested and ok doug@ mpi@. Nothing bad seen by millert@.
2015-03-15Bring back '#include <lib/libz/zlib.h>', but inside #ifdev GPT. GPTKenneth R Westerback
routines use crc32(). ok jsg@ doug@
2015-03-14Remove some includes include-what-you-use claims don'tJonathan Gray
have any direct symbols used. Tested for indirect use by compiling amd64/i386/sparc64 kernels. ok tedu@ deraadt@
2015-01-27remove the second void * argument on tasks.David Gwynne
when workqs were introduced, we provided a second argument so you could pass a thing and some context to work on it in. there were very few things that took advantage of the second argument, so when i introduced pools i suggested removing it. since tasks were meant to replace workqs, it was requested that we keep the second argument to make porting from workqs to tasks easier. now that workqs are gone, i had a look at the use of the second argument again and found only one good use of it (vdsp(4) on sparc64 if you're interested) and a tiny handful of questionable uses. the vast majority of tasks only used a single argument. i have since modified all tasks that used two args to only use one, so now we can remove the second argument. so this is a mechanical change. all tasks only passed NULL as their second argument, so we can just remove it. ok krw@
2014-12-30Rework disklabel reading taskq to plug holes pointed out by jsing@.Kenneth R Westerback
Diff from dlg@. ok jsing@
2014-12-28Replace last workq in tree (reading disklabels from newly attachedKenneth R Westerback
disks) with taskq. Diff originally from blambert@. ok kettenis@
2014-12-20Zap a sneaky trailing blank that was hiding in plain view.Kenneth R Westerback
2014-12-20Zap local variable that shadows another local variable. Fixes a panic causedMark Kettenis
by passing random stack garbage as the size to free(9). From David Imhoff
2014-12-20Zap a bunch of leading/trailing whitespace.Kenneth R Westerback
2014-12-16primary change: move uvm_vnode out of vnode, keeping only a pointer.Ted Unangst
objective: vnode.h doesn't include uvm_extern.h anymore. followup changes: include uvm_extern.h or lock.h where necessary. ok and help from deraadt
2014-11-03correct test logic. ok guentherTed Unangst
2014-11-03deobfuscate by pulling le conversions up. use mallocarray.Ted Unangst
2014-11-03pass size argument to free()Theo de Raadt
ok doug tedu