aboutsummaryrefslogtreecommitdiff
path: root/sys/fs/devfs
Commit message (Collapse)AuthorAgeFilesLines
* The VNASSERT in vflush() FORCECLOSE case is trying to panic early toKonstantin Belousov2015-02-271-2/+1
| | | | | | | | | | | | | prevent errors from yanking devices out from under filesystems. Only care about special vnodes on devfs, special nodes on other kinds of filesystems do not have special properties. Sponsored by: EMC / Isilon Storage Division Submitted by: Conrad Meyer MFC after: 1 week Notes: svn path=/head/; revision=279362
* Stop enforcing additional reference on all cdevs, which was introducedKonstantin Belousov2015-01-192-6/+1
| | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=277391
* Ignore devfs directory entries for devices either being destroyed orKonstantin Belousov2015-01-192-0/+13
| | | | | | | | | | | delisted. The check is racy. Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=277390
* Avoid race with "dev_rel()" when using the recently addedHans Petter Selasky2015-01-141-0/+6
| | | | | | | | | | | | "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@ Notes: svn path=/head/; revision=277199
* Fix up some session-related races in devfs.Mateusz Guzik2014-11-031-23/+42
| | | | | | | | | One was introduced with r272596, the rest was there to begin with. Noted by: jhb Notes: svn path=/head/; revision=274000
* Fix multiple incorrect SYSCTL arguments in the kernel:Hans Petter Selasky2014-10-211-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Wrong integer type was specified. - Wrong or missing "access" specifier. The "access" specifier sometimes included the SYSCTL type, which it should not, except for procedural SYSCTL nodes. - Logical OR where binary OR was expected. - Properly assert the "access" argument passed to all SYSCTL macros, using the CTASSERT macro. This applies to both static- and dynamically created SYSCTLs. - Properly assert the the data type for both static and dynamic SYSCTLs. In the case of static SYSCTLs we only assert that the data pointed to by the SYSCTL data pointer has the correct size, hence there is no easy way to assert types in the C language outside a C-function. - Rewrote some code which doesn't pass a constant "access" specifier when creating dynamic SYSCTL nodes, which is now a requirement. - Updated "EXAMPLES" section in SYSCTL manual page. MFC after: 3 days Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=273377
* When vnode bypass cannot be performed on the cdev file descriptor forKonstantin Belousov2014-10-151-7/+16
| | | | | | | | | | | | | | | | | | read/write/poll/ioctl, call standard vnode filedescriptor fop. This restores the special handling for terminals by calling the deadfs VOP, instead of always returning ENXIO for destroyed devices or revoked terminals. Since destroyed (and not revoked) device would use devfs_specops VOP vector, make dead_read/write/poll non-static and fill VOP table with pointers to the functions, to instead of VOP_PANIC. Noted and reviewed by: bde Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=273131
* devfs: tidy up after 272596Mateusz Guzik2014-10-061-3/+3
| | | | | | | | | This moves a var to an if statement, no functional changes. MFC after: 1 week Notes: svn path=/head/; revision=272600
* devfs: don't take proctree_lock unconditionally in devfs_closeMateusz Guzik2014-10-061-10/+13
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=272596
* Add a new fo_fill_kinfo fileops method to add type-specific information toJohn Baldwin2014-09-221-0/+1
| | | | | | | | | | | | | | | | | struct kinfo_file. - Move the various fill_*_info() methods out of kern_descrip.c and into the various file type implementations. - Rework the support for kinfo_ofile to generate a suitable kinfo_file object for each file and then convert that to a kinfo_ofile structure rather than keeping a second, different set of code that directly manipulates type-specific file information. - Remove the shm_path() and ksem_info() layering violations. Differential Revision: https://reviews.freebsd.org/D775 Reviewed by: kib, glebius (earlier version) Notes: svn path=/head/; revision=271976
* In msdosfs_setattr(), add a check for result of the utimes(2)Konstantin Belousov2014-06-171-4/+2
| | | | | | | | | | | | | | | | | permissions test, forgotten in r164033. Refactor the permission checks for utimes(2) into vnode helper function vn_utimes_perm(9), and simplify its code comparing with the UFS origin, by writing the call to VOP_ACCESSX only once. Use the helper for UFS(5), tmpfs(5), devfs(5) and msdosfs(5). Reported by: bde Reviewed by: bde, trasz Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=267564
* Fix long known bug with handling device aliases residing not in devfs root.Alexander Motin2013-12-121-4/+12
| | | | | | | | | | | | Historically creation of device aliases created symbolic links using only name of target device as a link target, not considering current directory. Fix that by adding number of "../" chunks to the terget device name, required to get out of the current directory to devfs root first. MFC after: 1 month Notes: svn path=/head/; revision=259254
* Similar to debug.iosize_max_clamp sysctl, introduceKonstantin Belousov2013-10-151-0/+4
| | | | | | | | | | | | devfs_iosize_max_clamp sysctl, which allows/disables SSIZE_MAX-sized i/o requests on the devfs files. Sponsored by: The FreeBSD Foundation Reminded by: Dmitry Sivachenko <trtrmitya@gmail.com> MFC after: 1 week Notes: svn path=/head/; revision=256502
* Remove two instances of ARGSUSED comment, and wrap lines nearby theKonstantin Belousov2013-10-151-4/+4
| | | | | | | | | | code that is to be changed. Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=256501
* Make the seek a method of the struct fileops.Konstantin Belousov2013-08-211-0/+1
| | | | | | | | Tested by: pho Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=254602
* Restore the previous sendfile(2) behaviour on the block devices.Konstantin Belousov2013-08-161-0/+1
| | | | | | | | | | Provide valid .fo_sendfile method for several missed struct fileops. Reviewed by: glebius Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=254415
* make path matching in devfs rules consistent and sane (and safer)Andriy Gapon2013-07-261-24/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this change path matching had the following features: - for device nodes the patterns were matched against full path - in the above case '/' in a path could be matched by a wildcard - for directories and links only the last component was matched So, for example, a pattern like 're*' could match the following entries: - re0 device - responder/u0 device - zvol/recpool directory Although it was possible to work around this behavior (once it was spotted and understood), it was very confusing and contrary to documentation. Now we always match a full path for all types of devfs entries (devices, directories, links) and a '/' has to be matched explicitly. This behavior follows the shell globbing rules. This change is originally developed by Jaakko Heinonen. Many thanks! PR: kern/122838 Submitted by: jh MFC after: 4 weeks Notes: svn path=/head/; revision=253677
* - Correct mispellings of the word necessaryGabor Kovesdan2013-04-171-1/+1
| | | | | | | Submitted by: Christoph Mallon <christoph.mallon@gmx.de> (via private mail) Notes: svn path=/head/; revision=249583
* Stop translating the ERESTART error from the open(2) into EINTR.Konstantin Belousov2013-02-071-1/+4
| | | | | | | | | | | | | | | Posix requires that open(2) is restartable for SA_RESTART. For non-posix objects, in particular, devfs nodes, still disable automatic restart of the opens. The open call to a driver could have significant side effects for the hardware. Noted and reviewed by: jilles Discussed with: bde MFC after: 2 weeks Notes: svn path=/head/; revision=246472
* Do not force a writer to the devfs file to drain the buffer writes.Konstantin Belousov2012-12-231-0/+11
| | | | | | | | Requested and tested by: Ian Lepore <freebsd@damnhippie.dyndns.org> MFC after: 2 weeks Notes: svn path=/head/; revision=244643
* Remove M_USE_RESERVE from the devfs cdp allocator, which is one of twoKonstantin Belousov2012-11-141-1/+1
| | | | | | | | | | | uses of M_USE_RESERVE in the kernel. This allocation is not special. Reviewed by: alc Tested by: pho MFC after: 2 weeks Notes: svn path=/head/; revision=243039
* Complete MPSAFE VFS interface and remove MNTK_MPSAFE flag.Attilio Rao2012-11-091-2/+1
| | | | | | | | Porters should refer to __FreeBSD_version 1000021 for this change as it may have happened at the same timeframe. Notes: svn path=/head/; revision=242833
* Prefer __containerof() above member2struct().Ed Schouten2012-09-151-1/+1
| | | | | | | | The first does proper checking of the argument types, while the latter does not. Notes: svn path=/head/; revision=240539
* Streamline use of cdevpriv and correct some corner cases.Hans Petter Selasky2012-08-151-0/+3
| | | | | | | | | | | | | | | | | | | | | | | 1) It is not useful to call "devfs_clear_cdevpriv()" from "d_close" callbacks, hence for example read, write, ioctl and so on might be sleeping at the time of "d_close" being called and then then freed private data can still be accessed. Examples: dtrace, linux_compat, ksyms (all fixed by this patch) 2) In sys/dev/drm* there are some cases in which memory will be freed twice, if open fails, first by code in the open routine, secondly by the cdevpriv destructor. Move registration of the cdevpriv to the end of the drm open routines. 3) devfs_clear_cdevpriv() is not called if the "d_open" callback registered cdevpriv data and the "d_open" callback function returned an error. Fix this. Discussed with: phk MFC after: 2 weeks Notes: svn path=/head/; revision=239303
* Extend the KPI to lock and unlock f_offset member of struct file. ItKonstantin Belousov2012-07-021-11/+4
| | | | | | | | | | | | | | | | | | | | | now fully encapsulates all accesses to f_offset, and extends f_offset locking to other consumers that need it, in particular, to lseek() and variants of getdirentries(). Ensure that on 32bit architectures f_offset, which is 64bit quantity, always read and written under the mtxpool protection. This fixes apparently easy to trigger race when parallel lseek()s or lseek() and read/write could destroy file offset. The already broken ABI emulations, including iBCS and SysV, are not converted (yet). Tested by: pho No objections from: jhb MFC after: 3 weeks Notes: svn path=/head/; revision=238029
* Revert devfs part of r235911. I was unaware about old but unfinishedAlexander Motin2012-05-241-45/+0
| | | | | | | discussion between kib@ and gibbs@ about it. Notes: svn path=/head/; revision=235922
* MFprojects/zfsd:Alexander Motin2012-05-241-0/+45
| | | | | | | | | | | | | | Revamp the CAM enclosure services driver. This updated driver uses an in-kernel daemon to track state changes and publishes physical path location information\for disk elements into the CAM device database. Sponsored by: Spectra Logic Corporation Sponsored by: iXsystems, Inc. Submitted by: gibbs, will, mav Notes: svn path=/head/; revision=235911
* Add "export" to devfs_opts[] and return EOPNOTSUPP if called with it.Martin Matuska2012-02-291-1/+4
| | | | | | | | | | Fixes mountd warnings. Reported by: kib MFC after: 1 week Notes: svn path=/head/; revision=232307
* To improve control over the use of mount(8) inside a jail(8), introduceMartin Matuska2012-02-231-15/+15
| | | | | | | | | | | | | | | | | | | | | | a new jail parameter node with the following parameters: allow.mount.devfs: allow mounting the devfs filesystem inside a jail allow.mount.nullfs: allow mounting the nullfs filesystem inside a jail Both parameters are disabled by default (equals the behavior before devfs and nullfs in jails). Administrators have to explicitly allow mounting devfs and nullfs for each jail. The value "-1" of the devfs_ruleset parameter is removed in favor of the new allow setting. Reviewed by: jamie Suggested by: pjd MFC after: 2 weeks Notes: svn path=/head/; revision=232059
* Fix found places where uio_resid is truncated to int.Konstantin Belousov2012-02-211-2/+4
| | | | | | | | | | | | Add the sysctl debug.iosize_max_clamp, enabled by default. Setting the sysctl to zero allows to perform the SSIZE_MAX-sized i/o requests from the usermode. Discussed with: bde, das (previous versions) MFC after: 1 month Notes: svn path=/head/; revision=231949
* Merge si_name and __si_namebuf.Ed Schouten2012-02-101-1/+0
| | | | | | | | The si_name pointer always points to the __si_namebuf member inside the same object. Remove it and rename __si_namebuf to si_name. Notes: svn path=/head/; revision=231379
* Add support for mounting devfs inside jails.Martin Matuska2012-02-091-1/+13
| | | | | | | | | | | | | | | | A new jail(8) option "devfs_ruleset" defines the ruleset enforcement for mounting devfs inside jails. A value of -1 disables mounting devfs in jails, a value of zero means no restrictions. Nested jails can only have mounting devfs disabled or inherit parent's enforcement as jails are not allowed to view or manipulate devfs(8) rules. Utilizes new functions introduced in r231265. Reviewed by: jamie MFC after: 1 month Notes: svn path=/head/; revision=231267
* Introduce the "ruleset=number" option for devfs(5) mounts.Martin Matuska2012-02-093-1/+79
| | | | | | | | | | | | | | | Add support for updating the devfs mount (currently only changing the ruleset number is supported). Check mnt_optnew with vfs_filteropt(9). This new option sets the specified ruleset number as the active ruleset of the new devfs mount and applies all its rules at mount time. If the specified ruleset doesn't exist, a new empty ruleset is created. MFC after: 1 month Notes: svn path=/head/; revision=231265
* Explicitly use curthread while manipulating td_fpop during last closeJohn Baldwin2011-12-091-3/+7
| | | | | | | | | | | | | | | | of a devfs file descriptor in devfs_close_f(). The passed in td argument may be NULL if the close was invoked by garbage collection of open file descriptors in pending control messages in the socket buffer of a UNIX domain socket after it was closed. PR: kern/151758 Submitted by: Andrey Shidakov andrey shidakov ru Submitted by: Ruben van Staveren ruben verweg com Reviewed by: kib MFC after: 2 weeks Notes: svn path=/head/; revision=228361
* Existing VOP_VPTOCNP() interface has a fatal flow that is critical forKonstantin Belousov2011-11-191-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | nullfs. The problem is that resulting vnode is only required to be held on return from the successfull call to vop, instead of being referenced. Nullfs VOP_INACTIVE() method reclaims the vnode, which in combination with the VOP_VPTOCNP() interface means that the directory vnode returned from VOP_VPTOCNP() is reclaimed in advance, causing vn_fullpath() to error with EBADF or like. Change the interface for VOP_VPTOCNP(), now the dvp must be referenced. Convert all in-tree implementations of VOP_VPTOCNP(), which is trivial, because vhold(9) and vref(9) are similar in the locking prerequisites. Out-of-tree fs implementation of VOP_VPTOCNP(), if any, should have no trouble with the fix. Tested by: pho Reviewed by: mckusick MFC after: 3 weeks (subject of re approval) Notes: svn path=/head/; revision=227697
* - fix duplicate "a a" in some commentsEitan Adler2011-11-131-1/+1
| | | | | | | | | Submitted by: eadler Approved by: simon MFC after: 3 days Notes: svn path=/head/; revision=227489
* Move the cleanup of f_cdevpriv when the reference count of a devfsJohn Baldwin2011-11-041-0/+7
| | | | | | | | | | | file descriptor drops to zero out of _fdrop() and into devfs_close_f() as it is only relevant for devfs file descriptors. Reviewed by: kib MFC after: 1 week Notes: svn path=/head/; revision=227069
* Fix kernel panic when d_fdopen csw method is called for NULL fp.Konstantin Belousov2011-11-031-0/+4
| | | | | | | | | | This may happen when kernel consumer calls VOP_OPEN(). Reported by: Tavis Ormandy <taviso cmpxchg8b com> through delphij MFC after: 3 days Notes: svn path=/head/; revision=227062
* Export devfs inode number allocator for the kernel consumers.Konstantin Belousov2011-10-051-3/+17
| | | | | | | | Reviewed by: jhb MFC after: 2 weeks Notes: svn path=/head/; revision=226041
* Add the fo_chown and fo_chmod methods to struct fileops and use themKonstantin Belousov2011-08-161-0/+2
| | | | | | | | | | | | | to implement fchown(2) and fchmod(2) support for several file types that previously lacked it. Add MAC entries for chown/chmod done on posix shared memory and (old) in-kernel posix semaphores. Based on the submission by: glebius Reviewed by: rwatson Approved by: re (bz) Notes: svn path=/head/; revision=224914
* Do not update mountpoint generation counter to the value which was notKonstantin Belousov2011-08-091-2/+4
| | | | | | | | | | | yet acted upon by devfs_populate(). Submitted by: Kohji Okuno <okuno.kohji jp panasonic com> Approved by: re (bz) MFC after: 1 week Notes: svn path=/head/; revision=224743
* While fixing the looping of a thread while devfs vnode is reclaimed,Konstantin Belousov2011-07-131-6/+12
| | | | | | | | | | | | | | | | | | | | | | r179247 introduced a possibility of devfs_allocv() returning spurious ENOENT. If the vnode is selected by vnlru daemon for reclamation, then devfs_allocv() can get ENOENT from vget() due to devfs_close() dropping vnode lock around the call to cdevsw d_close method. Use LK_RETRY in the vget() call, and do some part of the devfs_reclaim() work in devfs_allocv(), clearing vp->v_data and de->de_vnode. Retry the allocation of the vnode, now with de->de_vnode == NULL. The check vp->v_data == NULL at the start of devfs_close() cannot be affected by the change, since vnode lock must be held while VI_DOOMED is set, and only dropped after the check. Reported and tested by: Kohji Okuno <okuno.kohji jp panasonic com> Reviewed by: attilio MFC after: 3 weeks Notes: svn path=/head/; revision=223988
* Don't allow user created symbolic links to cover another entries markedJaakko Heinonen2010-12-151-0/+5
| | | | | | | | | | with DE_USER. If a devfs rule hid such entry, it was possible to create infinite number of symbolic links with the same name. Reviewed by: kib Notes: svn path=/head/; revision=216462
* - Assert that dm_lock is exclusively held in devfs_rules_apply() andJaakko Heinonen2010-12-153-0/+5
| | | | | | | | | | | in devfs_vmkdir() while adding the entry to de_list of the parent. - Apply devfs rules to newly created directories and symbolic links. PR: kern/125034 Submitted by: Mateusz Guzik (original version) Notes: svn path=/head/; revision=216461
* Handle the special ruleset 0 in devfs_ruleset_use(). An attempt set theJaakko Heinonen2010-12-121-0/+5
| | | | | | | | | | | current ruleset to 0 with command "devfs ruleset 0" triggered a KASSERT in devfs_ruleset_create(). PR: kern/125030 Submitted by: Mateusz Guzik Notes: svn path=/head/; revision=216391
* Format prototypes to follow style(9) more closely.Jaakko Heinonen2010-10-122-22/+25
| | | | | | | Discussed with: kib, phk Notes: svn path=/head/; revision=213725
* Add a new function devfs_dev_exists() to be able to find out if aJaakko Heinonen2010-09-272-0/+22
| | | | | | | | | | | | specific devfs path already exists. The function will be used from kern_conf.c to detect duplicate device registrations. Callers must hold the devmtx mutex. Reviewed by: kib Notes: svn path=/head/; revision=213221
* Add reference counting for devfs paths containing user created symbolicJaakko Heinonen2010-09-275-2/+199
| | | | | | | | | | | | | | | | | | | links. The reference counting is needed to be able to determine if a specific devfs path exists. For true device file paths we can traverse the cdevp_list but a separate directory list is needed for user created symbolic links. Add a new directory entry flag DE_USER to mark entries which should unreference their parent directory on deletion. A new function to traverse cdevp_list and the directory list will be introduced in a separate commit. Idea from: kib Reviewed by: kib Notes: svn path=/head/; revision=213215
* Modify devfs_fqpn() for future use in devfs path reference countingJaakko Heinonen2010-09-212-14/+23
| | | | | | | | | | | | | | | | code: - Accept devfs_mount and devfs_dirent as the arguments instead of a vnode. This generalizes the function so that it can be used from contexts where vnode references are not available. - Accept NULL cnp argument. No '/' will be appended, if a NULL cnp is provided. - Make the function global and add its prototype to devfs.h. Reviewed by: kib Notes: svn path=/head/; revision=212966
* - For consistency, remove "." and ".." entries from de_dlist beforeJaakko Heinonen2010-09-181-0/+4
| | | | | | | | | | | | calling devfs_delete() (and thus possibly dropping dm_lock) in devfs_rmdir_empty(). - Assert that we don't return doomed entries from devfs_find(). [1] Suggested by: kib [1] Reviewed by: kib Notes: svn path=/head/; revision=212826