18 years agoBuild infrastructure for GCC 3.4
Joerg Sonnenberger [Mon, 14 Jun 2004 22:27:56 +0000 (22:27 +0000)]
Build infrastructure for GCC 3.4

This is based both on the logical structure of GCC own Makefiles
and the build framework of GCC 3.3. For the moment, the generated
helper files are recreated for each directory using them to make
the dependencies simpler. libgcc_r is not included, because the
only difference is the normal version is an explicit call to
pthread_mutex_init instead of using the static init model, which
is serialized by a spinlock for all those locks.

This is not yet hooked into the normal buildworld system.

18 years agoAdd the old CSU files to list of file to be deleted and keep the new ones.
Joerg Sonnenberger [Mon, 14 Jun 2004 20:08:02 +0000 (20:08 +0000)]
Add the old CSU files to list of file to be deleted and keep the new ones.

18 years agoSwitch from GCC-version specific crtbegin/crtend code to the version
Joerg Sonnenberger [Mon, 14 Jun 2004 19:35:36 +0000 (19:35 +0000)]
Switch from GCC-version specific crtbegin/crtend code to the version
independent code. This is binary compatible with old version. The old
object files are currently left in place.

18 years agoImport BSD-licensed crtbegin/crtend support.
Joerg Sonnenberger [Mon, 14 Jun 2004 18:56:12 +0000 (18:56 +0000)]
Import BSD-licensed crtbegin/crtend support.

Obtained-from: NetBSD

Note: crtend.c comes without license header. I send a mail to Jason Thorpe
and will update it according to the response. I'm assuming the normal
4-clause NetBSD license for now.

18 years agoMake the procfs_validfile() function static.
Hiten Pandya [Mon, 14 Jun 2004 15:26:56 +0000 (15:26 +0000)]
Make the procfs_validfile() function static.

18 years agoIf there was a cache hit, and the msf->m_flags was set to SFBA_ONFREEQ,
Hiten Pandya [Mon, 14 Jun 2004 01:35:36 +0000 (01:35 +0000)]
If there was a cache hit, and the msf->m_flags was set to SFBA_ONFREEQ,
make sure we dequeue it properly before jumping to the 'done' label.

Reported-by: Emiel Kollof <coolvibe@gamepoint.net>
Discussed-with: Matthew Dillon <dillon@backplane.com>

18 years agostart_forked_proc() should not be called when rfork() is called without
Matthew Dillon [Sat, 12 Jun 2004 03:09:41 +0000 (03:09 +0000)]
start_forked_proc() should not be called when rfork() is called without
RFPROC, since no new process is being created.

Reported-by: Hiten
Testing-by: Hiten
18 years agoANSIfy the remaining K&R functions. Remove two bzero-after-malloc's in
Matthew Dillon [Sat, 12 Jun 2004 03:07:36 +0000 (03:07 +0000)]
ANSIfy the remaining K&R functions.  Remove two bzero-after-malloc's in
favor of M_ZERO, replace all uses of the MALLOC() macro with malloc(), and
replace all uses of the FREE() macro with free().

This is a cleanup commit only.

18 years agoFix a bug in the reply port path related to aborts. Aborted messages are
Matthew Dillon [Sat, 12 Jun 2004 01:55:59 +0000 (01:55 +0000)]
Fix a bug in the reply port path related to aborts.  Aborted messages are
requeued to the target port.  If the target is processing the message and
replies to it, the replyport code is supposed to remove any requeued aborts
(since the target completed processing of that message).

However, this was only occuring for MSGF_ASYNC messages.  It must be done for
both originator synchronous and originator asynchronous messages (abort
processing has nothing to do with how the originator sent the message).

Reported-by: David Rhodus
Testing-by: David Rhodus
18 years agoDo not produce a warning if the sysctl does not exist. This happens when
Hiten Pandya [Fri, 11 Jun 2004 12:03:15 +0000 (12:03 +0000)]
Do not produce a warning if the sysctl does not exist.  This happens when
the kernel is compiled without the INET6 option.

18 years agoBoth 'ps' and the loadav calculations got broken by thread sleeps, which
Matthew Dillon [Thu, 10 Jun 2004 22:11:39 +0000 (22:11 +0000)]
Both 'ps' and the loadav calculations got broken by thread sleeps, which
occur without knowledge by the proc and so ps/loadav thought processes
sitting in e.g. accept() were in a 'R'un state when they were actually

Make ps and the loadav calculator thread-aware.

18 years agoAdd Makefile support for host programs (.nx) just like we support normal
Joerg Sonnenberger [Thu, 10 Jun 2004 10:31:29 +0000 (10:31 +0000)]
Add Makefile support for host programs (.nx) just like we support normal
programs with bsd.prog.mk. The difference is that bsd.hostprog.mk doesn't
support man pages, scripts and builds ${PROG}.nx.

