History log of /freebsd-current/sys/kern/kern_conf.c
Revision Date Author Comments
# fdafd315 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

sys: Automated cleanup of cdefs and other formatting

Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by: Netflix


# a8bd34bf 31-Oct-2023 Zhenlei Huang <zlei@FreeBSD.org>

Giant: Postpone removal of Giant-locked drivers until 15

Reviewed by: imp
MFC after: 1 day
Differential Revision: https://reviews.freebsd.org/D42401


# 67864268 19-Sep-2023 Jason A. Harmening <jah@FreeBSD.org>

devfs: add integrity asserts for cdevp_list

It's possible for misuse of cdev KPIs or for bugs in devfs itself to
result in e.g. a cdev object's container being freed while still on the
global list used to populate each devfs mount; see PR 273418 for a
recent example.

Since a node may be marked inactive well before it is reaped from the
list, add a new flag solely to track list membership, and employ it in
some basic list integrity assertions to catch bad actors.

Discussed with: kib, mjg
MFC after: 1 week


# 685dc743 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix


# 497240de 19-Aug-2022 Mateusz Guzik <mjg@FreeBSD.org>

Retire clone_drain_lock

It is only ever xlocked in drain_dev_clone_events and the only consumer of
that routine does not need it -- eventhandler code already makes sure the
relevant callback is no longer running.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D36268


# 0f50da2e 13-May-2022 Mitchell Horne <mhorne@FreeBSD.org>

Drop d_dump from struct cdevsw

It appears to be unused. These days struct disk has a d_dump member,
which is what gets passed to the kernel dump framework.

Reviewed by: markj
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D35172


# d139909d 18-Apr-2022 John Baldwin <jhb@FreeBSD.org>

destroy_dev_sched*: Don't hold Giant for all deferred destroy_dev.

Rather than using taskqueue_swi_giant which holds Giant for all
deferred destroy_dev calls, create a separate queue for destroyed
devices with D_NEEDGIANT set in the corresponding cdevsw. The task
for this queue holds Giant whild destroying deferred devices while the
task for the default queue does not hold Giant.

In addition, switch to taskqueue_thread for destroy_dev_sched.
Deferred destroy_dev requests don't need to run at an SWI priority.

Reviewed by: imp, markj
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D34915


# 887c753c 07-Jun-2021 Mark Johnston <markj@FreeBSD.org>

Fix handling of D_GIANTOK

It was meant to suppress only the printf(), not the subsequent injection
of Giant-protected thunks for various file operations.

Fixes: fbeb4ccac9
Reported by: pho
Tested by: pho
MFC after: 6 days
Pointy hat: markj


# fbeb4cca 06-Jun-2021 Mark Johnston <markj@FreeBSD.org>

Suppress D_NEEDGIANT warnings for some drivers

During boot we warn that the kbd and openfirm drivers are Giant-locked
and may be deleted. Generally, the warning helps signal that certain
old drivers are not being maintained and are subject to removal, but
this doesn't really apply to certain drivers which are harder to
detangle from Giant.

Add a flag, D_GIANTOK, that devices can specify to suppress the
misleading warning. Use it in the kbd and openfirm drivers.

Reviewed by: imp, jhb
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30649


# 3428b6c0 28-Mar-2021 Mark Johnston <markj@FreeBSD.org>

Fix several dev_clone callbacks to avoid out-of-bounds reads

Use strncmp() instead of bcmp(), so that we don't have to find the
minimum of the string lengths before comparing.

Reviewed by: kib
Reported by: KASAN
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29463


# 00065c76 17-Feb-2021 Warner Losh <imp@FreeBSD.org>

Giant: move back Giant removal until 14

Update the Giant Lock warning message to FreeBSD 14. It's growing increasling
clear that this won't be done before 13.0.

