summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_disk.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Don't immediately try to checksum the GPT header using the sizekrw2015-09-251-15/+10
| | | | | | | | | | 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@.
* Move declaration of readdisksector() to disklabel.h. This makes itkrw2015-09-241-3/+1
| | | | | | | available to other areas of the kernel suffering from an overburden of buf tweaking to read a disk sector. ok mpi@
* A couple of missing letoh32() conversions of GPT header fields inkrw2015-09-241-3/+4
| | | | | | gpt_chk_hdr() and gpt_chk_parts(). Spotted when investigating zeloff's GPT bug report.
* Unbeak boot from GPT partition. Reported by Henrik Friedrichsen.yasuoka2015-09-151-2/+2
| | | | ok krw
* Move prototype for spoofgptlabel() from disklabel.h to subr_disk.c.krw2015-09-131-1/+2
| | | | | It's a helper function for readdoslabel(). Not something called outside of subr_disk.c.
* Rename readgptlabel() to spoofgptlabel() because that's what wekrw2015-09-131-63/+39
| | | | | | | really want it to do. Handle all the actual disklabel reading in readdoslabel(). Makes the code much simpler to understand. ok deraadt@
* Hoist all the GPT header checks into gpt_chk_header(). Tweak remainingkrw2015-09-111-60/+64
| | | | | | logic a bit so that an invalid primary header/partition entries table does not cause readgptlabel() to exit before the secondary header is tried.
* Move all prototypes of gpt helper functions to top of file. Renamekrw2015-09-111-7/+7
| | | | get_fstype() to gpt_get_fstype() as it moves.
* Shuffle some variables around, add a couple, and eliminate hordeskrw2015-09-111-16/+20
| | | | | of repeated lehto32() and lehtoh64() in readgptlabel() to make code more readable.
* Move initialization of count of spoofed GPT partitions closerkrw2015-09-111-2/+3
| | | | to use.
* GPT partitions cannot start at offset 0. Eliminate the variablekrw2015-09-111-11/+10
| | | | | | | | | | 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.
* KNF shuffling of local declarations in readgptlabel().krw2015-09-111-9/+6
|
* readgptlabel() is called from readdoslabel() so there is no needkrw2015-09-111-6/+1
| | | | | for readgptlable() to re-check that the label d_secpercyl and d_secsize are not 0.
* Spoof EFI SYSTEM GPT partitions as MSDOS partitions. As is donekrw2015-09-111-2/+6
| | | | with MBR EFI SYSTEM partitions.
* Eliminate use-once variable in readgptlabel() and just use thekrw2015-09-111-4/+2
| | | | function value the variable was being set to.
* Don't spoof GPT OpenBSD partitions. Simply record and use the first onekrw2015-09-111-2/+4
| | | | found, as is done in MBR processing.
* Now that the GPT code tries really hard not to get in the way andkrw2015-09-101-11/+1
| | | | | | | | | | 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@
* Call readgptlabel() from readdoslabel() instead of MD readdisklabel().krw2015-09-101-1/+59
| | | | | | | | | | | | | 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@
* Don't stop spoofing GPT partitions when the OpenBSD partition iskrw2015-09-101-4/+3
| | | | | found. Keep going until we spoof 8 or run out of partitions needing spoofing.
* No need to set d_npartitions in readdoslabel() or readgptlabel().krw2015-09-091-9/+1
| | | | | | | It has already been initialized in the MD readdisklabel() routines when they call initdisklabel(). ok deraadt@
* a white space krw could not seederaadt2015-09-011-2/+2
|
* 'bogous' is bogus spelling of 'bogus' in debug message.krw2015-09-011-2/+2
|
* Missing letoh64() when checking value of gh_lba_alt.krw2015-09-011-2/+2
|
* Abstract 5 identical code blocks into a readdisksector() function.krw2015-08-311-42/+31
| | | | | | | | | 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@.
* Rejig the the expression calculating of the address of the diskkrw2015-08-311-5/+5
| | | | | | | | | 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@.
* In readgptlabel() avoid pointless conversions from sector countskrw2015-08-301-9/+7
| | | | | | | | 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.
* Eliminate a couple of extraneous DL_SECTOBLK() calls.krw2015-08-301-5/+3
| | | | | | | | 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@
* In readgptlabel() the block offsets of the GPT header and GPT partitionkrw2015-08-291-5/+3
| | | | | | | | | 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.
* Move label 'offset' calculation out of the buf setup logic andkrw2015-08-281-5/+5
| | | | | | | closer to where it is used. It isn't part of the setup and we want to abstract the setup. ok deraadt@
* Rename 'part_blkno' to 'sector' as it has not held DEV_BSIZE values inkrw2015-08-281-11/+11
| | | | | | some time. ok deraadt@
* Enhance setdisklabel() to ensure that the disk size and 'C'krw2015-08-261-1/+7
| | | | | | partition information of the in-memory disklabel remains correct. ok deraadt@
* Fix GPT code to work with non-DEV_BSIZE disks.krw2015-08-241-21/+17
| | | | | | Part of GPT refactoring that was backed out at c2k15. ok deraadt@
* Remove last two 'uses' of d_subtype in tree. No point in settingkrw2015-08-121-2/+1
| | | | | | | | 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.
* Zap a couple of extra blank lines that keep showing up in diffs I'mkrw2015-07-291-3/+1
| | | | trying to build.
* Convert sectors to DEV_BSIZE block values were necessary to find,krw2015-07-281-7/+11
| | | | | | | | | | 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@
* Always initialize the b_error field and B_ERROR flag before usingkrw2015-07-261-3/+5
| | | | | | | a buf. Otherwise stale data might cause a successful I/O to be seen as a failed I/O. ok tedu@
* Revert attempted GPT code cleanup. Too much code, too little testing.krw2015-07-231-253/+192
| | | | Requested by deraadt@
* Cleanup/rejig GPT code to be more readable, support different endiankrw2015-05-091-192/+253
| | | | | | | | | 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@.
* Bring back '#include <lib/libz/zlib.h>', but inside #ifdev GPT. GPTkrw2015-03-151-1/+5
| | | | | | routines use crc32(). ok jsg@ doug@
* Remove some includes include-what-you-use claims don'tjsg2015-03-141-3/+1
| | | | | | | have any direct symbols used. Tested for indirect use by compiling amd64/i386/sparc64 kernels. ok tedu@ deraadt@
* remove the second void * argument on tasks.dlg2015-01-271-4/+4
| | | | | | | | | | | | | | | | | | | | | 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@
* Rework disklabel reading taskq to plug holes pointed out by jsing@.krw2014-12-301-28/+34
| | | | | | Diff from dlg@. ok jsing@
* Replace last workq in tree (reading disklabels from newly attachedkrw2014-12-281-23/+25
| | | | | | disks) with taskq. Diff originally from blambert@. ok kettenis@
* Zap a sneaky trailing blank that was hiding in plain view.krw2014-12-201-2/+2
|
* Zap local variable that shadows another local variable. Fixes a panic causedkettenis2014-12-201-2/+1
| | | | | | by passing random stack garbage as the size to free(9). From David Imhoff
* Zap a bunch of leading/trailing whitespace.krw2014-12-201-10/+10
|
* primary change: move uvm_vnode out of vnode, keeping only a pointer.tedu2014-12-161-5/+5
| | | | | | 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
* correct test logic. ok guenthertedu2014-11-031-2/+2
|
* deobfuscate by pulling le conversions up. use mallocarray.tedu2014-11-031-8/+16
|
* pass size argument to free()deraadt2014-11-031-2/+2
| | | | ok doug tedu