18 years agoRevert the locking of feof(3) for now; there is possibility of ill
Hiten Pandya [Wed, 9 Jun 2004 23:35:45 +0000 (23:35 +0000)]
Revert the locking of feof(3) for now; there is possibility of ill
effects due to the current implementation of funlockfile().

Inspired by rev. 1.7 of lib/libc/stdio/fclose.c.

18 years agoAdd some whitespace for clarity. No operational changes.
Hiten Pandya [Wed, 9 Jun 2004 20:26:04 +0000 (20:26 +0000)]
Add some whitespace for clarity.  No operational changes.

18 years agoAdd a 'big fat comment' about the FUNLOCKFILE(fp) implementation and why
Hiten Pandya [Wed, 9 Jun 2004 19:40:59 +0000 (19:40 +0000)]
Add a 'big fat comment' about the FUNLOCKFILE(fp) implementation and why
it needs to be called before modification of the FILE flags.

Requested-by: Matthew Dillon <dillon at backplane.com>

18 years agoRevert previous commit about FUNLOCKFILE(fp), it causes ill (and weird)
Hiten Pandya [Wed, 9 Jun 2004 19:28:04 +0000 (19:28 +0000)]
Revert previous commit about FUNLOCKFILE(fp), it causes ill (and weird)
effects for ports like Mozilla and net/freeraidus.

18 years agoAdd implemenation of lrealpath. This works like realpath, but returns
Joerg Sonnenberger [Wed, 9 Jun 2004 12:32:07 +0000 (12:32 +0000)]
Add implemenation of lrealpath. This works like realpath, but returns
a dynamically allocated string or a copy of the original pathname, if
realpath(3) failed. This can return NULL, if malloc(3) failed.

18 years agoFix the warranty, this is not UCB code
Joerg Sonnenberger [Wed, 9 Jun 2004 12:19:21 +0000 (12:19 +0000)]
Fix the warranty, this is not UCB code

18 years agoBegin implementing a -liberty replacement for binutils and GCC under
Joerg Sonnenberger [Wed, 9 Jun 2004 10:42:32 +0000 (10:42 +0000)]
Begin implementing a -liberty replacement for binutils and GCC under
BSD license. Any commit for this has to be carefully evaluated not to
create derived work from the corresponding GPL/LGPL code.

This is intentionally not yet hooked into the build tree.

18 years agoMerge with FreeBSD (RELENG_4) src/usr.bin/script/script.c, revision
Chris Pressey [Wed, 9 Jun 2004 07:53:55 +0000 (07:53 +0000)]
Merge ... FreeBSD (RELENG_4) src/usr.bin/script/script.c, revision

Let script(1)'s stdin/stdout be something besides a terminal,
allowing it to operate non-interactively.  (Addresses FreeBSD PR's
bin/56166, bin/57414, ports/57415, bin/59036, and ports/60534)

Approved-by: dillon
18 years agoAdd -u option to cpdup(1), which causes its -v[vv] logging output to
Chris Pressey [Wed, 9 Jun 2004 07:40:15 +0000 (07:40 +0000)]
Add -u option to cpdup(1), which causes its -v[vv] logging output to
stdout to be line-buffered instead of fully buffered.

Approved-by: dillon
18 years agoAdd the SysKonnect ethernet driver to the GENERIC kernel config.
David Rhodus [Tue, 8 Jun 2004 15:50:43 +0000 (15:50 +0000)]
Add the SysKonnect ethernet driver to the GENERIC kernel config.

18 years agoUpdate tcpslice to version 3.8.
Eirik Nygaard [Tue, 8 Jun 2004 13:20:56 +0000 (13:20 +0000)]
Update tcpslice to version 3.8.

Noticed by: David Rhodus <drhodus@machdep.com>

18 years agoTry the ELF image activator first.
Jeffrey Hsu [Tue, 8 Jun 2004 10:14:45 +0000 (10:14 +0000)]
Try the ELF image activator first.

18 years agoIf handed a bad file pointer that we can't write to, set the errno value
Hiten Pandya [Tue, 8 Jun 2004 04:04:11 +0000 (04:04 +0000)]
If handed a bad file pointer that we can't write to, set the errno value
to EBADF in order to get SUSv2 conformant behavior in higher level calls
like fputs() and puts().

Obtained-from:  FreeBSD (HEAD)

18 years agoIEEE Std. 1003.1-2001 wants feof(3) to behave as if it locked the FILE
Hiten Pandya [Tue, 8 Jun 2004 03:53:44 +0000 (03:53 +0000)]
IEEE Std. 1003.1-2001 wants feof(3) to behave as if it locked the FILE
stream for thread safety.

18 years agoIEEE Std. 1003.1-2001 dictates that fileno(3) behave as it locked the
Hiten Pandya [Tue, 8 Jun 2004 03:36:47 +0000 (03:36 +0000)]
IEEE Std. 1003.1-2001 dictates that fileno(3) behave as it locked the