MFC: Insta (re@'s request)


# 79a5c790 15-Jan-2021 Kirk McKusick <mckusick@FreeBSD.org>

Eliminate a locking panic when cleaning up UFS snapshots after a
disk failure.

Each vnode has an embedded lock that controls access to its contents.
However vnodes describing a UFS snapshot all share a single snapshot
lock to coordinate their access and update. As part of mounting a
UFS filesystem with snapshots, each of the vnodes describing a
snapshot has its individual lock replaced with the snapshot lock.
When the filesystem is unmounted the vnode's original lock is
returned replacing the snapshot lock.

When a disk fails while the UFS filesystem it contains is still
mounted (for example when a thumb drive is removed) UFS forcibly
unmounts the filesystem. The loss of the drive causes the GEOM
subsystem to orphan the provider, but the consumer remains until
the filesystem has finished with the unmount. Information describing
the snapshot locks was being prematurely cleared during the orphaning
causing the return of the snapshot vnode's original locks to fail.
The fix is to not clear the needed information prematurely.

Sponsored by: Netflix


# 6fed89b1 01-Sep-2020 Mateusz Guzik <mjg@FreeBSD.org>

kern: clean up empty lines in .c and .h files


# 887611b1 28-Aug-2020 Warner Losh <imp@FreeBSD.org>

Retire devctl_notify_f()

devctl_notify_f isn't needed, so retire it. The flags argument is now
unused, so rather than keep it around, retire it. Convert all old
users of it to devctl_notify(). This path no longer sleeps, so is safe
to call from any context. Since it doesn't sleep, it doesn't need to
know if it is OK to sleep or not.

Reviewed by: markj@
Differential Revision: https://reviews.freebsd.org/D26140


# 773e541e 20-Aug-2020 Warner Losh <imp@FreeBSD.org>

Use devctl.h instead of bus.h to reduce newbus pollution.

There's no need for these parts of the kernel to know about newbus,
so narrow what is included to devctl.h for device_notify_*.

Suggested by: kib@


# 0ac9e27b 11-Aug-2020 Conrad Meyer <cem@FreeBSD.org>

devfs: Abstract locking assertions

The conversion was largely mechanical: sed(1) with:

-e 's|mtx_assert(&devmtx, MA_OWNED)|dev_lock_assert_locked()|g'
-e 's|mtx_assert(&devmtx, MA_NOTOWNED)|dev_lock_assert_unlocked()|g'

The definitions of these abstractions in fs/devfs/devfs_int.h are the
only non-mechanical change.

No functional change.


# 3ff65f71 30-Jan-2020 Mateusz Guzik <mjg@FreeBSD.org>

Remove duplicated empty lines from kern/*.c

No functional changes.


# a02cab33 30-Nov-2019 Mateusz Guzik <mjg@FreeBSD.org>

devfs: introduce a per-dev lock to protect ->si_devsw

This allows bumping threadcount without taking the global devmtx lock.

In particular this eliminates contention on said lock while using bhyve
with multiple vms.

Reviewed by: kib
Tested by: markj
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D22548


# a921c200 23-Nov-2019 Warner Losh <imp@FreeBSD.org>

Add a warning about Giant Locked devices

Add a warning when a device registers with devfs and requests
D_NEEDGIANT. The warning says the device will go away before
13.0. This is needed to flush out the devices in the tree that are
still Giant locked. This warning, or some variant of it, should have
gone into the tree a long time ago...

The intention is to require all devices be converted to not use
automatic giant in this way, or remove any such devices that remain
that we don't have the hardware to test a conversion of.

kbd so far is the only device that can't leave the tree, yet needs
something sensible done to avoid the auto giant lock (even if it is
just doing the wrapping itself). There may be others added to this
list... Any discussions of this topic will take place on arch@.


# e3f35d56 05-Oct-2019 Kyle Evans <kevans@FreeBSD.org>

Remove the remnants of SI_CHEAPCLONE

SI_CHEAPCLONE was introduced in r66067 for use with cloned bpfs. It was
later also used in tty, tun, tap at points. The rough timeline for being
removed in each of these is as follows:

- r181690: bpf switched to use cdevpriv API by ed@
- r181905: ed@ rewrote the TTY later to be mpsafe
- r204464: kib@ removes it from tun/tap, declaring it unused

I've not yet been able to dig up any other consumers in the intervening 9
years. It is no longer set on any devices in the tree and leaves an
interesting situation in make_dev_sv where we're ok with the device already
being set SI_NAMED.


# d42fecb5 05-Oct-2019 Kyle Evans <kevans@FreeBSD.org>

kern_conf: fully initialize cloned devices with make_dev_args, too

Attempting to initialize si_drv{1,2} with mda_si_drv{1,2} does not work if
you are operating on cloned devices.

clone_create must be called prior to the make_dev* family to create/return
the device on the clonelist as needed. This device is later returned early
in newdev(), prior to si_drv{0,1,2} initialization.

This patch simply breaks out of the loop if we've found a device and
finishes init.

Reviewed by: kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D21904


# e5ac3049 26-Jan-2019 Konstantin Belousov <kib@FreeBSD.org>

Bump SPECNAMELEN to MAXNAMLEN.

This includes the bump for cdevsw d_version. Otherwise, the impact on
the ABI (not KBI) is surprisingly low. The most important affected
interface is devname(3) and ttyname(3) which already correctly handle
long names (and ttyname(3) should not be affected at all).

Still, due to the d_version bump, I argue that the change is not MFC-able.

Requested by: mmacy
Reviewed by: jhb
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D18932


# ec86f8b2 20-Oct-2018 Conrad Meyer <cem@FreeBSD.org>

dev_refthread: Do not initialize *ref when reference was not acquired

Like the companion API devvn_refthread, leave *ref uninitialized when a
reference was not acquired. Initializing to 1 provides a vaguely
correct-looking but bogus value for broken callers to (mistakenly) pass to
dev_relthread() when refthread fails.

Make it even more clear to consumers that dev_relthread is only valid when
dev_refthread succeeds.

Reviewed by: kib, markj
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D16885


# 6fa5abfd 18-May-2018 Matt Macy <mmacy@FreeBSD.org>

conf: revert last change and annotate unused var instead


# 926cfdb8 18-May-2018 Matt Macy <mmacy@FreeBSD.org>

make_dev: avoid unused assignments on non debug builds


# 8a36da99 27-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

sys/kern: adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.


# e3d4c4dc 12-Dec-2016 Edward Tomasz Napierala <trasz@FreeBSD.org>

Undo r309891. Konstantin is right in that this condition normally
cannot happen - the um_dev field is assigned at mount and never written
to afterwards.


# 223cb0e4 12-Dec-2016 Edward Tomasz Napierala <trasz@FreeBSD.org>

Avoid dereferencing NULL pointers in devtoname(). I've seen it panic,
called from ufs_print() in DDB.

MFC after: 1 month


# 48ce5d4c 07-Jan-2016 Konstantin Belousov <kib@FreeBSD.org>

Provide yet another KPI for cdev creation, make_dev_s(9).

Immediate problem fixed by the new KPI is the long-standing race
between device creation and assignments to cdev->si_drv1 and
cdev->si_drv2, which allows the window where cdevsw methods might be
called with si_drv1,2 fields not yet set. Devices typically checked
for NULL and returned spurious errors to usermode, and often left some
methods unchecked.

The new function interface is designed to be extensible, which should
allow to add more features to make_dev_s(9) without inventing yet
another name for function to create devices, while maintaining KPI and
even KBI backward-compatibility.

Reviewed by: hps, jhb
Sponsored by: The FreeBSD Foundation
MFC after: 3 weeks
Differential revision: https://reviews.freebsd.org/D4746


# 2793ea13 22-Mar-2015 Hans Petter Selasky <hselasky@FreeBSD.org>

Fix for out of order device destruction notifications when using the
delist_dev() function. In addition to this change:
- add a proper description of this function
- add a proper witness assert inside this function
- switch a nearby line to use the "cdp" pointer instead of cdev2priv()

MFC after: 3 days


# 3b50dff5 19-Jan-2015 Konstantin Belousov <kib@FreeBSD.org>

Stop enforcing additional reference on all cdevs, which was introduced
in r277199. Acquire the neccessary reference in delist_dev_locked()
and inform destroy_devl() about it using CDP_UNREF_DTR flag.

Fix some style nits, add asserts.

Discussed with: hselasky
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week


# d2955419 14-Jan-2015 Hans Petter Selasky <hselasky@FreeBSD.org>

Avoid race with "dev_rel()" when using the recently added
"delist_dev()" function. Make sure the character device structure
doesn't go away until the end of the "destroy_dev()" function due to
concurrently running cleanup code inside "devfs_populate()".

MFC after: 1 week
Reported by: dchagin@


# 07dbde67 14-Jan-2015 Hans Petter Selasky <hselasky@FreeBSD.org>

Add a kernel function to delist our kernel character devices, so that
the device name can be re-used right away in case we are destroying
the character devices in the background.

MFC after: 4 days
Reported by: dchagin@


# dde58752 17-Dec-2014 Gleb Kurtsou <gleb@FreeBSD.org>

Adjust printf format specifiers for dev_t and ino_t in kernel.

ino_t and dev_t are about to become uint64_t.

Reviewed by: kib, mckusick


# 9e8bd2ac 22-Oct-2013 Alexander Motin <mav@FreeBSD.org>

Remove global device lock acquisition from dev_relthread(), replacing it
with atomics on per-device data.


# b1e1f725 22-Dec-2012 Jaakko Heinonen <jh@FreeBSD.org>

Reject spaces and double quotation marks in device names. devctl(4)
and devd(8) can't handle names with such characters properly.

PR: bin/144736, kern/161912
Discussed with: imp, kib, pjd


# fa4dd278 28-Aug-2012 Ed Schouten <ed@FreeBSD.org>

Remove unused SI_* flags.

The SI_DEVOPEN, SI_CONSOPEN and SI_CANDELETE flags are not used by any
piece of code in the tree.


# f39f73f4 16-Aug-2012 John Baldwin <jhb@FreeBSD.org>

Remove D_NEEDGIANT from dead_devsw. biofinish() (and thus dead_strategy)
does not need Giant.

MFC after: 1 month


# 20654f4e 24-May-2012 Alexander Motin <mav@FreeBSD.org>

MFprojects/zfsd:
Hide warning behind bootverbose. Average user has nothing to do about it.


# 2dadbd3d 15-May-2012 Alexander Motin <mav@FreeBSD.org>

Hide warning message under bootverbose. It is impossible for user to do
anything about it.


# 852b05c5 10-Feb-2012 Ed Schouten <ed@FreeBSD.org>

Remove unneeded newline. It fits in 80 columns now.

Pointed out by: jh


# 8fac9b7b 09-Feb-2012 Ed Schouten <ed@FreeBSD.org>

Merge si_name and __si_namebuf.

The si_name pointer always points to the __si_namebuf member inside the
same object. Remove it and rename __si_namebuf to si_name.


# 268e76d8 22-Dec-2011 John Baldwin <jhb@FreeBSD.org>

Use TASK_INITIALIZER() for dev_dtr_task rather than a dedicated SYSINIT().


# 4d651f4e 10-Nov-2011 Konstantin Belousov <kib@FreeBSD.org>

Style.

MFC after: 1 week


# f403cfb1 10-Nov-2011 Konstantin Belousov <kib@FreeBSD.org>

Guard against the unlikely case of the alias path containing the '%' symbols.

Reported by: arundel
MFC after: 1 week


# 889dffba 30-Jul-2011 Konstantin Belousov <kib@FreeBSD.org>

Fix the devmtx lock leak from make_dev(9) when the old device cloning
failed due to invalid or duplicated path being generated.

Reviewed by: jh
Approved by: re (kensmith)
MFC after: 1 week


# aa76615d 14-Jun-2011 Justin T. Gibbs <gibbs@FreeBSD.org>

sys/sys/conf.h:
sys/kern/kern_conf.c:
Add make_dev_physpath_alias(). This interface takes
the parent cdev of the alias, an old alias cdev (if any)
to replace with the newly created alias, and the physical
path string. The alias is visiable as a symlink to the
parent, with the same name as the parent, rooted at
physpath in devfs.

Note: make_dev_physpath_alias() has hard coded knowledge of the
Solaris style prefix convention for physical path data,
"id1,". In the future, I expect the convention to change
to allow "physical path quality" to be reported in the
prefix. For example, a physical path based on NewBus
topology would be of "lower quality" than a physical path
reported by a device enclosure.

Sponsored by: Spectra Logic Corporation


# dbe66680 18-May-2011 Konstantin Belousov <kib@FreeBSD.org>

The CDP_ACTIVE flag is cleared at the beginning of destroy_devl(),
and destroy_devl() drops dev_mtx. The protection against the race
with dev_rel(), introduced in r163328, should be extended to cover
destroy_devl() calls for the children of the destroyed dev.

Reported and tested by: joerg
MFC after: 1 week


# b50a7799 03-May-2011 Andrey V. Elsukov <ae@FreeBSD.org>

Add make_dev_alias_p() function. It is similar to make_dev_alias(),
but it may return an error like make_dev_p() does.

Reviewed by: kib (previous version)
MFC after: 2 weeks


# 0bad52e1 11-Dec-2010 Hans Petter Selasky <hselasky@FreeBSD.org>

Fix race in devfs by using LIST_FIRST() instead of
LIST_FOREACH_SAFE() when freeing the devfs private
data entries.

Reviewed by: kib
MFC after: 3 days
Approved by: thompsa (mentor)


# ff91cc99 07-Nov-2010 Jaakko Heinonen <jh@FreeBSD.org>

Add missing curly brackets. By chance, the missing brackets didn't alter
the code behavior.

Submitted by: Lucius Windschuh


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# 68f7a013 07-Oct-2010 Jaakko Heinonen <jh@FreeBSD.org>

Check the device name validity on device registration.

A new function prep_devname() sanitizes a device name by removing
leading and redundant sequential slashes. The function returns an error
for names which already exist or are considered invalid.

A new flag MAKEDEV_CHECKNAME for make_dev_p(9) and make_dev_credf(9)
indicates that the caller is prepared to handle an error related to the
device name. An invalid name triggers a panic if the flag is not
specified.

Document the MAKEDEV_CHECKNAME flag in the make_dev(9) manual page.

Idea from: kib
Reviewed by: kib


# 6c5e633c 06-Aug-2010 Konstantin Belousov <kib@FreeBSD.org>

Add "show cdev" ddb command.

In collaboration with: pho
MFC after: 1 month


# 3979450b 06-Aug-2010 Konstantin Belousov <kib@FreeBSD.org>

Add new make_dev_p(9) flag MAKEDEV_ETERNAL to inform devfs that created
cdev will never be destroyed. Propagate the flag to devfs vnodes as
VV_ETERNVALDEV. Use the flags to avoid acquiring devmtx and taking a
thread reference on such nodes.

In collaboration with: pho
MFC after: 1 month


# 2e983ace 17-Jun-2010 Ed Schouten <ed@FreeBSD.org>

Remove the unit argument from the recently added make_dev_p().

New code that creates character devices shouldn't use device unit
numbers, but only si_drv[12] to hold pointer to per-device data. Make
this function more future proof by removing the unit number argument.

Discussed with: kib


# 8fa17b79 16-Jun-2010 Jaakko Heinonen <jh@FreeBSD.org>

Correct the function name in a KASSERT.


# f1bb758d 12-Jun-2010 Konstantin Belousov <kib@FreeBSD.org>

Add another variation of make_dev(9), make_dev_p(9), that is allowed
to fail and can return useful error code.

Requested by: jh
Reviewed by: imp, jh
MFC after: 3 weeks


# 76d43557 12-Jun-2010 Konstantin Belousov <kib@FreeBSD.org>

When make_dev_credf(MAKEDEV_WAITOK) is called, use
devctl_notify_f(M_WAITOK) for devfs notifications.

Suggested by: jh
Reviewed by: imp, jh
MFC after: 3 weeks


# c67c645d 20-May-2010 Konstantin Belousov <kib@FreeBSD.org>

MFC r207729:
Add MAKEDEV_NOWAIT flag for make_dev_credf(9).


# d2ba618a 06-May-2010 Konstantin Belousov <kib@FreeBSD.org>

Add MAKEDEV_NOWAIT flag to make_dev_credf(9), to create a device node
in a no-sleep context. If resource allocation cannot be done without
sleep, make_dev_credf() fails and returns NULL.

Reviewed by: jh
MFC after: 2 weeks


# bfc99044 02-Mar-2010 Konstantin Belousov <kib@FreeBSD.org>

MFC r204412:
Fix several style issues.
Define make_dev_credv() as static to match declaration.


# cf141467 27-Feb-2010 Konstantin Belousov <kib@FreeBSD.org>

Fix several style issues.
Define make_dev_credv() as static to match declaration.

MFC after: 3 days


# e2b36efd 29-Jan-2010 Antoine Brodin <antoine@FreeBSD.org>

MFC r201145 to stable/8:
(S)LIST_HEAD_INITIALIZER takes a (S)LIST_HEAD as an argument.
Fix some wrong usages.
Note: this does not affect generated binaries as this argument is not used.

PR: 137213
Submitted by: Eygene Ryabinkin (initial version)


# cfd7bace 29-Dec-2009 Robert Noland <rnoland@FreeBSD.org>

Update d_mmap() to accept vm_ooffset_t and vm_memattr_t.

This replaces d_mmap() with the d_mmap2() implementation and also
changes the type of offset to vm_ooffset_t.

Purge d_mmap2().

All driver modules will need to be rebuilt since D_VERSION is also
bumped.

Reviewed by: jhb@
MFC after: Not in this lifetime...


# 13e403fd 28-Dec-2009 Antoine Brodin <antoine@FreeBSD.org>

(S)LIST_HEAD_INITIALIZER takes a (S)LIST_HEAD as an argument.
Fix some wrong usages.
Note: this does not affect generated binaries as this argument is not used.

PR: 137213
Submitted by: Eygene Ryabinkin (initial version)
MFC after: 1 month


# a6fb7268 29-Oct-2009 John Baldwin <jhb@FreeBSD.org>

MFC 196615:
Extend the device pager to support different memory attributes on different
pages in an object.
- Add a new variant of d_mmap() currently called d_mmap2() which accepts
an additional in/out parameter that is the memory attribute to use for
the requested page.
- A driver either uses d_mmap() or d_mmap2() for all requests but not both.
The current implementation uses a flag in the cdevsw (D_MMAP2) to indicate
that the driver provides a d_mmap2() handler instead of d_mmap(). This
is done to make the change ABI compatible with existing drivers and
MFC'able to 7 and 8.


# 2fa8c8d2 28-Aug-2009 John Baldwin <jhb@FreeBSD.org>

Extend the device pager to support different memory attributes on different
pages in an object.
- Add a new variant of d_mmap() currently called d_mmap2() which accepts
an additional in/out parameter that is the memory attribute to use for
the requested page.
- A driver either uses d_mmap() or d_mmap2() for all requests but not both.
The current implementation uses a flag in the cdevsw (D_MMAP2) to indicate
that the driver provides a d_mmap2() handler instead of d_mmap(). This
is done to make the change ABI compatible with existing drivers and
MFC'able to 7 and 8.

Submitted by: alc
MFC after: 1 month


# 64345f0b 01-Jun-2009 John Baldwin <jhb@FreeBSD.org>

Add an extension to the character device interface that allows character
device drivers to use arbitrary VM objects to satisfy individual mmap()
requests.
- A new d_mmap_single(cdev, &foff, objsize, &object, prot) callback is
added to cdevsw. This function is called for each mmap() request.
If it returns ENODEV, then the mmap() request will fall back to using
the device's device pager object and d_mmap(). Otherwise, the method
can return a VM object to satisfy this entire mmap() request via
*object. It can also modify the starting offset into this object via
*foff. This allows device drivers to use the file offset as a cookie
to identify specific VM objects.
- vm_mmap_vnode() has been changed to call vm_mmap_cdev() directly when
mapping V_CHR vnodes. This avoids duplicating all the cdev mmap
handling code and simplifies some of vm_mmap_vnode().
- D_VERSION has been bumped to D_VERSION_02. Older device drivers
using D_VERSION_01 are still supported.

MFC after: 1 month


# 9995e57b 21-May-2009 Attilio Rao <attilio@FreeBSD.org>

Move the M_WAITOK flag in notify() into an M_NOWAIT one in order to match
the behaviour alredy present with the further malloc() call in
devctl_notify().
This fixes a bug in the CAM layer where the camisr handler finished to
call camperiphfree() (and subsequently destroy_dev() resulting in a new
dev notify) while the xpt lock is held.

PR: kern/130330
Tested by: Riccardo Torrini <riccardo dot torrini at esaote dot com>


# 66723610 15-Apr-2009 Ed Schouten <ed@FreeBSD.org>

Remove dead code from devtoname().

In the good old days it was possible to have dev_t's that referred to
nonexistent devices. In these cases devtoname() automatically generated
names. This is no longer possible, so remove this dead code.

Discussed with: kib


# bce79dbb2 15-Apr-2009 Ed Schouten <ed@FreeBSD.org>

Remove unneeded variable and casting from newdev().

Remove the `udev' variable, which has a different type than the original
function argument and si_drv0. The `udev' name is also misleading,
because it is not the number returned by dev2udev(). Rename this
argument to `unit'. It is the same number as returned by dev2unit().


# d7cbfc1b 15-Apr-2009 Ed Schouten <ed@FreeBSD.org>

Don't use si_drv0 directly.

We should still access si_drv0 using dev2unit(). Also change the
KASSERT() to really print the udev instead of the unit number. I suspect
it's still useful to print the unit number, especially for devices that
use clone lists, so keep the unit number in the panic string.


# 125dcf8c 06-Mar-2009 Konstantin Belousov <kib@FreeBSD.org>

Extract the no_poll() and vop_nopoll() code into the common routine
poll_no_poll().
Return a poll_no_poll() result from devfs_poll_f() when
filedescriptor does not reference the live cdev, instead of ENXIO.

Noted and tested by: hps
MFC after: 1 week


# b7a813fc 27-Nov-2008 Konstantin Belousov <kib@FreeBSD.org>

Explicitely note that destroy_dev() sleeps.

Requested by: ed (some time ago), Jaakko Heinonen <jh saunalahti fi>


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# c6ec8c53 27-Sep-2008 Ed Schouten <ed@FreeBSD.org>

Move uminor() and umajor() to the same place as userspace minor() and major().

The uminor() and umajor() functions have the same use in kernel space as
the minor() and major() functions in userspace. If we ever get rid of
the minor() function in kernel space, we could decide to just expose
minor() and major() to kernel space, making uminor() and umajor()
redundant.

There are two reasons why we want to have uminor() and umajor() in
<sys/types.h>:

- Having them close together prevents them from diverting. Even though
it's unlikely the definitions will change, it's a good habit to have
them at the same place.

- They don't really belong in kern_conf.c. kern_conf.c has been
liberated from dealing with device major and minor number handling.

The device_ids(9) manpage now lists the wrong #include's, because it
should only list <sys/types.h> now. I'm leaving it as it is now, because
I wonder if we should document them anyway. We're probably better off
documenting minor(3) and major(3).


# 6bfa9a2d 27-Sep-2008 Ed Schouten <ed@FreeBSD.org>

Replace all calls to minor() with dev2unit().

After I removed all the unit2minor()/minor2unit() calls from the kernel
yesterday, I realised calling minor() everywhere is quite confusing.
Character devices now only have the ability to store a unit number, not
a minor number. Remove the confusion by using dev2unit() everywhere.

This commit could also be considered as a bug fix. A lot of drivers call
minor(), while they should actually be calling dev2unit(). In -CURRENT
this isn't a problem, but it turns out we never had any problem reports
related to that issue in the past. I suspect not many people connect
more than 256 pieces of the same hardware.

Reviewed by: kib


# edde8745 26-Sep-2008 Ed Schouten <ed@FreeBSD.org>

Rename the `minor' argument of make_dev(9) to `unit'.

To prevent any further confusion about device minor and unit numbers,
we'd better just refer to device unit numbers. Many people still think
the numbers we show inside devfs have any relation to the numbers passed
to make_dev(9), which is not the case.

Discussed with: kib


# d3ce8327 26-Sep-2008 Ed Schouten <ed@FreeBSD.org>

Remove unit2minor() use from kernel code.

When I changed kern_conf.c three months ago I made device unit numbers
equal to (unneeded) device minor numbers. We used to require
bitshifting, because there were eight bits in the middle that were
reserved for a device major number. Not very long after I turned
dev2unit(), minor(), unit2minor() and minor2unit() into macro's.
The unit2minor() and minor2unit() macro's were no-ops.

We'd better not remove these four macro's from the kernel, because there
is a lot of (external) code that may still depend on them. For now it's
harmless to remove all invocations of unit2minor() and minor2unit().

Reviewed by: kib


# bc093719 20-Aug-2008 Ed Schouten <ed@FreeBSD.org>

Integrate the new MPSAFE TTY layer to the FreeBSD operating system.

The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:

- Improved driver model:

The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.

If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.

- Improved hotplugging:

With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).

The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.

- Improved performance:

One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.

Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.

Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan


# ae95dc623 11-Jul-2008 Konstantin Belousov <kib@FreeBSD.org>

Make it atomic for the devfs_populate_loop() to see the setting of
SI_ALIAS flag and initialization of the si_parent when alias is created.
Assert that supplied parent device is not NULL.

Both situations could cause NULL dereference in the
devfs_populate_loop() when creating a symlink for SI_ALIAS'ed device.
Namely, cdp->cdp_c.si_parent may be NULL.

Reported by: mav
MFC after: 2 weeks


# 05427aaf 16-Jun-2008 Konstantin Belousov <kib@FreeBSD.org>

Struct cdev is always the member of the struct cdev_priv. When devfs
needed to promote cdev to cdev_priv, the si_priv pointer was followed.

Use member2struct() to calculate address of the wrapping cdev_priv.
Rename si_priv to __si_reserved.

Tested by: pho
Reviewed by: ed
MFC after: 2 weeks


# 0f03ce1b 12-Jun-2008 Ed Schouten <ed@FreeBSD.org>

Turn dev2unit(), minor(), unit2minor() and minor2unit() into macro's.

Now that we got rid of the minor-to-unit conversion and the constraints
on device minor numbers, we can convert the functions that operate on
minor and unit numbers to simple macro's. The unit2minor() and
minor2unit() macro's are now no-ops.

The ZFS code als defined a macro named `minor'. Change the ZFS code to
use umajor() and uminor() here, as it is the correct approach to do
this. Also add $FreeBSD$ to keep SVN happy.

Approved by: philip (mentor), pjd


# 29d4cb24 11-Jun-2008 Ed Schouten <ed@FreeBSD.org>

Don't enforce unique device minor number policy anymore.

Except for the case where we use the cloner library (clone_create() and
friends), there is no reason to enforce a unique device minor number
policy. There are various drivers in the source tree that allocate unr
pools and such to provide minor numbers, without using them themselves.

Because we still need to support unique device minor numbers for the
cloner library, introduce a new flag called D_NEEDMINOR. All cdevsw's
that are used in combination with the cloner library should be marked
with this flag to make the cloning work.

This means drivers can now freely use si_drv0 to store their own flags
and state, making it effectively the same as si_drv1 and si_drv2. We
still keep the minor() and dev2unit() routines around to make drivers
happy.

The NTFS code also used the minor number in its hash table. We should
not do this anymore. If the si_drv0 field would be changed, it would no
longer end up in the same list.

Approved by: philip (mentor)


# 06d425f9 28-May-2008 Ed Schouten <ed@FreeBSD.org>

Remove the distinction between device minor and unit numbers.

Even though we got rid of device major numbers some time ago, device
drivers still need to provide unique device minor numbers to make_dev().
These numbers are only used inside the kernel. They are not related to
device major and minor numbers which are visible in devfs. These are
actually based on the inode number of the device.

It would eventually be nice to remove minor numbers entirely, but we
don't want to be too agressive here.

Because the 8-15 bits of the device number field (si_drv0) are still
reserved for the major number, there is no 1:1 mapping of the device
minor and unit numbers. Because this is now unused, remove the
restrictions on these numbers.

The MAXMAJOR definition was actually used for two purposes. It was used
to convert both the userspace and kernelspace device numbers to their
major/minor pair, which is why it is now named UMINORMASK.

minor2unit() and unit2minor() have now become useless. Both minor() and
dev2unit() now serve the same purpose. We should eventually remove some
of them, at least turning them into macro's. If devfs would become
completely minor number unaware, we could consider using si_drv0 directly,
just like si_drv1 and si_drv2.

Approved by: philip (mentor)


# 06fe1129 23-May-2008 Konstantin Belousov <kib@FreeBSD.org>

Assert that si_threadcount > 0 before decrementing it. This helps catching
the improper use of the dev_refthread/dev_relthread.

Tested by: pho
MFC after: 1 week


# 82f4d640 21-May-2008 Konstantin Belousov <kib@FreeBSD.org>

Implement the per-open file data for the cdev.

The patch does not change the cdevsw KBI. Management of the data is
provided by the functions
int devfs_set_cdevpriv(void *priv, cdevpriv_dtr_t dtr);
int devfs_get_cdevpriv(void **datap);
void devfs_clear_cdevpriv(void);
All of the functions are supposed to be called from the cdevsw method
contexts.

- devfs_set_cdevpriv assigns the priv as private data for the file
descriptor which is used to initiate currently performed driver
operation. dtr is the function that will be called when either the
last refernce to the file goes away, the device is destroyed or
devfs_clear_cdevpriv is called.
- devfs_get_cdevpriv is the obvious accessor.
- devfs_clear_cdevpriv allows to clear the private data for the still
open file.

Implementation keeps the driver-supplied pointers in the struct
cdev_privdata, that is referenced both from the struct file and struct
cdev, and cannot outlive any of the referee.

Man pages will be provided after the KPI stabilizes.

Reviewed by: jhb
Useful suggestions from: jeff, antoine
Debugging help and tested by: pho
MFC after: 1 month


# 48504cc2 14-May-2008 Konstantin Belousov <kib@FreeBSD.org>

Add the devctl notifications for the cdev create/destroy events.

Based on the submission by: Andriy Gapon <avg icyb net ua>
MFC after: 2 weeks


# 35b45029 02-Apr-2008 Konstantin Belousov <kib@FreeBSD.org>

Add two missed chunks from the rev. 1.210, for the giant_read() and
giant_ioctl().

PR: kern/122287
MFC after: 3 days


# aeeb4202 17-Mar-2008 Konstantin Belousov <kib@FreeBSD.org>

Fix two races in the handling of the d_gianttrick for the D_NEEDGIANT
drivers.

In the giant_XXX wrappers for the device methods of the D_NEEDGIANT
drivers, do not dereference the cdev->si_devsw. It is racing with
the destroy_devl() clearing of the si_devsw. Instead, use the
dev_refthread() and return ENXIO for the destroyed device. [1]

The check for the D_INIT in the prep_cdevsw() was not synchronized with
the call of the fini_cdevsw() in destroy_devl(), that under rapid device
creation/destruction may result in the use of uninitialized cdevsw [2].
Change the protocol for the prep_cdevsw(), requiring it to be called
under dev_mtx, where the check for D_INIT is done.

Do not free the memory allocated for the gianttrick cdevsw while holding
the dev_mtx, put it into the free list to be freed later. Reuse the
d_gianttrick pointer to keep the size and layout of the struct cdevsw
(requested by phk). Free the memory in the dev_unlock_and_free(), and do
all the free after the dev_mtx is dropped (suggested by jhb).

Reported by: bsdimp + many [1], pho [2]
Reviewed by: phk, jhb
Tested by: pho
MFC after: 1 week


# 22cf3475 04-Dec-2007 Andrew Thompson <thompsa@FreeBSD.org>

Apply a workaround for the unkillable jail problem where some devices created
within the jail are never freed. si_cred is only used by the MAC framework so
make the cred reference conditional on it being compiled in, this is not a fix
and will need to be reviewed for any new consumers of si_cred.

This will quell some user complaint when using jails with a default kernel.

Reviewed by: rwatson
MFC after: 3 days


# 196a7385 05-Jul-2007 Konstantin Belousov <kib@FreeBSD.org>

Revert destroy_dev() to the state before destroy_dev_sched() was introduced.
Attempt to spawn destroy_dev_sched() from it causes inadmissible races.

Requested by: tegge
Approved by: re (kensmith)


# 09828ba9 04-Jul-2007 Konstantin Belousov <kib@FreeBSD.org>

Since cdev mutex is after system map mutex in global lock order, free()
shall not be called while holding cdev mutex. devfs_inos unrhdr has cdev as
mutex, thus creating this LOR situation.

Postpone calling free() in kern/subr_unit.c:alloc_unr() and nested functions
until the unrhdr mutex is dropped. Save the freed items on the ppfree list
instead, and provide the clean_unrhdrl() and clean_unrhdr() functions to
clean the list.
Call clean_unrhdrl() after devfs_create() calls immediately before
dropping cdev mutex. devfs_create() is the only user of the alloc_unrl()
in the tree.

Reviewed by: phk
Tested by: Peter Holm
LOR: 80
Approved by: re (kensmith)


# 9d53363b 03-Jul-2007 Konstantin Belousov <kib@FreeBSD.org>

Rev. 1.204 and 1.205 got an erronous version of destroy_dev() that
calls destroy_dev_sched() with cdev mutex locked. Commit the code
that was actually tested.

Pointy hat to: kib
Approved by: re (implicit)


# 6f028193 03-Jul-2007 Konstantin Belousov <kib@FreeBSD.org>

Automatically detect deadlock condition in destroy_dev(), that is, if
destroy_dev() is called from csw method, and no d_purge driver method is
provided. Transform the direct call to destroy_dev() into destroy_dev_sched().

Reviewed by: njl (programming interface)
Debugging help and testing by: Peter Holm
Approved by: re (kensmith)


# de10ffa5 03-Jul-2007 Konstantin Belousov <kib@FreeBSD.org>

Since rev. 1.199 of sys/kern/kern_conf.c, the thread that calls
destroy_dev() from d_close() cdev method would self-deadlock.
devfs_close() bump device thread reference counter, and destroy_dev()
sleeps, waiting for si_threadcount to reach zero for cdev without
d_purge method.

destroy_dev_sched() could be used instead from d_close(), to
schedule execution of destroy_dev() in another context. The
destroy_dev_sched_drain() function can be used to drain the scheduled
calls to destroy_dev_sched(). Similarly, drain_dev_clone_events() drains
the events clone to make sure no lingering devices are left after
dev_clone event handler deregistered.

make_dev_credf(MAKEDEV_REF) function should be used from dev_clone
event handlers instead of make_dev()/make_dev_cred() to ensure that created
device has reference counter bumped before cdev mutex is dropped inside
make_dev().

Reviewed by: tegge (early versions), njl (programming interface)
Debugging help and testing by: Peter Holm
Approved by: re (kensmith)


# 9bc911d4 19-Jun-2007 Konstantin Belousov <kib@FreeBSD.org>

devfs_free() calls free_unr(), that may sleep.
Postpone call to devfs_free() after cdev mutex is dropped. Reuse
cdp_list link for queuing devices awaiting deletion in the
cdevp_free_list.

Reported by: Hans Petter Selasky <hselasky c2i net>
Tested by: Peter Holm
Approved by: re (kensmith)
MFC after: 2 weeks


# 9e223287 31-May-2007 Konstantin Belousov <kib@FreeBSD.org>

Revert UF_OPENING workaround for CURRENT.
Change the VOP_OPEN(), vn_open() vnode operation and d_fdopen() cdev operation
argument from being file descriptor index into the pointer to struct file.

Proposed and reviewed by: jhb
Reviewed by: daichi (unionfs)
Approved by: re (kensmith)


# 217f71d8 02-Feb-2007 Bruce M Simpson <bms@FreeBSD.org>

Use int instead of u_int for the 'extra' argument to the
clone_create() KPI.
This fixes a signedness bug in unit number comparisons.

Submitted by: imp, Landon Fuller
PR: kern/105228
MFC after: 2 weeks


# 1663075c 20-Oct-2006 Konstantin Belousov <kib@FreeBSD.org>

Fix the race between devfs_fp_check and devfs_reclaim. Derefence the
vnode' v_rdev and increment the dev threadcount , as well as clear it
(in devfs_reclaim) under the dev_lock().

Reviewed by: tegge
Approved by: pjd (mentor)


# e0c33ad5 13-Oct-2006 Tor Egge <tegge@FreeBSD.org>

Wait for thread count to reach zero in destroy_devl() even when no purge
method is defined, to avoid memory being modified after free.

Temporarily increase refcount in destroy_devl() to avoid a double free
if dev_rel() is called while waiting for thread count to reach zero.


# d595182f 17-May-2006 Poul-Henning Kamp <phk@FreeBSD.org>

Make the printfs relating to purging threads from a device less intrusive.


# 7d7e053c 12-Jan-2006 Alfred Perlstein <alfred@FreeBSD.org>

Novel idea, don't print a string if it is NULL!

This protects people from loading _really_ old modules, like say from
5.x to a 6.x or 7.x system, like for instance right after an upgrade.


# ba0b6851 04-Jan-2006 Bjoern A. Zeeb <bz@FreeBSD.org>

Minor whitespace cleanup.


# 8c4b6380 18-Oct-2005 John Baldwin <jhb@FreeBSD.org>

Move the initialization of the devmtx into the mutex_init() function
called during early init before cninit().

Tested on: i386, alpha, sparc64
Reviewed by: phk, imp
Reported by: Divacky Roman xdivac02 at stud dot fit dot vutbr dot cz
MFC after: 1 week


# 7bbb3a26 01-Oct-2005 Poul-Henning Kamp <phk@FreeBSD.org>

Make sure the clone lists are sorted in the right order.

Explosion triggered by: pjd
MFC: 3 days


# e606a3c6 19-Sep-2005 Poul-Henning Kamp <phk@FreeBSD.org>

Rewamp DEVFS internals pretty severely [1].

Give DEVFS a proper inode called struct cdev_priv. It is important
to keep in mind that this "inode" is shared between all DEVFS
mountpoints, therefore it is protected by the global device mutex.

Link the cdev_priv's into a list, protected by the global device
mutex. Keep track of each cdev_priv's state with a flag bit and
of references from mountpoints with a dedicated usecount.

Reap the benefits of much improved kernel memory allocator and the
generally better defined device driver APIs to get rid of the tables
of pointers + serial numbers, their overflow tables, the atomics
to muck about in them and all the trouble that resulted in.

This makes RAM the only limit on how many devices we can have.

The cdev_priv is actually a super struct containing the normal cdev
as the "public" part, and therefore allocation and freeing has moved
to devfs_devs.c from kern_conf.c.

The overall responsibility is (to be) split such that kern/kern_conf.c
is the stuff that deals with drivers and struct cdev and fs/devfs
handles filesystems and struct cdev_priv and their private liason
exposed only in devfs_int.h.

Move the inode number from cdev to cdev_priv and allocate inode
numbers properly with unr. Local dirents in the mountpoints
(directories, symlinks) allocate inodes from the same pool to
guarantee against overlaps.

Various other fields are going to migrate from cdev to cdev_priv
in the future in order to hide them. A few fields may migrate
from devfs_dirent to cdev_priv as well.

Protect the DEVFS mountpoint with an sx lock instead of lockmgr,
this lock also protects the directory tree of the mountpoint.

Give each mountpoint a unique integer index, allocated with unr.
Use it into an array of devfs_dirent pointers in each cdev_priv.
Initially the array points to a single element also inside cdev_priv,
but as more devfs instances are mounted, the array is extended with
malloc(9) as necessary when the filesystem populates its directory
tree.

Retire the cdev alias lists, the cdev_priv now know about all the
relevant devfs_dirents (and their vnodes) and devfs_revoke() will
pick them up from there. We still spelunk into other mountpoints
and fondle their data without 100% good locking. It may make better
sense to vector the revoke event into the tty code and there do a
destroy_dev/make_dev on the tty's devices, but that's for further
study.

Lots of shuffling of stuff and churn of bits for no good reason[2].

XXX: There is still nothing preventing the dev_clone EVENTHANDLER
from being invoked at the same time in two devfs mountpoints. It
is not obvious what the best course of action is here.

XXX: comment out an if statement that lost its body, until I can
find out what should go there so it doesn't do damage in the meantime.

XXX: Leave in a few extra malloc types and KASSERTS to help track
down any remaining issues.

Much testing provided by: Kris
Much confusion caused by (races in): md(4)

[1] You are not supposed to understand anything past this point.

[2] This line should simplify life for the peanut gallery.


# 74f46f19 15-Sep-2005 Poul-Henning Kamp <phk@FreeBSD.org>

Retire unused dev_named() function.


# 1d45c50e 19-Aug-2005 Poul-Henning Kamp <phk@FreeBSD.org>

Properly un-giant-trick the cdevsw in fini_cdevsw()

Tripped over by: Huang wen hui <huang@gddsn.org.cn>


# 516ad423 17-Aug-2005 Poul-Henning Kamp <phk@FreeBSD.org>

Handle device drivers with D_NEEDGIANT in a way which does not
penalize the 'good' drivers: Allocate a shadow cdevsw and populate
it with wrapper functions which grab Giant


# b3740d65 16-Aug-2005 Poul-Henning Kamp <phk@FreeBSD.org>

Remove stale comment.


# 9c0af131 16-Aug-2005 Poul-Henning Kamp <phk@FreeBSD.org>

Create a new internal .h file to communicate very private stuff
from kern_conf.c to devfs.

For now just two prototypes, more to come.


# d26dd2d9 14-Jul-2005 Robert Watson <rwatson@FreeBSD.org>

When devfs cloning takes place, provide access to the credential of the
process that caused the clone event to take place for the device driver
creating the device. This allows cloned device drivers to adapt the
device node based on security aspects of the process, such as the uid,
gid, and MAC label.

- Add a cred reference to struct cdev, so that when a device node is
instantiated as a vnode, the cloning credential can be exposed to
MAC.

- Add make_dev_cred(), a version of make_dev() that additionally
accepts the credential to stick in the struct cdev. Implement it and
make_dev() in terms of a back-end make_dev_credv().

- Add a new event handler, dev_clone_cred, which can be registered to
receive the credential instead of dev_clone, if desired.

- Modify the MAC entry point mac_create_devfs_device() to accept an
optional credential pointer (may be NULL), so that MAC policies can
inspect and act on the label or other elements of the credential
when initializing the skeleton device protections.

- Modify tty_pty.c to register clone_dev_cred and invoke make_dev_cred(),
so that the pty clone credential is exposed to the MAC Framework.

While currently primarily focussed on MAC policies, this change is also
a prerequisite for changes to allow ptys to be instantiated with the UID
of the process looking up the pty. This requires further changes to the
pty driver -- in particular, to immediately recycle pty nodes on last
close so that the credential-related state can be recreated on next
lookup.

Submitted by: Andrew Reisse <andrew.reisse@sparta.com>
Obtained from: TrustedBSD Project
Sponsored by: SPAWAR, SPARTA
MFC after: 1 week
MFC note: Merge to 6.x, but not 5.x for ABI reasons


# 9477d73e 31-Mar-2005 Poul-Henning Kamp <phk@FreeBSD.org>

cdev (still) needs per instance uid/gid/mode

Add unlocked version of dev_ref()

Clean up various stuff in sys/conf.h


# eb151cb9 30-Mar-2005 Poul-Henning Kamp <phk@FreeBSD.org>

Rename dev_ref() to dev_refl()


# b3d82c03 29-Mar-2005 Poul-Henning Kamp <phk@FreeBSD.org>

Remove the global cdev hash and use the cdevsw list instead.

Don't remove the now unused element from cdev yet, wait until
we have a better reason to bump the version.

There is now no longer any upper limit on how many device drivers
a FreeBSD kernel can have.


# ff7284ee 29-Mar-2005 Poul-Henning Kamp <phk@FreeBSD.org>

Remove the global cdev hash and use the cdevsw list instead.

Don't remove the now unused element from cdev yet, wait until
we have a better reason to bump the version.


# fd5f6f4c 29-Mar-2005 Poul-Henning Kamp <phk@FreeBSD.org>

Privatize major().


# bde1a9c9 17-Mar-2005 Poul-Henning Kamp <phk@FreeBSD.org>

Kill MAJOR_AUTO


# 800b42bd 16-Mar-2005 Poul-Henning Kamp <phk@FreeBSD.org>

Prepare for the final onslaught on devices:

Move uid/gid/mode from cdev to cdevsw.

Add kind field to use for devd(8) later.

Bump both D_VERSION and __FreeBSD_version


# 4ba679d6 14-Mar-2005 Poul-Henning Kamp <phk@FreeBSD.org>

Remove findcdev().


# 0a2e49f1 15-Mar-2005 Poul-Henning Kamp <phk@FreeBSD.org>

Rename cdev->si_udev to cdev->si_drv0 to reflect the new nature of
the field.


# b43ab0e3 10-Mar-2005 Poul-Henning Kamp <phk@FreeBSD.org>

Try to fix the mess I made of devname, with the minimal subset of the
larger minor/major patch which was posted for testing.


# 3238ec33 08-Mar-2005 Poul-Henning Kamp <phk@FreeBSD.org>

Fix signedness of minor2unit().


# 8045ce21 27-Feb-2005 Poul-Henning Kamp <phk@FreeBSD.org>

Also handle d_maj hints from cloning drivers correctly.


# 84f580a0 27-Feb-2005 Poul-Henning Kamp <phk@FreeBSD.org>

Whine about any drivers which hardcode the device major number.


# 89685e22 27-Feb-2005 Poul-Henning Kamp <phk@FreeBSD.org>

Use dynamic major number allocation for /dev/console, there is no
longer any benefit from hard wiring it.

Remove special hack used to wire major to zero despite zero having a
different magic meaning as well.


# aa2f6ddc 22-Feb-2005 Poul-Henning Kamp <phk@FreeBSD.org>

Reap more benefits from DEVFS:

List devfs_dirents rather than vnodes off their shared struct cdev, this
saves a pointer field in the vnode at the expense of a field in the
devfs_dirent. There are often 100 times more vnodes so this is bargain.
In addition it makes it harder for people to try to do stypid things like
"finding the vnode from cdev".

Since DEVFS handles all VCHR nodes now, we can do the vnode related
cleanup in devfs_reclaim() instead of in dev_rel() and vgonel().
Similarly, we can do the struct cdev related cleanup in dev_rel()
instead of devfs_reclaim().

rename idestroy_dev() to destroy_devl() for consistency.

Add LIST_ENTRY de_alias to struct devfs_dirent.
Remove v_specnext from struct vnode.
Change si_hlist to si_alist in struct cdev.
String new devfs vnodes' devfs_dirent on si_alist when
we create them and take them off in devfs_reclaim().

Fix devfs_revoke() accordingly. Also don't clear fields
devfs_reclaim() will clear when called from vgone();

Let devfs_reclaim() call dev_rel() instead of vgonel().

Move the usecount tracking from dev_rel() to devfs_reclaim(),
and let dev_rel() take a struct cdev argument instead of vnode.

Destroy SI_CHEAPCLONE devices in dev_rel() (instead of
devfs_reclaim()) when they are no longer used. (This
should maybe happen in devfs_close() instead.)


# 1a1457d4 22-Feb-2005 Poul-Henning Kamp <phk@FreeBSD.org>

Make dev_ref() require the dev_lock() to be held and use it from
devfs instead of directly frobbing the si_refcount.


# d9aaa28f 29-Jan-2005 Poul-Henning Kamp <phk@FreeBSD.org>

Use MAXMINOR


# 37085a39 29-Jan-2005 Poul-Henning Kamp <phk@FreeBSD.org>

Typo.


# 3a85fd26 29-Jan-2005 Poul-Henning Kamp <phk@FreeBSD.org>

Add MAXMINOR #define, we should have had this long time ago.

Add minor2unit() in addition to dev2unit() and unit2minor().

If it wasn't such a hazzle we should redefine minor numbers in
the kernel without the gap for the major number, but it's not worth
the bother (yet).


# 027b1f71 23-Jan-2005 Poul-Henning Kamp <phk@FreeBSD.org>

Fix a list corruption issue in cloning device management using the
western strategy ("allocate first, ask questions later") so we can
extend the devmtx coverage to the clone list.


# 1a1b2800 25-Oct-2004 Poul-Henning Kamp <phk@FreeBSD.org>

Get rid of the magic "stash" of cdev structures, we no longer call
make_dev() before malloc works.


# ba285125 01-Oct-2004 Poul-Henning Kamp <phk@FreeBSD.org>

Fix a LOR relating to freeing cdevs.


# 1abf2c36 29-Sep-2004 Brian Feldman <green@FreeBSD.org>

Account for alias devices when tearing them down in destroy_dev() so we
don't panic on a NULL cdev->si_devsw.


# a5993c33 27-Sep-2004 Poul-Henning Kamp <phk@FreeBSD.org>

Used cached cdevsw pointer.


# 743cd76a 27-Sep-2004 Poul-Henning Kamp <phk@FreeBSD.org>

Add cdevsw->d_purge() support.

This device method shall wake up any threads sleeping in the device driver
and make the depart the drivers code for good.


# b2deb1d2 24-Sep-2004 Poul-Henning Kamp <phk@FreeBSD.org>

Remove the cdevsw() function which is now unused.


# 8ff33adb 24-Sep-2004 Poul-Henning Kamp <phk@FreeBSD.org>

Hold threadref while we throb cdevsw in devtoname()


# 2c15afd8 23-Sep-2004 Poul-Henning Kamp <phk@FreeBSD.org>

Introduce dev_re[lf]thread() functions.

dev_refthread() will return the cdevsw pointer or NULL. If the
return value is non-NULL a threadcount is held which much be released
with dev_relthread(). If the returned cdevsw is NULL no threadcount
is held on the device.


# a0e78d2e 23-Sep-2004 Poul-Henning Kamp <phk@FreeBSD.org>

Do not refcount the cdevsw, but rather maintain a cdev->si_threadcount
of the number of threads which are inside whatever is behind the
cdevsw for this particular cdev.

Make the device mutex visible through dev_lock() and dev_unlock().
We may want finer granularity later.

Replace spechash_mtx use with dev_lock()/dev_unlock().


# 67673e66 13-Sep-2004 Poul-Henning Kamp <phk@FreeBSD.org>

Create struct snapdata which contains the snapshot fields from cdev
and the previously malloc'ed snapshot lock.

Malloc struct snapdata instead of just the lock.

Replace snapshot fields in cdev with pointer to snapdata (saves 16 bytes).

While here, give the private readblock() function a vnode argument
in preparation for moving UFS to access GEOM directly.


# 2e4db7cf 29-Aug-2004 Pawel Jakub Dawidek <pjd@FreeBSD.org>

Add a missing '\n'.


# ad3b9257 15-Aug-2004 John-Mark Gurney <jmg@FreeBSD.org>

Add locking to the kqueue subsystem. This also makes the kqueue subsystem
a more complete subsystem, and removes the knowlege of how things are
implemented from the drivers. Include locking around filter ops, so a
module like aio will know when not to be unloaded if there are outstanding
knotes using it's filter ops.

Currently, it uses the MTX_DUPOK even though it is not always safe to
aquire duplicate locks. Witness currently doesn't support the ability
to discover if a dup lock is ok (in some cases).

Reviewed by: green, rwatson (both earlier versions)


# 9ef295b7 11-Jul-2004 Poul-Henning Kamp <phk@FreeBSD.org>

Better descriptions of the cdev malloc class and mutex.


# 9a98ae94 22-Jun-2004 Lukas Ertl <le@FreeBSD.org>

Fix a few spelling mistakes in comments and clean them up a bit.


# f3732fd1 17-Jun-2004 Poul-Henning Kamp <phk@FreeBSD.org>

Second half of the dev_t cleanup.

The big lines are:
NODEV -> NULL
NOUDEV -> NODEV
udev_t -> dev_t
udev2dev() -> findcdev()

Various minor adjustments including handling of userland access to kernel
space struct cdev etc.


# 89c9c53d 16-Jun-2004 Poul-Henning Kamp <phk@FreeBSD.org>

Do the dreaded s/dev_t/struct cdev */
Bump __FreeBSD_version accordingly.


# 3a95025f 01-Jun-2004 Poul-Henning Kamp <phk@FreeBSD.org>

Introduce a ttyioctl() cdevsw default function.


# 8666b655 11-Mar-2004 Poul-Henning Kamp <phk@FreeBSD.org>

Correctly account for extra bits in unit numbers when looking for
next free unit.


# 9397290e 10-Mar-2004 Poul-Henning Kamp <phk@FreeBSD.org>

Add clone_setup() function rather than rely on lazy initialization.

Requested by: rwatson


# 652d0472 23-Feb-2004 Poul-Henning Kamp <phk@FreeBSD.org>

Fix two oversights here: don't trash the freelist, and properly cleanup
the cdevsw{}.

Submitted by: tegge


# cd690b60 21-Feb-2004 Poul-Henning Kamp <phk@FreeBSD.org>

Device megapatch 6/6:

This is what we came here for: Hang dev_t's from their cdevsw,
refcount cdevsw and dev_t and generally keep track of things a lot
better than we used to:

Hold a cdevsw reference around all entrances into the device driver,
this will be necessary to safely determine when we can unload driver
code.

Hold a dev_t reference while the device is open.

KASSERT that we do not enter the driver on a non-referenced dev_t.

Remove old D_NAG code, anonymous dev_t's are not a problem now.

When destroy_dev() is called on a referenced dev_t, move it to
dead_cdevsw's list. When the refcount drops, free it.

Check that cdevsw->d_version is correct. If not, set all methods
to the dead_*() methods to prevent entrance into driver. Print
warning on console to this effect. The device driver may still
explode if it is also incompatible with newbus, but in that case
we probably didn't get this far in the first place.


# 816d62bb 21-Feb-2004 Poul-Henning Kamp <phk@FreeBSD.org>

Device megapatch 5/6:

Remove the unused second argument from udev2dev().

Convert all remaining users of makedev() to use udev2dev(). The
semantic difference is that udev2dev() will only locate a pre-existing
dev_t, it will not line makedev() create a new one.

Apart from the tiny well controlled windown in D_PSEUDO drivers,
there should no longer be any "anonymous" dev_t's in the system
now, only dev_t's created with make_dev() and make_dev_alias()


# dc08ffec 21-Feb-2004 Poul-Henning Kamp <phk@FreeBSD.org>

Device megapatch 4/6:

Introduce d_version field in struct cdevsw, this must always be
initialized to D_VERSION.

Flip sense of D_NOGIANT flag to D_NEEDGIANT, this involves removing
four D_NOGIANT flags and adding 145 D_NEEDGIANT flags.


# 8e1f1df0 21-Feb-2004 Poul-Henning Kamp <phk@FreeBSD.org>

Device megapatch 3/6:

Add missing D_TTY flags to various drivers.

Complete asserts that dev_t's passed to ttyread(), ttywrite(),
ttypoll() and ttykqwrite() have (d_flags & D_TTY) and a struct tty
pointer.

Make ttyread(), ttywrite(), ttypoll() and ttykqwrite() the default
cdevsw methods for D_TTY drivers and remove the explicit initializations
in various drivers cdevsw structures.


# b0b03348 21-Feb-2004 Poul-Henning Kamp <phk@FreeBSD.org>

Device megapatch 2/6:

This commit adds a couple of functions for pseudodrivers to use for
implementing cloning in a manner we will be able to lock down (shortly).

Basically what happens is that pseudo drivers get a way to ask for
"give me the dev_t with this unit number" or alternatively "give
me a dev_t with the lowest guaranteed free unit number" (there is
unfortunately a lot of non-POLA in the exact numeric value of this
number, just live with it for now)

