Commit Graph

1166 Commits

Author SHA1 Message Date
Mark Murray
fa860c783c Unbreak LINT; sort the includes so that functions are explicitly
declared. Remove duplicate includes.
2002-07-16 09:33:33 +00:00
Jeff Roberson
ad70122060 - Change all LK_SHARE locks to LK_EXCLUSIVE. Shared locks aren't quite safe
yet
 - Use vop_std{lock,unlock,islocked}.
2002-07-09 19:43:39 +00:00
Jeff Roberson
922b974a44 Lock down pseudofs:
- Initialize lock structure in vncache_alloc
 - Return locked vnodes from vncache_alloc
 - Setup vnode op vectors to use default lock, unlock, and islocked
 - Implement simple locking scheme required for lookup
2002-07-08 01:50:14 +00:00
Julian Elischer
e602ba25fd Part 1 of KSE-III
The ability to schedule multiple threads per process
(one one cpu) by making ALL system calls optionally asynchronous.
to come: ia64 and power-pc patches, patches for gdb, test program (in tools)

Reviewed by:	Almost everyone who counts
	(at various times, peter, jhb, matt, alfred, mini, bernd,
	and a cast of thousands)

	NOTE: this is still Beta code, and contains lots of debugging stuff.
	expect slight instability in signals..
2002-06-29 17:26:22 +00:00
Maxime Henrion
4ce86ffd17 nmount'ify unionfs further by using separate options instead
of passing a flags mount options.  This removes the include of
sys/fs/unionfs/union.h in mount_unionfs as it should be.

Reviewed by:	phk
2002-06-15 22:48:14 +00:00
Maxime Henrion
c3210a83c0 Convert UDF to nmount.
Reviewed by:	scottl
2002-06-15 22:40:13 +00:00
Semen Ustimenko
1cfdefbb9f Fix a race during null node creation between relookuping the hash and
adding vnode to hash. The fix is to use atomic hash-lookup-and-add-if-
not-found operation. The odd thing is that this race can't happen
actually because the lowervp vnode is locked exclusively now during the
whole process of null node creation. This must be thought as a step
toward shared lookups.

Also remove vp->v_mount checks when looking for a match in the hash,
as this is the vestige.

Also add comments and cosmetic changes.
2002-06-13 21:49:09 +00:00
Semen Ustimenko
1542003115 Change null_hashlock into null_hashmtx, because there is no need for
lockmgr and this helps to vget() vnode from hash without a race.

Reviewed by:	bp
MFC after:	2 weeks
2002-06-13 20:18:50 +00:00
Semen Ustimenko
08720e34b0 Fix the "error" path (when dropping not fully initialized vnode).
Also move hash operations out of null_vnops.c and explicitly initialize
v_lock in null_node_alloc (to set wmesg).

Reviewed by:	bp
MFC after:	2 weeks
2002-06-13 18:25:06 +00:00
Semen Ustimenko
ebe0bdddac Fix wrong locking in null_inactive and null_reclaim. This makes nullfs
relatively working back.

Reviewed by:	mckusick, bp
2002-06-13 17:30:40 +00:00
Dag-Erling Smørgrav
a3d37b1322 Gratuitous whitespace cleanup. 2002-06-06 16:59:24 +00:00
Semen Ustimenko
c83fca1f1f Make devfs to give honour to PDIRUNLOCK flag.
Reviewed by:	jeff
MFC after:	1 week
2002-06-01 09:17:43 +00:00
Seigo Tanimura
4cc20ab1f0 Back out my lats commit of locking down a socket, it conflicts with hsu's work.
Requested by:	hsu
2002-05-31 11:52:35 +00:00
Maxime Henrion
a9f5c04aae Convert unionfs to nmount. 2002-05-24 00:44:44 +00:00
Maxime Henrion
23bb7c1425 Fix comments. 2002-05-24 00:16:13 +00:00
Maxime Henrion
9fcc512cd6 Convert nullfs to nmount. 2002-05-23 23:07:27 +00:00
Bruce Evans
fba2e6106f Quick fix for non-unique inode numbers for hard links. We use the
byte offset of the directory entry for the inode number for all types
of files except directories, although this breaks hard links for
non-directories even if it doesn't cause overflow.  Just ignore this
broken inode number for stat() and readdir() and return a less broken
one (the block offset of the file), so that applications normally can't
see the brokenness.

This leaves at least the following brokenness:
- extra inodes, vnodes and caching for hard links.
- various overflow bugs.  cd9660 supports 64-bit block numbers, but we
  silently ignore the top 32 bits in isonum_733() and then drop another
  10 bits for our broken inode numbers.  We may also have sign extension
  bugs from storing 32-bit extents in ints and longs even if ints are
  32-bits.  These bugs affect DVDs.  mkisofs apparently limits them
  by writing directory entries first.

