Commit Graph

87 Commits

Author SHA1 Message Date
hannken 9e1aa1e4ed It is not sufficient to have a comment /* Sanity check the size. */,
also check the size is greater than zero and a multiple of DEV_BSIZE.

Reported-by: syzbot+318187e5124846542f8d@syzkaller.appspotmail.com
2023-01-13 15:46:40 +00:00
thorpej 4083ede6c6 malloc(9) -> kmem(9) 2022-09-24 23:16:37 +00:00
msaitoh 8012ca3f0e Remove extra semicolon. 2020-05-14 08:34:17 +00:00
maxv babb6cb124 constify 2020-04-13 08:05:02 +00:00
ad 024332fd3d Mark the cdev MPSAFE too. 2020-01-18 14:02:18 +00:00
hannken 34f2edab48 Add "d_minphys" to "mddkdriver" to make physio() on wedges happy. 2019-08-29 16:20:48 +00:00
hannken eeb3ed56d8 Take "sc_lock" after calling disk_ioctl() to make GPT partitioning work. 2019-05-26 10:22:07 +00:00
christos 0fd2932532 conditionally elide conditional for rump. 2018-03-03 19:26:12 +00:00
riastradh 1f73c3c78a Kill some more extern cfdriver xyz_cd in favour of #include "ioconf.h". 2017-10-28 03:47:24 +00:00
pgoyette 827e59d955 Don't mutex_exit() if we didn't mutex_enter().
Pointed out by coypu. Thanks!
2016-07-27 05:14:40 +00:00
pgoyette 2d03daa3b0 If we're going to check for a NULL pointer, do the check before we
dereference it (to get the lock address).
2016-07-27 01:09:44 +00:00
hannken 0d7df2cb48 Notify disk subsystem of the current geometry.
Ok: Michael van Elst
2016-01-04 16:24:52 +00:00
christos e7ae23fd9e include "ioconf.h" to get the 'void <driver>attach(int count);' prototype. 2015-08-20 14:40:16 +00:00
mlelstv 6f00c789e1 Use C99-style initializers for struct dkdriver. 2015-04-26 15:15:19 +00:00
christos c182898b0d We have three sets of DTYPE_ constants in the kernel:
altq		Drop 		Type
	disklabel	Disk 		Type
	file		Descriptor	Type
(not to mention constants that contain the string DTYPE).
Let's make them two, by changing the disklabel one to be DisK TYPE since the
other disklabel constants seem to do that. Not many userland programs use
these constants (and the ones that they do are mostly in ifdefs). They will
be fixed shortly.
2015-01-02 19:42:05 +00:00
christos c60db2e923 make more drivers use disk_ioctl, and add a dev parameter to it so that
we can merge the "easy" disklabel ioctls to it. Ultimately all this will
go do dk_ioctl once all the drivers have been converted.
2014-12-31 19:52:04 +00:00
dholland f9228f4225 Add d_discard to all struct cdevsw instances I could find.
All have been set to "nodiscard"; some should get a real implementation.
2014-07-25 08:10:31 +00:00
dholland 8c70ef39af Add d_discard to all struct bdevsw instances I could find.
I've set them all to nodiscard. Some of them (wd, dk, vnd, ld,
raidframe, maybe cgd) should be implemented for real.
2014-07-25 08:02:18 +00:00
dholland a68f9396b6 Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.
2014-03-16 05:20:22 +00:00
hannken e331e1e077 No need to detach (and return EBUSY) if dk_openmask is non-zero. 2014-03-13 10:22:35 +00:00
tsutsui 4403aae449 Make sure that disklabel of md(4) device is initialized
in the case where it's configured in MD md_open_hook().

Without this, msdosfs_mountfs() (which is called from msdosfs_mountroot())
will be called with uninitialized disklabel (d_secsize == 0) and
it gets "panic: buf mem pool index 23" later on atari.
This is because getdisksize() doesn't check returned d_secsize value
and msdosfs_mountfs() blindly calls bread(9) with size==0 in that case.

Should be pulled up to netbsd-6 (at least for atari).
2012-06-30 10:52:31 +00:00
hannken 83b532dd44 - Don't detach configured devices on last close.
- No kmem allocation and biodone() under lock (from rmind@netbsd.org).
2010-11-25 08:53:30 +00:00
hannken cec7ede499 Make md(4) mp-safe. 2010-11-23 09:30:43 +00:00
pooka 22506639fc Don't have a COW (Compiler OW) in case there is no kernel_opt. 2010-11-22 21:10:10 +00:00
hannken c7919375e5 Change md(4) to:
- create md devices on first open and destroy on last close.
- add enough disk label support to make DIOCGDINFO and DIOCGPART work.
- add disk_busy()/disk_unbusy() instrumentation.