Managing the unit number space this way removes the need to use
rman(9) to do so in the drivers this greatly simplifies the code in
the drivers because even using rman(9) they still needed to manage
their dev_t's anyway.

I have taken the if_tun, if_tap, snp and nmdm drivers through the
mill, partly because they (ab)used makedev(), but mostly because
together they represent three different problems for device-cloning:

if_tun and snp is the plain case: just give me a device.

if_tap has two kinds of devices, with a flag for device type.

nmdm has paired devices (ala pty) can you can clone either of them.


# 72632ef2 15-Feb-2004 Bruce Evans <bde@FreeBSD.org>

Fixed style bugs near previous commit (mainly formatting errors and
missing parentheses). Use default handling (trap to debugger) for
udev2dev(x, 1) since it is an error and doesn't happen anywhere in
the sys tree except in bogusly commented out code in coda.


# 2a3faf2f 15-Feb-2004 Poul-Henning Kamp <phk@FreeBSD.org>

Split the initialization of the cdevsw into a separate function.


# d08c5d0b 14-Feb-2004 Poul-Henning Kamp <phk@FreeBSD.org>

Remove the check which used to protect us against make_dev() being
called until DEVFS had a chance to initialize. Since DEVFS is mandatory
and things over in that department coincidentally works from without
any initialization now, this is safe.