18 years agoReplace the use of specially reserved pbufs in NFS's nfs_getpages() and
Hiten Pandya [Tue, 8 Jun 2004 02:58:52 +0000 (02:58 +0000)]
Replace the use of specially reserved pbufs in NFS's nfs_getpages() and
nfs_putpages() with MSF BUFs.  The pbufs were only used for providing a
KVA start address for the UIO and then released, thus being temporary.

This will not give a very huge boost in performance just yet because
not enough MSF_BUFs being reserved due to shortages of available KVA.
Until we convert the BUF and DEV subsystems to utilize the MSF_BUF+XIO
combo, we are pretty much limited.

In the worst case, the thrashing effect of MSF_BUFs will be no more then
the temporary pbuf+qenter; instead, the MSF_BUF will not be able to
cache the page-list mappings and end up doing a pmap_qenter() everytime.

Discussed-with:  Matthew Dillon <dillon@backplane.com>
                 (Earlier version of these changes were tested by him)

18 years agoRemove an accessory function called msf_buf_xio(); it is unnecessary for
Hiten Pandya [Tue, 8 Jun 2004 02:41:41 +0000 (02:41 +0000)]
Remove an accessory function called msf_buf_xio(); it is unnecessary for
now and was just additional bloat.

18 years agoConditionally include the essential header files, sys/queue.h and
Hiten Pandya [Tue, 8 Jun 2004 02:27:49 +0000 (02:27 +0000)]
Conditionally include the essential header files, sys/queue.h and

18 years agoRe-order include, 'sys' includes first, 'vm' includes after.
Hiten Pandya [Tue, 8 Jun 2004 02:15:38 +0000 (02:15 +0000)]
Re-order include, 'sys' includes first, 'vm' includes after.

18 years agoC99 update: freopen(3) with NULL 'path' argument so that it opens the
Hiten Pandya [Tue, 8 Jun 2004 00:45:00 +0000 (00:45 +0000)]
C99 update: freopen(3) with NULL 'path' argument so that it opens the
same file with a different mode.

At the moment, we just recycle the old file descriptor instead of storing
it somewhere and using that to reopen the file, as the standard seems to
require.  Strictly conforming C99 applications would probably not be able
to tell the difference but POSIX ones can.

While I am there, update the manual page about the new functionality and
correct nearby mdoc(7) markup errors.

Original-work-by: Tim J. Robbins <tjr@freebsd.org>
Additional-work-by: Hiten Pandya <hmp@backplane.com>
18 years agomdoc(7) corrections; use .Dv instead of .Em etc, fix grammar.
Hiten Pandya [Tue, 8 Jun 2004 00:29:47 +0000 (00:29 +0000)]
mdoc(7) corrections; use .Dv instead of .Em etc, fix grammar.

18 years agoDocument security issues with gets(3) in a proper manner.
Hiten Pandya [Tue, 8 Jun 2004 00:29:03 +0000 (00:29 +0000)]
Document security issues with gets(3) in a proper manner.

18 years agoSet the return value properly for fgetpos(3).
Hiten Pandya [Mon, 7 Jun 2004 20:57:15 +0000 (20:57 +0000)]
Set the return value properly for fgetpos(3).

18 years agoFUNLOCKFILE(fp) *after* modifying the FILE pointer's fields.
Hiten Pandya [Mon, 7 Jun 2004 20:45:14 +0000 (20:45 +0000)]
FUNLOCKFILE(fp) *after* modifying the FILE pointer's fields.

18 years agoUse ANSI C prototypes and remove the !__STDC__ varargs compatibility
Hiten Pandya [Mon, 7 Jun 2004 20:35:41 +0000 (20:35 +0000)]
Use ANSI C prototypes and remove the !__STDC__ varargs compatibility

Add a missing '$DragonFly$' tag in stdio/setbuf.c file.

18 years agoAvoid a memory leak if vfprintf(3) by always calling va_end(3); this
Hiten Pandya [Mon, 7 Jun 2004 17:59:42 +0000 (17:59 +0000)]
Avoid a memory leak if vfprintf(3) by always calling va_end(3); this
happens if vfprintf(3) runs out of memory.

Move the va_start(3) closer to the vfprintf(3) call; free the buffer
when if there is a failure condition and don't bother to realloc the
buffer before returning it.

Work done by Bruce Evans and Tim J. Robbins of the FreeBSD Project.

18 years agoRemove useless __STDC__ junk.
Hiten Pandya [Mon, 7 Jun 2004 16:53:40 +0000 (16:53 +0000)]
Remove useless __STDC__ junk.

Correct a nearby comment, s/NULL/NUL/ (NUL char...)

18 years agoUse correct sentence structure.
Hiten Pandya [Mon, 7 Jun 2004 16:37:56 +0000 (16:37 +0000)]
Use correct sentence structure.

18 years agoDissolve use of the 'register' keyword.
Hiten Pandya [Mon, 7 Jun 2004 16:31:02 +0000 (16:31 +0000)]
Dissolve use of the 'register' keyword.

