summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_disk.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* Restore previous behaviour - only print the DUID if we used it tojsing2012-01-131-4/+4
| | | | select root.
* If the DUID of the boot disk has not been provided, attempt to locate itjsing2012-01-111-1/+13
| | | | | | | | | | | via the boot device. This allows root on softraid to work on most architectures. For architectures that cannot clearly identify their boot device, the DUID of the boot disk can still be passed from the boot loader, as is already done for amd64 and i386. Based on a suggestion from kettenis@ ok krw@
* Move softraid root mapping to later in the boot process - this will allowjsing2012-01-111-1/+9
| | | | us to play some tricks in setroot().
* Avoid the use of an invalid disklabel by setting a DK_LABELVALID flagjsing2011-12-281-5/+11
| | | | | | | | | if we correctly read and validated the disklabel. Always check that this flag is set before using the DUID from the disklabel. Discussed with deraadt@ ok krw@
* An all-zero DUID is considered to be a blank DUID - ensure that we do notjsing2011-12-281-4/+5
| | | | | | generate one. ok krw@
* Move the prototype for disk_readlabel to the .h file so that hibernatederaadt2011-09-211-2/+1
| | | | | can get at it. ok jsing
* Do not use the `hh' modifier in printf format strings, as the kernel printfmiod2011-09-181-4/+4
| | | | | implementation does not support it and handles it as `h'. ok jsing@
* No need to byte-swap d_checksum just before setting it to zero.krw2011-07-261-2/+1
| | | | ok matthew@
* On several archs (e.g. hppa, sgi, macppc) readdoslabel() is called after an attempt tokrw2011-07-061-2/+3
| | | | | read a native label fails. Reset B_ERROR/b_error on buf to ensure any i/o failure on that first attempt is forgiven. A la the dkcsum() fix to recover from a disk error.
* Eliminate redundant buf validation checks in xxstrategy() methods nowmatthew2011-07-061-2/+2
| | | | | | | | | | | | that they're implemented consistently in bounds_check_with_label(). Also, per krw's request, change bounds_check_with_label() to return 0 if the checks succeed, and change the drivers to test == -1 instead of <= 0. (Man page update to follow; intentionally omitting arch/vax/mba/hp.c from this commit because it doesn't even build currently and miod@ promises to kill it soon.) ok krw@
* Add checks for sector-alignment and whole number of sectors tomatthew2011-07-051-17/+24
| | | | | | bounds_check_with_label() and generally cleanup the code while here. ok krw@ ("I like this a *lot*"); "i like it" tedu@
* Refactor some common open/close/detach disk driver code intomatthew2011-06-301-1/+58
| | | | | | subr_disk.c. For now just the MI disk drivers. ok deraadt@, krw@; jsing@ liked the approach too
* Minor cleanup for disk_lock() and disk_unlock().matthew2011-06-191-7/+3
| | | | ok deraadt@
* Add disk_lock_nointr() as a way to acquire the disk lock without beingmatthew2011-06-191-1/+7
| | | | | | interrupted by signals. ok deraadt@
* Kill the "lockname" argument to disk_construct().matthew2011-06-191-3/+3
| | | | ok deraadt@
* Get rid of the wlabel argument to bounds_check_with_label(). It'smatthew2011-06-031-2/+2
| | | | | | | | | never done anything in OpenBSD and just clutters disk drivers with silly flag handling. More cleanup to follow. ok deraadt@, millert@; no objections krw@
* Add device_ref/device_unref calls to prevent a possible use-after-freematthew2011-06-011-1/+6
| | | | | | | | | issue in disk_attach_callback. Assumes that the struct disk is part of the driver's softc, but this is always true in practice. Still other scary use-after-free races lying around here though... ok jsing@, deraadt@
* spacesmarco2011-04-281-4/+4
|
* Allow the root device to be identified via its disklabel UID.jsing2011-04-261-1/+27
| | | | ok deraadt@ marco@ krw@
* Use 'CLR(<buf>->b_flags, B_READ | B_WRITE | B_DONE)' regardless ofkrw2011-04-161-3/+3
| | | | | what the previous IO was. Less chance of copy and paste errors. Suggested by miod@.
* In days of yore one could arbitrarily whack buffer flags. Those dayskrw2011-04-151-3/+5
| | | | | | | | | | | | | are past. Use CLR() and SET() to modify necessary flags while leaving the flags used by the buffer cache in peace. Should make bufcache code much less confused about the state of the bufs used in reading/writing disklabels. Other such flag abuses no doubt await a visit. Errors in original diff found by miod@. ok beck@ deraadt@
* Repair spoofing. We want to start at 'i', not 'j'.krw2011-03-191-6/+2
| | | | Spotted by deraadt@.
* Uncommitted bits. Spotted by deraadt@, who theorizes I have insuffientkrw2011-03-171-2/+2
| | | | sushi level.
* Don't confuse limiting spoofed partitions with limiting how manykrw2011-03-141-5/+9
| | | | | EBRs to follow looking for the OpenBSD partition. Just stop spoofing if necessary.
* Ensure that hw.disknames gets updated whenever a disklabel is set, sincejsing2010-11-241-1/+4
| | | | | | the disklabel UID may have changed. ok krw@ deraadt@
* Do not #include <sys/dkstat.h> if you don't need anything from it.miod2010-11-181-2/+1
| | | | ok krw@ deraadt@
* Fixes before-boot umass hangs on units without media.deraadt2010-09-241-35/+20
| | | | | | | | In disk_readlabel() if the ioctl fails don't forget to close the disk. Avoid sharing a static error buffer between a workq and mountroot since they can compete. Pass the dev_t to the workq inside one of the arguments without a malloc'd object. ok miod dlg krw
* The only sensible argument for VOP_* calls that take a struct proc pointer isoga2010-09-231-3/+3
| | | | | | | | | | | | | | | | | | curproc. A bunch of callers were passing in 0 (not even NULL, 0) as this pointer, which was fine until the called vnode function tried to do something with it. Typically, this code was then copy/pasted to various parts of the tree. Accept the facts of life and switch all of these over to passing curproc for now until the argument can be removed. Discovered by stsp trying to create a softraid on top of a vnd, which crashed with a NULL deref in vndioctl. softraid bits tested by mikeb and jsing. raidframe bits tested by pea, matthieu and naddy. The rest tested by at least thib, jsing and myself. ok thib@, jsing@.
* When a disk is attached create a workq task to read the disklabel,jsing2010-09-231-1/+35
| | | | | | | providing the DKF_NOLABELREAD flag is not set. This provides the kernel with the actual disklabel which includes the disklabel UID. ok deraadt@ miod@ krw@
* Introduce a disk_lookup() function which calls device_lookup(), beforejsing2010-09-081-1/+26
| | | | | | | | | | | | | verifying that the resulting device is present on the disklist. This avoids a race whereby the disk driver can be accessed as soon as the softc has been allocated, but before the disk has completed initialisation and has called disk_attach() (up until this point dk_label is still a null pointer). Cut cd(4), sd(4) and wd(4) across to disk_lookup(). All callers of disk_attach() need to be tested and cut over in due course. ok deraadt@ krw@
* Store a struct device pointer within struct disk and populate this whenjsing2010-09-081-9/+12
| | | | | | | disk_attach() is called by the device driver. We will be building on this shortly. ok deraadt@ krw@
* Do not panic in parsedisk() for ``second class'' block devices (which we can'tmiod2010-09-011-2/+2
| | | | root off), return NULL instead.
* Add a device number to struct disk and populate it on disk attach. Whilstjsing2010-08-301-1/+11
| | | | | | here also expose disklist for future use. ok deraadt@ miod@
* - fix compilation of kernel without FFS...don't ask ;-)jasper2010-08-181-3/+3
| | | | ok jsing@
* Factor out code used to read a disklabel. We'll be making use of this soon.jsing2010-06-271-28/+56
| | | | ok deraadt@
* Provide a disk_map() function which attempts to map a disklabel UID to thejsing2010-05-031-4/+74
| | | | | | | actual device. If successful, the real path is returned via mappath. Soon to be used by several other diffs. ok krw@
* When setting a disklabel automatically generate a new UID if it does notjsing2010-04-281-2/+17
| | | | | | already have one. ok krw@
* introducing a 64-bit type to the disklabel structure leads some architecturesderaadt2010-04-251-2/+2
| | | | | | | to pad-align the size of the structure; it grows, the disklabel ioctl's are break ABI. Change the uid to a character array. this also simplifies some other stuff ok jsing
* Recycle unused disklabel fields in order to create a disklabel uniquejsing2010-04-231-5/+2
| | | | | | | identifier, allowing the disk to be identified without relying on the device name. ok deraadt@ krw@ beck@ marco@ todd@
* fix typos in comments, no code changes;schwarze2010-01-141-2/+2
| | | | | from Brad Tilley <brad at 16systems dot com>; ok oga@
* Negative offset or negative size in a buf is invalid. Treat just like otherkrw2010-01-111-6/+3
| | | | | | invalid offsets and sizes: reject the i/o. ok deraadt@ beck@
* Replace the error strings that were being passed around with much simplerderaadt2009-08-131-25/+27
| | | | | | | | | errnos. Note that the error strings are being ignored, since we long ago decided to not spam the console, and there is no other nice way to use the errors (without changing the ioctls to pass it back) The errno is now useful, since we can pass b_error from failing IO up, and the drive can decide how to use that ok miod
* Make dk_mmountroot use vnodes instead of d_open/d_close. This does uglymarco2009-08-091-7/+12
| | | | | | things to softraid. ok jsing thib krw beck oga
* Revert bufq's. this is inline with the major midlayer reverts thatthib2009-06-171-9/+2
| | | | | | have been going on. this appears to bring us back to stable state. lots of testing by oga and ariane and my self.
* Don't mess with the bounds in the lp if *partoffp is non-NULL, since thisderaadt2009-06-141-5/+7
| | | | | | indicates that writedisklabel is trying to find the location for writing the label. If the lp is messed with, an invalid checksum is written. done with miod and kettenis, lots of moaning and gnashing of teeth, etc
* Clamp the ending bound to the size of the disk. This makes disklabel -Aderaadt2009-06-051-3/+3
| | | | still do the right thing if the MBR has a lie in it
* Recycle four ancient fields in the disklabel structure, replacing them withderaadt2009-06-041-11/+14
| | | | | | | | | | | | bounds information, ie. the zone of the disk that OpenBSD can use. Have each pre-disklabel parser (MBR, DPME, or per-arch MD disklabel parsers) figure out this area and pass it up to userland. Then, delete all the same disk parsing code from disklabel(8) since the kernel passes it up. Lots and lots of - signs in the disklabel(8) code. Tested on as many platforms as possible, the fallout will be repaired as time goes on. To test, use disklabel -d <drive> and validate that the bounds do not overlap any boot blocks. This same information is used by disklabel -A... OK for the concept from krw, miod, and drahn
* add a flexible buffer queue (bufq) api, based on the never usedthib2009-06-031-3/+10
| | | | | | | | | one by tedu@. It doesn't do anything smart yet, it just uses plain old disksort. we also keep the old method of queueing bufs since some miods have crazy MD drivers that need some love. ok beck@, art@ tested by many on many archs.
* Add a callback specifically for softraid. If you touch this kittens willmarco2009-06-031-1/+10
| | | | | | be murdered and theo will visit with a 2x4. ok deraadt
* remove the never used bufq_ code.thib2009-06-031-58/+1
| | | | | ok oga@ 'dance for me' blambert@