aboutsummaryrefslogtreecommitdiff
path: root/sys/fs/devfs
Commit message (Collapse)AuthorAgeFilesLines
...
* Remove zero assignments in the cdev allocator. cdp memory isKonstantin Belousov2016-05-211-5/+0
| | | | | | | | | | requested with M_ZERO. Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Notes: svn path=/head/; revision=300365
* sys/devfs: unsign an index to prevent signed integer overflow.Pedro F. Giffuni2016-04-281-1/+1
| | | | | | | | | | cdp_maxdirent in struct:cdev_priv is of type u_int. Use the same type for the corresponding index in devfs_revoke(). MFC after: 1 week Notes: svn path=/head/; revision=298732
* When devfs dirent is freed, a vnode might still keep a pointer to it,Konstantin Belousov2016-01-221-0/+7
| | | | | | | | | | | apparently. Interlock and clear the pointer to avoid free memory dereference. Submitted by: bde (previous version) MFC after: 3 weeks Notes: svn path=/head/; revision=294595
* Assert that the linkage between struct cdev_privdata and and structKonstantin Belousov2016-01-171-0/+2
| | | | | | | | | | | file is consistent. Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Notes: svn path=/head/; revision=294204
* Make devfs_fpdrop() static. It was not a public KPI, and it has noKonstantin Belousov2016-01-131-1/+1
| | | | | | | | | | reason to remain exported for some time. Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=293827
* Hide transient EBADF errors caused by the parallel revoke(2) or forcedKonstantin Belousov2016-01-021-3/+3
| | | | | | | | | | | | | | | | unmount of devfs mounts, by restarting the failed syscall. When restarted, failing syscalls eventually either stop finding the node and returning ENOENT, or the vnode op vectors finally transition to the deadfs vop. The later return EIO or other error, more appropriate for the operation. Submitted by: bde Tested by: pho MFC after: 3 weeks Notes: svn path=/head/; revision=293059
* Minor style cleanup.Konstantin Belousov2016-01-011-1/+1
| | | | | | | | Submitted by: bde MFC after: 1 week Notes: svn path=/head/; revision=293042
* Make it possible for the cdevsw d_close() driver method to detect lastKonstantin Belousov2015-12-221-3/+9
| | | | | | | | | | | | | | | | | | | close and close due to revoke(2)-like operation. A new FLASTCLOSE flag indicates that this is last close. FREVOKE is set for revokes, and FNONBLOCK is also set, same as is already done for VOP_CLOSE() call from vgonel(). The flags reuse user open(2) flags which are never stored in f_flag, to not consume bit space in the ABI visible way. Assert this with the static check. Requested and reviewed by: bde Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Notes: svn path=/head/; revision=292624
* Keep devfs mount locked for the whole duration of the devfs_setattr(),Konstantin Belousov2015-12-221-7/+14
| | | | | | | | | | | and ensure that our dirent is instantiated. Reported and tested by: bde Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=292621
* The cdevpriv_dtr_t typedef was not able to be used in a function prototypeJohn Baldwin2015-12-021-1/+1
| | | | | | | | | | | | | | | | | | like the various d_*_t typedefs since it declared a function pointer rather than a function. Add a new d_priv_dtor_t typedef that declares the function and can be used as a function prototype. The previous typedef wasn't useful outside of the cdevpriv implementation, so retire it. The name d_priv_dtor_t was chosen to be more consistent with cdev methods since it is commonly used in place of d_close_t even though it is not a direct pointer in struct cdevsw. Reviewed by: kib, imp MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D4340 Notes: svn path=/head/; revision=291653
* Make it possible to forcibly unmount devfs.Edward Tomasz Napierala2015-08-241-0/+2
| | | | | | | | MFC after: 1 month Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=287109
* After r286237 it should be fine to call vgone(9) on a busy GEOM vnode;Edward Tomasz Napierala2015-08-231-1/+2
| | | | | | | | | | remove KASSERT that would prevent forced devfs unmount from working. MFC after: 1 month Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=287033
* The changes that introduced fo_mmap() treated all character deviceJohn Baldwin2015-08-061-6/+17
| | | | | | | | | | | | | | | | | mappings as if MAP_SHARED was always present since in general MAP_PRIVATE is not permitted for character devices. However, there is one exception in that MAP_PRIVATE mappings are permitted for /dev/zero. Only require a writable file descriptor (FWRITE) for shared, writable mappings of character devices. vm_mmap_cdev() will reject any private mappings for other devices. Reviewed by: kib Reported by: sbruno (broke qemu cross-builds), peter Differential Revision: https://reviews.freebsd.org/D3316 Notes: svn path=/head/; revision=286371
* Add a new file operations hook for mmap operations. File type-specificJohn Baldwin2015-06-041-0/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | logic is now placed in the mmap hook implementation rather than requiring it to be placed in sys/vm/vm_mmap.c. This hook allows new file types to support mmap() as well as potentially allowing mmap() for existing file types that do not currently support any mapping. The vm_mmap() function is now split up into two functions. A new vm_mmap_object() function handles the "back half" of vm_mmap() and accepts a referenced VM object to map rather than a (handle, handle_type) tuple. vm_mmap() is now reduced to converting a (handle, handle_type) tuple to a a VM object and then calling vm_mmap_object() to handle the actual mapping. The vm_mmap() function remains for use by other parts of the kernel (e.g. device drivers and exec) but now only supports mapping vnodes, character devices, and anonymous memory. The mmap() system call invokes vm_mmap_object() directly with a NULL object for anonymous mappings. For mappings using a file descriptor, the descriptors fo_mmap() hook is invoked instead. The fo_mmap() hook is responsible for performing type-specific checks and adjustments to arguments as well as possibly modifying mapping parameters such as flags or the object offset. The fo_mmap() hook routines then call vm_mmap_object() to handle the actual mapping. The fo_mmap() hook is optional. If it is not set, then fo_mmap() will fail with ENODEV. A fo_mmap() hook is implemented for regular files, character devices, and shared memory objects (created via shm_open()). While here, consistently use the VM_PROT_* constants for the vm_prot_t type for the 'prot' variable passed to vm_mmap() and vm_mmap_object() as well as the vm_mmap_vnode() and vm_mmap_cdev() helper routines. Previously some places were using the mmap()-specific PROT_* constants instead. While this happens to work because PROT_xx == VM_PROT_xx, using VM_PROT_* is more correct. Differential Revision: https://reviews.freebsd.org/D2658 Reviewed by: alc (glanced over), kib MFC after: 1 month Sponsored by: Chelsio Notes: svn path=/head/; revision=283998
* Refine r280308. Do not completely disable timestamping of devfs nodesKonstantin Belousov2015-04-011-7/+25
| | | | | | | | | | | | | | | | | | on reads or writes, the time marks are used to display idle time by w(1) [1]. Instead, use vfs.devfs.dotimes as the selector of default precision vs. using time_second. The later gives seconds precision, which is good enough for the purpose. Note that timestamp updates are unlocked and the updates itself, as well as the check in devfs_timestamp, are non-atomic. Noted by: truckman [1] Reviewed by: bde Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=280949
* Disable timestamping on devfs read/write operations by default.Xin LI2015-03-212-3/+12
| | | | | | | | | | | | | | | | | | | | | Currently we update timestamps unconditionally when doing read or write operations. This may slow things down on hardware where reading timestamps is expensive (e.g. HPET, because of the default vfs.timestamp_precision setting is nanosecond now) with limited benefit. A new sysctl variable, vfs.devfs.dotimes is added, which can be set to non-zero value when the old behavior is desirable. Differential Revision: https://reviews.freebsd.org/D2104 Reported by: Mike Tancsa <mike sentex net> Reviewed by: kib Relnotes: yes Sponsored by: iXsystems, Inc. MFC after: 2 weeks Notes: svn path=/head/; revision=280308
* 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