Commit Graph

1309 Commits

Author SHA1 Message Date
Dag-Erling Smørgrav
134ce0f9cc Add pfs_visible() checks to pfs_getattr() and pfs_getextattr(). This
also fixes pfs_access() since it relies on VOP_GETATTR() which will call
pfs_getattr().  This prevents jailed processes from discovering the
existence, start time and ownership of processes outside the jail.

PR:		kern/48156
2003-08-19 10:26:41 +00:00
John Baldwin
d49ebea58c Spell the name of the lock right in addition to getting the type right.
Submitted by:	Kim Culhan <kimc@w8hd.org>
2003-08-18 19:23:01 +00:00
John Baldwin
cda369cac4 The allproc lock is a sx lock, not a mutex, so fix the assertion. This
asserts that the sx lock is held, but does not specify if the lock is held
shared or exclusive, thus either type of lock satisfies the assertion.
2003-08-18 18:02:33 +00:00
Dag-Erling Smørgrav
653fae1761 Rework pfs_iterate() a bit to eliminate a bug related to process
directories.  Previously, pfs_iterate() would return -1 when it
reached the end of the process list while processing a process
directory node, even if the parent directory contained further nodes
(which is the case for the linprocfs root directory, where the process
directory node is actually first in the list).  With this patch,
pfs_iterate() will continue to traverse the parent directory's node
list after exhausting the process list (as was the intention all
along).  The code should hopefully be easier to read as well.

While I'm here, have pfs_iterate() assert that the allproc lock is
held.
2003-08-18 13:36:09 +00:00
Poul-Henning Kamp
29796304f8 Do not call VOP_BMAP() on our own vnodes.
It is particularly silly when all it does is a minor piece of math.
2003-08-17 23:00:30 +00:00
Robert Watson
946e86b7e1 Add p_candebug() check to access a process map file in procfs; limit
access to map information for processes that you wouldn't otherwise
have debug rights on.

Tested by:	bms
2003-08-14 15:26:44 +00:00
Tom Rhodes
c98a31cad3 Add a '-M mask' option so that users can have different
masks for files and directories.  This should make some
of the Midnight Commander users happy.

Remove an extra ')' in the manual page.

PR:		35699
Submitted by:	Eugene Grosbein <eugen@grosbein.pp.ru> (original version)
Tested by:	simon
2003-08-12 20:06:56 +00:00
John Baldwin
8b149b5131 Consistently use the BSD u_int and u_short instead of the SYSV uint and
ushort.  In most of these files, there was a mixture of both styles and
this change just makes them self-consistent.

Requested by:	bde (kern_ktrace.c)
2003-08-07 15:04:27 +00:00
Poul-Henning Kamp
291faa1677 Don't drop giant around ->d_strategy(), too much code explodes. 2003-08-06 06:49:18 +00:00
Poul-Henning Kamp
f4a3d9da6e Only drop Giant around the drivers ->d_strategy() if the buffer is not
marked to prevent this.
2003-08-05 06:43:56 +00:00
Poul-Henning Kamp
a8d43c90af Add a "int fd" argument to VOP_OPEN() which in the future will
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.
2003-07-26 07:32:23 +00:00
Tim J. Robbins
c8db6734e0 Revise and improve ntfs_subr.c 1.30: read only a single cluster at a time
in ntfs_writentvattr_plain and ntfs_readntvattr_plain, and purge the boot
block from the buffer cache if isn't exactly one cluster long. These two
changes work around the same buffer cache bug that ntfs_subr.c 1.30 tried
to, but in a different way. This may decrease throughput by reading smaller
amounts of data from the disk at a time, but may increase it by avoiding
bogus writes of clean buffers.
Problem (re)reported by Karel J. Bosschaart on -current.
2003-07-26 02:21:49 +00:00
Peter Wemm
7d6207b7dd size_t != int. Make this compile on 64 bit platforms (eg: amd64).
Also, "u_short value; if (value > 0xffff)" can never be true.
2003-07-24 01:59:18 +00:00
Tom Rhodes
3c01bab8a3 If bread() returns a zero-length buffer, as can happen after a
failed write, return an error instead of looping forever.

PR:		37035
Submitted by:	das
2003-07-03 14:54:47 +00:00
Tim J. Robbins
ae620d4480 XXX Copy workaround from UFS: open device for write access even if
the user requests a read-only mount. This is necessary because we
don't do the VOP_OPEN again if they upgrade a read-only mount to
read-write.

Fixes lockup when creating files on msdosfs mounts that have been
mounted read-only then upgraded to read-write. The exact cause of
the lockup is not known, but it is likely to be the kernel getting
stuck in an infinite loop trying to write dirty buffers to a device
without write permission.