# 43102178 28-Sep-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Retire revoke_and_destroy_dev() with extreme prejudice.


# 98c469d4 27-Sep-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Make life a little bit easier for cloning device drivers.


# b2941431 26-Sep-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Introduce no_poll() default method for device drivers. Have it
do exactly the same as vop_nopoll() for consistency and put a
comment in the two pointing at each other.

Retire seltrue() in favour of no_poll().

Create private default functions in kern_conf.c instead of public
ones.

Change default strategy to return the bio with ENODEV instead of
doing nothing which would lead the bio stranded.

Retire public nullopen() and nullclose() as well as the entire band
of public no{read,write,ioctl,mmap,kqfilter,strategy,poll,dump}
funtions, they are the default actions now.

Move the final two trivial functions from subr_xxx.c to kern_conf.c
and retire the now empty subr_xxx.c


# 70cd7713 26-Sep-2003 Poul-Henning Kamp <phk@FreeBSD.org>

The present defaults for the open and close for device drivers which
provide no methods does not make any sense, and is not used by any
driver.

It is a pretty hard to come up with even a theoretical concept of
a device driver which would always fail open and close with ENODEV.

Change the defaults to be nullopen() and nullclose() which simply
does nothing.

Remove explicit initializations to these from the drivers which
already used them.