Inode numbers were broken mainly in 4.4BSD-Lite2.  FreeBSD-1.1.5 seems
to have a correct implementation modulo the overflow bugs.  We need
to look up directory entries from inodes for symlinks only.  FreeBSD-1.1.5
use separate fields (iso_parent_extent, iso_parent) to point to the
directory entry.  4.4BSD-Lite doesn't have these, and abuses i_ino to
point to the directory entry.  Correct pointers are impossible for
hard links, but symlinks can't be hard links.
2002-05-22 08:50:18 +00:00
Semen Ustimenko
96b825e7ca Fix null_lock() not unlocking vp->v_interlock if LK_THISLAYER.
Reviewed by:	bp@FreeBSD.org
MFC after:	1 week
2002-05-21 18:07:33 +00:00
Seigo Tanimura
102638407c Lock the writer socket across sorwakeup(fip->fi_writesock).
Spotted by:	peter
2002-05-21 02:37:56 +00:00
Seigo Tanimura
243917fe3b Lock down a socket, milestone 1.
o Add a mutex (sb_mtx) to struct sockbuf. This protects the data in a
  socket buffer. The mutex in the receive buffer also protects the data
  in struct socket.

o Determine the lock strategy for each members in struct socket.

o Lock down the following members:

  - so_count
  - so_options
  - so_linger
  - so_state

o Remove *_locked() socket APIs.  Make the following socket APIs
  touching the members above now require a locked socket:

 - sodisconnect()
 - soisconnected()
 - soisconnecting()
 - soisdisconnected()
 - soisdisconnecting()
 - sofree()
 - soref()
 - sorele()
 - sorwakeup()
 - sotryfree()
 - sowakeup()
 - sowwakeup()

Reviewed by:	alfred
2002-05-20 05:41:09 +00:00
John Baldwin
f44d9e24fb Change p_can{debug,see,sched,signal}()'s first argument to be a thread
pointer instead of a proc pointer and require the process pointed to
by the second argument to be locked.  We now use the thread ucred reference
for the credential checks in p_can*() as a result.  p_canfoo() should now
no longer need Giant.
2002-05-19 00:14:50 +00:00
Poul-Henning Kamp
17b5825d7e Remove a check of blocknumbers/offsets which will be pointless with
64 bit daddr_t.

Sponsored by: DARPA & NAI Labs.
2002-05-18 09:32:56 +00:00
Tom Rhodes
d394511de3 More s/file system/filesystem/g 2002-05-16 21:28:32 +00:00
Maxime Henrion
fc6f338fd2 In VOP_LOOKUP, don't assume that the final pathname component
will be in the same filesystem than the one where the current
component is.

Approved by:	scottl
2002-05-16 19:22:39 +00:00
Poul-Henning Kamp
98b0c78978 Make daddr_t and u_daddr_t 64bits wide.
Retire daddr64_t and use daddr_t instead.

Sponsored by:	DARPA & NAI Labs.
2002-05-14 11:09:43 +00:00
Maxime Henrion
8eee3a3d58 Fix several bugs in devfs_lookupx(). When we check the nameiop to
make sure it's a correct operation for devfs, do it only in the
ISLASTCN case.  If we don't, we are assuming that the final file will
be in devfs, which is not true if another partition is mounted on top
of devfs or with special filenames (like /dev/net/../../foo).

Reviewed by:	phk
2002-05-10 15:41:14 +00:00
Jeff Roberson
441271159e Include systm.h for panic(9) so that DEBUG_ALL_VFS_LOCKS compiles. 2002-05-04 02:37:00 +00:00
Poul-Henning Kamp
1ed91802ee HPFS picks up the vop_stdgetpages and vop_stdputpages member functions
via the default entry and the default vop vector.
2002-05-03 18:23:29 +00:00
Dag-Erling Smørgrav
d95ec55335 s/pfs_badop/vop_eopnotsupp/
Submitted by:	phk
2002-05-03 14:58:25 +00:00
Maxime Henrion
6dbde1fe23 Convert devfs to nmount.
Reviewed by:	phk
2002-05-02 20:27:42 +00:00
Maxime Henrion
8392a47923 Convert the pseudofs framework to nmount (thus procfs and linprocfs).
Reviewed by:	des (some time ago), phk
2002-05-02 20:25:55 +00:00
Maxime Henrion
4d8b916946 Convert fdescfs to nmount.
Reviewed by:	phk
2002-05-02 20:24:50 +00:00
Scott Long
1347b4e84f Don't reference vop_std* since they are already implicitly
referenced through the VOP_DEFAULT vector

Submitted by:	phk
2002-05-02 20:23:47 +00:00
Poul-Henning Kamp
ef41ad17bd Use vop_panic() instead of rolling our own. 2002-05-02 19:13:44 +00:00
Scott Long
cd1b1a1d35 In udf_bmap(), return the physical block number, not the logical
block number.  This fixes things like cp (ouch!) which use mmap.
2002-05-02 05:01:14 +00:00
Scott Long
d1def83b54 Fix udf_read(). Honor the uio_resid when determining the size of
the block to read and copy out.  This removes the hack in
udf_readatoffset() for only reading one block at a time.  WooHoo!
Remove a redundant test for fragmented fids in both udf_readdir()
and udf_lookup().  Add comment to both as to why the test is
written the way it is.  Add a few more safety checks for brelse().

