summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_disk.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* kern/subr_disk.c: convert ifunit() to if_unit(9)mvs2021-01-191-3/+5
| | | | ok dlg@
* dev/rndvar.h no longer has statistical interfaces (removed during variousderaadt2020-05-291-2/+1
| | | | | | conversion steps). it only contains kernel prototypes for 4 interfaces, all of which legitimately belong in sys/systm.h, which are already included by all enqueue_randomness() users.
* Simplify logic, the "netboot" interface is always related to `bootdv'.mpi2020-03-131-4/+2
| | | | | | | | Logic is hard, so keep only one of two logically equivalent statements. CID 271085 ok kettenis@, deraadt@, miod@
* tsleep -> tsleep_nsec(9) in setroot()kn2019-12-261-2/+2
| | | | OK cheloha bluhm
* replace add_*_randomness with enqueue_randomness()jasper2018-04-281-3/+3
| | | | | | | | | this gets rid of the source annotation which doesn't really add anything other than adding complexitiy. randomess is generally good enough that the few extra bits that the source type would add are not worth it. ok mikeb@ deraadt@
* fix a memory leak in readdoslabel()jsg2018-03-051-8/+5
| | | | ok krw@
* Turns out gcc complains about %02hhx. So simply use %02x instead. This iskettenis2017-08-071-2/+2
| | | | | | | | | | accepted by both clang and gcc and safe given that varargs arguments are promoted to int anyway. Using %h in the kernel is discouraged anyway according to bluhm@. Unbreaks the tree on gcc architectures. ok pirofti@, bluhm@, florian@
* Use %hhx instead of %hx to print u_char. Silences clang warning.kettenis2017-08-061-2/+2
| | | | ok jca@, florian@
* Also pass the blk offset to disk_unbusy(), so that it can pass it toderaadt2017-05-041-3/+4
| | | | | | the random subsystem as entropy. This value is pretty much unknown, and anyways our entropy input ring does not saturate from knowns. ok mikeb djm
* Tweak lock inits to make the system runnable with witness(4)visa2017-04-201-2/+2
| | | | on amd64 and i386.
* Don't bother with 'ghpartnum' in gpt_chk_hdr(); it's not usedtom2016-09-021-3/+2
| | | | ok krw@
* Fix logic bug in DUID generation - we want to generate DUIDs until we havejsing2016-05-211-2/+2
| | | | | | one that is not a duplicate and not a zero DUID. ok krw@
* Cleanup some of the DUID code and refactor for readability.jsing2016-05-211-28/+48
| | | | ok krw@ kettenis@
* Remove dead assignment/unused variable.jsing2016-05-201-4/+2
|
* Let setroot() pick the boot disk based on the DUID provided in bootduid ifkettenis2016-05-191-2/+10
| | | | | | a boot disk has not been selected by its caller. ok jsing@, millert@
* "exceeds past the end" -> "extends past the end" in comment.krw2016-02-081-2/+2
|
* Make gpt_chk_mbr() instances even more identicaller by alwayskrw2015-12-241-2/+2
| | | | | returning 0 or 1 since only boolean checks of the result are done. No need for EINVAL as a return value.
* Make all instances of gpt_chk_mbr() identical (bar static vskrw2015-12-241-6/+4
| | | | | | non-static) by passing disk size as 2nd parameter instead of the different structures holding the disk size info. The fifth copy of gpt_chk_mbr() in fdisk is a little specialer. No functional change.
* 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@