Reported/tested by andreas, discussed with phk.
2003-06-29 03:05:59 +00:00
Tom Rhodes
c2f95f6688 Fix a bug where a truncate operation involving truncate() or ftruncate() on
an MSDOSFS file system either failed, silently corrupted the file, or
sometimes corrupted the neighboring file.

PR:		53695
Submitted by:	Ariff Abdullah <skywizard@MyBSD.org.my> (original version)
MFC:		3 days
2003-06-27 15:46:38 +00:00
John-Mark Gurney
4119b6e581 change dev_t to struct cdev * to match ufs. This fixes fstat for cd9660
and msdosfs.

Reviewed by:	bde
2003-06-24 22:11:20 +00:00
Poul-Henning Kamp
3b6d965263 Add a f_vnode field to struct file.
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.
2003-06-22 08:41:43 +00:00
John-Mark Gurney
efe0afa930 fix grammar in comment 2003-06-20 23:29:04 +00:00
Tim J. Robbins
a222314fe6 Merge from NetBSD src/sys/ntfs/ntfs_subr.c 1.5 & 1.30 (jdolecek):
- Avoid calling bread() with different sizes on the same blkno.
  Although the buffer cache is designed to handle differing size
  buffers, it erroneously tries to write the incorrectly-sized buffer
  buffer back to disk before reading the correctly-sized one, even
  when it's not dirty. This behaviour caused a panic for read-only
  NTFS mounts when INVARIANTS was enabled ("bundirty: buffer x still
  on queue y"), reported by NAKAJI Hiroyuki.
- Fix a bug in the code handling holes: a variable was incremented
  instead of decremented, which could cause an infinite loop.
2003-06-20 14:52:52 +00:00
Alan Cox
a38918cdbd Lock the vm object when freeing a vm page. 2003-06-19 17:56:12 +00:00
Alan Cox
82b8b18959 Lock the vm object when freeing a vm page. 2003-06-19 03:38:05 +00:00
Alan Cox
95aada383f Lock the vm object when freeing a vm page. 2003-06-19 03:08:10 +00:00
Tim J. Robbins
2a4ad25895 Send the close request to the SMB server in smbfs_inactive(), instead of
smbfs_close(). This fixes paging to and from mmap()'d regions of smbfs
files after the descriptor has been closed, and makes thttpd, GNU ld,
and perhaps more things work that depend on being able to do this.

PR:		48291
2003-06-17 12:58:02 +00:00
Tim J. Robbins
8e78890396 Set f_mntfromname[] to "fdescfs" instead of "fdesc" for consistency
with other synthetic filesystems, which have f_mntfromname the same
as f_fstypename. Noticed by Sean Kelly on -current.
2003-06-17 09:00:15 +00:00
Tim J. Robbins
549398753a MFp4: Fix two bugs causing possible deadlocks or panics, and one nit:
- Emulate lock draining (LK_DRAIN) in null_lock() to avoid deadlocks
  when the vnode is being recycled.
- Don't allow null_nodeget() to return a nullfs vnode from the wrong
  mount when multiple nullfs's are mounted. It's unclear why these checks
  were removed in null_subr.c 1.35, but they are definitely necessary.
  Without the checks, trying to unmount a nullfs mount will erroneously
  return EBUSY, and forcibly unmounting with -f will cause a panic.
- Bump LOG2_SIZEVNODE up to 8, since vnodes are >256 bytes now. The old
  value (7) didn't cause any problems, but made the hash algorithm
  suboptimal.

These changes fix nullfs enough that a parallel buildworld succeeds.

Submitted by:	tegge (partially; LK_DRAIN)
Tested by:	kris
2003-06-17 08:52:45 +00:00
Don Lewis
bbddbed9f3 Partially back out rev 1.87 by nuking fifo_inactive() and moving the
resource deallocation back to fifo_close().  This eliminates any
stale data that might be stuck in the socket buffers after all the
readers and writers have closed the fifo.

Tested by: Thorsten Schroeder <ths@katjusha.de>
2003-06-16 17:17:09 +00:00
Poul-Henning Kamp
e04393d6de In specfs::vop_specstratey(), assert that the vnode and buffer agree about
the device.
2003-06-15 20:31:04 +00:00
Poul-Henning Kamp
2a0f8aeb52 I have not had any reports of trouble for a long time, so remove the
gentle versions of the vop_strategy()/vop_specstrategy() mismatch methods
and use vop_panic() instead.
2003-06-15 19:49:14 +00:00
Poul-Henning Kamp
dc81367d8d Take 2: Remove _both_ KASSERTS. 2003-06-15 19:16:34 +00:00
Poul-Henning Kamp
d5bde314e9 Duh! I misread my handwritte notes: We do _not_ want to asser that
vp == bp->b_vp in specfs, that was the entire point of VOP_SPECSTRATEGY().
2003-06-15 19:14:03 +00:00
Poul-Henning Kamp
cefb5754dd Add the same KASSERT to all VOP_STRATEGY and VOP_SPECSTRATEGY implementations
to check that the buffer points to the correct vnode.
2003-06-15 18:53:00 +00:00
Poul-Henning Kamp
e5fb1850ae Remove in toto coda_strategy which incorrectly implemented vop_panic(); 2003-06-15 18:45:15 +00:00
David Schultz
3bb3827fcf Fix some style problems, some of which are old, some new, and some
inherited from UFS.

Requested by:	bde, njl
2003-06-15 02:21:13 +00:00
David Xu
0e2a4d3aeb Rename P_THREADED to P_SA. P_SA means a process is using scheduler
activations.
2003-06-15 00:31:24 +00:00
David Schultz
ac092fb30c If someone tries to mount a union filesystem with another unionfs as
the upper layer, fail gracefully instead of panicing.

MFC after:	3 days
2003-06-14 23:56:27 +00:00
David Schultz
0614a6351f Introduce malloc types M_UNDCACHE and M_UNPATH for important
unionfs-related data structures to aid in debugging memory leaks.
Use NULL and NULLVP instead of 0 as appropriate.

MFC after: 3 days
2003-06-14 23:48:20 +00:00
David Schultz
d8c6e674a4 Factor out the process of freeing ``directory caches'', which unionfs
directory vnodes use to refer to their constituent vnodes, into
union_dircache_free().  Also s/union_dircache/union_dircache_get/ and
tweak the structure of union_dircache_r().

MFC after:	3 days
2003-06-14 23:27:29 +00:00
Tim J. Robbins
35c5de54e8 Don't follow smbnode n_parent pointer when NREFPARENT flag is not set
in smb_fphelp(): the parent vnode may have already been recycled
since we don't hold a reference to it. Fixes a panic when rebooting
with mdconfig -t vnode devices referring to vnodes on a smbfs mount.
2003-06-14 15:24:54 +00:00
David Schultz
177935c8d6 Plug a serious memory leak. The -STABLE equivalent of this patch has
been tested extensively, but -CURRENT testing has been hampered by a
number of panics that also occur without the patch.  Since the
destabilizing changes between 4.X and 5.X are external to unionfs,
I believe this patch applies equally well to both.

Thanks to scrappy for assistance testing these and other changes.

MFC after:	4 days
2003-06-13 08:59:37 +00:00
Don Lewis
b156281658 Clean up the fifo_open() implementation:
Restructure the error handling portion of the resource allocation
        code to eliminate duplicated code.

        Test for the O_NONBLOCK && fi_readers == 0 case before incrementing
        fi_writers and modifying the the socket flag to avoid having to
        undo these operations in this error case.

        Restructure and simplify the code that handles blocking opens.

There should be no change to functionality.
2003-06-13 06:58:11 +00:00
Poul-Henning Kamp
7652131bee Initialize struct vfsops C99-sparsely.
Submitted by:   hmp
Reviewed by:	phk
2003-06-12 20:48:38 +00:00
David E. O'Brien
8c9bbf484a Use __FBSDID(). 2003-06-11 00:34:37 +00:00
David E. O'Brien
16dbc7f228 Use __FBSDID(). 2003-06-10 21:29:12 +00:00
Don Lewis
64820e19bc Don't unlock the parent directory vnode twice if the ISDOTDOT flag
is set.
2003-06-01 09:16:26 +00:00
Don Lewis
3a140162b4 Fix up locking problems in fifo_open() and fifo_close():
Sleep on the vnode interlock while waiting for another
	caller to increment fi_readers or fi_writers.  Hold the
	vnode interlock while incrementing fi_readers or fi_writers
	to prevent a wakeup from being missed.

	Only access fi_readers and fi_writers while holding the vnode
	lock.  Previously fifo_close() decremented their values without
	holding a lock.

	Move resource deallocation from fifo_close() to fifo_inactive(),
	which allows the VOP_CLOSE() call in the error return path in
	fifo_open() to be removed.  Fifo_open() was calling VOP_CLOSE()
	with the vnode lock held, in violation the current vnode locking
	API.  Also the way fifo_close() used vrefcnt() to decide whether
	to deallocate resources was bogus according to comments in the
	vrefcnt() implementation.

Reviewed by:	bde
2003-06-01 06:24:32 +00:00
Poul-Henning Kamp
670966596b Remove unused variable(s).
Found by:       FlexeLint
2003-05-31 20:29:34 +00:00
Poul-Henning Kamp
1e18ce425e emove unused variable(s).
Found by:       FlexeLint
2003-05-31 20:19:13 +00:00
Poul-Henning Kamp
2f613363c7 Remove unused variable.
Found by:       FlexeLint
2003-05-31 19:34:52 +00:00
Poul-Henning Kamp
ff81e317d4 Use temporary variable to avoid double expansion of macro with side effects.
Found by:       FlexeLint
2003-05-31 18:46:45 +00:00