summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_disk.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* 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@
* Validate the main MBR minimally; if it does not have the AA55 thingy we mustderaadt2009-05-151-7/+11
| | | | | | not read garbage values as partitions... which we then put into the spoofed label... and which would lead disklabel -A to make surprising decisions. earlier versions which did too much validation tested by many
* initialize d_npartitions to MAXPARTITIONS always; ok krwderaadt2009-05-131-2/+2
|
* Discovering an extended MBR partition and setting 'wander' to 1krw2009-05-031-5/+6
| | | | | | | | | should not stop the spoofing process. Setting 'wander' means when we are done with this MBR, read the next one. Problem noted and fix tested by Nick Guenther. ok weingart@ (I think), deraadt@
* use a static and unique string as the disk lock name, so if we're waitingdlg2009-03-281-2/+2
| | | | | | | on the disk lock we can find that code rather than wondering where "sd0" gets passed to tsleep. ok deraadt@
* two more consistency checks for a disklabel, to prevent havoc laterotto2009-02-091-3/+7
| | | | on; prompted by Thorsten Glaser; ok miod@ krw@
* Relax sanity check so any two-byte jmp followed by a NOP, or anykrw2008-11-211-5/+20
| | | | | | | | | | | three-byte jmp will be acceptable as the preamble to a FAT boot sector for the purposes of spoofing an 'i' partition. Problem noted most recently by mbalmer@. Fixes mbalmer@, fkr@ and jmc@'s Nokia E71 phones. "seems silly" tedu@ "disgusting" deraadt@ "makes sense" fkr@ ok jmc@ "looks ok" weingart@
* If partoffp is non-NULL then readdoslabel() is just looking for thekrw2008-08-251-10/+16
| | | | | | | | correct address to write the passed label. Don't spoof partitions while looking for the address, as this could result in an invalid label being written out. "That looks right" deraadt@ "Looks good to me" miod@
* simplification, and repair findblkmajor for name## lookups; ok krwderaadt2008-08-221-7/+11
|
* Admit b_blkno means block number; a block is DEV_BSIZE (a.k.a.krw2008-08-081-10/+13
| | | | | | | | | | | | | | | | | | | | | | 512) bytes; ffs is inextricably tied to using b_blkno and disklabel always uses sectorsize units. Thus use DEV_BSIZE units for all fields describing ffs filesystems and convert to/from sectors where required. This enables the creation and use of ffs filesystems on non-512 byte sectorsize devices. This diff allows i386 and sgi (the two test platforms) to find disklabels that are not on a sectorsize boundary. Same change to further archs coming. This is a no-op on 512-byte sectorsize devices. This work triggered by jsing@'s need to create ffs filesystems on sgi cdroms so we can create cdrom install media for sgi. sgi testing by jsing@ ok jsing@ pedro@ "looks sane" beck@ weingart@
* allow to install and boot the OpenBSD A6 partition and disklabel in anreyk2008-06-251-7/+15
| | | | | | | | | | | | extended DOS partition. the concept of extended partitions is very simple, it is just another mbr at the partition offset (well, the standard "EBR" is a linked list with a few limitations, but this diff works with both variants). this diff has been in the snapshots for a while. with input from weingart@ and krw@ ok deraadt@
* Bring biomem diff back into the tree after the nfs_bio.c fix went in.deraadt2008-06-121-3/+3
| | | | ok thib beck art
* back out biomem diff since it is not right yet. Doing very largederaadt2008-06-111-3/+3
| | | | | | | | file copies to nfsv2 causes the system to eventually peg the console. On the console ^T indicates that the load is increasing rapidly, ddb indicates many calls to getbuf, there is some very slow nfs traffic making none (or extremely slow) progress. Eventually some machines seize up entirely.
* Fix buffer cache pending read statistics by ensuring we can identifybeck2008-06-101-2/+2
| | | | | | | | biowait() reads that do *not* come from the buffer cache - we use the B_RAW flag to identify these at art's suggestion - since it makes sense and the flag was not being used. this just flags all these buffers with B_RAW - biodone already ignores returned buffers marked B_RAW. ok art@
* Buffer cache revampbeck2008-06-101-2/+2
| | | | | | | | | | | | | | | | 1) remove multiple size queues, introduced as a stopgap. 2) decouple pages containing data from their mappings 3) only keep buffers mapped when they actually have to be mapped (right now, this is when buffers are B_BUSY) 4) New functions to make a buffer busy, and release the busy flag (buf_acquire and buf_release) 5) Move high/low water marks and statistics counters into a structure 6) Add a sysctl to retrieve buffer cache statistics Tested in several variants and beat upon by bob and art for a year. run accidentally on henning's nfs server for a few months... ok deraadt@, krw@, art@ - who promises to be around to deal with any fallout
* Make rd act more like a 'normal' disk device, allowing the elimination ofkrw2008-05-231-26/+5
| | | | | | | | | | | 'fakerootdev' hackery. This allows us to bring back miod@'s r1.70 subr_disk.c change to avoid the GENERIC dance when rootdev has been initialized. This in turn re-enables raidframe root devices. Add a nice panic if rootdev can't be initialized, displaying the name of the device that didn't work rather than just blowing up by de-referencing NULL. ok deraadt@
* Compare device names consistantly in parsedisk().krw2008-04-071-2/+2
| | | | ok deraadt@
* nope, sorry, the miod/naddy raidframe change breaks almost all ramdisks.deraadt2008-03-311-3/+6
| | | | | | | | | | the basic idea is that ramdisks boot the same way as swap generic -- this commit also improves the comment in that area. in this case the one outlier is raidframe, and those who use it will no longer be able to put off repairing it -- raidframe must follow the same setroot() / bootdv API that everything else in the system uses. debugged with krw
* Refine "netboot" interface group semantics to indicate the interface wederaadt2008-03-311-1/+15
| | | | | | | booted from to the most precision; preferring the boot device, or if that is not known, the root device discussed with miod and reyk tested by beck