# 677b542e 10-Jun-2003 David E. O'Brien <obrien@FreeBSD.org>

Use __FBSDID().


# 1e93e04f 31-May-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Remove return after panic.

Found by: FlexeLint


# 7c1d57b6 13-Apr-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Since dynamic allocation of device major numbers so far have not
resulted in any earthquakes, civil wars or early onset hair-loss,
I think we can do without the printf announcing the assigned number.


# 06a8bb90 09-Mar-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Add one little hack to allow us to make MAJOR_AUTO be zero:

Let the console driver ask for major 256 and magically change this to
mean zero.


# 7ac40f5f 02-Mar-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Gigacommit to improve device-driver source compatibility between
branches:

Initialize struct cdevsw using C99 sparse initializtion and remove
all initializations to default values.

This patch is automatically generated and has been tested by compiling
LINT with all the fields in struct cdevsw in reverse order on alpha,
sparc64 and i386.

Approved by: re(scottl)


# f16304aa 02-Mar-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Explicitly initialize all cdevsw methods with the relevant nofoo() function
if they are NULL.


# 9c486c30 02-Mar-2003 Poul-Henning Kamp <phk@FreeBSD.org>

NO_GEOM cleanup:

Remove cdevsw->d_size() implementation. No longer needed.


# 9285a87e 02-Mar-2003 Poul-Henning Kamp <phk@FreeBSD.org>

NODEVFS cleanup:

Replace devfs_{create,destroy} hooks with direct function calls.


# 85f19dcc 27-Feb-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Add the flip-side check: If a driver wants a particular major#, make
sure it is marked as allocated in reserved_majors[]. Whine if it wasn't.


# beea48b2 27-Feb-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Add support for allocating a device driver major number on demand.

To do this, initialize the d_maj member of the cdevsw to MAJOR_AUTO.
When the cdevsw is first passed to make_dev() a free major number
will be assigned.