Thanks to Timothy Shimmin <tes@boing.melbourne.sgi.com> for pointing
out these problems.
2002-04-30 05:05:05 +00:00
Seigo Tanimura
960ed29c4b Revert the change of #includes in sys/filedesc.h and sys/socketvar.h.
Requested by:	bde

Since locking sigio_lock is usually followed by calling pgsigio(),
move the declaration of sigio_lock and the definitions of SIGIO_*() to
sys/signalvar.h.

While I am here, sort include files alphabetically, where possible.
2002-04-30 01:54:54 +00:00
Robert Watson
a12cfddc0f Use vnode locking with devfs; permit VFS locking assertions to make
sense for devfs vnodes, and reduce/remove potential races in the devfs
code.

Submitted by:	iadowse
Approved by:	phk
2002-04-29 20:00:39 +00:00
Boris Popov
b88157559d UIO_NOCOPY is not supported for now, so refuse read opeartion if this flag
is set. The full emulation of bio are on its way...
2002-04-26 03:49:02 +00:00
Boris Popov
959b83b921 Track nfs's getpages() changes:
Properly count v_vnodepgsin.
    Do not reread page if is already valid.
    Properly handle partially filled pages.
2002-04-23 14:30:43 +00:00
Boris Popov
3f36e6f21a Get rid from extra #ifdefs. 2002-04-23 13:55:14 +00:00
Bruce Evans
4cc6241557 Don't attempt to decvlare M_DEVFS whern MALLOC_DECLARE is not defined.
This fixes warnings that should be errors in fstat.

Reminded by:	alpha tinderbox

Fixed some style bugs (ones near BOF and EOF; there are many more).
2002-04-21 15:47:03 +00:00
Bruce Evans
54a4c5bf21 Include <sys/systm.h> for (at least) the definition of atomic functions
which are sometimes used by the macros in <sys/mutex.h>; don't depend
on not-quite-necessary namespace pollution in <sys/mutex.h>.
2002-04-21 15:35:54 +00:00
Marcel Moolenaar
5ce9299f05 Don't put a line break in string literals. GCC 3.1 complains and GCC
3.2 drops the ball.
2002-04-20 01:42:56 +00:00
Robert Watson
d51ed1a04a Spelling fix for comment. 2002-04-20 01:14:25 +00:00
Alfred Perlstein
7858dcd629 Cleanup of logic, flow and comments.
Submitted by: bde
2002-04-18 14:47:34 +00:00
John Baldwin
ba626c1db2 Lock proctree_lock instead of pgrpsess_lock. 2002-04-16 17:11:34 +00:00
Jeroen Ruigrok van der Werven
c2d6947d14 Sync with UDF p4 tree: Use POSIX integer types instead of BSD types. 2002-04-15 19:49:15 +00:00
Scott Long
51a7b740a1 Actually add the UDF files! 2002-04-14 16:52:14 +00:00
John Baldwin
87484be35f Remove stale XXX comment. 2002-04-14 04:12:44 +00:00
John Baldwin
a92e7c792a - Change procfs_control()'s first argument to be a thread pointer instead
of a process pointer.
- Move the p_candebug() at the start of procfs_control() a bit to make
  locking feasible.  We still perform the access check before doing
  anything, we just now perform it after acquiring locks.
- Don't lock the sched_lock for TRACE_WAIT_P() and when checking to see if
  p_stat is SSTOP.  We lock the process while setting p_stat to SSTOP
  so locking the process is sufficient to do a read to see if p_stat is
  SSTOP or not.
2002-04-13 23:19:13 +00:00
John Baldwin
ce5aaf4554 Lock the target process for p_candebug(). 2002-04-13 23:15:28 +00:00
John Baldwin
ff7299d998 Lock the target process in procfs_doproc*regs() for p_candebug and while
reading/writing the registers.
2002-04-13 23:14:08 +00:00
John Baldwin
590ae816c2 - p_cansee() needs the target process locked.
- We need the proc lock held for more of procfs_doprocstatus().
2002-04-13 23:09:41 +00:00
Boris Popov
6e8681aa50 Check write permissions before creating anything.
PR:		kern/27883
MFC after:	1 week
2002-04-13 15:33:26 +00:00
Poul-Henning Kamp
a1f1e35d8b Remove 3 instances of vm_zone.h inclusion. 2002-04-08 08:12:46 +00:00
Jeff Roberson
8396dd9eaa Change the vm_zone calls over to uma calls. Remove the reference to the
vm_zone header.
2002-04-08 06:57:43 +00:00
Bruce Evans
11257f4d1a Fixed assorted bugs in setting of timestamps in devfs_setattr().
Setting of timestamps on devices had no effect visible to userland
because timestamps for devices were set in places that are never used.
This broke:
- update of file change time after a change of an attribute
- setting of file access and modification times.

The VA_UTIMES_NULL case did not work.  Revs 1.31-1.32 were supposed to
fix this by copying correct bits from ufs, but had little or no effect
because the old checks were not removed.
2002-04-05 15:16:08 +00:00
Bruce Evans
32a95d83f9 Fixed a very old bug in setting timestamps using utimes(2) on msdosfs
files.  We didn't clear the update marks when we set the times, so
some of the settings were sometimes clobbered with the current time a
little later.  This caused cp -p even by root to almost always fail
to preserve any times despite not reporting any errors in attempting
to preserve them.

