summaryrefslogtreecommitdiffstats
path: root/sys/compat/linux/linux_file.c
Commit message (Collapse)AuthorAgeFilesLines
* Do not call VOP_GETATTR in getdents function. It does not serve anykan2003-11-191-6/+0
| | | | | | | | | | purpose and the resulting vattr structure was ignored. In addition, the VOP_GETATTR call was made with no vnode lock held, resulting in vnode locking violation panic with debug kernels. Reported by: truckman Approved by: re@ (rwatson)
* Add a f_vnode field to struct file.phk2003-06-221-1/+1
| | | | | | | | | | | | 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.
* Use __FBSDID().obrien2003-06-101-2/+3
|
* Fix a lock order reversal. Unlock the proc before calling fget().jhb2003-04-231-1/+1
| | | | Reported by: kris
* Use td->td_ucred instead of td->td_proc->p_ucred.jhb2003-03-201-1/+1
|
* Clean up whitespace and remove register keyword.des2003-03-031-16/+16
|
* More caddr_t removal, in conjunction with copy{in,out}(9) this time.des2003-03-031-10/+10
| | | | Also clean up some egregious casts and incorrect use of sizeof.
* Back out M_* changes, per decision of the TRB.imp2003-02-191-1/+1
| | | | Approved by: trb
* Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.alfred2003-01-211-1/+1
| | | | 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-1/+1
| | | | | 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-1/+1
| | | | | | | | | | 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.
* Fix emulation of the fcntl64() syscall. In Linux, this is exactlyiedowse2002-12-081-39/+33
| | | | | | | | | | | | | | | | | | | | the same as fcntl() except that it supports the new 64-bit file locking commands (LINUX_F_GETLK64 etc) that use the `flock64' structure. We had been interpreting all flock structures passed to fcntl64() as `struct flock64' instead of only the ones from F_*64 commands. The glibc in linux_base-7 uses fcntl64() by default, but the bug was often non-fatal since the misinterpretation typically only causes junk to appear in the `l_len' field and most junk values are accepted as valid range lengths. The result is occasional EINVAL errors from F_SETLK and a few bytes after the supplied `struct flock' getting clobbered during F_GETLK. PR: kern/37656 Reviewed by: marcel Approved by: re MFC after: 1 week
* Use the new kern_*() functions to avoid using the stack gap iniedowse2002-09-021-69/+33
| | | | linux_fcntl*() and linux_getcwd().
* Use the new kern_* functions to avoid the need to store argumentsiedowse2002-09-011-165/+144
| | | | | | | | in the stack gap. This converts most VFS and signal related system calls, as well as select(). Discussed on: -arch Approved by: marcel
* In continuation of early fileop credential changes, modify fo_ioctl() torwatson2002-08-171-1/+2
| | | | | | | | | | | | | | | | | | | | | | accept an 'active_cred' argument reflecting the credential of the thread initiating the ioctl operation. - Change fo_ioctl() to accept active_cred; change consumers of the fo_ioctl() interface to generally pass active_cred from td->td_ucred. - In fifofs, initialize filetmp.f_cred to ap->a_cred so that the invocations of soo_ioctl() are provided access to the calling f_cred. Pass ap->a_td->td_ucred as the active_cred, but note that this is required because we don't yet distinguish file_cred and active_cred in invoking VOP's. - Update kqueue_ioctl() for its new argument. - Update pipe_ioctl() for its new argument, pass active_cred rather than td_ucred to MAC for authorization. - Update soo_ioctl() for its new argument. - Update vn_ioctl() for its new argument, use active_cred rather than td->td_ucred to authorize VOP_IOCTL() and the associated VOP_GETATTR(). Obtained from: TrustedBSD Project Sponsored by: DARPA, NAI Labs
* Fix missing parens in MAC readdir() check. This fix was in the MACrwatson2002-08-121-1/+1
| | | | | | | branch, but apparently didn't get moved over when it was made. Obtained from: TrustedBSD Project Sponsored by: DARPA, NAI Labs
* Introduce support for Mandatory Access Control and extensiblerwatson2002-08-011-0/+9
| | | | | | | | | | | | kernel access control. Invoke appropriate MAC entry points for a number of VFS-related operations in the Linux ABI module. In particular, handle uselib in a manner similar to open() (more work is probably needed here), as well as handle statfs(), and linux readdir()-like calls. Obtained from: TrustedBSD Project Sponsored by: DARPA, NAI Labs
* Move the switch statement labels for the explicit 64-bitrobert2002-07-091-3/+3
| | | | | | | | command arguments into the correct function, linux_fcntl64(), and thus out of the scope of a compilation for the alpha platform. Requested by: obrien
* Enable emulation of the F_GETLK64, F_SETLK64, and F_SETLKW64robert2002-07-091-0/+3
| | | | lock commands arguments to linux_fcntl64().
* Fix typo in the BSD copyright: s/withough/without/schweikh2002-06-021-1/+1
| | | | | Spotted and suggested by: des MFC after: 3 weeks
* Simple p_ucred -> td_ucred changes to start using the per-thread ucredjhb2002-02-271-1/+1
| | | | reference.
* Lock struct pgrp, session and sigio.tanimura2002-02-231-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | New locks are: - pgrpsess_lock which locks the whole pgrps and sessions, - pg_mtx which protects the pgrp members, and - s_mtx which protects the session members. Please refer to sys/proc.h for the coverage of these locks. Changes on the pgrp/session interface: - pgfind() needs the pgrpsess_lock held. - The caller of enterpgrp() is responsible to allocate a new pgrp and session. - Call enterthispgrp() in order to enter an existing pgrp. - pgsignal() requires a pgrp lock held. Reviewed by: jhb, alfred Tested on: cvsup.jp.FreeBSD.org (which is a quad-CPU machine running -current)
* Replace ffind_* with fget calls.alfred2002-01-141-7/+9
| | | | | | | | Make fget MPsafe. Make fgetvp and fgetsock use the fget subsystem to reduce code bloat. Push giant down in fpathconf().
* Remove unused variable.alfred2002-01-131-1/+0
|
* SMP Lock struct file, filedesc and the global file list.alfred2002-01-131-11/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Seigo Tanimura (tanimura) posted the initial delta. I've polished it quite a bit reducing the need for locking and adapting it for KSE. Locks: 1 mutex in each filedesc protects all the fields. protects "struct file" initialization, while a struct file is being changed from &badfileops -> &pipeops or something the filedesc should be locked. 1 mutex in each struct file protects the refcount fields. doesn't protect anything else. the flags used for garbage collection have been moved to f_gcflag which was the FILLER short, this doesn't need locking because the garbage collection is a single threaded container. could likely be made to use a pool mutex. 1 sx lock for the global filelist. struct file * fhold(struct file *fp); /* increments reference count on a file */ struct file * fhold_locked(struct file *fp); /* like fhold but expects file to locked */ struct file * ffind_hold(struct thread *, int fd); /* finds the struct file in thread, adds one reference and returns it unlocked */ struct file * ffind_lock(struct thread *, int fd); /* ffind_hold, but returns file locked */ I still have to smp-safe the fget cruft, I'll get to that asap.
* Implement linux_chown and linux_lchown. The fchown syscall mapsmarcel2001-10-161-0/+42
| | | | | | | directly to the native syscall, because no filename handling needs to be done. Tested by: Martin Blapp <mb@imp.ch>
* Whitespace fix.jhb2001-09-121-1/+1
|
* KSE Milestone 2julian2001-09-121-107/+108
| | | | | | | | | | | | | | Note ALL MODULES MUST BE RECOMPILED make the kernel aware that there are smaller units of scheduling than the process. (but only allow one thread per process at this time). This is functionally equivalent to teh previousl -current except that there is a thread associated with each process. Sorry john! (your next MFC will be a doosie!) Reviewed by: peter@freebsd.org, dillon@freebsd.org X-MFC after: ha ha ha ha
* Round of cleanups and enhancements. These include (in random order):marcel2001-09-081-387/+558
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | o Introduce private types for use in linux syscalls for two reasons: 1. establish type independence for ease in porting and, 2. provide a visual queue as to which syscalls have proper prototypes to further cleanup the i386/alpha split. Linuxulator types are prefixed by 'l_'. void and char have not been "virtualized". o Provide dummy functions for all syscalls and remove dummy functions or implementations of truely obsolete syscalls. o Sanitize the shm*, sem* and msg* syscalls. o Make a first attempt to implement the linux_sysctl syscall. At this time it only returns one MIB (KERN_VERSION), but most importantly, it tells us when we need to add additional sysctls :-) o Bump the kenel version up to 2.4.2 (this is not the same as the KERN_VERSION MIB, BTW). o Implement new syscalls, of which most are specific to i386. Our syscall table is now up to date with Linux 2.4.2. Some highlights: - Implement the 32-bit uid_t and gid_t bases syscalls. - Implement a couple of 64-bit file size/offset bases syscalls. o Fix or improve numerous syscalls and prototypes. o Reduce style(9) violations while I'm here. Especially indentation inconsistencies within the same file are addressed. Re-indenting did not obfuscate actual changes to the extend that it could not be combined. NOTE: I spend some time testing these changes and found that if there were regressions, they were not caused by these changes AFAICT. It was observed that installing a RH 7.1 runtime environment did make matters worse. Hangs and/or reboots have been observed with and without these changes, so when it failed to make life better in cases it doesn't look like it made it worse.
* Fix linux_getcwd() so that if the cwd isn't cached (__getcwd() fails),gallatin2001-08-291-28/+0
| | | | | | | | | | the cwd is looked up inside the kernel. The native getcwd() in libc handles this in userland if __getcwd() fails. Obtained from: NetBSD via OpenBSD Tested by: Chris Casey <chriss@phys.ksu.edu>, Markus Holmberg <markush@acc.umu.se> Reviewed by: Darrell Anderson <anderson@cs.duke.edu> PR: kern/24315
* Undo part of the tangle of having sys/lock.h and sys/mutex.h included inmarkm2001-05-011-5/+6
| | | | | | | | | | | other "system" header files. Also help the deprecation of lockmgr.h by making it a sub-include of sys/lock.h and removing sys/lockmgr.h form kernel .c files. Sort sys/*.h includes where possible in affected files. OK'ed by: bde (with reservations)
* Reviewed by: jlemonadrian2001-03-011-16/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | An initial tidyup of the mount() syscall and VFS mount code. This code replaces the earlier work done by jlemon in an attempt to make linux_mount() work. * the guts of the mount work has been moved into vfs_mount(). * move `type', `path' and `flags' from being userland variables into being kernel variables in vfs_mount(). `data' remains a pointer into userspace. * Attempt to verify the `type' and `path' strings passed to vfs_mount() aren't too long. * rework mount() and linux_mount() to take the userland parameters (besides data, as mentioned) and pass kernel variables to vfs_mount(). (linux_mount() already did this, I've just tidied it up a little more.) * remove the copyin*() stuff for `path'. `data' still requires copyin*() since its a pointer into userland. * set `mount->mnt_statf_mntonname' in vfs_mount() rather than in each filesystem. This variable is generally initialised with `path', and each filesystem can override it if they want to. * NOTE: f_mntonname is intiailised with "/" in the case of a root mount.
* Allow debugging output to be controlled on a per-syscall granularity.jlemon2001-02-161-41/+48
| | | | | | Also clean up debugging output in a slightly more uniform fashion. The default behavior remains the same (all debugging output is turned on)
* Add mount syscall to linux emulation. Also improve emulation of reboot.jlemon2001-02-161-0/+89
|
* Back out proc locking to protect p_ucred for obtaining additionaljhb2001-01-271-8/+1
| | | | references along with the actual obtaining of additional references.
* Lock access to proc members.jhb2000-12-151-2/+12
| | | | Glanced over by: marcel
* Don't auto-generate the syscalls.marcel2000-12-031-4/+0
|
* Fix F_SETOWN on pipes. Linux returns EINVAL while we send a SIGIOmarcel2000-11-131-5/+19
| | | | | | | | signal. There's at least 1 program that is known to break. Submitted patch has been edited to match current code. MFC: yes Submitted by: bde
* Revert auto-generation. The Alpha port is broken.marcel2000-11-101-0/+4
| | | | Syncing with it is wrong.
* Sync with Alpha:marcel2000-11-091-4/+0
| | | | | Do not use sysent.c, proto.h and syscall.h in source tree; use auto-generated versions.
* Fix getdents syscall.marcel2000-11-051-1/+4
| | | | | | | | | | The offset field in struct dirent was set to the offset of the next dirent in rev 1.36. The offset was calculated from the current offset and the record length. This offset does not necessarily match the real offset when we are using cookies. Therefore, also use the cookies to set the offset field in struct dirent if we're using cookies to iterate through the dirents.
* The MI/MD split wasn't perfect and the MI files need hacks for theobrien2000-11-011-3/+15
| | | | | | AlphaLinux compat bits. This will be better cleaned up soon. Agreed to what ever was necessary by: marcel
* Update include directives and remove linux_execve.marcel2000-08-221-23/+3
|
* Implement pread and pwrite.marcel2000-07-171-0/+28
| | | | | PR: 17991 Submitted by: Geoffrey Speicher <geoff@caribbean.sea-incorporated.com>
* Simplify the F_GETOWN and F_SETOWN fcntl commands. The workaroundmarcel2000-07-151-49/+7
| | | | | | | | is not needed since the FreeBSD native implementation switched from TIOC{G|S}PGRP to FIO{G|S}ETOWN (kern_descrip.c rev 1.55). PR: 16946 Submitted by: Victor Salaman <salaman@teknos.com>
* Implement fdatasync in terms of fsync. The regeneration of proto.h,marcel1999-11-261-0/+11
| | | | | syscall.h and sysent.h was probably forgotten after the last change syscalls.master.
* simplify check for device.phk1999-11-081-1/+1
|
* Fix the duplicate filenames that are the result of using getdents.marcel1999-10-211-1/+1
| | | | | | | | | | | glibc2 defines struct dirent differently than the Linux kernel does. The getdents function therefore needs to read a heuristically defined number of kernel dirents to satisfy the request. In case where too many kernel dirents have been read, the function lseeks on the directory so that a next call will start with the right dirent. The offset used in lseeking is the offset-field in the last dirent passed to the application. This can only mean that the offset-field holds the offset of the next dirent and not the offset of the dirent itself.
* This patch clears the way for removing a number of tty relatedphk1999-09-251-4/+5
| | | | | | | | | | | | | | | | | | | | | fields in struct cdevsw: d_stop moved to struct tty. d_reset already unused. d_devtotty linkage now provided by dev_t->si_tty. These fields will be removed from struct cdevsw together with d_params and d_maxio Real Soon Now. The changes in this patch consist of: initialize dev->si_tty in *_open() initialize tty->t_stop remove devtotty functions rename ttpoll to ttypoll a few adjustments to these changes in the generic code a bump of __FreeBSD_version add a couple of FreeBSD tags
* This is what was "fdfix2.patch," a fix for fd sharing. It's prettygreen1999-09-191-1/+1
| | | | | | | | | | | | | | | | | far-reaching in fd-land, so you'll want to consult the code for changes. The biggest change is that now, you don't use fp->f_ops->fo_foo(fp, bar) but instead fo_foo(fp, bar), which increments and decrements the fp refcount upon entry and exit. Two new calls, fhold() and fdrop(), are provided. Each does what it seems like it should, and if fdrop() brings the refcount to zero, the fd is freed as well. Thanks to peter ("to hell with it, it looks ok to me.") for his review. Thanks to msmith for keeping me from putting locks everywhere :) Reviewed by: peter
OpenPOWER on IntegriCloud