18 years agoFix improper vm_object ref counting in procfs that was introduced in the last
Matthew Dillon [Mon, 7 Jun 2004 16:26:51 +0000 (16:26 +0000)]
Fix improper vm_object ref counting in procfs that was introduced in the last
commit.  This resulted in a panic under certain circumstances (e.g. when
configure got to the 'checking for correct flags to ps...' stage).

Reported-by: "GeekGod" <GeekGod@GeekGod.com> and others
18 years agoulimit.h needed to be added to the include file list for installation.
Matthew Dillon [Mon, 7 Jun 2004 07:06:31 +0000 (07:06 +0000)]
ulimit.h needed to be added to the include file list for installation.

Reported-by: Francois Briere <f.briere@dopha.org>
18 years agoConvert netproto/ns to the pr_usrreqs structure. This is untested work
Matthew Dillon [Mon, 7 Jun 2004 07:04:33 +0000 (07:04 +0000)]
Convert netproto/ns to the pr_usrreqs structure.  This is untested work
but NS didn't work at all before so...

18 years agoAdditional listhead->pcblisthead and marker support for netinet6.
Matthew Dillon [Mon, 7 Jun 2004 07:02:42 +0000 (07:02 +0000)]
Additional listhead->pcblisthead and marker support for netinet6.

18 years agoRecent accept() changes started depending on the protosw->pr_mport field
Matthew Dillon [Mon, 7 Jun 2004 07:01:36 +0000 (07:01 +0000)]
Recent accept() changes started depending on the protosw->pr_mport field
being non-NULL, but unix domain sockets still used a NULL pr_mport field.
This was causing e.g. XFree86 to panic the system.

Unix domain socket calls must still be executed synchronously in the context
of the originating process in order to access the proc structure (for ucred
and other things).

Implement a special synchronous port (netisr_sync_port) and hook function
for the protosw called sync_soport() and hook it into the unix domain
socket protosw.  This port executes netmsg's synchronously and also supports
aborts for predicate messages (used by connect and accept).

The atm protosw also specified NULL which we change to the standard

Remove previous workaround code for NULL mports, since we no longer have
any NULL mports.  Remove an assertion in connect2() that was designed to
detect mis-programmed use of the UNIX DOMAIN socket protosw structure.