Don't forget to set the archive attribute when we set the read-only
attribute.  We should only set the archive attribute if we actually
change something, but we mostly don't bother avoiding setting it
elsewhere, so don't bother here yet.

MFC after:	1 week
2002-04-05 14:01:04 +00:00
John Baldwin
6008862bc2 Change callers of mtx_init() to pass in an appropriate lock type name. In
most cases NULL is passed, but in some cases such as network driver locks
(which use the MTX_NETWORK_LOCK macro) and UMA zone locks, a name is used.

Tested on:	i386, alpha, sparc64
2002-04-04 21:03:38 +00:00
Bruce Evans
79065dba2a Moved signal handling and rescheduling from userret() to ast() so that
they aren't in the usual path of execution for syscalls and traps.
The main complication for this is that we have to set flags to control
ast() everywhere that changes the signal mask.

Avoid locking in userret() in most of the remaining cases.

Submitted by:	luoqi (first part only, long ago, reorganized by me)
Reminded by:	dillon
2002-04-04 17:49:48 +00:00
John Baldwin
44731cab3b Change the suser() API to take advantage of td_ucred as well as do a
general cleanup of the API.  The entire API now consists of two functions
similar to the pre-KSE API.  The suser() function takes a thread pointer
as its only argument.  The td_ucred member of this thread must be valid
so the only valid thread pointers are curthread and a few kernel threads
such as thread0.  The suser_cred() function takes a pointer to a struct
ucred as its first argument and an integer flag as its second argument.
The flag is currently only used for the PRISON_ROOT flag.

Discussed on:	smp@
2002-04-01 21:31:13 +00:00
Bruce Evans
0508986cce In ffs_mountffs(), set mnt_iosize_max to si_iosize_max unconditionally
provided the latter is nonzero.  At this point, the former is a fairly
arbitrary default value (DFTPHYS), so changing it to any reasonable
value specified by the device driver is safe.  Using the maximum of
these limits broke ffs clustered i/o for devices whose si_iosize_max
is < DFLTPHYS.  Using the minimum would break device drivers' ability
to increase the active limit from DFTLPHYS up to MAXPHYS.

Copied the code for this and the associated (unnecessary?) fixup of
mp_iosize_max to all other filesystems that use clustering (ext2fs and
msdosfs).  It was completely missing.

PR:		36309
MFC-after:	1 week
2002-03-30 15:12:57 +00:00
Alfred Perlstein
e9b192b758 Protect proc struct (p_args and p_comm) when doing procfs IO that pulls
data from it.

Submitted by: Jonathan Mini <mini@haikugeek.com>
2002-03-29 19:12:40 +00:00
Bruce Evans
69c59d8703 Fixed some style bugs in the removal of __P(()). Continuation lines
were not outdented to preserve non-KNF lining up of code with parentheses.
Switch to KNF formatting in some cases.
2002-03-24 04:35:23 +00:00
Bruce Evans
b76d0b3217 Fixed some style bugs in the removal of __P(()). Continuation lines
were not outdented to preserve non-KNF lining up of code with parentheses.
Switch to KNF formatting.
2002-03-23 12:38:05 +00:00
Jeff Roberson
2684b6af7a Remove references to vm_zone.h and switch over to the new uma API. 2002-03-20 10:17:00 +00:00
Alfred Perlstein
89c9a48352 Remove __P. 2002-03-20 07:51:46 +00:00
Alfred Perlstein
aa075405f6 Remove __P. 2002-03-20 05:00:21 +00:00
Alfred Perlstein
11caded34f Remove __P. 2002-03-19 22:20:14 +00:00
Kirk McKusick
b70428b2f0 Cannot release vnode underlying the nullfs vnode in null_inactive
as it leaves the nullfs vnode allocated, but with no identity. The
effect is that a null mount can slowly accumulate all the vnodes
in the system, reclaiming them only when it is unmounted. Thus
the null_inactive state instead accelerates the release of the
null vnode by calling vrecycle which will in turn call the
null_reclaim operator. The null_reclaim routine then does the
freeing actions previosuly (incorrectly) done in null_inactive.
2002-03-18 05:39:04 +00:00
Kirk McKusick
a0595d0249 Add a flags parameter to VFS_VGET to pass through the desired
locking flags when acquiring a vnode. The immediate purpose is
to allow polling lock requests (LK_NOWAIT) needed by soft updates
to avoid deadlock when enlisting other processes to help with
the background cleanup. For the future it will allow the use of
shared locks for read access to vnodes. This change touches a
lot of files as it affects most filesystems within the system.
It has been well tested on FFS, loopback, and CD-ROM filesystems.
only lightly on the others, so if you find a problem there, please
let me (mckusick@mckusick.com) know.
2002-03-17 01:25:47 +00:00
Kirk McKusick
0d2af52141 Introduce the new 64-bit size disk block, daddr64_t. Change
the bio and buffer structures to have daddr64_t bio_pblkno,
b_blkno, and b_lblkno fields which allows access to disks
larger than a Terabyte in size. This change also requires
that the VOP_BMAP vnode operation accept and return daddr64_t
blocks. This delta should not affect system operation in
any way. It merely sets up the necessary interfaces to allow
the development of disk drivers that work with these larger
disk block addresses. It also allows for the development of
UFS2 which will use 64-bit block addresses.
2002-03-15 18:49:47 +00:00
Maxim Konovalov
e9fc9230a6 Be consistent with UFS in a way how devfs_setattr() checks credentials
for chmod(2), chown(2) and utimes(2) with respect to jail(2).