Until we have a bit more experience with this a printf will announce
this fact.

Major numbers are not reclaimed, so loading/unloading the same
device driver which uses MAJOR_AUTO will eventually deplete the
pool of free major numbers and the system will panic when it can
not allocate one. Still undecided who to invonvenience with the
solution to this.


# f477b4fd 27-Feb-2003 Poul-Henning Kamp <phk@FreeBSD.org>

NODEVFS cleanup:

Remove cdevsw_add() and cdevsw_remove(), they served us well for a long time.
Bump __FreeBSD_version to 500104 to mark this.


# 2c6b49f6 21-Feb-2003 Poul-Henning Kamp <phk@FreeBSD.org>

NO_GEOM cleanup:

Retire the "d_dump_t" and use the "dumper_t" type instead.

Dumper_t takes a void * as first arg which is more general than the
dev_t taken by d_dump_t. (Remember: we could have net-dumpers if
somebody wrote us one!)

Define the convention for GEOM controlled disk devices to be that the
first argument to the dumper function is the struct disk pointer.

Change device drivers accordingly.


# 02574b19 20-Feb-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Add a dead_cdevsw which does its best to return ENXIO if at all possible.

In devsw() return dead_cdevsw instead of NULL in case the dev_t does not
have a si_devsw.

This may improve our survival chances with devices which go away unexpectedly.


# 0c977c9c 19-Feb-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Add M_WAITOK


# 6334a663 04-Feb-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Implement proper bounds-checking and truncation of device names, this has
become an issue now that end-user controlable attributes can become devices
names with the geom_vol_ffs class.


# 237d2765 04-Feb-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Pave the road to removing the fixed size limit on device nodes:

Change the si_name of dev_t's to be a char * and put a private buffer for
holding the name at then end of the struct.

Initialize si_name to point to the private buffer.

Put a KASSERT in geom_disk to prevent overrun on the fake dev_t we still
have to generate for the disk_drivers.


# 6e1203e5 30-Jan-2003 Poul-Henning Kamp <phk@FreeBSD.org>

NO_GEOM cleanup: unifdef;


# 34189c03 29-Jan-2003 Poul-Henning Kamp <phk@FreeBSD.org>

NODEVFS cleanup: Remove cdevsw[].

This implicitly removes the need for major numbers, but a number of
drivers still know things they shouldn't need to, and we need to
consider if there are applications which cache major(+minor) gleaned
from stat(2) and rely on it being constant over reboots before we
start assigning random majors.


# c0805171 20-Jan-2003 Poul-Henning Kamp <phk@FreeBSD.org>

disk_dev_synth() is a NO_GEOM hack.


# 5ecd6fd4 19-Jan-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Mark more code #ifdef NODEVFS


# 7e760e14 19-Jan-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Originally when DEVFS was added, a global variable "devfs_present"
was used to control code which were conditional on DEVFS' precense
since this avoided the need for large-scale source pollution with
#include "opt_geom.h"

Now that we approach making DEVFS standard, replace these tests
with an #ifdef to facilitate mechanical removal once DEVFS becomes
non-optional.

No functional change by this commit.


# f53c6e5c 28-Dec-2002 Poul-Henning Kamp <phk@FreeBSD.org>

Remove unused cdevsw_ALLOCSTART macro.


# dab3d85f 05-Oct-2002 Brian Feldman <green@FreeBSD.org>

Don't allow dev_stdclone(9) to accept minors larger than the system is
able to handle (0xffffff).


# ca916247 27-Sep-2002 Poul-Henning Kamp <phk@FreeBSD.org>

Rename struct specinfo to the more appropriate struct cdev.

Agreed on: jake, rwatson, jhb


# 66cdbc28 20-Sep-2002 Poul-Henning Kamp <phk@FreeBSD.org>

Assert my copyright on this file (using the default 2-clause BSD).

The vast majority of the contents is from my keyboard and no
significant pieces remain of the former copyright holders code.


# 5ea98f59 08-Sep-2002 Poul-Henning Kamp <phk@FreeBSD.org>

Fix a logic bug in the struct dev_t allocation code.

Spotted by: Neelkanth Natu <neelnatu@yahoo.com>


# ff557fa1 25-Apr-2002 Bruce Evans <bde@FreeBSD.org>

Break the following implementation of panic(3):

#!bin/sh

# Original version of this by Michael Reifenberger
# <root@nihil.plaut.de>.

mdconfig -d -u 11 >/dev/null 2>&1
dd if=/dev/zero of=zz bs=1m count=1

while :
do
mdconfig -a -t vnode -f zz -u 11
fdisk -f - -iv /dev/md11 <<EOF1
g c1 h64 s32
p 1 165 0 2048
a 1
EOF1
mdconfig -d -u 11
done

Garbage pointers in __si_u were not cleared by destroy_dev(). Not
clearing si_disk made the above fatal because the disk layer uses
si_disk as a flag to indicate that the dev_t has been completely
initialized. disk_destroy() clears si_disk for the parent dev_t
but doesn't get called for children.

Not fixed:
- setting the undocumented sysctl debug.free_devt should cause more
complete destruction of the dev_t including clearing of __si_u, but
actually causes the above to panic a little earlier.
- the loop leaks 10 memory allocations per iteration (4 DEVFS, 2 devbuf
and 4 dev_t).

Reviewed by: timeout by MAINTAINER after 3 months


# 01de1b13 10-Mar-2002 Poul-Henning Kamp <phk@FreeBSD.org>

Make the proposed name arg to dev_stdclone() const.


# 1b567820 16-Feb-2002 Brian Feldman <green@FreeBSD.org>

(Doing that whole test-immediately-after-commit-thing like obrien sez:)
Forgot to include lock.h and mutex.h for GIANT_REQUIRED.


# 1fd9f8f4 16-Feb-2002 Brian Feldman <green@FreeBSD.org>

Add revoke_and_destroy_dev(), to be used by devices which decide when
they choose to destroy themselves without regard to whether or not
they are open.


# a7489fe5 08-Jan-2002 Mike Smith <msmith@FreeBSD.org>

Add a new sysinit SI_SUB_DEVFS. Devfs hooks into the kernel at SI_ORDER_FIRST,
and devices can be created anytime after that.

Print a warning if an atttempt is made to create a device too early.


# 24d5c954 16-Nov-2001 Poul-Henning Kamp <phk@FreeBSD.org>

Back out the previous fix to the leading zero problem, I hadn't
noticed it in there already. That should teach me to check exit
code from cvsup.


# 10786074 16-Nov-2001 Poul-Henning Kamp <phk@FreeBSD.org>

Reject leading zeros in dev_stdclone().

PR: 32019
Submitted by: fenner


# b519852a 15-Nov-2001 Bill Fenner <fenner@FreeBSD.org>

Do not allow leading zeros on device names in dev_stdclone().

PR: kern/32019
Reviewed by: phk


# 4e130067 28-Oct-2001 Poul-Henning Kamp <phk@FreeBSD.org>

Fix a problem in the disk related hack where device nodes for a physically
non-existent disk in a legacy /dev on a DEVFS system would panic the system
if stat(2)'ed.

Do not whine about anonymous device nodes not having a si_devsw, they're
not supposed to.


# 4e4a7663 27-Oct-2001 Poul-Henning Kamp <phk@FreeBSD.org>

Nudge the axe a bit closer to cdevsw[]:

Make it a panic to repeat make_dev() or destroy_dev(), this check
should maybe be neutered when -current goes -stable.

Whine if devsw() is called on anon dev_t's in a devfs system.

Make a hack to avoid our lazy-eval disk code triggering the above whine.

Fix the multiple make_dev() in disk code by making ${disk}${unit}s${slice}
an alias/symlink to ${disk}${unit}s${slice}c


# 5f7806ab 26-Oct-2001 Poul-Henning Kamp <phk@FreeBSD.org>

Make cdevsw[] static.


# 7e7c3f3f 17-Oct-2001 Jonathan Lemon <jlemon@FreeBSD.org>

Add dev_named(dev, name), which is similar in spirit to devtoname().
This function returns success if the device is known by either 'name'
or any of its aliases.


# b40ce416 12-Sep-2001 Julian Elischer <julian@FreeBSD.org>

KSE Milestone 2
Note ALL MODULES MUST BE RECOMPILED
make the kernel aware that there are smaller units of scheduling than the
process. (but only allow one thread per process at this time).
This is functionally equivalent to teh previousl -current except
that there is a thread associated with each process.

Sorry john! (your next MFC will be a doosie!)

Reviewed by: peter@freebsd.org, dillon@freebsd.org

X-MFC after: ha ha ha ha


# c7021493 02-Aug-2001 Warner Losh <imp@FreeBSD.org>

Make the fmt arguments to make_dev and make_dev_alias const char *.

Approved on IRC as long as it didn't cause a large number of warnings by: phk

MFC After: 700 hours


# 3344c5a1 26-May-2001 Poul-Henning Kamp <phk@FreeBSD.org>

Create a general facility for making dev_t's depend on another
dev_t. The dev_depends(dev_t, dev_t) function is for tying them
to each other.

When destroy_dev() is called on a dev_t, all dev_t's depending
on it will also be destroyed (depth first order).

Rewrite the make_dev_alias() to use this dependency facility.

kern/subr_disk.c:
Make the disk mini-layer use dependencies to make sure all
relevant dev_t's are removed when the disk disappears.

Make the disk mini-layer precreate some magic sub devices
which the disk/slice/label code expects to be there.

kern/subr_disklabel.c:
Remove some now unneeded variables.

kern/subr_diskmbr.c:
Remove some ancient, commented out code.

kern/subr_diskslice.c:
Minor cleanup. Use name from dev_t instead of dsname()


# 56700d46 14-Apr-2001 Brian Somers <brian@FreeBSD.org>

Call strlen() once instead of twice.


# 15b6f00f 20-Mar-2001 Poul-Henning Kamp <phk@FreeBSD.org>

Add a KASSERT on unit2minor() so that we catch it if people try to pass
us unit numbers which doesn't fit in 24 bits.


# 589c7af9 07-Mar-2001 Kirk McKusick <mckusick@FreeBSD.org>

Fixes to track snapshot copy-on-write checking in the specinfo
structure rather than assuming that the device vnode would reside
in the FFS filesystem (which is obviously a broken assumption with
the device filesystem).


# 11586717 01-Feb-2001 Brian Somers <brian@FreeBSD.org>

KASSERT that the minor number passed to make_dev() is valid.


# 1fd7b93f 21-Jan-2001 Poul-Henning Kamp <phk@FreeBSD.org>

Convert a Debugger(3) to a panic(9) and a EINVAL.

Reminded by: bde


# 7cc0979f 08-Dec-2000 David Malone <dwmalone@FreeBSD.org>

Convert more malloc+bzero to malloc+M_ZERO.

Submitted by: josh@zipperup.org
Submitted by: Robert Drehmel <robd@gmx.net>


# 959b7375 08-Dec-2000 Poul-Henning Kamp <phk@FreeBSD.org>

Staticize some malloc M_ instances.


# 9842fc8d 10-Nov-2000 John Baldwin <jhb@FreeBSD.org>

Axe some unused variables.


# a16d0eb2 31-Oct-2000 Poul-Henning Kamp <phk@FreeBSD.org>

Deprecate devsw->d_bmaj entirely.

This removes support for booting current kernels with very old bootblocks.

Device driver writers: Please remove initializations for the d_bmaj
field in your cdevsw{}.


# fe4e3243 29-Oct-2000 Poul-Henning Kamp <phk@FreeBSD.org>

Allow all users to access the dev -> devname sysctl.


# b0d17ba6 19-Sep-2000 Poul-Henning Kamp <phk@FreeBSD.org>

Rename lminor() to dev2unit(). This function gives a linear unit number
which hides the 'hole' in the minor bits.

Introduce unit2minor() to do the reverse operation.

Fix some some make_dev() calls which didn't use UID_* or GID_* macros.

Kill the v_hashchain alias macro, it hides the real relationship.

Introduce experimental SI_CHEAPCLONE flag set it on cloned bpfs.


# 5ef2707e 11-Sep-2000 Poul-Henning Kamp <phk@FreeBSD.org>

revent multiple make_dev() calls on the same dev_t and similar bogosities.
A couple of new warnings may be emitted during boot if drivers DTWT.

Tested by: George Cox <gjvc@gjvc.com>


# 8d25eb2c 09-Sep-2000 Poul-Henning Kamp <phk@FreeBSD.org>

Add code to devname(3) so it can find the names of devices which
were not present when dev_mkdb(8) was run.

First the dev_mkdb(8) database is searched, this caters for non-DEVFS
cases where people have renamed a device.

If that fails we ask the kernel using sysctl kern.devname if the device
driver has put a name in the dev_t. This covers DEVFS cloned devices.

If that also fails we format a string which isn't entirely useless.


# db901281 02-Sep-2000 Poul-Henning Kamp <phk@FreeBSD.org>

