summaryrefslogtreecommitdiffstats
path: root/sys/kern/vfs_syscalls.c
Commit message (Collapse)AuthorAgeFilesLines
* Update the statfs structure with 64-bit fields to allowmckusick2003-11-121-13/+296
| | | | | | | | | | | | | | | | | accurate reporting of multi-terabyte filesystem sizes. You should build and boot a new kernel BEFORE doing a `make world' as the new kernel will know about binaries using the old statfs structure, but an old kernel will not know about the new system calls that support the new statfs structure. Running an old kernel after a `make world' will cause programs such as `df' that do a statfs system call to fail with a bad system call. Reviewed by: Bruce Evans <bde@zeta.org.au> Reviewed by: Tim Robbins <tjr@freebsd.org> Reviewed by: Julian Elischer <julian@elischer.org> Reviewed by: the hoards of <arch@freebsd.org> Sponsored by: DARPA & NAI Labs.
* falloc allocates a file structure and adds it to the file descriptordwmalone2003-10-191-10/+2
| | | | | | | | | | | | | | | | | | | | | table, acquiring the necessary locks as it works. It usually returns two references to the new descriptor: one in the descriptor table and one via a pointer argument. As falloc releases the FILEDESC lock before returning, there is a potential for a process to close the reference in the file descriptor table before falloc's caller gets to use the file. I don't think this can happen in practice at the moment, because Giant indirectly protects closes. To stop the file being completly closed in this situation, this change makes falloc set the refcount to two when both references are returned. This makes life easier for several of falloc's callers, because the first thing they previously did was grab an extra reference on the file. Reviewed by: iedowse Idea run past: jhb
* Add mac_check_vnode_deleteextattr() and mac_check_vnode_listextattr():rwatson2003-08-211-4/+3
| | | | | | | | | | | explicit access control checks to delete and list extended attributes on a vnode, rather than implicitly combining with the setextattr and getextattr checks. This reflects EA API changes in the kernel made recently, including the move to explicit VOP's for both of these operations. Obtained from: TrustedBSD PRoject Sponsored by: DARPA, Network Associates Laboratories
* td_dupfd just needs to be less than 0, it does not have to hold thejhb2003-08-071-1/+1
| | | | negative value of the index of the new file, so just use -1.
* In the mknod(), mkfifo(), link(), symlink() and undelete() syscalls,iedowse2003-08-051-5/+23
| | | | | | | | | | | | | | use vrele() instead of vput() on the parent directory vnode returned by namei() in the case where it is equal to the target vnode. This handles namei()'s somewhat strange (but documented) behaviour of not locking either vnode when the two vnodes are equal and LOCKPARENT but not LOCKLEAF is specified. Note that since a vnode double-unlock is not currently fatal, these coding errors were effectively harmless. Spotted by: Juergen Hannken-Illjes <hannken@eis.cs.tu-bs.de> Reviewed by: mckusick
* Rename VOP_RMEXTATTR() to VOP_DELETEEXTATTR() for consistency with therwatson2003-07-281-1/+2
| | | | | | | | | | | | kernel ACL interfaces and system call names. Break out UFS2 and FFS extattr delete and list vnode operations from setextattr and getextattr to deleteextattr and listextattr, which cleans up the implementations, and makes the results more readable, and makes the APIs more clear. Obtained from: TrustedBSD Project Sponsored by: DARPA, Network Associates Laboratories
* Pass the file descriptor index down to vn_open.phk2003-07-271-1/+13
| | | | | If the method vector was replaced and we got the "special return code" smile and trust that whatever happened below DTRT.
* Add fdidx argument to vn_open() and vn_open_cred() and pass -1 throughout.phk2003-07-271-1/+1
|
* Add a "int fd" argument to VOP_OPEN() which in the future willphk2003-07-261-1/+1
| | | | | | | | | contain the filedescriptor number on opens from userland. The index is used rather than a "struct file *" since it conveys a bit more information, which may be useful to in particular fdescfs and /dev/fd/* For now pass -1 all over the place.
* Use the f_vnode field to tell which file descriptors have a vnode.phk2003-07-041-1/+2
|
* Prefer the vop_rmextattr() vnode operation for removing extendedrwatson2003-06-221-2/+4
| | | | | | | | | attributes from objects over vop_setextattr() with a NULL uio; if the file system doesn't support the vop_rmextattr() method, fall back to the vop_setextattr() method. Obtained from: TrustedBSD Project Sponsored by: DARPA, Network Associates Laboratories
* Add a f_vnode field to struct file.phk2003-06-221-16/+20
| | | | | | | | | | | | Several of the subtypes have an associated vnode which is used for stuff like the f*() functions. By giving the vnode a speparate field, a number of checks for the specific subtype can be replaced simply with a check for f_vnode != NULL, and we can later free f_data up to subtype specific use. At this point in time, f_data still points to the vnode, so any code I might have overlooked will still work.
* Don't (re)initialize f_gcflag to zero.phk2003-06-201-0/+1
| | | | | Move initialization of DTYPE_VNODE specific field f_seqcount into the DTYPE_VNODE specific code.
* FILE_LOCK() uses a pool mutex, as does the vnode v_vnlock. Since pooltruckman2003-06-191-5/+5
| | | | | | | | | | mutexes are supposed to only be used as leaf mutexes, and what appear to be separate pool mutexes could be aliased together, it is bad idea for a thread to attempt to hold two pool mutexes at the same time. Slightly rearrange the code in kern_open() so that FILE_UNLOCK() is called before calling VOP_GETVOBJECT(), which will grab the v_vnlock mutex.
* Introduce a new flag on a file descriptor: DFLAG_SEEKABLE and use thatphk2003-06-181-1/+1
| | | | rather than assume that only DTYPE_VNODE is seekable.
* Use __FBSDID().obrien2003-06-111-1/+3
|
* If a system call comes in requesting to retrieve an attribute namedrwatson2003-06-051-1/+13
| | | | | | | | | | | | "", temporarily map it to a call to extattr_list_vp() to provide compatibility for older applications using the "" API to retrieve EA lists. Use VOP_LISTEXTATTR() to support extattr_list_vp() rather than VOP_GETEXTATTR(..., "", ...). Obtained from: TrustedBSD Project Sponsored by: DARPA, Network Asssociates Laboratories
* Implementations of extattr_list_fd(), extattr_list_file(), andrwatson2003-06-041-0/+143
| | | | | | | | | | | | | | | extattr_list_link() system calls, which return a least of extended attributes defined for a vnode referenced by a file descriptor or path name. Currently, we just invoke VOP_GETEXTATTR() since it will convert a request for an empty name into a query for a name list, which was the old (more hackish) API. At some point in the near future, we'll push the distinction between get and list down to the vnode operation layer, but this provides access to the new API for applications in the short term. Pointed out by: Dominic Giampaolo <dbg@apple.com> Obtained from: TrustedBSD Project Sponsored by: DARPA, Network Associates Laboratories
* Remove unused variable(s).phk2003-05-311-6/+1
| | | | Found by: FlexeLint
* Deprecate machine/limits.h in favor of new sys/limits.h.kan2003-04-291-1/+1
| | | | | | | Change all in-tree consumers to include <sys/limits.h> Discussed on: standards@ Partially submitted by: Craig Rodrigues <rodrigc@attbi.com>
* - Acquire the vm_object's lock when performing vm_object_page_clean().alc2003-04-241-0/+2
| | | | | | - Add a parameter to vm_pageout_flush() that tells vm_pageout_flush() whether its caller has locked the vm_object. (This is a temporary measure to bootstrap vm_object locking.)
* o In struct prison, add an allprison linked list of prisons (protectedmike2003-04-091-44/+65
| | | | | | | | | | | | | | | by allprison_mtx), a unique prison/jail identifier field, two path fields (pr_path for reporting and pr_root vnode instance) to store the chroot() point of each jail. o Add jail_attach(2) to allow a process to bind to an existing jail. o Add change_root() to perform the chroot operation on a specified vnode. o Generalize change_dir() to accept a vnode, and move namei() calls to callers of change_dir(). o Add a new sysctl (security.jail.list) which is a group of struct xprison instances that represent a snapshot of active jails. Reviewed by: rwatson, tjr
* Move the initialization of the vattr flags field in setfflags() torwatson2003-03-051-6/+3
| | | | | | | | | | | | | before the MAC check so that we pass the flags field into the MAC check properly initialized. This didn't affect any current MAC modules since they didn't care what the flags argument was (as they were primarily interested in the fact that it was a meta-data write, not the contents of the write), but would be relevant to future modules relying on that field. Submitted by: Mike Halderman <mrh@spawar.navy.mil> Obtained from: TrustedBSD Project Sponsored by: DARPA, Network Associates Laboratories
* Back out M_* changes, per decision of the TRB.imp2003-02-191-2/+2
| | | | Approved by: trb
* Remove extraneous FILEDESC_LOCK around atomic read.hsu2003-02-161-2/+0
|
* Correct handling of locking for chroot() and chdir() cases: ratherrwatson2003-01-311-7/+8
| | | | | | | | | than having change_dir() release the vnode lock on success, hold the lock so that we can use it later when invoking MAC checks and VOP_ACCESS() in the chroot() code. Update the comment to reflect this calling convention. Update callers to unlock the vnode lock. Correct a typo regarding vnode naming in the MAC case that crept in via the previous patch applied.
* Clean up vnode handling on return from chroot() in certain errorrwatson2003-01-311-2/+4
| | | | | | | | cases: we might multiply vrele() a vnode when certain classes of failures occur. This appears to stem from earlier Giant/file descriptor lock pushdown and restructuring. Submitted by: maxim
* Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.alfred2003-01-211-2/+2
| | | | Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.
* Bow to the whining masses and change a union back into void *. Retaindillon2003-01-131-21/+21
| | | | | removal of unnecessary casts and throw in some minor cleanups to see if anyone complains, just for the hell of it.
* Change struct file f_data to un_data, a union of the correct structdillon2003-01-121-21/+21
| | | | | | | | | | pointer types, and remove a huge number of casts from code using it. Change struct xfile xf_data to xun_data (ABI is still compatible). If we need to add a #define for f_data and xf_data we can, but I don't think it will be necessary. There are no operational changes in this commit.
* Correct file descriptor leaks in lseek and do_dup.nectar2003-01-061-8/+15
| | | | | | | The leak in lseek was introduced in vfs_syscalls.c revision 1.218. The leak in do_dup was introduced in kern_descrip.c revision 1.158. Submitted by: iedowse
* unwrap lines made short enough by SCARGS removalalfred2002-12-141-8/+4
|
* remove syscallarg().alfred2002-12-141-177/+177
| | | | Suggested by: peter
* SCARGS removal take II.alfred2002-12-141-85/+85
|
* Backout removal SCARGS, the code freeze is only "selectively" over.alfred2002-12-131-85/+85
|
* Remove SCARGS.alfred2002-12-131-85/+85
| | | | Reviewed by: md5
* Fix a case in kern_rename() where a vn_finished_write() call wasiedowse2002-10-271-2/+2
| | | | | | | | missed. This bug has been present since the vn_start_write() and vn_finished_write() calls were first added in revision 1.159. When the case is triggered, any attempts to create snapshots on the filesystem will deadlock and also prevent further write activity on that filesystem.
* Change the way support for asynchronous I/O is indicated to applicationswollman2002-10-271-1/+14
| | | | | | | | | | to conform to 1003.1-2001. Make it possible for applications to actually tell whether or not asynchronous I/O is supported. Since FreeBSD's aio implementation works on all descriptor types, don't call down into file or vnode ops when [f]pathconf() is asked about _PC_ASYNC_IO; this avoids the need for every file and vnode op to know about it.
* Hook up most of the MAC entry points relating to file/directory/noderwatson2002-10-191-2/+68
| | | | | | | | | | | | | | | | | | | creation, deletion, and rename. There are one or two other stray cases I'll catch in follow-up commits (such as unix domain socket creation); this permits MAC policy modules to limit the ability to perform these operations based on existing UNIX credential / vnode attributes, extended attributes, and security labels. In the rename case using MAC, we now have to lock the from directory and file vnodes for the MAC check, but this is done only in the MAC case, and the locks are immediately released so that the remainder of the rename implementation remains the same. Because the create check takes a vattr to know object type information, we now initialize additional fields in the VATTR passed to VOP_SYMLINK() in the MAC case. Approved by: re Obtained from: TrustedBSD Project Sponsored by: DARPA, Network Associates Laboratories
* Incremental style improvements: more consistently avoid assignmentsrwatson2002-10-101-18/+31
| | | | | | | in conditionals; remove some excess vertical whitespace; remove a bug in the return handling of the delete_vp() case for MAC. Spotted by: bde
* Explore new heights in alphabetization for _file and _fd variations onrwatson2002-10-101-60/+60
| | | | the extended attribute system calls.
* Implement extattr_{delete,get,set}_link() system calls: extended attributerwatson2002-10-091-0/+90
| | | | | | | operations that do not follow links. Sync to MAC tree. Obtained from: TrustedBSD Project Sponsored by: DARPA, Network Associates Laboratories
* Add back a fdrop() call at the end of kern_open() that got lost iniedowse2002-10-071-0/+1
| | | | | | | | | revision 1.218. This bug caused a "struct file" reference to be leaked if VOP_ADVLOCK(), vn_start_write(), or mac_check_vnode_write() failed during the open operation. PR: kern/43739 Reported by: Arne Woerner <woerner@mediabase-gmbh.de>
* Merge support for mac_check_vnode_link(), a MAC framework/policy entryrwatson2002-10-051-1/+6
| | | | | | | | point that instruments the creation of hard links. Policy implementations to follow. Obtained from: TrustedBSD Project Sponsored by: DARPA, Network Associates Laboratories
* Fix mis-indentation.phk2002-10-021-1/+1
| | | | Spotted by: FlexeLint
* - Properly lock v_vflags in getdirents().jeff2002-09-251-4/+14
|
* VOP_FSYNC() requires that it's vnode argument be locked, which nfs_link()truckman2002-09-191-1/+3
| | | | | | | | | | wasn't doing. Rather than just lock and unlock the vnode around the call to VOP_FSYNC(), implement rwatson's suggestion to lock the file vnode in kern_link() before calling VOP_LINK(), since the other filesystems also locked the file vnode right away in their link methods. Remove the locking and and unlocking from the leaf filesystem link methods. Reviewed by: rwatson, bde (except for the unionfs_link() changes)
* vfs_syscalls.c:bde2002-09-101-7/+3
| | | | | | | | | | | | | | | | | | | | | | Changed rename(2) to follow the letter of the POSIX spec. POSIX requires rename() to have no effect if its args "resolve to the same existing file". I think "file" can only reasonably be read as referring to the inode, although the rationale and "resolve" seem to say that sameness is at the level of (resolved) directory entries. ext2fs_vnops.c, ufs_vnops.c: Replaced code that gave the historical BSD behaviour of removing one link name by checks that this code is now unreachable. This fixes some races. All vnodes needed to be unlocked for the removal, and locking at another level using something like IN_RENAME was not even attempted, so it was possible for rename(x, y) to return with both x and y removed even without any unlink(2) syscalls (one process can remove x using rename(x, y) and another process can remove y using rename(y, x)). Prodded by: alfred MFC after: 8 weeks PR: 42617
* Split out a number of mostly VFS and signal related syscalls intoiedowse2002-09-011-82/+214
| | | | | | | | | | | | a kernel-internal kern_*() version and a wrapper that is called via the syscall vector table. For paths and structure pointers, the internal version either takes a uio_seg parameter or requires the caller to copyin() the data to kernel memory as appropiate. This will permit emulation layers to use these syscalls without having to copy out translated arguments to the stack gap. Discussed on: -arch Review/suggestions: bde, jhb, peter, marcel
* - Hold the vnode lock across unlink() so that the v_vflag check is safe.jeff2002-08-211-15/+20
| | | | - Fix the long broken error handling for VV_ROOT and VDIR.
OpenPOWER on IntegriCloud