Original-problem-reported-by: David Rhodus
18 years agoAdd in_pcbinfo_init() to encapsulate basic structural setup (right now just
Matthew Dillon [Mon, 7 Jun 2004 02:36:28 +0000 (02:36 +0000)]
Add in_pcbinfo_init() to encapsulate basic structural setup (right now just
the LIST_INIT).  Rename inpcbinfo->listhead to inpcbinfo->pcblisthead due
to changes in the API (addition of markers).

Add support for markers in the inpcbinfo->pcblisthead lists of INPCB
structures.  Use markers in sysctl output code to iterate through these lists
without losing its place or having to worry about structures being ripped out
from under it.  Scrap the original two-pass code.

Redo the sysctl INPCB output code for tcp, udp, and other protocols so we
always output the correct number of structures (as specified in xig_count).

Generate output for all cpus (for TCP).  This is accomplished by using
lwkt_setcpu_self() to migrate the kernel thread to each cpu, which allows us
to iterate the list(s) managed by that cpu without having to deal with mutexes
or other forms of locks.  Iterations always wind up on the same cpu they began

Redo netstat to properly iterate across as many cpu chunks as the inpcb
sysctl's return, rather then just the first one.

Work-by: Hiten Pandya and Matthew Dillon
18 years agoRemove dtom() from comment.
Matthew Dillon [Mon, 7 Jun 2004 02:18:13 +0000 (02:18 +0000)]
Remove dtom() from comment.

18 years agoBack out the last change. Normal 'make' builds in the source tree are
Matthew Dillon [Sun, 6 Jun 2004 22:44:34 +0000 (22:44 +0000)]
Back out the last change.  Normal 'make' builds in the source tree are
expected to use the system installed includes, special-casing libc would
make libc operate differently from other libraries.  Note that a buildworld
always has and continues to use the include files from the source tree.

In-discussion-with: Hiten Pandya

18 years agoAdd the prototype for the recently added XIO API call xio_init().
Matthew Dillon [Sun, 6 Jun 2004 19:16:51 +0000 (19:16 +0000)]
Add the prototype for the recently added XIO API call xio_init().

18 years agoRemove the canwait argument to dup_sockaddr(). Callers of dup_sockaddr()
Matthew Dillon [Sun, 6 Jun 2004 19:16:17 +0000 (19:16 +0000)]
Remove the canwait argument to dup_sockaddr().  Callers of dup_sockaddr()
all assume that it just works, so it really has to work.  Since interrupts
are now threads we can use M_INTWAIT.  While it is possible that a memory
deadlock issue exists here (e.g. if swapping over NFS), it isn't likely in
this case.

18 years agoThe usbcom's device was being released too early in the close sequence.
Matthew Dillon [Sun, 6 Jun 2004 18:58:09 +0000 (18:58 +0000)]
The usbcom's device was being released too early in the close sequence.
Note that this fixes a null pointer panic but we still get the
following warning: 'ucom: Warning: cdevsw_remove() called while 1 device
refs still exist! (major 138)'

Submitted-by: YONETANI Tomokazu <qhwt+dragonfly-bugs@les.ath.cx>
18 years agoDeal with revoke()'d descriptors. The underlying vnode is vgone()'d, which
Matthew Dillon [Sun, 6 Jun 2004 18:47:51 +0000 (18:47 +0000)]
Deal with revoke()'d descriptors.  The underlying vnode is vgone()'d, which
means that it is forceably closed.  This clears v_rdev even though file
descriptors may still have references to the vnode, which leads to panics
(mainly on tty devices).

Check for v_rdev == NULL in most specfs fileops calls and return an error
code instead of panicing.   This isn't the cleanest solution but it's fine
for now.

Reported-by: Sascha Wildner <saw@online.de>
18 years agoANSI-fication. No operational changes.
Hiten Pandya [Sun, 6 Jun 2004 16:41:05 +0000 (16:41 +0000)]
ANSI-fication.  No operational changes.

18 years agoRegister keyword removal. No operational changes.
Hiten Pandya [Sun, 6 Jun 2004 15:05:55 +0000 (15:05 +0000)]
Register keyword removal.  No operational changes.

18 years agoAdd a reference to the ulimit(3) manual page.
Hiten Pandya [Sun, 6 Jun 2004 13:33:28 +0000 (13:33 +0000)]
Add a reference to the ulimit(3) manual page.

18 years agoImplement POSIX.1-2001 (XSI)'s ulimit(3) library call.
Hiten Pandya [Sun, 6 Jun 2004 13:32:27 +0000 (13:32 +0000)]
Implement POSIX.1-2001 (XSI)'s ulimit(3) library call.

Obtained-from:   FreeBSD (HEAD)

18 years agoDo not use the installed include files, instead, set the include path
Hiten Pandya [Sun, 6 Jun 2004 13:30:33 +0000 (13:30 +0000)]
Do not use the installed include files, instead, set the include path
to ${.CURDIR}/../../include; so that the right version is used.

18 years agoNow that we have clients that use m_getcl(9), set the default mcl_pool_max
Hiten Pandya [Sun, 6 Jun 2004 11:49:54 +0000 (11:49 +0000)]
Now that we have clients that use m_getcl(9), set the default mcl_pool_max
pool size for mbuf+clusters to '10' instead of '0', to improve performace.

Obtained-from:   FreeBSD, rev. (RELENG_4)

18 years agoDiscard the first 1024 bytes of output as suggested by
Hiten Pandya [Sun, 6 Jun 2004 10:58:31 +0000 (10:58 +0000)]
Discard the first 1024 bytes of output as suggested by
http://citeseer.nj.nec.com/fluhrer01weaknesses.html and

Obtained-from: FreeBSD rev. 1.7 src/lib/libc/gen/arc4random.c

18 years agoClose race condition in accept(2).
Jeffrey Hsu [Sun, 6 Jun 2004 05:59:44 +0000 (05:59 +0000)]
Close race condition in accept(2).

18 years agoFix typo in error message - there is no system call named "lchflags."
Chris Pressey [Sun, 6 Jun 2004 05:48:01 +0000 (05:48 +0000)]
Fix typo in error message - there is no system call named "lchflags."

18 years agoDetect and foil optimistic ACK attack with forced slow-start
Jeffrey Hsu [Sun, 6 Jun 2004 05:38:58 +0000 (05:38 +0000)]
Detect and foil optimistic ACK attack with forced slow-start
as suggested by Azcorra, Bernardos, and Soto.

18 years agoAdd the MSFBUF API. MSFBUFs are like SFBUFs but they manage ephermal
Matthew Dillon [Sat, 5 Jun 2004 19:57:40 +0000 (19:57 +0000)]
Add the MSFBUF API.  MSFBUFs are like SFBUFs but they manage ephermal
multi-page mappings instead of single-page mappings.  MSFBUFs have the
same caching and page invalidation optimizations that SFBUFs have and are
considered to be SMP-friendly.

Whereas XIO manages pure page lists, MSFBUFs manage KVA mappings of pure
page lists.

This initial commit just gets the basic API operational.  The roadmap for
future work includes things like better interactions with third-party XIOs,
mapping user buffers into the kernel (extending the xio_init_ubuf() API into
the MSFBUF API), and allowing higher level subsystems to pass previously
released MSFBUFs as a hint to speed-up regeneration.  We also need to come
up with a way to overload additional sets of MSFBUFs representing smaller
chunks of memory on top of the same KVA space in order to efficiently use
our KVA reservation when dealing with subsystems like the buffer cache.

MSFBUFs will eventually replace the KVA management in the BUF/BIO, PIPE,
and other subsystems which create fake linear mappings with pbufs.  The
general idea for BUF/BIO will be to use XIO and MSFBUFs to avoid KVA
mapping file data through the nominal I/O path.  XIO will be the primary I/O
buffer mechanism while MSFBUFs will be used when things like UFS decide they
need a temporary mapping.

This is a collaborative work between Hiten Pandya <hmp@leaf.dragonflybsd.org>
and Matthew Dillon <dillon@backplane.com>.

18 years agoM_NOWAIT is just wrong in the init code. The allocation must succeed.
Matthew Dillon [Sat, 5 Jun 2004 18:04:47 +0000 (18:04 +0000)]
M_NOWAIT is just wrong in the init code.  The allocation must succeed.

18 years agoRearrange the kern_getcwd() procedure to return the base of the string
Matthew Dillon [Sat, 5 Jun 2004 16:34:07 +0000 (16:34 +0000)]
Rearrange the kern_getcwd() procedure to return the base of the string
rather then relocating the string.

Also fix two bugs: (1) the original bcopy was copying data beyond the end of
the buffer ([bp, bp+buflen] exceeds the buffer), and (2), the uap->buflen
checks must be made in __getcwd(), before the kernel tries to malloc() space.

18 years agoAdd a manual page describing the LSI Fusion family of devices with a
Hiten Pandya [Sat, 5 Jun 2004 15:02:05 +0000 (15:02 +0000)]
Add a manual page describing the LSI Fusion family of devices with a
few changes by me.

Requested-by: David Rhodus <drhodus@machdep.com>

18 years agoem(4) assumes that bus_dmamap_destroy of bus_dmamap_load_mbuf maps
Joerg Sonnenberger [Sat, 5 Jun 2004 13:52:29 +0000 (13:52 +0000)]
em(4) assumes that bus_dmamap_destroy of bus_dmamap_load_mbuf maps
unconditionally succeds w/o previous bus_dmamap_unload. This assumption
is currently true because bus_dmamap_load_mbuf doesn't support bounce
pages. Nevertheless is that an implementation detail which em(4) should
not depend on.

Discussed-with: Hiten Pandya <hmp@backplane.com>

18 years agoFix a small bug in the last commit. ether_ifdetach has to be called
Joerg Sonnenberger [Sat, 5 Jun 2004 13:09:00 +0000 (13:09 +0000)]
Fix a small bug in the last commit. ether_ifdetach has to be called
explicitly if bus_setup_intr fails.

18 years agoSwap order of first and second argument in bcopy, forgot this when changing
Eirik Nygaard [Sat, 5 Jun 2004 10:27:58 +0000 (10:27 +0000)]
Swap order of first and second argument in bcopy, forgot this when changing
from strncpy.

18 years agoUse MAXPATHLEN as the size of the checkpoint filename sysctl variable instead
Eirik Nygaard [Sat, 5 Jun 2004 10:04:38 +0000 (10:04 +0000)]
Use MAXPATHLEN as the size of the checkpoint filename sysctl variable instead
of a hardcoded value.

18 years agoPrint the entire path to where the checkpoint file is being created to avoid
Eirik Nygaard [Sat, 5 Jun 2004 10:02:07 +0000 (10:02 +0000)]
Print the entire path to where the checkpoint file is being created to avoid
confusion if the application changes it's working dir.

Pointers by: Matthew Dillon <dillon@apollo.backplane.com>

18 years agoSplit the __getcwd syscall into a kernel and an userland part, so it can be
Eirik Nygaard [Sat, 5 Jun 2004 09:58:15 +0000 (09:58 +0000)]
Split the __getcwd syscall into a kernel and an userland part, so it can be
used in the kernel as well.

Pointers by: Matthew Dillon <dillon@apollo.backplane.com>

18 years agoAllow dup_sockaddr() to block, otherwise the code becomes non-deterministic.
Matthew Dillon [Sat, 5 Jun 2004 05:34:57 +0000 (05:34 +0000)]
Allow dup_sockaddr() to block, otherwise the code becomes non-deterministic.
Since we are a thread now this should be fairly safe.

18 years agoFix typo.
Chris Pressey [Sat, 5 Jun 2004 03:23:14 +0000 (03:23 +0000)]
Fix typo.

Reported-by: Brad Harvell
18 years agoasync syscall work: The async syscall code got dated by recent LWKT
Matthew Dillon [Fri, 4 Jun 2004 20:35:39 +0000 (20:35 +0000)]
async syscall work: The async syscall code got dated by recent LWKT
changes, set mp_abort_port and clear MSGF_DONE as appropriate.

If a system call returns EASYNC, record the message in p->p_sysmsgq so we
can run them down in exit1().

In exit1(), run down any asynch system calls that are still running.  Note
that this commit does not implement abort support (yet).

Get rid of lwkt_port->mp_refs, it was not being used and it is likely never
going to be used (reference counting LWKT is hazzardous anyway since it
doesn't really fit the access model).

Add lwkt_checkmsg() to support some of the rearranged async syscall code.

18 years agoRemove dtom(). dtom() is no longer supported (precursor requirement for
Matthew Dillon [Fri, 4 Jun 2004 20:29:02 +0000 (20:29 +0000)]
Remove dtom().  dtom() is no longer supported (precursor requirement for
eventual mbuf allocator replacement).

18 years agoUse a normal malloc() for PCB allocations instead of the really aweful mbuf
Matthew Dillon [Fri, 4 Jun 2004 20:27:32 +0000 (20:27 +0000)]
Use a normal malloc() for PCB allocations instead of the really aweful mbuf
hacks that were previously being used (which also gets rid of the remaining
dtom() calls).

Get rid of the packet/queue overloading and instead malloc() a queue header
for queueing packets.  The old code depended on dtom() to figure out the
mbuf associated with the packet and we are removing dtom().

Give NS a default usrreq so it doesn't panic the system on boot, but note
that NS will remain broken until the usrreq can be tied into the existing

Review and testing by: Hiten Pandya and David Rhodus

18 years agoRe-arrange the 'Executable' column for the '-l' option so that long
Hiten Pandya [Fri, 4 Jun 2004 17:30:26 +0000 (17:30 +0000)]
Re-arrange the 'Executable' column for the '-l' option so that long
pathnames are printed correctly.

Suggested-by: Matthew Dillon <dillon at backplane.com>

18 years agoContinue cleaning em(4).
Joerg Sonnenberger [Fri, 4 Jun 2004 16:32:11 +0000 (16:32 +0000)]
Continue cleaning em(4).

Merge PCI resource allocation / deallocation into em_attach and em_detach.
Change the order of allocations in em_attach to work without splimp()
Remove adapter->unit, adapter->next and adapter->prev.
Use em_detach for the error handling in em_attach as well.
Move the reset of if_timer into em_stop.
Use adapter->hw.mac_addr instead of arpcom's entry.

18 years agoAllow top(1) to toggle display of processes+threads or *only* threads
Hiten Pandya [Fri, 4 Jun 2004 11:21:53 +0000 (11:21 +0000)]
Allow top(1) to toggle display of processes+threads or *only* threads
by adding a '-O' command line argument and run-time toggle.

This is useful when one wants to only monitor activity of current
active threads.

Document this new functionality and update the patches accordingly.

Requested-by: David Rhodus <drhodus@machdep.com>

18 years agoDeprecate use of m_act, which is an alias of m_nextpkt; just use
Hiten Pandya [Fri, 4 Jun 2004 07:45:46 +0000 (07:45 +0000)]
Deprecate use of m_act, which is an alias of m_nextpkt; just use
m_nextpkt instead.

18 years agoAdd MPF_INT (for mpipe_init()), which allows one to specify that an MPIPE
Matthew Dillon [Fri, 4 Jun 2004 06:56:12 +0000 (06:56 +0000)]
Add MPF_INT (for mpipe_init()), which allows one to specify that an MPIPE
allocation request may use the interrupt memory reserve.

18 years agoFlush cached access mode after modifying a files attributes for NFSv3.
Hiten Pandya [Fri, 4 Jun 2004 05:06:40 +0000 (05:06 +0000)]
Flush cached access mode after modifying a files attributes for NFSv3.
It's likely that modifying the attiributes will affect the file's

Fix created by Ian Dowse and Peter Edwards of the FreeBSD Project.
Test case available in PR# 44336 in FreeBSD GNATS.

18 years agoUse MPIPE instead of misusing m_getclr() (i.e. m_get) for NETNS's
Matthew Dillon [Fri, 4 Jun 2004 04:59:57 +0000 (04:59 +0000)]
Use MPIPE instead of misusing m_getclr() (i.e. m_get) for NETNS's
struct nspcb.  This also gets rid of a dtom() call.

Note: the changes compile but are untested.

18 years agoUse MPIPE instead of the really hackish use of m_get() and mtod()/dtom()
Matthew Dillon [Fri, 4 Jun 2004 04:32:23 +0000 (04:32 +0000)]
Use MPIPE instead of the really hackish use of m_get() and mtod()/dtom()
for the 'tcptemp' structure.

18 years agoRemove dtom() in unused (#ifndef notdef'd) code. Well, just remove the whole
Matthew Dillon [Fri, 4 Jun 2004 04:30:55 +0000 (04:30 +0000)]
Remove dtom() in unused (#ifndef notdef'd) code.  Well, just remove the whole
of the related #ifdef notdef'd sections.

18 years agoTEST
Matthew Dillon [Fri, 4 Jun 2004 04:25:07 +0000 (04:25 +0000)]

18 years agoUse MPIPE instead of (the really aweful improper use of) mbuf_alloc() for
Matthew Dillon [Fri, 4 Jun 2004 03:57:41 +0000 (03:57 +0000)]
Use MPIPE instead of (the really aweful improper use of) mbuf_alloc() for
struct ipq.  This also gets rid of a nasty dtoc().

18 years agoANSIfication. No functional changes.
Matthew Dillon [Fri, 4 Jun 2004 01:46:49 +0000 (01:46 +0000)]
ANSIfication.  No functional changes.

18 years agoms_cmd has changed to a union, update the test code.
Matthew Dillon [Thu, 3 Jun 2004 21:03:32 +0000 (21:03 +0000)]
ms_cmd has changed to a union, update the test code.

18 years agoAdd a manual page which describes the vn_fullpath(9) function.
Hiten Pandya [Thu, 3 Jun 2004 19:26:36 +0000 (19:26 +0000)]
Add a manual page which describes the vn_fullpath(9) function.

Adapted from the manual page in the FreeBSD CVS repository.

18 years agoMake pr_input use variadic arguments for anything but the first mbuf.
Joerg Sonnenberger [Thu, 3 Jun 2004 18:30:04 +0000 (18:30 +0000)]
Make pr_input use variadic arguments for anything but the first mbuf.

Add a warning for NSIP, it is likely to be broken.

18 years agoLock manipulation of the 'exec_res_list', i.e., the list of resident
Hiten Pandya [Thu, 3 Jun 2004 18:17:43 +0000 (18:17 +0000)]
Lock manipulation of the 'exec_res_list', i.e., the list of resident

Joerg Sonnenberger <joerg@bec.de>, Matthew Dillon <dillon@backplane.com>

18 years agoSurround a multi-line conditional block with braces for readability.
Hiten Pandya [Thu, 3 Jun 2004 18:12:41 +0000 (18:12 +0000)]
Surround a multi-line conditional block with braces for readability.

Suggested-by: Matthew Dillon <dillon at backplane.com>

18 years agoRemove the compat macro textvp_fullpath(), and use vn_fullpath()
Hiten Pandya [Thu, 3 Jun 2004 18:09:33 +0000 (18:09 +0000)]
Remove the compat macro textvp_fullpath(), and use vn_fullpath()

Discussed-with:  Matthew Dillon <dillon at backplane.com>

18 years agoCleanup the manual page:
Hiten Pandya [Thu, 3 Jun 2004 16:37:05 +0000 (16:37 +0000)]
Cleanup the manual page:

* add an AUTHORS section.

* use the '.Pa' command to markup a filename.

* remove hard sentence breaks and an empty section command.

18 years agoVM Resident Executables update:
Hiten Pandya [Thu, 3 Jun 2004 16:28:15 +0000 (16:28 +0000)]
VM Resident Executables update:

Kernel Part:

* decrement the exec_res_id counter in exec_sys_unregister, otherwise
  we will have an incorrect count of currently resident executables.

* add a structure called 'xresident' which stores enough information
  about resident executables, so that we can export it to userland
  via sysctl; the structure resides in sys/resident.h.

* add a sysctl node, called 'vm.resident' which enumerates though
  exec_res_list, i.e., the queue which stores information about the
  executables that are currently resident

* move the exec_res_list queue initialization and a MALLOC_DEFINE
  near the top of the file, right after the include files; and also
  initialize the exec_res_id counter to '0'.

NOTE! The 'vm.resident' sysctl node is only available to root!

Userland Part:

* add a '-l' option to resident(8), so that it displays the list
  of executables that are currently memory-resident.

* update the program usage string so that it is in par with the
  functionality offered by the program.

* update the manual page.

Requested-by: many...
Discussed-with:  Matthew Dillon <dillon@backplane.com>

18 years agoMake pr_domain and pr_usrreqs pointers to const. The general stack is not
Joerg Sonnenberger [Thu, 3 Jun 2004 16:21:22 +0000 (16:21 +0000)]
Make pr_domain and pr_usrreqs pointers to const. The general stack is not
supposed to change this and it allows us to make all this structures
const like they should be. If a network protocol wants to modify them,
they can still either modify the private version directly or create a copy
and change that.

18 years agoCleanup the textvp_fullpath() function; summary of changes:
Hiten Pandya [Thu, 3 Jun 2004 15:54:14 +0000 (15:54 +0000)]
Cleanup the textvp_fullpath() function; summary of changes:

* rename it to vn_fullpath(), and move prototype to sys/vnode.h;
  for now, keep a compat macro called textvp_fullpath(); this
  macro is temporary until I change linprocfs and procfs to play
  with vn_fullpath().

* rename last argument to 'freebuf', instead of 'retfreebuf'.

* if the second argument (vnode pointer) is NULL, fall back
  and use the passed-in process' p->p_textvp.

* make sure the client passes a process pointer, otherwise
  return EINVAL.

A manual page will be added real soon.