aboutsummaryrefslogtreecommitdiff
path: root/sys/fs/devfs/devfs_devs.c
Commit message (Collapse)AuthorAgeFilesLines
* This commit was manufactured by cvs2svn to create tagrelease/7.0.0_cvscvs2svn2008-02-241-1/+1
| | | | | | 'RELENG_7_0_0_RELEASE'. This commit was manufactured to restore the state of the 7.0-RELEASE image.
* Rename mac*devfsdirent*() to mac*devfs*() to synchronize with SEDarwin,Robert Watson2007-04-231-2/+2
| | | | | | | | | | | where similar data structures exist to support devfs and the MAC Framework, but are named differently. Obtained from: TrustedBSD Project Sponsored by: SPARTA, Inc. Notes: svn path=/head/; revision=168977
* Complete break-out of sys/sys/mac.h into sys/security/mac/mac_framework.hRobert Watson2006-10-221-1/+2
| | | | | | | | | | | | | | | | begun with a repo-copy of mac.h to mac_framework.h. sys/mac.h now contains the userspace and user<->kernel API and definitions, with all in-kernel interfaces moved to mac_framework.h, which is now included across most of the kernel instead. This change is the first step in a larger cleanup and sweep of MAC Framework interfaces in the kernel, and will not be MFC'd. Obtained from: TrustedBSD Project Sponsored by: SPARTA Notes: svn path=/head/; revision=163606
* Properly lock the vnode around vgone() calls.Konstantin Belousov2006-10-181-15/+45
| | | | | | | | | | | | | | Unlock the vnode in devfs_close() while calling into the driver d_close() routine. devfs_revoke() changes by: ups Reviewed and bugfixes by: tegge Tested by: mbr, Peter Holm Approved by: pjd (mentor) MFC after: 1 week Notes: svn path=/head/; revision=163481
* Resolve the devfs deadlock caused by LOR between devfs_mount->dm_lock andKonstantin Belousov2006-09-181-1/+12
| | | | | | | | | | | | | | | | | | vnode lock in devfs_allocv. Do this by temporary dropping dm_lock around vnode locking. For safe operation, add hold counters for both devfs_mount and devfs_dirent, and DE_DOOMED flag for devfs_dirent. The facilities allow to continue after dropping of the dm_lock, by making sure that referenced memory does not disappear. Reviewed by: tegge Tested by: kris Approved by: kan (mentor) PR: kern/102335 Notes: svn path=/head/; revision=162398
* Remove the NDEVFSINO and NDEVFSOVERFLOW options which no longer exists inPoul-Henning Kamp2006-07-171-1/+0
| | | | | | | | | DEVFS. Remove the opt_devfs.h file now that it is empty. Notes: svn path=/head/; revision=160425
* - We must hold a reference to a vnode before calling vgone() otherwiseJeff Roberson2006-02-221-0/+2
| | | | | | | | | | it may not be removed from the freelist. MFC After: 1 week Found by: kris Notes: svn path=/head/; revision=155903
* Rewamp DEVFS internals pretty severely [1].Poul-Henning Kamp2005-09-191-255/+291
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=150342
* Don't attempt to recurse lockmgr, it doesn't like it.Poul-Henning Kamp2005-09-151-2/+0
| | | | Notes: svn path=/head/; revision=150200
* Various minor polishing.Poul-Henning Kamp2005-09-151-6/+5
| | | | Notes: svn path=/head/; revision=150151
* Close a race which could result in unwarranted "ruleset %d alreadyPoul-Henning Kamp2005-09-151-0/+4
| | | | | | | | | | | | | | | | | | | | running" panics. Previously, recursion through the "include" feature was prevented by marking each ruleset as "running" when applied. This doesn't work for the case where two DEVFS instances try to apply the same ruleset at the same time. Instead introduce the sysctl vfs.devfs.rule_depth (default == 1) which limits how many levels of "include" we will traverse. Be aware that traversal of "include" is recursive and kernel stack size is limited. MFC: after 3 days Notes: svn path=/head/; revision=150147
* Collect the devfs related sysctls in one placePoul-Henning Kamp2005-08-161-0/+32
| | | | Notes: svn path=/head/; revision=149146
* Create a new internal .h file to communicate very private stuffPoul-Henning Kamp2005-08-161-0/+1
| | | | | | | | | from kern_conf.c to devfs. For now just two prototypes, more to come. Notes: svn path=/head/; revision=149144
* Eliminate effectively unused dm_basedir field from devfs_mount.Poul-Henning Kamp2005-08-151-1/+1
| | | | Notes: svn path=/head/; revision=149107
* When devfs cloning takes place, provide access to the credential of theRobert Watson2005-07-141-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=147982
* cdev (still) needs per instance uid/gid/modePoul-Henning Kamp2005-03-311-3/+3
| | | | | | | | | Add unlocked version of dev_ref() Clean up various stuff in sys/conf.h Notes: svn path=/head/; revision=144385
* Prepare for the final onslaught on devices:Poul-Henning Kamp2005-03-171-3/+3
| | | | | | | | | | | Move uid/gid/mode from cdev to cdevsw. Add kind field to use for devd(8) later. Bump both D_VERSION and __FreeBSD_version Notes: svn path=/head/; revision=143746
* Try to fix the mess I made of devname, with the minimal subset of thePoul-Henning Kamp2005-03-101-4/+5
| | | | | | | larger minor/major patch which was posted for testing. Notes: svn path=/head/; revision=143381
* Make a SYSCTL_NODE staticPoul-Henning Kamp2005-02-101-1/+1
| | | | Notes: svn path=/head/; revision=141633
* /* -> /*- for copyright notices, minor format tweaks as necessaryWarner Losh2005-01-061-1/+1
| | | | Notes: svn path=/head/; revision=139776
* Reduce a fair bit of the atomics because we are now called with aPoul-Henning Kamp2004-06-181-73/+55
| | | | | | | | lock from kern_conf.c and cdev's act a lot more like real objects these days. Notes: svn path=/head/; revision=130678
* Do the dreaded s/dev_t/struct cdev */Poul-Henning Kamp2004-06-161-11/+11
| | | | | | | Bump __FreeBSD_version accordingly. Notes: svn path=/head/; revision=130585
* White-space align a struct definition.Poul-Henning Kamp2004-02-151-11/+0
| | | | | | | Move a SYSINIT to the file where it belongs. Notes: svn path=/head/; revision=125855
* NODEVFS cleanup:Poul-Henning Kamp2003-03-021-4/+3
| | | | | | | Replace devfs_{create,destroy} hooks with direct function calls. Notes: svn path=/head/; revision=111730
* Back out M_* changes, per decision of the TRB.Warner Losh2003-02-191-5/+5
| | | | | | | Approved by: trb Notes: svn path=/head/; revision=111119
* NODEVFS cleanup: remove #ifdefs.Poul-Henning Kamp2003-01-291-2/+0
| | | | Notes: svn path=/head/; revision=110063
* Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.Alfred Perlstein2003-01-211-5/+5
| | | | | | | Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT. Notes: svn path=/head/; revision=109623
* Originally when DEVFS was added, a global variable "devfs_present"Poul-Henning Kamp2003-01-191-1/+0
| | | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=109526
* Remove dm_root entry from struct devfs_mount. It's never set, and isRobert Watson2002-12-091-3/+3
| | | | | | | | | | | | | | | unused. Replace it with a dm_mount back-pointer to the struct mount that the devfs_mount is associated with. Export that pointer to MAC Framework entry points, where all current policies don't use the pointer. This permits the SEBSD port of SELinux's FLASK/TE to compile out-of-the-box on 5.0-CURRENT with full file system labeling support. Approved by: re (murray) Obtained from: TrustedBSD Project Sponsored by: DARPA, Network Associates Laboratories Notes: svn path=/head/; revision=107698
* s/struct dev_t */dev_t */Poul-Henning Kamp2002-09-281-1/+1
| | | | Notes: svn path=/head/; revision=104113
* Introduce support for Mandatory Access Control and extensibleRobert Watson2002-07-311-0/+15
| | | | | | | | | | | | | | | | | | | kernel access control. Instrument devfs to support per-dirent MAC labels. In particular, invoke MAC framework when devfs directory entries are instantiated due to make_dev() and related calls, and invoke the MAC framework when vnodes are instantiated from these directory entries. Implement vop_setlabel() for devfs, which pushes the label update into the devfs directory entry for semi-persistant store. This permits the MAC framework to assign labels to devices and directories as they are instantiated, and export access control information via devfs vnodes. Obtained from: TrustedBSD Project Sponsored by: DARPA, NAI Labs Notes: svn path=/head/; revision=101069
* Introduce the DEVFS "rule" subsystem. DEVFS rules permit theDima Dorfman2002-07-171-0/+2
| | | | | | | | | | | | | | administrator to define certain properties of new devfs nodes before they become visible to the userland. Both static (e.g., /dev/speaker) and dynamic (e.g., /dev/bpf*, some removable devices) nodes are supported. Each DEVFS mount may have a different ruleset assigned to it, permitting different policies to be implemented for things like jails. Approved by: phk Notes: svn path=/head/; revision=100206
* Add a new sysinit SI_SUB_DEVFS. Devfs hooks into the kernel at SI_ORDER_FIRST,Mike Smith2002-01-091-1/+1
| | | | | | | | | and devices can be created anytime after that. Print a warning if an atttempt is made to create a device too early. Notes: svn path=/head/; revision=89118
* Use a sysinit to initialise the devfs hooks in kern_conf.c rather than commonMike Smith2002-01-091-3/+10
| | | | | | | | | variables. Reviewed by: phk (in principle) Notes: svn path=/head/; revision=89107
* Use vfs_timestamp() instead of getnanotime() directly.Poul-Henning Kamp2001-11-031-3/+3
| | | | | | | | | Fix some modes on directories and symlinks. Instructed by: bde Notes: svn path=/head/; revision=85979
* KSE Milestone 2Julian Elischer2001-09-121-2/+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 Notes: svn path=/head/; revision=83366
* Create a general facility for making dev_t's depend on anotherPoul-Henning Kamp2001-05-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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() Notes: svn path=/head/; revision=77215
* Convert DEVFS from an "opt-in" to an "opt-out" option.Poul-Henning Kamp2001-05-131-0/+2
| | | | | | | | | | | | If for some reason DEVFS is undesired, the "NODEVFS" option is needed now. Pending any significant issues, DEVFS will be made mandatory in -current on july 1st so that we can start reaping the full benefits of having it. Notes: svn path=/head/; revision=76554
* Undo part of the tangle of having sys/lock.h and sys/mutex.h included inMark Murray2001-05-011-4/+5
| | | | | | | | | | | | | | other "system" header files. Also help the deprecation of lockmgr.h by making it a sub-include of sys/lock.h and removing sys/lockmgr.h form kernel .c files. Sort sys/*.h includes where possible in affected files. OK'ed by: bde (with reservations) Notes: svn path=/head/; revision=76166
* At the point in time where most devices are created, we don't know whatPoul-Henning Kamp2001-02-021-1/+1
| | | | | | | | time it is because boottime is not yet initialized. Finagle the relevant fields when we get the chance. Notes: svn path=/head/; revision=71945
* Fix two minor nits.Poul-Henning Kamp2001-01-301-1/+2
| | | | | | | Existences revealed, but no details offered by: bp Notes: svn path=/head/; revision=71822
* Convert more malloc+bzero to malloc+M_ZERO.David Malone2000-12-081-8/+4
| | | | | | | | Submitted by: josh@zipperup.org Submitted by: Robert Drehmel <robd@gmx.net> Notes: svn path=/head/; revision=69781
* staticize.Poul-Henning Kamp2000-12-081-2/+5
| | | | Notes: svn path=/head/; revision=69767
* Remove unneeded #include <sys/proc.h> lines.Poul-Henning Kamp2000-10-291-1/+0
| | | | Notes: svn path=/head/; revision=67882
* Don't hold an extra reference to vnodes. Devfs vnodes are sufficientlyPoul-Henning Kamp2000-10-091-10/+6
| | | | | | | | | | | | | | | | | cheap to setup that it doesn't really matter that we recycle device vnodes at kleenex speed. Implement first cut try at killing cloned devices when they are not needed anymore. For now only the bpf driver is involved in this experiment. Cloned devices can set the SI_CHEAPCLONE flag which allows us to destroy_dev() it when the vcount() drops to zero and the vnode is reclaimed. For now it's a requirement that the driver doesn't keep persistent state from close to (re)open. Some whitespace changes. Notes: svn path=/head/; revision=66877
* Add refcounts to the "global" DEVFS inode slots, this allows usPoul-Henning Kamp2000-09-061-23/+211
| | | | | | | | | | | | | | | | | | | | | | to recycle inodes after a destroy_dev() but not until all mounts have picked up the change. Add support for an overflow table for DEVFS inodes. The static table defaults to 1024 inodes, if that fills, an overflow table of 32k inodes is allocated. Both numbers can be changed at compile time, the size of the overflow table also with the sysctl vfs.devfs.noverflow. Use atomic instructions to barrier between make_dev()/destroy_dev() and the mounts. Add lockmgr() locking of directories for operations accessing or modifying the directory TAILQs. Various nitpicking here and there. Notes: svn path=/head/; revision=65515
* Avoid the modules madness I inadvertently introduced by making thePoul-Henning Kamp2000-09-021-25/+3
| | | | | | | | | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=65374
* Reorder vop's alphabetically.Poul-Henning Kamp2000-08-271-16/+27
| | | | | | | | | Smarter use of devfs_allocv() (from bp@) Introduce devfs_find() ".." fixes to devfs_lookup (from bp@) Notes: svn path=/head/; revision=65132
* Fix panic when removing open device (found by bp@)Poul-Henning Kamp2000-08-241-23/+56
| | | | | | | | | | | | | | | Implement subdirs. Build the full "devicename" for cloning functions. Fix panic when deleted device goes away. Collaps devfs_dir and devfs_dirent structures. Add proper cloning to the /dev/fd* "device-"driver. Fix a bug in make_dev_alias() handling which made aliases appear multiple times. Use devfs_clone to implement getdiskbyname() Make specfs maintain the stat(2) timestamps per dev_t Notes: svn path=/head/; revision=65051
* Fix devfs_access() bug on directories.Poul-Henning Kamp2000-08-211-3/+0
| | | | | | | | | Remove unused #includes. Bug spotted by: markm Notes: svn path=/head/; revision=64895