Reviewed by:		rwatson, ru
Not objected by:	phk
Approved by:		ru
2002-03-14 11:18:42 +00:00
Poul-Henning Kamp
26facaeb4d If in strategy we find that we have no devsw on the device anymore we
are probably talking about some disk-device which wente away, so
return ENXIO instead of panicing.
2002-03-05 13:25:57 +00:00
John Baldwin
a854ed9893 Simple p_ucred -> td_ucred changes to start using the per-thread ucred
reference.
2002-02-27 18:32:23 +00:00
Thomas Moestl
d2d45a4aa5 Fix LINT breakage by adding a missing include. 2002-02-23 22:55:47 +00:00
Seigo Tanimura
f591779bb5 Lock struct pgrp, session and sigio.
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)
2002-02-23 11:12:57 +00:00
Dag-Erling Smørgrav
cd9e3b208c Paranoia: if the process is setugid, set all sensitive files mode 0. 2002-02-18 21:41:11 +00:00
Poul-Henning Kamp
76b82a7ffb Don't even think about using v_id for magic tricks, v_id is giving
us enough trouble as it is for SMPng.
2002-02-17 20:39:42 +00:00
Bruce Evans
a21759a1a9 FIxed the following style bugs:
- clobbering of jsp's $Id$ by FreeBSD's old $Id$.
- long lines in recent KSE changes (procfs_ctl.c).
- other style bugs in KSE changes (most related to an shadowed variable
  in procfs_status.c -- the td in the outer scope is obfuscated by
  PFS_FILL_ARGS).

Approved by:	des
2002-02-16 05:59:26 +00:00
Bruce Evans
a76d60f014 FIxed the following style bugs:
- clobbering of jsp's $Id$ by FreeBSD's old $Id$.
- lost Berkeley id in procfs_dbregs.c
- long lines in recent KSE changes.
- various gratuitous differences between procfs_*regs.c.
2002-02-16 05:38:07 +00:00
Bruce Evans
ff3741f519 Fixed missing PHOLD()/PRELE().
Obtained from:	procfs_dbregs.c
Approved by:	des
2002-02-16 04:05:32 +00:00
Poul-Henning Kamp
40f7b5a9cc Various nit-picking, mostly of style(9) character.
Obtained from:	~bde/sys.dif.gz
2002-02-10 22:00:20 +00:00
Robert Watson
74237f55b0 Part I: Update extended attribute API and ABI:
o Modify the system call syntax for extattr_{get,set}_{fd,file}() so
  as not to use the scatter gather API (which appeared not to be used
  by any consumers, and be less portable), rather, accepts 'data'
  and 'nbytes' in the style of other simple read/write interfaces.
  This changes the API and ABI.

o Modify system call semantics so that extattr_get_{fd,file}() return
  a size_t.  When performing a read, the number of bytes read will
  be returned, unless the data pointer is NULL, in which case the
  number of bytes of data are returned.  This changes the API only.

o Modify the VOP_GETEXTATTR() vnode operation to accept a *size_t
  argument so as to return the size, if desirable.  If set to NULL,
  the size will not be returned.

o Update various filesystems (pseodofs, ufs) to DTRT.

These changes should make extended attributes more useful and more
portable.  More commits to rebuild the system call files, as well
as update userland utilities to follow.

Obtained from:	TrustedBSD Project
Sponsored by:	DARPA, NAI Labs
2002-02-10 04:43:22 +00:00
Julian Elischer
079b7badea Pre-KSE/M3 commit.
this is a low-functionality change that changes the kernel to access the main
thread of a process via the linked list of threads rather than
assuming that it is embedded in the process. It IS still embeded there
but remove all teh code that assumes that in preparation for the next commit
which will actually move it out.

Reviewed by: peter@freebsd.org, gallatin@cs.duke.edu, benno rice,
2002-02-07 20:58:47 +00:00
Robert Watson
416031dcb8 Change EPERM to EOPNOTSUPP when failing pseudofs_setattr() arbitrarily.
Quoth the alfred:	The latter would be better.
2002-02-04 18:21:59 +00:00
Robert Watson
dfe5fa8eb7 Return EPERM instead of 0 in the un-implemented pseudofs_setattr().
Conceivably, it should even return EOPNOTSUPP.
2002-02-04 18:09:29 +00:00
Alfred Perlstein
468485b8d2 Fix select on fifos.
Backout revision 1.56 and 1.57 of fifo_vnops.c.

Introduce a new poll op "POLLINIGNEOF" that can be used to ignore
EOF on a fifo, POLLIN/POLLRDNORM is converted to POLLINIGNEOF within
the FIFO implementation to effect the correct behavior.

