summaryrefslogtreecommitdiffstats
path: root/sys/fs/devfs
Commit message (Collapse)AuthorAgeFilesLines
...
* - Add a bogus vhold/vdrop around vgone() in devfs_revoke. Without thisjeff2006-03-311-0/+3
| | | | | the vnode is never recycled. It is bogus because the reference really should be associated with the devfs dirent.
* - We must hold a reference to a vnode before calling vgone() otherwisejeff2006-02-221-0/+2
| | | | | | | it may not be removed from the freelist. MFC After: 1 week Found by: kris
* - Remove a stale comment. This function was rewritten to be SMP safe somejeff2006-01-301-6/+0
| | | | | | time ago. Sponsored by: Isilon Systems, Inc.
* When returning EIO from DEVFSIO_RADD ioctl, drop the exclusive rulerwatson2006-01-031-2/+4
| | | | | | | lock. Otherwise the system comes to a rather sudden and grinding halt. MFC after: 1 week
* This is a workaround for a complicated issue involving VFS cookies and devfs.dwhite2005-11-091-0/+24
| | | | | | | | | | | | | The PR and patch have the details. The ultimate fix requires architectural changes and clarifications to the VFS API, but this will prevent the system from panicking when someone does "ls /dev" while running in a shell under the linuxulator. This issue affects HEAD and RELENG_6 only. PR: 88249 Submitted by: "Devon H. O'Dell" <dodell@ixsystems.com> MFC after: 3 days
* Use correct cirteria for determining which directory entries we canphk2005-10-181-1/+1
| | | | | | purge right away and which we merely can hide. Beaten into my skull by: kris
* Make rule zero really magical, that way we don't have to do anythingphk2005-09-243-153/+99
| | | | | | | | | | | | | | | | | | when we mount and get zero cost if no rules are used in a mountpoint. Add code to deref rules on unmount. Switch from SLIST to TAILQ. Drop SYSINIT, use SX_SYSINIT and static initializer of TAILQ instead. Drop goto, a break will do. Reduce double pointers to single pointers. Combine reaping and destroying rulesets. Avoid memory leaks in a some error cases.
* Rewamp DEVFS internals pretty severely [1].phk2005-09-196-446/+437
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Don't attempt to recurse lockmgr, it doesn't like it.phk2005-09-152-3/+6
|
* Various minor polishing.phk2005-09-153-22/+10
|
* Protect the devfs rule internal global lists with a sx lock, the perphk2005-09-151-1/+9
| | | | | mount locks are not enough. Finer granularity (x)locking could be implemented, but I prefer to keep it simple for now.
* Absolve devfs_rule.c from locking responsibility and call it withphk2005-09-153-19/+5
| | | | all necessary locking held.
* Close a race which could result in unwarranted "ruleset %d alreadyphk2005-09-153-44/+34
| | | | | | | | | | | | | | | | | 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
* Clean up prototypes.phk2005-09-121-258/+96
|
* Add a missing dev_relthread() call.phk2005-08-291-4/+5
| | | | | | Remove unused variable. Spotted by: Hans Petter Selasky <hselasky@c2i.net>
* Handle device drivers with D_NEEDGIANT in a way which does notphk2005-08-171-24/+0
| | | | | penalize the 'good' drivers: Allocate a shadow cdevsw and populate it with wrapper functions which grab Giant
* Collect the devfs related sysctls in one placephk2005-08-162-49/+34
|
* Create a new internal .h file to communicate very private stuffphk2005-08-162-0/+46
| | | | | | from kern_conf.c to devfs. For now just two prototypes, more to come.
* Eliminate effectively unused dm_basedir field from devfs_mount.phk2005-08-155-5/+3
|
* Merge the dev_clone and dev_clone_cred event handlers into a singlerwatson2005-08-081-7/+4
| | | | | | | | | | | | | event handler, dev_clone, which accepts a credential argument. Implementors of the event can ignore it if they're not interested, and most do. This avoids having multiple event handler types and fall-back/precedence logic in devfs. This changes the kernel API for /dev cloning, and may affect third party packages containg cloning kernel modules. Requested by: phk MFC after: 3 days
* devfs is not yet fully MPSAFE - for example, multiple concurrent devfs(8)kris2005-07-291-1/+0
| | | | | | processes can cause a panic when operating on rulesets. Approved by: phk
* Correct devfs ruleset bypass.simon2005-07-201-0/+6
| | | | | | | Submitted by: csjp Reviewed by: phk Security: FreeBSD-SA-05:17.devfs Approved by: cperciva
* When devfs cloning takes place, provide access to the credential of therwatson2005-07-142-4/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Do not declare a struct as extern, and then implementrodrigc2005-05-311-59/+57
| | | | | | | | it as static in the same file. This is not legal C, and GCC 4.0 will issue an error. Reviewed by: phk Approved by: das (mentor)
* - In devfs_open() and devfs_close() grab Giant if the driver sets NEEDGIANT.jeff2005-05-011-5/+12
| | | | | We still have to DROP_GIANT and PICKUP_GIANT when NEEDGIANT is not set because vfs is still sometime entered with Giant held.
* - Mark devfs as MNTK_MPSAFE as I belive it does not require Giant.jeff2005-04-301-0/+1
| | | | | Sponsored by: Isilon Systems, Inc. Agreed in principle by: phk
* - Change all filesystems and vfs_cache to relock the dvp once the child isjeff2005-04-131-2/+1
| | | | | | locked in the ISDOTDOT case. Se vfs_lookup.c r1.79 for details. Sponsored by: Isilon Systems, Inc.
* Explicitly hold a reference to the cdev we have just cloned. Thisphk2005-03-311-0/+1
| | | | | closes the race where the cdev was reclaimed before it ever made it back to devfs lookup.
* cdev (still) needs per instance uid/gid/modephk2005-03-311-3/+3
| | | | | | Add unlocked version of dev_ref() Clean up various stuff in sys/conf.h
* Rename dev_ref() to dev_refl()phk2005-03-311-1/+1
|
* - LK_NOPAUSE is a nop now.jeff2005-03-311-1/+1
| | | | Sponsored by: Isilon Systems, Inc.
* - We no longer have to bother with PDIRUNLOCK, lookup() handles it for us.jeff2005-03-281-21/+2
| | | | Sponsored by: Isilon Systems, Inc.
* - Update vfs_root implementations to match the new prototype. None ofjeff2005-03-241-2/+3
| | | | | | | | these filesystems will support shared locks until they are explicitly modified to do so. Careful review must be done to ensure that this is safe for each individual filesystem. Sponsored by: Isilon Systems, Inc.
* Prepare for the final onslaught on devices:phk2005-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
* - The VI_DOOMED flag now signals the end of a vnode's relationship withjeff2005-03-131-9/+2
| | | | | | the filesystem. Check that rather than VI_XLOCK. Sponsored by: Isilon Systems, Inc.
* One more bit of the major/minor patch to make ttyname happy as well.phk2005-03-101-2/+11
|
* Try to fix the mess I made of devname, with the minimal subset of thephk2005-03-102-5/+64
| | | | larger minor/major patch which was posted for testing.
* Remove kernelside support for devfs rules filtering on major numbers.phk2005-03-082-5/+0
|
* We may not have an actual cdev at this point.phk2005-02-221-0/+3
|
* Reap more benefits from DEVFS:phk2005-02-222-16/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.)
* Make dev_ref() require the dev_lock() to be held and use it fromphk2005-02-221-1/+1
| | | | devfs instead of directly frobbing the si_refcount.
* Introduce vx_wait{l}() and use it instead of home-rolled versions.phk2005-02-171-6/+2
|
* Make a SYSCTL_NODE staticphk2005-02-101-1/+1
|
* Statize devfs_ops_fphk2005-02-101-1/+1
|
* Make filesystems get rid of their own vnodes vnode_pager object inphk2005-01-281-0/+1
| | | | VOP_RECLAIM().
* Whitespace in vop_vector{} initializations.phk2005-01-131-0/+2
|
* Silently ignore forced argument to unmount.phk2005-01-111-2/+0
|
* /* -> /*- for copyright notices, minor format tweaks as necessaryimp2005-01-063-3/+3
|
* Unsupport forceful unmounts of DEVFS.phk2005-01-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After disscussing things I have decided to take the easy and consistent 90% solution instead of aiming for the very involved 99% solution. If we allow forceful unmounts of DEVFS we need to decide how to handle the devices which are in use through this filesystem at the time. We cannot just readopt the open devices in the main /dev instance since that would open us to security issues. For the majority of the devices, this is relatively straightforward as we can just pretend they got revoke(2)'ed. Some devices get tricky: /dev/console and /dev/tty for instance does a sort of recursive open of the real console device. Other devices may be mmap'ed (kill the processes ?). And then there are disk devices which are mounted. The correct thing here would be to recursively unmount the filesystems mounte from devices from our DEVFS instance (forcefully) and if this succeeds, complete the forcefully unmount of DEVFS. But if one of the forceful unmounts fail we cannot complete the forceful unmount of DEVFS, but we are likely to already have severed a lot of stuff in the process of trying. Event attempting this would be a lot of code for a very far out corner-case which most people would never see or get in touch with. It's just not worth it.
* Be consistent about flag values passed to device drivers read/writephk2004-12-221-11/+4
| | | | | | | | | | | methods: Read can see O_NONBLOCK and O_DIRECT. Write can see O_NONBLOCK, O_DIRECT and O_FSYNC. In addition O_DIRECT is shadowed as IO_DIRECT for now for backwards compatibility.
OpenPOWER on IntegriCloud