summaryrefslogtreecommitdiff
path: root/sys/fs/devfs/devfs_vfsops.c
Commit message (Collapse)AuthorAgeFilesLines
* vfs: drop the mostly unused flags argument from VOP_UNLOCKMateusz Guzik2020-01-031-1/+1
| | | | | | | | | | | Filesystems which want to use it in limited capacity can employ the VOP_UNLOCK_FLAGS macro. Reviewed by: kib (previous version) Differential Revision: https://reviews.freebsd.org/D21427 Notes: svn path=/head/; revision=356337
* devfs: use MNTK_NOMSYNCMateusz Guzik2019-10-131-1/+2
| | | | | | | | | Reviewed by: kib Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D22009 Notes: svn path=/head/; revision=353471
* devfs: add root vnode cachingMateusz Guzik2019-10-061-1/+3
| | | | | | | | | | See r353150. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D21646 Notes: svn path=/head/; revision=353152
* Make it easier for filesystems to count themselves as jail-enabled,Jamie Gritton2018-05-041-3/+0
| | | | | | | | | | | | | | | by doing most of the work in a new function prison_add_vfs in kern_jail.c Now a jail-enabled filesystem need only mark itself with VFCF_JAIL, and the rest is taken care of. This includes adding a jail parameter like allow.mount.foofs, and a sysctl like security.jail.mount_foofs_allowed. Both of these used to be a static list of known filesystems, with predefined permission bits. Reviewed by: kib Differential Revision: D14681 Notes: svn path=/head/; revision=333263
* sys/fs: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-271-0/+2
| | | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=326268
* 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
* 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
* 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
* 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-091-1/+42
| | | | | | | | | | | | | | | 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
* Enable shared lookups and externed shared ops for devfs.Konstantin Belousov2010-08-061-1/+2
| | | | | | | | In collaboration with: pho MFC after: 1 month Notes: svn path=/head/; revision=210925
* Enable shared locks for the devfs vnodes. Honor the locking modeKonstantin Belousov2010-08-061-1/+1
| | | | | | | | | | requested by lookup(). This should be a nop at the moment. In collaboration with: pho MFC after: 1 month Notes: svn path=/head/; revision=210921
* Move "options MAC" from opt_mac.h to opt_global.h, as it's now in GENERICRobert Watson2009-06-051-2/+0
| | | | | | | | | | | and used in a large number of files, but also because an increasing number of incorrect uses of MAC calls were sneaking in due to copy-and-paste of MAC-aware code without the associated opt_mac.h include. Discussed with: pjd Notes: svn path=/head/; revision=193511
* Re-add opt_mac.h include, which is required in order for MNT_MULTILABELRobert Watson2009-06-041-0/+2
| | | | | | | | | | | to be set properly on devfs. Otherwise, it isn't possible to set labels on /dev nodes. Reported by: Sergio Rodriguez <sergiorr at yahoo.com> MFC after: 3 days Notes: svn path=/head/; revision=193433
* Remove the thread argument from the FSD (File-System Dependent) parts ofAttilio Rao2009-05-111-7/+7
| | | | | | | | | | | | | | | | | | | | the VFS. Now all the VFS_* functions and relating parts don't want the context as long as it always refers to curthread. In some points, in particular when dealing with VOPs and functions living in the same namespace (eg. vflush) which still need to be converted, pass curthread explicitly in order to retain the old behaviour. Such loose ends will be fixed ASAP. While here fix a bug: now, UFS_EXTATTR can be compiled alone without the UFS_EXTATTR_AUTOSTART option. VFS KPI is heavilly changed by this commit so thirdy parts modules needs to be recompiled. Bump __FreeBSD_version in order to signal such situation. Notes: svn path=/head/; revision=191990
* VOP_LOCK1() (and so VOP_LOCK()) and VOP_UNLOCK() are only used inAttilio Rao2008-01-131-1/+1
| | | | | | | | | | | | | | conjuction with 'thread' argument passing which is always curthread. Remove the unuseful extra-argument and pass explicitly curthread to lower layer functions, when necessary. KPI results broken by this change, which should affect several ports, so version bumping and manpage update will be further committed. Tested by: kris, pho, Diego Sardina <siarodx at gmail dot com> Notes: svn path=/head/; revision=175294
* Use mount interlock to protect all changes to mnt_flag and mnt_kern_flag.Tor Egge2006-09-261-0/+2
| | | | | | | | This eliminates a race where MNT_UPDATE flag could be lost when nmount() raced against sync(), sync_fsync() or quotactl(). Notes: svn path=/head/; revision=162647
* Resolve the devfs deadlock caused by LOR between devfs_mount->dm_lock andKonstantin Belousov2006-09-181-4/+20
| | | | | | | | | | | | | | | | | | 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-2/+0
| | | | | | | | | DEVFS. Remove the opt_devfs.h file now that it is empty. Notes: svn path=/head/; revision=160425
* Remove now unneeded opt_mac.h and mac.h includes.Robert Watson2006-07-061-2/+0
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=160133
* Make rule zero really magical, that way we don't have to do anythingPoul-Henning Kamp2005-09-241-1/+1
| | | | | | | | | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=150501
* Rewamp DEVFS internals pretty severely [1].Poul-Henning Kamp2005-09-191-33/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Eliminate effectively unused dm_basedir field from devfs_mount.Poul-Henning Kamp2005-08-151-1/+0
| | | | Notes: svn path=/head/; revision=149107
* devfs is not yet fully MPSAFE - for example, multiple concurrent devfs(8)Kris Kennaway2005-07-291-1/+0
| | | | | | | | | processes can cause a panic when operating on rulesets. Approved by: phk Notes: svn path=/head/; revision=148547
* - Mark devfs as MNTK_MPSAFE as I belive it does not require Giant.Jeff Roberson2005-04-301-0/+1
| | | | | | | | Sponsored by: Isilon Systems, Inc. Agreed in principle by: phk Notes: svn path=/head/; revision=145698
* - LK_NOPAUSE is a nop now.Jeff Roberson2005-03-311-1/+1
| | | | | | | Sponsored by: Isilon Systems, Inc. Notes: svn path=/head/; revision=144366
* - Update vfs_root implementations to match the new prototype. None ofJeff Roberson2005-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. Notes: svn path=/head/; revision=144058
* Silently ignore forced argument to unmount.Poul-Henning Kamp2005-01-111-2/+0
| | | | Notes: svn path=/head/; revision=140067
* /* -> /*- for copyright notices, minor format tweaks as necessaryWarner Losh2005-01-061-1/+1
| | | | Notes: svn path=/head/; revision=139776
* Unsupport forceful unmounts of DEVFS.Poul-Henning Kamp2005-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. Notes: svn path=/head/; revision=139664
* Use vfs_mountedfrom() and rely on vfs_mount.c to call VFS_STATFS()Poul-Henning Kamp2004-12-061-3/+2
| | | | Notes: svn path=/head/; revision=138481
* VFS_STATFS(mp, ...) is mostly called with &mp->mnt_stat, but a few casesPoul-Henning Kamp2004-12-051-6/+0
| | | | | | | | | | | doesn't. Most of the implementations have grown weeds for this so they copy some fields from mnt_stat if the passed argument isn't that. Fix this the cleaner way: Always call the implementation on mnt_stat and copy that in toto to the VFS_STATFS argument if different. Notes: svn path=/head/; revision=138412
* Ignore MNT_NODEV, it is implicit in choice of filesystem these days.Poul-Henning Kamp2004-11-261-1/+1
| | | | Notes: svn path=/head/; revision=138106
* Refuse attemps to mount root filesystemPoul-Henning Kamp2004-11-091-1/+1
| | | | Notes: svn path=/head/; revision=137478
* What can I say: don't allow people to mount DEVFS with option "nodev".Poul-Henning Kamp2004-10-281-4/+2
| | | | Notes: svn path=/head/; revision=137006
* Put a version element in the VFS filesystem configuration structurePoul-Henning Kamp2004-07-301-6/+3
| | | | | | | | | | | | | | | | | | | | | and refuse initializing filesystems with a wrong version. This will aid maintenance activites on the 5-stable branch. s/vfs_mount/vfs_omount/ s/vfs_nmount/vfs_mount/ Name our filesystems mount function consistently. Eliminate the namiedata argument to both vfs_mount and vfs_omount. It was originally there to save stack space. A few places abused it to get hold of some credentials to pass around. Effectively it is unused. Reorganize the root filesystem selection code. Notes: svn path=/head/; revision=132902
* Make VFS_ROOT() and vflush() take a thread argument.Alfred Perlstein2004-07-121-5/+4
| | | | | | | | | This is to allow filesystems to decide based on the passed thread which vnode to return. Several filesystems used curthread, they now use the passed thread. Notes: svn path=/head/; revision=132023
* Initialize struct vfsops C99-sparsely.Poul-Henning Kamp2003-06-121-15/+4
| | | | | | | | Submitted by: hmp Reviewed by: phk Notes: svn path=/head/; revision=116271
* Rename vfs_stdsync function to vfs_stdnosync which matches moreAlexander Kabaev2003-03-111-1/+1
| | | | | | | | | | | | | | | | closely what function is really doing. Update all existing consumers to use the new name. Introduce a new vfs_stdsync function, which iterates over mount point's vnodes and call FSYNC on each one of them in turn. Make nwfs and smbfs use this new function instead of rolling their own identical sync implementations. Reviewed by: jeff Notes: svn path=/head/; revision=112119
* Back out M_* changes, per decision of the TRB.Warner Losh2003-02-191-2/+2
| | | | | | | 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-2/+2
| | | | | | | Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT. Notes: svn path=/head/; revision=109623
* Remove dm_root entry from struct devfs_mount. It's never set, and isRobert Watson2002-12-091-1/+2
| | | | | | | | | | | | | | | 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
* A better solution to avoiding variable sized structs in DEVFS.Poul-Henning Kamp2002-10-161-0/+4
| | | | Notes: svn path=/head/; revision=105210
* Introduce typedefs for the member functions of struct vfsops and employPoul-Henning Kamp2002-08-131-9/+6
| | | | | | | | | | these in the main filesystems. This does not change the resulting code but makes the source a little bit more grepable. Sponsored by: DARPA and NAI Labs. Notes: svn path=/head/; revision=101777
* - Replace v_flag with v_iflag and v_vflagJeff Roberson2002-08-041-1/+1
| | | | | | | | | | | | | | | | | | - v_vflag is protected by the vnode lock and is used when synchronization with VOP calls is needed. - v_iflag is protected by interlock and is used for dealing with vnode management issues. These flags include X/O LOCK, FREE, DOOMED, etc. - All accesses to v_iflag and v_vflag have either been locked or marked with mp_fixme's. - Many ASSERT_VOP_LOCKED calls have been added where the locking was not clear. - Many functions in vfs_subr.c were restructured to provide for stronger locking. Idea stolen from: BSD/OS Notes: svn path=/head/; revision=101308
* Introduce support for Mandatory Access Control and extensibleRobert Watson2002-07-311-0/+8
| | | | | | | | | | | | | | | | | | | 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/+1
| | | | | | | | | | | | | | 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
* Convert devfs to nmount.Maxime Henrion2002-05-021-6/+5
| | | | | | | Reviewed by: phk Notes: svn path=/head/; revision=95954