This should allow one to view a fifo pretty much as a data source
rather than worry about connections coming and going.

Reviewed by: bde
2002-01-14 22:03:48 +00:00
Semen Ustimenko
8a87e8a94f Commit a know fix for hpfs to use vop_defaultop plug instead of wrong
hpfs_bypass() routine.

MFC after:	1 day
2002-01-14 20:13:42 +00:00
Alfred Perlstein
3fc6a31403 don't initialize the mutex in the temporary struct file, the soo_*
functions just grab f_data and don't muck with anything else so this
should be ok.

this fixes a panic with invariants where it thinks we've doubly initialized
the filetmp mutex even though all we've done is neglect to bzero it.
2002-01-14 02:18:59 +00:00
Alfred Perlstein
a4db49537b Replace ffind_* with fget calls.
Make fget MPsafe.

Make fgetvp and fgetsock use the fget subsystem to reduce code bloat.

Push giant down in fpathconf().
2002-01-14 00:13:45 +00:00
Alfred Perlstein
6c697c900f remove unused socket pointer 2002-01-13 22:15:18 +00:00
Alfred Perlstein
9e209b124a Include sys/_lock.h and sys/_mutex.h to reduce namespace pollution.
Requested by: jhb
2002-01-13 21:37:49 +00:00
Alfred Perlstein
426da3bcfb SMP Lock struct file, filedesc and the global file list.
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.
2002-01-13 11:58:06 +00:00
Mike Smith
a7489fe56f Add a new sysinit SI_SUB_DEVFS. Devfs hooks into the kernel at SI_ORDER_FIRST,
and devices can be created anytime after that.

Print a warning if an atttempt is made to create a device too early.
2002-01-09 04:58:49 +00:00
Mike Smith
92fef27d97 Use a sysinit to initialise the devfs hooks in kern_conf.c rather than common
variables.

Reviewed by:	phk (in principle)
2002-01-09 01:00:20 +00:00
Mike Smith
eeff042fb3 Staticise the coda vfsop pointer. 2002-01-08 19:33:51 +00:00
Mike Smith
7577116e1e Staticise pfs_vncache, it's not used anywhere else.
Reviewed by:	des
2002-01-08 11:15:57 +00:00
Seigo Tanimura
233beff278 Do not derefer null.
Reviewed by:	des
2002-01-04 01:03:46 +00:00
Robert Watson
9c4d63da6d o Make the credential used by socreate() an explicit argument to
socreate(), rather than getting it implicitly from the thread
  argument.

o Make NFS cache the credential provided at mount-time, and use
  the cached credential (nfsmount->nm_cred) when making calls to
  socreate() on initially connecting, or reconnecting the socket.

This fixes bugs involving NFS over TCP and ipfw uid/gid rules, as well
as bugs involving NFS and mandatory access control implementations.

Reviewed by:	freebsd-arch
2001-12-31 17:45:16 +00:00
Matthew Dillon
23b590188f Fix a BUF_TIMELOCK race against BUF_LOCK and fix a deadlock in vget()
against VM_WAIT in the pageout code.  Both fixes involve adjusting
the lockmgr's timeout capability so locks obtained with timeouts do not
interfere with locks obtained without a timeout.

Hopefully MFC: before the 4.5 release
2001-12-20 22:42:27 +00:00
Boris Popov
d9d8c8172d Previous commit was intented to silence a warning, not to change codepath. 2001-12-20 15:56:45 +00:00
Sheldon Hearn
5bd80fc519 Silence harmless "smbfs_closel: Negative opencount" messages at
unmount time.

Thanks to iedowse for the background information.

Submitted by:	bp
2001-12-20 11:23:49 +00:00
Matthew Dillon
08f3c74981 Pseudofs was leaking VFS cache entries badly due to its cache and use of
the wrong VOP descriptor.  This misuse caused VFS-cached vnodes to be
re-cached, resulting in the leak.  This commit is an interim fix until DES
has a chance to rework the code involved.
2001-12-19 23:58:09 +00:00
Sheldon Hearn
53f09e7248 Add module dependency on libmchain.
With this change, mounting an smb share (using mount_smb, which is not
yet included in the tree) without any of smbfs, libiconv or libmchain
compiled into the kernel or loaded works.
2001-12-13 13:08:34 +00:00
Alfred Perlstein
118fdf009f Fix select on named pipes without a reader.
PR: kern/19871
MFC after: 1 month
2001-12-12 09:35:33 +00:00
Brian Feldman
41a35633ba Add VOP_GETEXTATTR(9) passthrough support to pseudofs.
Obtained from:	TrustedBSD Project
Sponsored by:	DARPA, NAI Labs
2001-12-11 20:48:20 +00:00
Dag-Erling Smørgrav
40e7a740c9 Remove an obsolete prototype for procfs_kmemaccess().
Submitted by:	rwatson
2001-12-11 19:07:10 +00:00
David E. O'Brien
6e551fb628 Update to C99, s/__FUNCTION__/__func__/,
also don't use ANSI string concatenation.
2001-12-10 08:09:49 +00:00
Dag-Erling Smørgrav
50cb89eed2 Fix various bugs in the debugging code and reenable it. 2001-12-09 00:35:30 +00:00
Dag-Erling Smørgrav
c07f9fc134 Fix an incorrect PFS_TRACE. Also, use __func__ instead of __FUNCTION__. 2001-12-09 00:28:12 +00:00
Dag-Erling Smørgrav
4aac2aa96c Fix a KSEfication brain-o in procfs_doprocfile(): return the path of the target process,
not the calling process.  While we're here, also unstaticize procfs_doprocfile() and
procfs_docurproc() so linprocfs can call them directly instead of duplicating them.