Ok: David Young <dyoung@netbsd.org>
2010-11-11 11:07:06 +00:00
dyoung 975667d3ea Take care not to dereference a NULL softc. 2010-01-21 02:14:42 +00:00
snj b094016798 Drop 3rd and 4th clauses. OK gwr@ leo@ (copyright holders). 2009-10-22 20:15:45 +00:00
dyoung 974833df66 Make mdopen() and mdclose() maintain the openmask. md_detach()
depends on the openmask to know whether it should either return
EBUSY because the device is open, or tear the device down.

Alan Barrett reports that this fixes kern/41725, in part: it prevents
the UVM fault, and the kernel detaches /dev/md0a after unmounting
/ on /dev/md0a instead of before.
2009-07-28 17:55:27 +00:00
dyoung 9167c17dd5 Add a detachment hook. Detach md(4) at shutdown. 2009-05-19 20:25:41 +00:00
manu c328d568d4 TFTPROOT loads the RAMdisk through TFTP at boot time. It needs the
network to be functionnal, and therefore must be called after
config_finalize(). Unfortunately, config_finalize() attaches md0
through mdattach(), and when tftproot_getfile() attempts to attach it
later by calling mdattach() again, it gets a failure.

This change checks for the RAMdisk size in mdattach(). If it is zero, then
the RAMdisk has not been loaded yet, and nothing is done. It will be
attached later when tftproot_getfile() will call mdattach()
2009-05-04 16:20:41 +00:00
yamt 70de973662 g/c BUFQ_FOO() macros and use bufq_foo() directly. 2009-01-13 13:33:58 +00:00
drochner c4003ef269 more cleanup: the sc_dev backpointer is unused, remove it 2008-06-16 10:27:47 +00:00
cegger 13a6ae7a5f register NULL pmf handlers. md(4) is supposed to not loose / change when resuming from S3. 2008-06-13 20:05:06 +00:00
cegger 9fca1f317d device_t/softc split
while here, remove unused variables and do some other cleanups
with feedback from cube
2008-06-13 19:55:26 +00:00
drochner 29fbb6a62e Replace the weird method to create instances by config_attach_pseudo()
as everyone else does, and remove the private table of instances which
is replaced by the table in the cfdriver.
This could get more cleanup, and I didn't split device/softc yet.
2008-06-11 10:38:44 +00:00
cegger c1886a2781 use aprint_*_dev and device_xname 2008-04-09 05:47:19 +00:00
ad 2af68666da Merge disk init changes from the vmlocking branch. These seperate init /
destroy of 'struct disk' from attach / detach.
2007-10-08 16:41:05 +00:00
ad eb171eaaa7 It's not a good idea for device drivers to modify b_flags, as they don't
need to understand the locking around that field. Instead of setting
B_ERROR, set b_error instead. b_error is 'owned' by whoever completes
the I/O request.
2007-07-29 12:50:17 +00:00
dsl 9a71120654 Default MEMORY_DISK_SERVER to 1 instead of using 'undefined' to mean 1. 2007-07-15 08:40:22 +00:00
christos 53524e44ef Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
christos 168cd830d2 __unused removal on arguments; approved by core. 2006-11-16 01:32:37 +00:00
christos 4d595fd7b1 - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
2006-10-12 01:30:41 +00:00
christos a569a4d291 add missing initializer 2006-09-02 07:01:20 +00:00
thorpej 39cd836ee1 Use device_unit(). 2006-03-28 17:38:24 +00:00
christos 95e1ffb156 merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
yamt aec75b1cc6 - change the way to specify a bufq strategy. (by string rather than by number)
- rather than embedding bufq_state in driver softc,
  have a pointer to the former.
- move bufq related functions from kern/subr_disk.c to kern/subr_bufq.c.
- rename method to strategy for consistency.
- move some definitions which don't need to be exposed to the rest of kernel
  from sys/bufq.h to sys/bufq_impl.h.
  (is it better to move it to kern/ or somewhere?)
- fix some obvious breakage in dev/qbus/ts.c.  (not tested)
2005-10-15 17:29:10 +00:00
yamt 6b2d8b66a4 merge yamt-km branch.
- don't use managed mappings/backing objects for wired memory allocations.
  save some resources like pv_entry.  also fix (most of) PR/27030.
- simplify kernel memory management API.
- simplify pmap bootstrap of some ports.
- some related cleanups.
2005-04-01 11:59:21 +00:00
perry f31bd063e9 nuke trailing whitespace 2005-02-27 00:26:58 +00:00
yamt 05f25dcc2a move buffer queue related stuffs from buf.h to their own header, bufq.h. 2004-10-28 07:07:35 +00:00
thorpej b560f85cc5 Use ANSI function decls, sprinkle static. 2004-08-30 00:34:41 +00:00