Avoid the modules madness I inadvertently introduced by making the
cloning infrastructure standard in kern_conf. Modules are now
the same with or without devfs support.

If you need to detect if devfs is present, in modules or elsewhere,
check the integer variable "devfs_present".

This happily removes an ugly hack from kern/vfs_conf.c.

This forces a rename of the eventhandler and the standard clone
helper function.

Include <sys/eventhandler.h> in <sys/conf.h>: it's a helper #include
like <sys/queue.h>

Remove all #includes of opt_devfs.h they no longer matter.


# 3f54a085 20-Aug-2000 Poul-Henning Kamp <phk@FreeBSD.org>

Remove all traces of Julians DEVFS (incl from kern/subr_diskslice.c)

Remove old DEVFS support fields from dev_t.

Make uid, gid & mode members of dev_t and set them in make_dev().

Use correct uid, gid & mode in make_dev in disk minilayer.

Add support for registering alias names for a dev_t using the
new function make_dev_alias(). These will show up as symlinks
in DEVFS.

Use makedev() rather than make_dev() for MFSs magic devices to prevent
DEVFS from noticing this abuse.

Add a field for DEVFS inode number in dev_t.

Add new DEVFS in fs/devfs.

Add devfs cloning to:
disk minilayer (ie: ad(4), sd(4), cd(4) etc etc)
md(4), tun(4), bpf(4), fd(4)

If DEVFS add -d flag to /sbin/inits args to make it mount devfs.

Add commented out DEVFS to GENERIC


# e3975643 25-May-2000 Jake Burkholder <jake@FreeBSD.org>

Back out the previous change to the queue(3) interface.
It was not discussed and should probably not happen.

Requested by: msmith and others


# 740a1973 23-May-2000 Jake Burkholder <jake@FreeBSD.org>

Change the way that the queue(3) structures are declared; don't assume that
the type argument to *_HEAD and *_ENTRY is a struct.

Suggested by: phk
Reviewed by: phk
Approved by: mdodd


# 192c06ea 09-May-2000 Poul-Henning Kamp <phk@FreeBSD.org>

Change the "bdev-whiner" to whine when open is attempted and extend
the deadline a month.


# 8c6ac5e5 25-Mar-2000 Kris Kennaway <kris@FreeBSD.org>