Submitted by:	Dominic Mitchell <dom@semantico.com>
2001-12-08 22:34:14 +00:00
Dag-Erling Smørgrav
3a669c52a8 Pseudofsize procfs(5). 2001-12-04 01:35:06 +00:00
Robert Watson
011376308f o Introduce pr_mtx into struct prison, providing protection for the
mutable contents of struct prison (hostname, securelevel, refcount,
  pr_linux, ...)
o Generally introduce mtx_lock()/mtx_unlock() calls throughout kern/
  so as to enforce these protections, in particular, in kern_mib.c
  protection sysctl access to the hostname and securelevel, as well as
  kern_prot.c access to the securelevel for access control purposes.
o Rewrite linux emulator abstractions for accessing per-jail linux
  mib entries (osname, osrelease, osversion) so that they don't return
  a pointer to the text in the struct linux_prison, rather, a copy
  to an array passed into the calls.  Likewise, update linprocfs to
  use these primitives.
o Update in_pcb.c to always use prison_getip() rather than directly
  accessing struct prison.

Reviewed by:	jhb
2001-12-03 16:12:27 +00:00
Boris Popov
b1c996c40b Catch up with KSE changes.
Submitted by:	Max Khon <fjoe@iclub.nsu.ru>
2001-12-02 08:56:58 +00:00
John Baldwin
88736e1d37 Fix indentation after removing GEMDOS support. Whitespace changes only. 2001-11-28 18:29:16 +00:00
John Baldwin
5a7f3ebb94 Use suser_td() instead of explicitly checking cr_uid against 0.
PR:		kern/21809
Submitted by:	<mbendiks@eunet.no>
Reviewed by:	rwatson
2001-11-28 18:25:39 +00:00
John Baldwin
d3990d589f Axe more unused GEMDOS code that was #ifdef atari.
PR:		kern/21809
Submitted by:	<mbendiks@eunet.no>
2001-11-28 16:56:42 +00:00
John Baldwin
64bf8541f0 Remove GEMDOS support from msdosfs. I don't think anyone is going to
port FreeBSD to Atari machines any time soon.
2001-11-27 21:00:15 +00:00
Dag-Erling Smørgrav
98c7e22c50 Add support for a last-close handler.
Revert the module version bumps; they're quite pointless as long as the
only pseudofs consumer is linprocfs, which is in the tree.
2001-11-27 13:26:27 +00:00
Kenneth D. Merry
94a0557ad7 Fix mounting root from a ISO9660 filesystem on a SCSI CDROM.
The problem was that the ISO9660 code wasn't opening the device prior to
issuing ioctl calls.  In particular, the device must be open before
iso_get_ssector() is called in iso_mountroot().

If the device isn't opened first, the disk layer blows up due to an
uninitialized variable.

The solution was to open the device, call iso_get_ssector() and then close
it again.

The ATAPI CDROM driver doesn't have this problem because it doesn't use the
disk layer, and evidently doesn't mind if someone issues an ioctl without
first issuing an open call.

Thanks to phk for pointing me at the source of this problem.

Tested by:	dirk
MFC after:	1 week
2001-11-27 03:55:43 +00:00
John Baldwin
d2cb9f715f Replace 'p' with 'td' as appropriate. 2001-11-27 00:34:13 +00:00
John Baldwin
c5c6ef2c27 GC compat macros HASHINIT, VOP__LOCK, VOP__UNLOCK, VGET, and VN_LOCK. 2001-11-27 00:18:33 +00:00
John Baldwin
b2ba87cec3 Expand LOCKMGR() compat macro. 2001-11-27 00:08:04 +00:00
John Baldwin
cfaffc10b5 GC some KSE compatiblity macros that were somehow still here. 2001-11-26 23:52:35 +00:00
John Baldwin
8a918adb2b GC non-FreeBSD code that didn't work anyways. 2001-11-26 23:45:12 +00:00
Dima Dorfman
2ab80ed8cf Address two minor issues: implement the _PC_NAME_MAX and _PC_PATH_MAX
pathconf() variables for directories, and set st_size and st_blocks
(of struct stat) for directories as appropriate.  Note that st_size is
always set to DEV_BSIZE, since the size of the directories is not
currently kept.

Reviewed by:	phk, bde
2001-11-25 21:00:38 +00:00
Matthew Dillon
0dbd8b1b08 convert holdsock() to fget(). Add XXX reminder for future socket locking. 2001-11-24 18:28:22 +00:00
Peter Wemm
bc5f905080 Missing KSE s/curproc/curthread/ 2001-11-17 01:09:53 +00:00
Alfred Perlstein
d25c683ad5 Switch behavior of fifos to more closely match what goes on in other OSes.
Basically FIFOs become a real pain to abuse as a rendevous point without
this change because you can't really select(2) on them because they always
return ready even though there is no writer (to signal EOF).

Obtained from: BSD/os
2001-11-08 10:28:32 +00:00
Peter Wemm
4ff021c699 Fix printf format bugs introduced in rev 1.34 for printing times.
quad_t cannot be printed with %lld on 64 bit systems.

Dont waste cpu to round user and system times up to long long, it is
highly improbable that a process will have accumulated 68 years of
user or system cpu time (not wall clock time) before a reboot or
process restart.
2001-11-07 02:51:25 +00:00
Brian Feldman
4228024de2 Correctly unlock the target process if /proc/$foo/mem is open()ed by
another process which cannot p_candebug() it.  The bug was introduced
in rev. 1.100.

Approved by:	des
2001-11-06 17:00:40 +00:00
Matthew Dillon
67fa60faa8 Fix the fix. BIO_ERROR must be set in b_ioflags, not b_flags 2001-11-04 23:52:49 +00:00
Poul-Henning Kamp
d018a84cbc Fix "echo > /dev/null" for non-root users which broke in previous commit. 2001-11-04 19:12:59 +00:00
Matthew Dillon
6b8bd2efc1 Add mnt_reservedvnlist so we can MFC to 4.x, in order to make all mount
structure changes now rather then piecemeal later on.  mnt_nvnodelist
currently holds all the vnodes under the mount point.  This will eventually
be split into a 'dirty' and 'clean' list.  This way we only break kld's once
rather then twice.  nvnodelist will eventually turn into the dirty list
and should remain compatible with the klds.
2001-11-04 18:55:42 +00:00
Poul-Henning Kamp
d7c95b6e27 B_ERROR is BIO_ERROR on -current.
Now it compiles, I don't know if it works.
2001-11-04 08:53:38 +00:00
Matthew Dillon
aa454a4b53 Fix a bug in CD9660 when vmiodirenable is turned on. CD9660 was assuming
that a buffer's b_blkno would be valid.  This is true when vmiodirenable
is turned off because the B_MALLOC'd buffer's data is invalidated when
the buffer is destroyed.  But when vmiodirenable is turned on a buffer
can be reconstituted from its VMIO backing store.  The reconstituted buffer
will have no knowledge of the physical block translation and the result is
serious directory corruption of the CDROM.

The solution is to fix cd9660_blkatoff() to always BMAP the buffer if
b_lblkno == b_blkno.

MFC after:	0 days
2001-11-04 06:18:55 +00:00
Poul-Henning Kamp
9607027339 Use vfs_timestamp() instead of getnanotime().
Add magic stuff copied from ufs_setattr().

Instructed by:	bde
2001-11-03 17:00:02 +00:00
Poul-Henning Kamp
93432a92a4 Use vfs_timestamp() instead of getnanotime() directly.
Fix some modes on directories and symlinks.

Instructed by:	bde
2001-11-03 16:53:24 +00:00
Dag-Erling Smørgrav
41aa8697b5 Reduce the number of #include dependencies by declaring some of the structs
used in pseudofs.h as opaque structs.
2001-11-03 03:07:09 +00:00
Matthew Dillon
0e9fe2127c Adjust printfs to be time_t agnostic. 2001-10-28 22:53:45 +00:00
Dag-Erling Smørgrav
1831900053 Add VOP_IOCTL support, and fix a bug that would cause a panic if a file or
symlink lacked a filler function.
2001-10-26 18:52:47 +00:00
Matthew Dillon
c72ccd014d Change the vnode list under the mount point from a LIST to a TAILQ
in preparation for an implementation of limiting code for kern.maxvnodes.

MFC after:	3 days
2001-10-23 01:21:29 +00:00
Dag-Erling Smørgrav
c193b945eb No, you may not /* FALLTHROUGH */. Not only will you return an incorrect
result, but you'd corrupt the kernel malloc() arena if it weren't for a
small but life-saving optimization in ioctl().

MFC after:	1 week
2001-10-22 16:13:38 +00:00
Dag-Erling Smørgrav
7c62990641 Move procfs_* from procfs_machdep.c into sys_process.c, and rename them to
proc_* in the process; procfs_machdep.c is no longer needed.

Run-tested on i386, build-tested on Alpha, untested on other platforms.
2001-10-21 23:57:24 +00:00
John Baldwin
dee2bb2540 Assert that a ucred is unshared before we remap its ids. 2001-10-20 03:30:34 +00:00
Dag-Erling Smørgrav
32c798f806 Argh! I updated the version number in the MODULE_DEPEND() thingamagook but
not in the actual MODULE_VERSION().  Pass me the pointy hat.
2001-10-19 18:23:51 +00:00
Dag-Erling Smørgrav
33802b9eff Switch to dynamic rather than static initialization.
This makes it possible (in theory) for nodes to be added and / or removed
from pseudofs filesystems at runtime.
2001-10-19 01:43:06 +00:00
Bruce Evans
4e567de4ae Fixed bitrot in a banal comment by removing the comment. 2001-10-13 06:57:59 +00:00