Reword warning to make it clearer (I read it as "remove block devices created
before 2000-06-01" which is obviously not what was intended :-)


# e0040677 21-Mar-2000 Poul-Henning Kamp <phk@FreeBSD.org>

Whine at users who still have block devices in /dev, give them until
june 1st to fix their system.


# 8dc74b62 23-Jan-2000 Boris Popov <bp@FreeBSD.org>

Backout previous commit. It was a mistake.


# 9e991dfa 23-Jan-2000 Boris Popov <bp@FreeBSD.org>

Replace non obvious number with SPECNAMELEN constant.

Reviewed by: phk


# fb01c24c 03-Jan-2000 Poul-Henning Kamp <phk@FreeBSD.org>

Be more careful about NOUDEV and NODEV.

Submitted by: bde


# c464420c 29-Nov-1999 Poul-Henning Kamp <phk@FreeBSD.org>

Report swapdevices as cdevs rather than bdevs.

Remove unused dev2budev() function.


# 38941f35 29-Nov-1999 Poul-Henning Kamp <phk@FreeBSD.org>

Remove the now unused chrtoblk() function.


# 900942ba 08-Nov-1999 Peter Wemm <peter@FreeBSD.org>

Zap devsw_module_handler().


# 44d1184e 08-Nov-1999 Poul-Henning Kamp <phk@FreeBSD.org>

Rename remove_dev() to destroy_dev().

Nagged about by: msmith


# d53dedee 07-Nov-1999 Poul-Henning Kamp <phk@FreeBSD.org>

Remove the devsw magic from DEV_MODULE()


# 662761a7 04-Oct-1999 Poul-Henning Kamp <phk@FreeBSD.org>

A little step further in the dev_t cleanups:

Refuse to register a bmajor if the D_DISK flag is not set in cdevsw.

A little bit of cleanup while here.


# c32cc149 12-Sep-1999 Bruce Evans <bde@FreeBSD.org>

Const'ify devtoname() and d_name. This exposes some errors (2 non-benign).

Handle negative minor numbers properly in devtoname().


# d137accc 29-Aug-1999 Poul-Henning Kamp <phk@FreeBSD.org>

Add dev_t freeing code. Controlled by sysctl debug.free_devt, default
is off.


# a87b5350 28-Aug-1999 Poul-Henning Kamp <phk@FreeBSD.org>

Put a brief comment on a couple of #defines.


# c3aac50f 27-Aug-1999 Peter Wemm <peter@FreeBSD.org>

$Id$ -> $FreeBSD$


# 9dcbe240 23-Aug-1999 Poul-Henning Kamp <phk@FreeBSD.org>

Convert DEVFS hooks in (most) drivers to make_dev().

Diskslice/label code not yet handled.

Vinum, i4b, alpha, pc98 not dealt with (left to respective Maintainers)

Add the correct hook for devfs to kern_conf.c

The net result of this excercise is that a lot less files depends on DEVFS,
and devtoname() gets more sensible output in many cases.

A few drivers had minor additional cleanups performed relating to cdevsw
registration.

A few drivers don't register a cdevsw{} anymore, but only use make_dev().


# 1744fcd0 20-Aug-1999 Julian Elischer <julian@FreeBSD.org>

First small steps at merging DEVFS and PHK's Dev_t stuff.


# b8e49f68 17-Aug-1999 Bill Fumerola <billf@FreeBSD.org>

Welcome devtoname(), to most likely be used when printing information
about a dev_t.

printf("%x", dev) now becomes printf("%s", devtoname(dev)) because
printing actual information about the device is much more useful then
printing a pointer to an address that would never help the developer debug.

Submitted by: phk, bde


# 9a27d579 15-Aug-1999 Poul-Henning Kamp <phk@FreeBSD.org>

Introduce lminor(dev_t dev), which returns a linear minor number,
ie: hides the fact that the major number is stuck in the middle.


# 7dc5cd04 13-Aug-1999 Poul-Henning Kamp <phk@FreeBSD.org>

The bdevsw() and cdevsw() are now identical, so kill the former.


# 0ef1c826 08-Aug-1999 Poul-Henning Kamp <phk@FreeBSD.org>

Decommision miscfs/specfs/specdev.h. Most of it goes into <sys/conf.h>,
a few lines into <sys/vnode.h>.

Add a few fields to struct specinfo, paving the way for the fun part.


# 32c0c324 07-Aug-1999 Greg Lehey <grog@FreeBSD.org>

cdevsw_remove: place correct value in bmaj2cmaj. This had caused
warnings of the following nature on reloading a kld:

WARNING: "vinum" is usurping "console"'s bmaj

This only applies to cases where "console" is mentioned.

Broken-by: grog


# 57d86fc6 20-Jul-1999 Brian Feldman <green@FreeBSD.org>

Fix a REALLY embarrassing mistake. Don't look; I warned you.


# fb30b5bd 20-Jul-1999 Brian Feldman <green@FreeBSD.org>

Make a dev2budev() function, and use it. This refixes pstat (working, broken,
working, broken, working) and savecore (working, working, broken, working,
working).

Sorta Reviewed by: phk


# 698bfad7 20-Jul-1999 Poul-Henning Kamp <phk@FreeBSD.org>

Now a dev_t is a pointer to struct specinfo which is shared by all specdev
vnodes referencing this device.

Details:
cdevsw->d_parms has been removed, the specinfo is available
now (== dev_t) and the driver should modify it directly
when applicable, and the only driver doing so, does so:
vn.c. I am not sure the logic in checking for "<" was right
before, and it looks even less so now.

An intial pool of 50 struct specinfo are depleted during
early boot, after that malloc had better work. It is
likely that fewer than 50 would do.

Hashing is done from udev_t to dev_t with a prime number
remainder hash, experiments show no better hash available
for decent cost (MD5 is only marginally better) The prime
number used should not be close to a power of two, we use
83 for now.

Add new checkalias2() to get around the loss of info from
dev2udev() in bdevvp();

The aliased vnodes are hung on a list straight of the dev_t,
and speclisth[SPECSZ] is unused. The sharing of struct
specinfo means that the v_specnext moves into the vnode
which grows by 4 bytes.

Don't use a VBLK dev_t which doesn't make sense in MFS, now
we hang a dummy cdevsw on B/Cmaj 253 so that things look sane.

Storage overhead from all of this is O(50k).

Bump __FreeBSD_version to 400009

The next step will add the stuff needed so device-drivers can start to
hang things from struct specinfo


# 3de280c4 19-Jul-1999 Poul-Henning Kamp <phk@FreeBSD.org>

[click] Now all dev_t's in the kernel have their char device major.

Only know casualy of this is swapinfo/pstat which should be fixes
the right way: Store the actual pathname in the kernel like mount
does. [Volounteers sought for this task]

The road map from here is roughly: expand struct specinfo into struct
based dev_t. Add dev_t registration facilities for device drivers and
start to use them.


# d21c632c 17-Jul-1999 Poul-Henning Kamp <phk@FreeBSD.org>

Use 256 as magic in bmaj2cmaj[]. Treat BLK/CHR dev_t more correctly.


# f008cfcc 17-Jul-1999 Poul-Henning Kamp <phk@FreeBSD.org>

I have not one single time remembered the name of this function correctly
so obviously I gave it the wrong name. s/umakedev/makeudev/g


# 03016f42 04-Jul-1999 Poul-Henning Kamp <phk@FreeBSD.org>

Remove cmaj and bmaj args from DEV_DRIVER_MODULE.


# c31558b2 03-Jul-1999 Poul-Henning Kamp <phk@FreeBSD.org>

Warn about drivers which take over other drivers cdevsw entries, but still
grant them squatters right.


# 6d4ce7aa 26-Jun-1999 Doug Rabson <dfr@FreeBSD.org>

* Call cdevsw_remove from the MOD_UNLOAD event.
* Fix a couple of warnings while I'm here.


# 9a9eb2b9 25-Jun-1999 Greg Lehey <grog@FreeBSD.org>

Add function cdevsw_remove, the opposite of cdevsw_add: remove an
entry in cdevsw (and bdevsw if appropriate).

Reviewed-by: phk


# 4ea5ad99 01-Jun-1999 Dmitrij Tejblum <dt@FreeBSD.org>

|| vs && confusion in cdevsw_add().


# 6fcd8a7c 01-Jun-1999 Poul-Henning Kamp <phk@FreeBSD.org>

Introduce the makebdev() function, it does the same as the makedev()
function for now, but that will change.


# 2447bec8 31-May-1999 Poul-Henning Kamp <phk@FreeBSD.org>

Simplify cdevsw registration.

The cdevsw_add() function now finds the major number(s) in the
struct cdevsw passed to it. cdevsw_add_generic() is no longer
needed, cdevsw_add() does the same thing.

cdevsw_add() will print an message if the d_maj field looks bogus.

Remove nblkdev and nchrdev variables. Most places they were used
bogusly. Instead check a dev_t for validity by seeing if devsw()
or bdevsw() returns NULL.

Move bdevsw() and devsw() functions to kern/kern_conf.c

Bump __FreeBSD_version to 400006

This commit removes:
72 bogus makedev() calls
26 bogus SYSINIT functions

if_xe.c bogusly accessed cdevsw[], author/maintainer please fix.

I4b and vinum not changed. Patches emailed to authors. LINT
probably broken until they catch up.


# 519566d2 18-May-1999 Luoqi Chen <luoqi@FreeBSD.org>

Avoid negative numbers in dev_t manipulation. This should fix recent MFS
related crashes.


# e519e78b 12-May-1999 Poul-Henning Kamp <phk@FreeBSD.org>

braino.


# adfea48f 12-May-1999 Poul-Henning Kamp <phk@FreeBSD.org>

Produce compiler warning if dev_t and udev_t is confused.


# bfbb9ce6 11-May-1999 Poul-Henning Kamp <phk@FreeBSD.org>

Divorce "dev_t" from the "major|minor" bitmap, which is now called
udev_t in the kernel but still called dev_t in userland.

Provide functions to manipulate both types:
major() umajor()
minor() uminor()
makedev() umakedev()
dev2udev() udev2dev()

For now they're functions, they will become in-line functions
after one of the next two steps in this process.

Return major/minor/makedev to macro-hood for userland.

Register a name in cdevsw[] for the "filedescriptor" driver.

In the kernel the udev_t appears in places where we have the
major/minor number combination, (ie: a potential device: we
may not have the driver nor the device), like in inodes, vattr,
cdevsw registration and so on, whereas the dev_t appears where
we carry around a reference to a actual device.

In the future the cdevsw and the aliased-from vnode will be hung
directly from the dev_t, along with up to two softc pointers for
the device driver and a few houskeeping bits. This will essentially
replace the current "alias" check code (same buck, bigger bang).

A little stunt has been provided to try to catch places where the
wrong type is being used (dev_t vs udev_t), if you see something
not working, #undef DEVT_FASCIST in kern/kern_conf.c and see if
it makes a difference. If it does, please try to track it down
(many hands make light work) or at least try to reproduce it
as simply as possible, and describe how to do that.

Without DEVT_FASCIST I belive this patch is a no-op.

Stylistic/posixoid comments about the userland view of the <sys/*.h>
files welcome now, from userland they now contain the end result.

Next planned step: make all dev_t's refer to the same devsw[] which
means convert BLK's to CHR's at the perimeter of the vnodes and
other places where they enter the game (bootdev, mknod, sysctl).


# 52400704 09-May-1999 Poul-Henning Kamp <phk@FreeBSD.org>

Unconfuse DEV_MODULE() and DEV_DRIVER_MODULE() about the difference between
a major number for a dev_t.


# 8f0024a5 09-May-1999 Poul-Henning Kamp <phk@FreeBSD.org>

Peter beat me to half this patch, but didn't do the other half:

set d_bmaj

don't cast a dev_t to int before comparing to NODEV


# 0da14f00 09-May-1999 Peter Wemm <peter@FreeBSD.org>

Comment advising ordering of cdevsw_add and bdevsw_add is obsolete (no
bdevsw_add any more).


# 4be2eb8c 08-May-1999 Poul-Henning Kamp <phk@FreeBSD.org>

I got tired of seeing all the cdevsw[major(foo)] all over the place.

Made a new (inline) function devsw(dev_t dev) and substituted it.

Changed to the BDEV variant to this format as well: bdevsw(dev_t dev)

DEVFS will eventually benefit from this change too.


# 46eede00 07-May-1999 Poul-Henning Kamp <phk@FreeBSD.org>

Continue where Julian left off in July 1998:

Virtualize bdevsw[] from cdevsw. bdevsw() is now an (inline)
function.

Join CDEV_MODULE and BDEV_MODULE to DEV_MODULE (please pay attention
to the order of the cmaj/bmaj arguments!)

Join CDEV_DRIVER_MODULE and BDEV_DRIVER_MODULE to DEV_DRIVER_MODULE
(ditto!)

(Next step will be to convert all bdev dev_t's to cdev dev_t's
before they get to do any damage^H^H^H^H^H^Hwork in the kernel.)


# 6ca34d85 23-Mar-1999 Doug Rabson <dfr@FreeBSD.org>

Call the module's unload handler before removing the device from the
cdevsw list. This allows a handler to veto the load without losing its
place in the list.

PR: kern/10653


# d254af07 27-Jan-1999 Matthew Dillon <dillon@FreeBSD.org>

Fix warnings in preparation for adding -Wall -Wcast-qual to the
kernel compile


# 14177d72 14-Nov-1998 Garrett Wollman <wollman@FreeBSD.org>

My changes to the new device interface:

- Interface wth the new resource manager.
- Allow for multiple drivers implementing a single devclass.
- Remove ordering dependencies between header files.
- Style cleanup.
- Add DEVICE_SUSPEND and DEVICE_RESUME methods.
- Move to a single-phase interrupt setup scheme.

Kernel builds on the Alpha are brken until Doug gets a chance to incorporate
these changes on that side.

Agreed to in principle by: dfr


# f5ef029e 25-Oct-1998 Poul-Henning Kamp <phk@FreeBSD.org>

Nitpicking and dusting performed on a train. Removes trivial warnings
about unused variables, labels and other lint.


# f7ea2f55 04-Jul-1998 Julian Elischer <julian@FreeBSD.org>

There is no such thing any more as "struct bdevsw".

There is only cdevsw (which should be renamed in a later edit to deventry
or something). cdevsw contains the union of what were in both bdevsw an
cdevsw entries. The bdevsw[] table stiff exists and is a second pointer
to the cdevsw entry of the device. it's major is in d_bmaj rather than
d_maj. some cleanup still to happen (e.g. dsopen now gets two pointers
to the same cdevsw struct instead of one to a bdevsw and one to a cdevsw).

rawread()/rawwrite() went away as part of this though it's not strictly
the same patch, just that it involves all the same lines in the drivers.

cdroms no longer have write() entries (they did have rawwrite (?)).
tapes no longer have support for bdev operations.

Reviewed by: Eivind Eklund and Mike Smith
Changes suggested by eivind.


# 7c281842 26-Jun-1998 Poul-Henning Kamp <phk@FreeBSD.org>

Remove isdisk() hacks.


# b6259105 25-Jun-1998 Poul-Henning Kamp <phk@FreeBSD.org>

Remove bdevsw_add(), change the only two users to use bdevsw_add_generic().
Extend cdevsw to be superset of bdevsw.
Remove non-functional bdev lkm support.
Teach wcd what the open() args mean.


# ecbb00a2 07-Jun-1998 Doug Rabson <dfr@FreeBSD.org>

This commit fixes various 64bit portability problems required for
FreeBSD/alpha. The most significant item is to change the command
argument to ioctl functions from int to u_long. This change brings us
inline with various other BSD versions. Driver writers may like to
use (__FreeBSD_version == 300003) to detect this change.

The prototype FreeBSD/alpha machdep will follow in a couple of days
time.


# cb451ebd 22-Nov-1997 Bruce Evans <bde@FreeBSD.org>

Staticized.


# 81bca6dd 27-Sep-1997 KATO Takenori <kato@FreeBSD.org>

Clustered read and write are switched at mount-option level.

1. Clustered I/O is switched by the MNT_NOCLUSTERR and MNT_NOCLUSTERW
bits of the mnt_flag. The sysctl variables, vfs.foo.doclusterread
and vfs.foo.doclusterwrite are deleted. Only mount option can
control clustered I/O from userland.
2. When foofs_mount mounts block device, foofs_mount checks D_CLUSTERR
and D_CLUSTERW bits of the d_flags member in the block device switch
table. If D_NOCLUSTERR / D_NOCLUSTERW are set, MNT_NOCLUSTERR /
MNT_NOCLUSTERW bits will be set. In this case, MNT_NOCLUSTERR and
MNT_NOCLUSTERW cannot be cleared from userland.
3. Vnode driver disables both clustered read and write.
4. Union filesystem disables clutered write.

Reviewed by: bde


# e29b30aa 21-Sep-1997 Julian Elischer <julian@FreeBSD.org>

urk, fix spelling error in comment I just fixed.


# 4010d6d9 21-Sep-1997 Julian Elischer <julian@FreeBSD.org>

Fix a comment.


# 51338ea8 13-Sep-1997 Peter Wemm <peter@FreeBSD.org>

Various select -> poll changes


# 1fd0b058 02-Aug-1997 Bruce Evans <bde@FreeBSD.org>

Removed unused #includes.


# 939c1961 01-Jun-1997 Julian Elischer <julian@FreeBSD.org>

tiny spelling fix in comment


# 6875d254 22-Feb-1997 Peter Wemm <peter@FreeBSD.org>

Back out part 1 of the MCFH that changed $Id$ to $FreeBSD$. We are not
ready for it yet.


# 996c772f 09-Feb-1997 John Dyson <dyson@FreeBSD.org>

This is the kernel Lite/2 commit. There are some requisite userland
changes, so don't expect to be able to run the kernel as-is (very well)
without the appropriate Lite/2 userland changes.

The system boots and can mount UFS filesystems.

Untested: ext2fs, msdosfs, NFS
Known problems: Incorrect Berkeley ID strings in some files.
Mount_std mounts will not work until the getfsent
library routine is changed.

Reviewed by: various people
Submitted by: Jeffery Hsu <hsu@freebsd.org>


# 1130b656 14-Jan-1997 Jordan K. Hubbard <jkh@FreeBSD.org>

Make the long-awaited change from $Id$ to $FreeBSD$

This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore. This update would have been
insane otherwise.


# f7f70b3d 05-Dec-1996 Bruce Evans <bde@FreeBSD.org>

Fixed a null pointer panic in ADDENTRY(). Unloading the lkm and joy
modules sort of works now. Their devswitch entries aren't cleaned
up, so accessing them after they have been unloaded causes a panic
in spec_open().

Submitted by: durian@plutotech.com (Mike Durian), IIRC


# 19060a3a 28-Oct-1996 Poul-Henning Kamp <phk@FreeBSD.org>

init_main.c: pass -d to init if DEVFS_ROOT
kern_conf.c: gd driver is a disk.
vfs_subr.c: include opt_devfs.h


# 313861b8 19-Aug-1996 Julian Elischer <julian@FreeBSD.org>

for kern_conf.c, start allocating dynamic major numbers
half way through the range rather than possibly colliding with
fixed elements. Increase the size of the arrays to take this into account..
remember that each element in the array is now only 1 ponter so this
isn't that much..

also note a possible bug in debugging code in uipc_socket2.c (add XXX)


# cba8a5dd 23-Jul-1996 Poul-Henning Kamp <phk@FreeBSD.org>

Make a "DWIM" function for adding [bc]devsw entries for bdev drivers.

Saves about 280 butes of source per driver, 56 bytes in object size
and another 56 bytes moves from data to bss.

No functional change intended nor expected.

GENERIC should be about one k smaller now :-)


# 79c0c4b7 22-Dec-1995 Poul-Henning Kamp <phk@FreeBSD.org>

kern_conf.c: remove a now unused variable.
vfs_cache.c: Fix a very rare probelm in the vnode-cache.
Submitted by: Terry Lambert <terry@lambert.org>


# 1dfcbb0c 21-Dec-1995 Julian Elischer <julian@FreeBSD.org>

i386/i386/conf.c is no longer needed.. remove it from files.i386
redistribute a few last routines to beter places and shoot the file

I haven't act actually 'deleted' the file yet togive people time
to
have done a config.. I.e. they are likely to have done one in a week or so
so I'll remove it then..
it's now empty.
makes the question of a USL copyright rather moot.


# 6ba9ebce 13-Dec-1995 Julian Elischer <julian@FreeBSD.org>

devsw tables are now arrays of POINTERS to struct [cb]devsw
seems to work hre just fine though I can't check every file
that changed due to limmited h/w, however I've checked enught to be petty
happy withe hte code..

WARNING... struct lkm[mumble] has changed
so it might be an idea to recompile any lkm related programs


# 87f6c662 08-Dec-1995 Julian Elischer <julian@FreeBSD.org>

Pass 3 of the great devsw changes
most devsw referenced functions are now static, as they are
in the same file as their devsw structure. I've also added DEVFS
support for nearly every device in the system, however
many of the devices have 'incorrect' names under DEVFS
because I couldn't quickly work out the correct naming conventions.
(but devfs won't be coming on line for a month or so anyhow so that doesn't
matter)

If you "OWN" a device which would normally have an entry in /dev
then search for the devfs_add_devsw() entries and munge to make them right..
check out similar devices to see what I might have done in them in you
can't see what's going on..
for a laugh compare conf.c conf.h defore and after... :)
I have not doen DEVFS entries for any DISKSLICE devices yet as that will be
a much more complicated job.. (pass 5 :)

pass 4 will be to make the devsw tables of type (cdevsw * )
rather than (cdevsw)
seems to work here..
complaints to the usual places.. :)


# de1676f9 29-Nov-1995 Julian Elischer <julian@FreeBSD.org>

A pair of really tiny patches that not only allow it all to compile
but also IT ACTUALLY WORKS!
FreeBSD with options JREMOD now runs with no entries in the devsw tables
prior to the devices puting their own entries there..

Thanks to bde and terry for thoughts and comments.
next stop 'Real' devfs support in devices.


# adb2dc29 28-Nov-1995 Julian Elischer <julian@FreeBSD.org>

#ifdef out nearly the entire file of conf.c when JREMOD is defined
add a few safety checks in specfs because
now it's possible to get entries in [cd]devsw[] which are ALL NULL
so it's better to discover this BEFORE jumping into the d_open() entry..

more check to come later.. this getsthe code to the stage where I
can start testing it, even if I haven't caught every little error case...
I guess I'll find them quick enough..


# 4c1a35b2 04-Oct-1995 Julian Elischer <julian@FreeBSD.org>

fix REALLY STUPID bug/typo
don't look at the diffs.. it's too embarassing :)


# f8a760b3 02-Oct-1995 Julian Elischer <julian@FreeBSD.org>

actually compiles.. (previous commit was to just get it into the tree)


# 26453f35 02-Oct-1995 Julian Elischer <julian@FreeBSD.org>

Obtained from: well it has a relationship with the LKM code..

This is a place for all things to do with conf.c and conf.h
that are not machine specific.
Other things that are at present in i386/isa/conf.c might
migrate into here..
It's the first small step in cleaning up the device interface
to make it more dynamic and to assist in more modular drivers
(i.e. both loadable via LKMs and linked in..
e.g able to add a device without having to edit conf.c)

this code is not yet used and the whole thing will be conditionally
compiled in for a while till proven useful :)