dragonfly.git
12 years agodsched(4): Some miscellaneous cleanup.
Sascha Wildner [Mon, 20 Feb 2012 11:58:50 +0000 (12:58 +0100)]
dsched(4): Some miscellaneous cleanup.

* Rename the bfq manpage to dsched_bfq(4), so that we don't run into
  name conflicts in the future. If someone wrote a manpage for
  dsched_as, it would have resulted in an as(4) manpage.

* Add options DSCHED_AS and DSCHED_BFQ to LINT*.

* Also, remove an unneeded check in dsched_as.

12 years agokern build: Update ldscripts
John Marino [Sun, 19 Feb 2012 16:24:56 +0000 (17:24 +0100)]
kern build: Update ldscripts

All for ldscripts (includes two virtual kernel scripts) have been
synchronized with binutils 2.22.  The previous sync was with FreeBSD
which is still using binutils 2.17.50.

A notable update is the usage of "-z max-page-size".  This is required
because the gold linker has a standard maximum page size of 0x1000 bytes
compared to 0x200000 bytes for the gnu ld linker.  It's an option to
change the default, but the gold default of 4KB has advantages.  Or in
other words, using a default maximum page size of 2MB has impacts to
library size and available memory that can be avoided.

Another thing to note is the vkernel64 has now been changed to load at
0x200000 like it's pc64 counterpart.

12 years agox86_64 getmemsize: Recover 0x100000 bytes
John Marino [Sun, 19 Feb 2012 15:26:19 +0000 (16:26 +0100)]
x86_64 getmemsize: Recover 0x100000 bytes

When binutils 2.20 was brought in, the x86_64 kernel built with it loaded
at 0x200000 instead of 0x100000 as it was previously.  The getmemsize()
function was never updated with the new address so the physical memory
between 0x100000 and 0x200000 has been lost since then.

The hardcoded value has been updated.  In the future, it may be a good
idea to replace with a variable as FreeBSD has done.

12 years agoMerge remote-tracking branch 'crater/master'
Thomas Nikolajsen [Sat, 18 Feb 2012 10:42:01 +0000 (11:42 +0100)]
Merge remote-tracking branch 'crater/master'

12 years agotmpfs.5: Add note that DragonFly NFS client needs to disable ReaddirPlus
Thomas Nikolajsen [Sat, 18 Feb 2012 10:37:22 +0000 (11:37 +0100)]
tmpfs.5: Add note that DragonFly NFS client needs to disable ReaddirPlus

12 years agoVFS accounting: optimize vop_write() performance
François Tigeot [Sat, 18 Feb 2012 09:36:06 +0000 (10:36 +0100)]
VFS accounting: optimize vop_write() performance

* Avoid a mount list scan if accounting is globally disabled

12 years agoVFS accounting: check if nullfs mp* really exist
Francois Tigeot [Fri, 17 Feb 2012 22:58:58 +0000 (23:58 +0100)]
VFS accounting: check if nullfs mp* really exist

* Nullfs are a clever hack, they forget their mp after mount and let the
  non-nullfs underlying mount point do all the work

* Nevertheless, we need to get the real struct mount associated to a mount
  point to count the space used by PFSes. We cache it in the vnode.

* But since the vnode we use really belongs to the lowest underlying
  mount point, the upper-level mp may already have been freed.

* We need to first check if it still valid; a new function,
  mountlist_exists() now exists for that purpose.

* Should fix issue #2266

12 years agortld: add carriage return to die()
John Marino [Sat, 18 Feb 2012 07:47:35 +0000 (08:47 +0100)]
rtld: add carriage return to die()

Add missing EOL character to the die() message.  This was lost when rtld_fdputstr() was
brought into rtld.

origin:
FreeBSD PR bin/165075
FreeBSD SVN 231582 (13 Feb 2012)

12 years agohier.7: Add back a .Bl that was removed with the binutils 2.20 removal.
Sascha Wildner [Fri, 17 Feb 2012 22:05:03 +0000 (23:05 +0100)]
hier.7: Add back a .Bl that was removed with the binutils 2.20 removal.

12 years agokernel/pf: In the ioctl code, make sure NPFLOG is actually defined.
Sascha Wildner [Fri, 17 Feb 2012 11:22:26 +0000 (12:22 +0100)]
kernel/pf: In the ioctl code, make sure NPFLOG is actually defined.

The inclusion of if_pflog.h was conditionalized on NPFLOG but it is
if_pflog.h itself that actually defines NPFLOG (because it includes
use_pflog.h).

So if_pflog.h was never included and some initialization code in
the ioctls for adding and changing rules was not executed.

12 years agokernel: Remove unused attributes from stuff that is, in fact, used.
Sascha Wildner [Thu, 16 Feb 2012 22:56:53 +0000 (23:56 +0100)]
kernel: Remove unused attributes from stuff that is, in fact, used.

12 years agopuc(4): Enable it for x86_64, too.
Sascha Wildner [Thu, 16 Feb 2012 21:30:49 +0000 (22:30 +0100)]
puc(4): Enable it for x86_64, too.

I have no idea if it works, but it is not in our GENERIC kernels so it
looks safe to just lurk for someone adding it to their config and
reporting breakage.

12 years agopuc.4: Fix path.
Sascha Wildner [Thu, 16 Feb 2012 21:28:44 +0000 (22:28 +0100)]
puc.4: Fix path.

12 years agokernel/i386: Remove a no longer needed include, too.
Sascha Wildner [Thu, 16 Feb 2012 19:53:33 +0000 (20:53 +0100)]
kernel/i386: Remove a no longer needed include, too.

12 years agokernel: Remove the unused is_physical_memory() function.
Sascha Wildner [Thu, 16 Feb 2012 19:51:28 +0000 (20:51 +0100)]
kernel: Remove the unused is_physical_memory() function.

It used to be used in dumping functions of raid and disk drivers but
updates and alexh's dumping upgrades (b24cd69c3515fbc52) removed all
usage more than two years ago.

12 years agokernel: mfs -- Fix unmount panic for MFS filesystems.
Venkatesh Srinivas [Thu, 16 Feb 2012 15:53:22 +0000 (07:53 -0800)]
kernel: mfs -- Fix unmount panic for MFS filesystems.

mfs_start() is active for the life of an MFS mount, handling copyin/out
requests. It is directed to exit when an MFS filesystem is unmounted.
The VFS accounting code and VFS MPLOCK code assumed that the mountpoint
structure was stable on return of mfs_start, which was not the case.

To work around that, don't call acinit if the vfs_start vfsop returns
EMOUNTEXIT, a kernel-specific pseudo-errno. Also allow marking vfs_start
MPSAFE and mark mfs vfs_start MPSAFE, to avoid accessing a per-mount
token field. A future commit will rework MFS's locking so that critical
sections are not used to protect the MFS bioq.

This is a hack for MFS; future work should either rework the filesystem
or replace it outright with tmpfs.

Closes: Bug 2276

12 years agoisp(4): Fix wrong sizeof().
Sascha Wildner [Thu, 16 Feb 2012 14:48:27 +0000 (15:48 +0100)]
isp(4): Fix wrong sizeof().

12 years agoproplib manpages: Add missing .Nd
Sascha Wildner [Thu, 16 Feb 2012 10:48:59 +0000 (11:48 +0100)]
proplib manpages: Add missing .Nd

12 years agoobjformat.1: Fix date.
Sascha Wildner [Thu, 16 Feb 2012 10:00:54 +0000 (11:00 +0100)]
objformat.1: Fix date.

12 years agokernel: Include <sys/ioccom.h> where ioctls are defined (part 2).
Sascha Wildner [Thu, 16 Feb 2012 09:35:04 +0000 (10:35 +0100)]
kernel: Include <sys/ioccom.h> where ioctls are defined (part 2).

Some cases that I previously missed.

12 years agokernel: Include <sys/ioccom.h> where ioctls are defined.
Sascha Wildner [Thu, 16 Feb 2012 09:08:57 +0000 (10:08 +0100)]
kernel: Include <sys/ioccom.h> where ioctls are defined.

Not where they are used.

See http://bugs.dragonflybsd.org/issues/1334

12 years agokernel: Remove opt_bus.h references where they are not needed.
Sascha Wildner [Thu, 16 Feb 2012 07:54:23 +0000 (08:54 +0100)]
kernel: Remove opt_bus.h references where they are not needed.

It only defines BUS_DEBUG (if set) and BUS_DEBUG is only used in
subr_bus.c, so it doesn't need to be included anywhere else.

12 years agoMerge remote-tracking branch 'crater/master'
Thomas Nikolajsen [Thu, 16 Feb 2012 06:35:29 +0000 (07:35 +0100)]
Merge remote-tracking branch 'crater/master'

12 years agoRevert "libstand.3: remove .Xo/.Xc"
Thomas Nikolajsen [Thu, 16 Feb 2012 06:25:06 +0000 (07:25 +0100)]
Revert "libstand.3: remove .Xo/.Xc"

.Xo/.Xc support has been added to mandoc(1).

This reverts commit 7ad109144437549598e004ac327522a3106f57f9.

12 years agomfiutil(8): Fix typo.
Sascha Wildner [Thu, 16 Feb 2012 05:12:49 +0000 (06:12 +0100)]
mfiutil(8): Fix typo.

12 years agokernel/pci: Implement the PCIOCATTACHED ioctl.
Sascha Wildner [Tue, 14 Feb 2012 22:18:33 +0000 (23:18 +0100)]
kernel/pci: Implement the PCIOCATTACHED ioctl.

This fixes pciconf -a

Taken-from: FreeBSD

12 years agoLINT/LINT64: Remove obsolete comment.
Sascha Wildner [Tue, 14 Feb 2012 23:35:56 +0000 (00:35 +0100)]
LINT/LINT64: Remove obsolete comment.

12 years agoRemove an obsolete header file specific to labpc(4) (which was removed).
Sascha Wildner [Mon, 13 Feb 2012 22:54:06 +0000 (23:54 +0100)]
Remove an obsolete header file specific to labpc(4) (which was removed).

12 years agoworld: Add missing DPADDs in some Makefiles.
Sascha Wildner [Mon, 13 Feb 2012 21:37:59 +0000 (22:37 +0100)]
world: Add missing DPADDs in some Makefiles.

12 years agoFix some typos.
Sascha Wildner [Mon, 13 Feb 2012 14:09:01 +0000 (15:09 +0100)]
Fix some typos.

12 years agobinutils: Fix typo in Makefile
John Marino [Sun, 12 Feb 2012 22:10:28 +0000 (23:10 +0100)]
binutils: Fix typo in Makefile

The variable for the backup binutils is BU_BACKUP, not BU_SECONDARY.
The backup binutils wasn't getting built after the recent makefile
changes due to this mixup.

12 years agobinutils: Revert unwanted change to Makefile.inc
John Marino [Sun, 12 Feb 2012 21:28:31 +0000 (22:28 +0100)]
binutils: Revert unwanted change to Makefile.inc

In the original changeset, Makefile.inc1 was incorporated into
Makefile.inc.  When it was split out, one of the variables was orphaned,
and as a result some of the binaries won't get installed.  Changes to
these two files should not have been committed before.

12 years agoremove unused /usr/libexec/binutils2*/elf/ld
John Marino [Sun, 12 Feb 2012 17:44:21 +0000 (18:44 +0100)]
remove unused /usr/libexec/binutils2*/elf/ld

After a recent commit (0784934ab2d8a3bba5ad1f59713db3cea8005865),
objformat handles the execution of the linker.  It chooses between
/usr/libexec/binutils*/elf/ld.bfd and /usr/libexec/binutils*/elf/ld.gold
and  /usr/libexec/binutils*/elf/ld is no longer referenced.

This commit cleans up the binutils 2.21 and 2.22 ld binaries using the
"make upgrade" command.

12 years agobinutils: Make manpage handling generic to ease maintenance
John Marino [Sun, 12 Feb 2012 17:35:45 +0000 (18:35 +0100)]
binutils: Make manpage handling generic to ease maintenance

DragonFly has two sets of binutils with one designated as primary and the
other is the backup.  In the recent past, every time these designation
were switched or a new binutils was brought in, around 30 makefiles had
to be manually and tediously updated in at least 3 places per file.

This commit implements common variables that will make future primary
designation changes not require changes to individual makefiles, but
rather limit the update to a couple of commons ones.

12 years agoobjformat - Duplicate NELEM() macro
Samuel J. Greear [Sun, 12 Feb 2012 18:24:26 +0000 (11:24 -0700)]
objformat - Duplicate NELEM() macro

* Fix buildworld on DragonFly hosts built before Dec 18, 2010 (2.9).

* NELEM() macro was added to sys/param.h on Dec 18, 2010 and objformat was
  made to use it on May 20, 2011. This broke upgrades for machines running a
  DragonFly version built prior to Dec 18, 2010 since objformat is built with
  the hosts headers as part of the cross tools stage.

12 years agoobjformat: Avoid unnecessary getenv calls
John Marino [Sun, 12 Feb 2012 11:13:28 +0000 (12:13 +0100)]
objformat: Avoid unnecessary getenv calls

The CCVER and BINUTILSVERS are always checked by objformat, even when
these values won't be used.  For example, there's no need to know the
value of CCVER when executing the realelf binutils binary, but it was
getting requested in all cases.

This commit limits the getenv requests to the bare minimum required.
Additionally it adds whitespace to the commands structure for the
purpose of aesthetics.

12 years agoobjformat: Add LINKERVER environment variable recognition
John Marino [Sun, 12 Feb 2012 09:48:33 +0000 (10:48 +0100)]
objformat: Add LINKERVER environment variable recognition

objformat will now scan for the LINKERVER environment variable.  If this
variable exists *AND* it has the value of "ld.gold", the command "ld"
will point at the gold linker.  In every other case, it will point at
the classic "gnu ld" linker.

The relative command position of "ld" was moved to after the compiler
group because it's a popular command and having it towards the front
means less time in the search loop.

12 years agostatic dl_iterate_phdr: remove unused phent variable
John Marino [Sat, 11 Feb 2012 22:23:14 +0000 (23:23 +0100)]
static dl_iterate_phdr: remove unused phent variable

This variable had been used in a validity check that was removed before
the last commit of dlfcn.c and it got orphaned.

12 years agogold linker v2.22: Return to constructors in DT_INIT_ARRAY
John Marino [Sat, 11 Feb 2012 21:17:12 +0000 (22:17 +0100)]
gold linker v2.22: Return to constructors in DT_INIT_ARRAY

This commit effectively reverses 17078250df568635285cd6be4515d29ee8c1b72a.
At the time, DragonFly did not recognize .init_array sections in an elf
file, and the gold linker was lumping the contructors from gcc into this
array which was subsequently filtered out.

DT_INIT_ARRAY and friends are now fully supported since commit
b28bf640312db2b299faff75052fbb01d67fd821 so the local modification is
being removed in favor of a default build.

12 years agortld: Add support for preinit, init, and fini arrays
John Marino [Sat, 11 Feb 2012 19:17:51 +0000 (20:17 +0100)]
rtld: Add support for preinit, init, and fini arrays

As far as I can tell, all BSDs limit their ELF executable file
initialization and termination to the .init and .fini sections.  In
contrast, Linux has additionally supported the .preinit_array,
.init_array, and .fini_array sections for over a decade through glibc.
With this commit, DragonFly becomes the first BSD to support these
arrays of function pointers.  It was tested using test cases taken from
glibc, gnu ld linker, and the gold linker.

For the main executable file, the .init_array and .fini_array sections
are handled by crt1, just like .init and .fini are.  In the case of
a statically linked binary, the .preinit_array section is also handled
by crt1.  The real-time linker handles the .init_array and .fini_array
sections for dynamically shared objects (libraries) and .preinit_array
for dynamically-linked binaries.  There are no .preinit_array sections
in the DSOs per standard.

These sections are described by the System V Application Binary Interface
http://www.sco.com/developers/gabi/latest/ch4.sheader.html#special_sections

The .init_array and .fini_array handling by rtld was reviewed by
Konstantin Belousov.

12 years agoRemove the duplicate fsx from tools/regression.
Sascha Wildner [Sat, 11 Feb 2012 19:29:36 +0000 (20:29 +0100)]
Remove the duplicate fsx from tools/regression.

12 years agodisk - add uuid to udev dict of parts
Alex Hornung [Fri, 10 Feb 2012 16:44:28 +0000 (16:44 +0000)]
disk - add uuid to udev dict of parts

 * Add the partition (disklabel64) UUID to the
   udev dictionary of partition disk devices,
   e.g. da0s1a.

12 years agodevattr - add more helpful failure message
Alex Hornung [Thu, 9 Feb 2012 21:49:14 +0000 (21:49 +0000)]
devattr - add more helpful failure message

Reported-by: luxh, swildner
12 years agondis(4): Use callout_init_mp(). Overlooked when I ported it.
Sascha Wildner [Thu, 9 Feb 2012 16:52:59 +0000 (17:52 +0100)]
ndis(4): Use callout_init_mp(). Overlooked when I ported it.

12 years agopuffs(4): Don't reference vp before it's initialized.
Sascha Wildner [Thu, 9 Feb 2012 16:30:16 +0000 (17:30 +0100)]
puffs(4): Don't reference vp before it's initialized.

12 years agohptiop(4): Use cam_calc_geometry() instead of duplicating it.
Sascha Wildner [Thu, 9 Feb 2012 13:02:07 +0000 (14:02 +0100)]
hptiop(4): Use cam_calc_geometry() instead of duplicating it.

Taken-from: FreeBSD

12 years agohptiop(4): Remove an unused variable.
Sascha Wildner [Thu, 9 Feb 2012 12:25:58 +0000 (13:25 +0100)]
hptiop(4): Remove an unused variable.

12 years agotest - Adjust randread to not share file descriptors
Matthew Dillon [Wed, 8 Feb 2012 23:32:52 +0000 (15:32 -0800)]
test - Adjust randread to not share file descriptors

* Close and reopen the device when randread fork()s so the physical
  file descriptor is not shared.  The vnode will still be shared.

* Works around a serialization issue when a file descriptor is shared.

12 years agomps(4): Add module version.
Sascha Wildner [Wed, 8 Feb 2012 20:40:35 +0000 (21:40 +0100)]
mps(4): Add module version.

12 years agolibexec: Remove duplicate includes.
Sascha Wildner [Wed, 8 Feb 2012 12:59:10 +0000 (13:59 +0100)]
libexec: Remove duplicate includes.

12 years agoRevert "mount_psshfs: Add a missing include dir to the Makefile."
Sascha Wildner [Wed, 8 Feb 2012 12:48:14 +0000 (13:48 +0100)]
Revert "mount_psshfs: Add a missing include dir to the Makefile."

This reverts commit 25766f8a90b7331f83451cfc4e175d1148a5dd08.

My thinking was wrong and it is not needed.

12 years agousr.sbin: Remove duplicate includes.
Sascha Wildner [Wed, 8 Feb 2012 12:37:51 +0000 (13:37 +0100)]
usr.sbin: Remove duplicate includes.

12 years agomount_psshfs: Add a missing include dir to the Makefile.
Sascha Wildner [Wed, 8 Feb 2012 12:37:23 +0000 (13:37 +0100)]
mount_psshfs: Add a missing include dir to the Makefile.

12 years agousr.bin: Remove duplicate includes.
Sascha Wildner [Wed, 8 Feb 2012 12:17:10 +0000 (13:17 +0100)]
usr.bin: Remove duplicate includes.

12 years agomps(4): Mark a function __printflike() and fix a resulting warning.
Sascha Wildner [Wed, 8 Feb 2012 11:01:20 +0000 (12:01 +0100)]
mps(4): Mark a function __printflike() and fix a resulting warning.

12 years agosbin: Remove duplicate includes.
Sascha Wildner [Tue, 7 Feb 2012 16:41:13 +0000 (17:41 +0100)]
sbin: Remove duplicate includes.

12 years agoSome cleanup in the puffs manpages.
Sascha Wildner [Tue, 7 Feb 2012 13:28:53 +0000 (14:28 +0100)]
Some cleanup in the puffs manpages.

12 years agoifconfig(8): Use strdup() instead of duplicating it.
Sascha Wildner [Tue, 7 Feb 2012 02:27:58 +0000 (03:27 +0100)]
ifconfig(8): Use strdup() instead of duplicating it.

12 years agomps(4): Remove some useless casts.
Sascha Wildner [Tue, 7 Feb 2012 10:53:42 +0000 (11:53 +0100)]
mps(4): Remove some useless casts.

I've inserted them by mistake because I had not realized that the
wrong typedefs for U32 and S32 were the real issue.

12 years agomps: Hold lock for the shutdown event handler
Sepherosa Ziehau [Tue, 7 Feb 2012 09:36:19 +0000 (17:36 +0800)]
mps: Hold lock for the shutdown event handler

12 years agomps: If we don't have enough space for a sge and chain, don't claim we can
Sepherosa Ziehau [Tue, 7 Feb 2012 09:35:20 +0000 (17:35 +0800)]
mps: If we don't have enough space for a sge and chain, don't claim we can

12 years agomps: Use WAITOK to allocate critical data struct on attach path
Sepherosa Ziehau [Tue, 7 Feb 2012 09:17:55 +0000 (17:17 +0800)]
mps: Use WAITOK to allocate critical data struct on attach path

12 years agomps: Properly define U32 and S32
Sepherosa Ziehau [Tue, 7 Feb 2012 09:15:45 +0000 (17:15 +0800)]
mps: Properly define U32 and S32

12 years agomps.4: Document how we disable MSI and comment out MSI-X documentation.
Sascha Wildner [Tue, 7 Feb 2012 08:50:08 +0000 (09:50 +0100)]
mps.4: Document how we disable MSI and comment out MSI-X documentation.

12 years agomps(4): Sync with FreeBSD.
Sascha Wildner [Tue, 7 Feb 2012 08:42:32 +0000 (09:42 +0100)]
mps(4): Sync with FreeBSD.

This a still in progress port of the new, LSI-supported version of the
mps(4) driver from FreeBSD.

Some of the changes are (from FreeBSD's commit msg):

- Integrated RAID (IR) support.
- Support for WarpDrive controllers.
- Support for SCSI protection information (EEDP).
- Support for TLR (Transport Level Retries), needed for tape drives.
- Improved error recovery code.
- ioctl interface compatible with LSI utilities.

This commit also moves the driver from sys/dev/disk to sys/dev/raid.

It still fails attaching at this stage. Work on it will continue in
master.

12 years agodpt(4): Remove an old unneeded file.
Sascha Wildner [Mon, 6 Feb 2012 13:29:06 +0000 (14:29 +0100)]
dpt(4): Remove an old unneeded file.

12 years agomlx(4): Remove an unused variable.
Sascha Wildner [Mon, 6 Feb 2012 08:29:22 +0000 (09:29 +0100)]
mlx(4): Remove an unused variable.

12 years agosnd_hda(4): Use MSI if it is supported by the device.
Sascha Wildner [Mon, 6 Feb 2012 03:42:17 +0000 (04:42 +0100)]
snd_hda(4): Use MSI if it is supported by the device.

12 years agopci: Fix manual interrupt routing support
Sepherosa Ziehau [Mon, 6 Feb 2012 03:02:18 +0000 (11:02 +0800)]
pci: Fix manual interrupt routing support

- Add function id to tunable name
- Call BUS_CONFIG_INTR upon manually assigned interrupt

Tested-by: swildner@
12 years agoUpdate the pciconf(8) database.
Sascha Wildner [Mon, 6 Feb 2012 02:17:58 +0000 (03:17 +0100)]
Update the pciconf(8) database.

Jan 18, 2012 snapshot from http://pciids.sourceforge.net/

12 years agosh: Test EXIT trap with multiple statements in it
Peter Avalos [Sun, 5 Feb 2012 20:43:12 +0000 (12:43 -0800)]
sh: Test EXIT trap with multiple statements in it

Obtained-from:  FreeBSD 230211

12 years agosh: Add testcases that should not be broken by future optimizations.
Peter Avalos [Sun, 5 Feb 2012 20:38:57 +0000 (12:38 -0800)]
sh: Add testcases that should not be broken by future optimizations.

Obtained-from:  FreeBSD 230121

12 years agosh: Avoid possible echo options in a testcase.
Peter Avalos [Sun, 5 Feb 2012 20:36:00 +0000 (12:36 -0800)]
sh: Avoid possible echo options in a testcase.

Obtained-from:  FreeBSD 229742

12 years agosh: Fix swapped INTON/INTOFF.
Peter Avalos [Sun, 5 Feb 2012 20:26:01 +0000 (12:26 -0800)]
sh: Fix swapped INTON/INTOFF.

A possible consequence of this bug was a memory leak if SIGINT arrived
during a 'set' command (listing variables).

Obtained-from:  FreeBSD 231001

12 years agosh: Use vfork in a few common cases.
Peter Avalos [Sun, 5 Feb 2012 20:21:25 +0000 (12:21 -0800)]
sh: Use vfork in a few common cases.

This uses vfork() for simple commands and command substitutions containing a
single simple command, invoking an external program under certain conditions
(no redirections or variable assignments, non-interactive shell, no job
control). These restrictions limit the amount of code executed in a vforked
child.

There is a large speedup (for example 35%) in microbenchmarks. The
difference in buildkernel is smaller (for example 0.5%) but still
statistically significant. See
http://lists.freebsd.org/pipermail/freebsd-hackers/2012-January/037581.html
for some numbers.

The use of vfork() can be disabled by setting a variable named
SH_DISABLE_VFORK.

Obtained-from:  FreeBSD 230998

12 years agosh: Fix $? in the first command of a 'for'.
Peter Avalos [Sun, 5 Feb 2012 20:12:44 +0000 (12:12 -0800)]
sh: Fix $? in the first command of a 'for'.

In the first command of a 'for', $? should be the exit status of the last
pipeline (command substitution in the word list or command before 'for'),
not always 0.

Obtained-from:  FreeBSD 230463

12 years agosh: Remove "kill" example function, which is superseded by the kill
Peter Avalos [Sun, 5 Feb 2012 20:10:27 +0000 (12:10 -0800)]
sh: Remove "kill" example function, which is superseded by the kill
builtin

Obtained-from:  FreeBSD 230437

12 years agosh: Fix execution of multiple statements in a trap when evalskip is set
Peter Avalos [Sun, 5 Feb 2012 20:07:56 +0000 (12:07 -0800)]
sh: Fix execution of multiple statements in a trap when evalskip is set

Before this fix, only the first statement of the trap was executed if
evalskip was set. This is for example the case when:
    o  "-e" is set for this shell
    o  a trap is set on EXIT
    o  a function returns 1 and causes the script to abort

Obtained-from:  FreeBSD 230212

12 years agosh: Fix some bugs with exit status from case containing ;&.
Peter Avalos [Sun, 5 Feb 2012 20:04:53 +0000 (12:04 -0800)]
sh: Fix some bugs with exit status from case containing ;&.

Also, rework evalcase() to not evaluate any tree. Instead, return the
NCLISTFALLTHRU node and handle it in evaltree().

Fixed bugs:

* If a ;& list with non-zero exit status is followed by an empty ;; or final
  list, the exit status of the case command should be equal to the exit
  status of the ;& list, not 0.

* An empty ;& case should not reset $?.

Obtained-from:  FreeBSD 230161

12 years agosh: Fix two bugs with case and exit status:
Peter Avalos [Sun, 5 Feb 2012 20:02:44 +0000 (12:02 -0800)]
sh: Fix two bugs with case and exit status:

* If no pattern is matched, POSIX says the exit status shall be 0 (even if
  there are command substitutions).
* If a pattern is matched and there are no command substitutions, the first
  command should see the $? from before the case command, not always 0.

Obtained-from:  FreeBSD 230154

12 years agosh: Change input buffer size from 1023 to 1024.
Peter Avalos [Sun, 5 Feb 2012 20:00:29 +0000 (12:00 -0800)]
sh: Change input buffer size from 1023 to 1024.

Apparently this improves performance on slower platforms.

Obtained-from:  FreeBSD 230118

12 years agosh: Fix out of bounds array access when trap is used with an invalid
Peter Avalos [Sun, 5 Feb 2012 19:52:44 +0000 (11:52 -0800)]
sh: Fix out of bounds array access when trap is used with an invalid
signal.

Obtained-from:  FreeBSD 230117

12 years agosh: Properly show "Not a directory" error in cd builtin.
Peter Avalos [Sun, 5 Feb 2012 19:44:29 +0000 (11:44 -0800)]
sh: Properly show "Not a directory" error in cd builtin.

The errno message display added in 72cbf4010 did not take attempting to
cd to a non-directory or something that cannot be stat()ed into account.

Obtained-from:  FreeBSD 230095

12 years agosh: Make various functions static.
Peter Avalos [Sun, 5 Feb 2012 19:42:22 +0000 (11:42 -0800)]
sh: Make various functions static.

Obtained-from:  FreeBSD 229220

12 years agosh: Remove unused function scopyn().
Peter Avalos [Sun, 5 Feb 2012 19:30:56 +0000 (11:30 -0800)]
sh: Remove unused function scopyn().

Obtained-from: FreeBSD 229219

12 years agosh: Make patmatch() non-recursive.
Peter Avalos [Sun, 5 Feb 2012 19:28:08 +0000 (11:28 -0800)]
sh: Make patmatch() non-recursive.

Obtained-from:  FreeBSD 229201

12 years agosh: Allow quoting ^ and ] in bracket expressions.
Peter Avalos [Sun, 5 Feb 2012 19:23:10 +0000 (11:23 -0800)]
sh: Allow quoting ^ and ] in bracket expressions.

Obtained-from:  FreeBSD 228943

12 years agosh: Use dirent.d_type in pathname generation.
Peter Avalos [Sun, 5 Feb 2012 19:20:09 +0000 (11:20 -0800)]
sh: Use dirent.d_type in pathname generation.

This improves performance for globs where a slash or another component
follows a component with metacharacters by eliminating unnecessary
attempts to open directories that are not.

Obtained-from:  FreeBSD 228942

12 years agosh: Cache de->d_namlen in a local variable.
Peter Avalos [Sun, 5 Feb 2012 19:16:08 +0000 (11:16 -0800)]
sh: Cache de->d_namlen in a local variable.

Obtained-from:  FreeBSD 228941

12 years agosh: Don't force special builtins non-special in optimized command subst.
Peter Avalos [Sun, 5 Feb 2012 19:11:06 +0000 (11:11 -0800)]
sh: Don't force special builtins non-special in optimized command subst.

This is not necessary: errors are already caught in evalbackcmd() and
forcelocal handles changes to variables.

Obtained-from:  FreeBSD 228937

12 years agoSupport exception handling on statically-linked binaries
John Marino [Sun, 5 Feb 2012 16:21:27 +0000 (17:21 +0100)]
Support exception handling on statically-linked binaries

The real-time dynamic linker handles exceptions on dynamically-linked
binaries through the dl_iterate_phdr function.  The RTLD isn't invoked
on statically-built executables so thrown exceptions weren't getting
handled.  There was a dummy dl_iterate_phdr function in libc with a
weak symbol that gets looked at when the rtld version isn't present.
This function was populated and gets called when the statically-linked
executable throws an exception.

It requires the GNU_EH_FRAME program header to be present.  The base
gcc 4.4 spec file was modified to emit this header for statically-built
binaries in addition to the dynamically lined ones.

12 years agocdefs: Rework and augment visibility attributes
John Marino [Sun, 5 Feb 2012 16:14:25 +0000 (17:14 +0100)]
cdefs: Rework and augment visibility attributes

One macro based on GCC visibility functions was already defined,
__exported.  However, it was marked as available for all GCC versions
when it fact it was introduced with gcc 4.0.

There was no macro for hidden visibility attributes, so the macros
__dso_hidden and __dso_public were borrowed from NetBSD.  __dso_public
is an alias for __exported.  The definition for all three macros were
made on the condition that the gcc version used is 4.0 or later.

12 years agokernel -- linprocfs: linprocfs_allocvp should return a locked vnode.
Venkatesh Srinivas [Sun, 5 Feb 2012 15:04:57 +0000 (10:04 -0500)]
kernel -- linprocfs: linprocfs_allocvp should return a locked vnode.

Fixes a panic where VFS_ROOT returned an unlocked vnode and led to
a lockmgr panic from vput in the namecache.

Reported-by: phma
Bug: 2298

12 years agoRevert "librefuse: Remove from Makefile; it breaks world"
Sascha Wildner [Sun, 5 Feb 2012 13:30:14 +0000 (14:30 +0100)]
Revert "librefuse: Remove from Makefile; it breaks world"

This reverts commit 7e1d2825717ccf4a77edc0de7cf1ae109928db1f.

12 years agolibpuffs: Fix a path that was assuming source is in /usr/src.
Sascha Wildner [Sun, 5 Feb 2012 13:28:41 +0000 (14:28 +0100)]
libpuffs: Fix a path that was assuming source is in /usr/src.

12 years agoboot2: slim it down about 300 bytes
John Marino [Sun, 5 Feb 2012 10:28:50 +0000 (11:28 +0100)]
boot2: slim it down about 300 bytes

The boot2_32.ld loader file needs to come in at 7680 bytes or less, while
boot2_64.ld can be a little bigger with a 14848 byte threshold.  The
32-bit version has the least memory margin.  Using the base gcc 4.4
compiler, it only has 396 bytes to spare.

Using updates from FreeBSD buys 292 additional bytes when built by the
base compiler.  This additional space may be useful for building world
with clang which may have slightly larger executables.

List of changes from FreeBSD
==========================
SVN 151382 (16 OCT 2005)
SHRINK: Convert load() ep and es arrays to static variables

SVN 180145 (01 JUL 2008)
BUG: parse function off by one
change "if (dsk.slice > NDOSPART)" to "if (dsk.slice > NDOSPART + 1)"

SVN 214210 (22 OCT 2010)
SHRINK: Avoid using memcpy() for copying 32bit chunks.

SVN 218713 (15 FEB 2011)
SHRINK: Change autoboot type from int to uint8_t

SVN 218745 (16 FEB 2011)
SHRINK: Remove reading of symbols from a.out loaded files.  This
functionality was left over from the early FreeBSD 3.x days to
support kernels in a.out format which never applied to DragonFly.
Removing it saves around 100 bytes.  bootinfo.bi_esymtab was also
relocated to the ELF section rather than aways being set.

SVN 219186 (02 MAR 2011)
SHRINK: Change the tick overflow computation.
Remove bi_basemem, bi_extmem, bi_memsizes_valid (unused).
Switch kname to a pointer from an array to avoid using memcpy() twice.
Remove memsize function (unused)

SVN 219452 (10 MAR 2011)
SHRINK: Convert to uint8_t: dsk.slice, dsk.part, sl.
Remove fmt variable in load() used in redundant condition ladder.
Set buffer as static in printf() to save space.

SVN 220392 (06 APR 2011)
BUG: Move getc() before xgetc() so gcc does not emit a warning about
function having no body.

Minor changes from John Marino
==============================
Created RBF_NOINTR and RBF_PROBEKBD macros for consist style.
Removed "#if 0" sections to clean up.
returned "static" back to drvread body (was still in prototype).
Changed xputc() to return the char rather than void (matches FreeBSD),

12 years agoCCVER=gcc46: Now builds world and kernel cleanly
John Marino [Sun, 5 Feb 2012 07:00:44 +0000 (08:00 +0100)]
CCVER=gcc46: Now builds world and kernel cleanly

Starting with gcc 4.5, sbin/restore would break on interactive.c with
the complaint that the designated length of the storage array within
the adirent union structure was not constant.  After three previous
proposals on the best way to fix it, this is the one requiring the
least code change.  (Don't count the spelling correction!)

This was the last place the breaks using WORLD_CCVER=gcc46.  The
kernel builds cleanly.  Both the gcc46-built world and kernel load
and function normally.

suggested-by: vsrinivas

12 years agolibrefuse: Remove from Makefile; it breaks world
John Marino [Sun, 5 Feb 2012 07:52:26 +0000 (08:52 +0100)]
librefuse: Remove from Makefile; it breaks world

The refuse library fails during a clean build (presumably on test machines
/usr/include/fuse_opt.h existed and the build defaulted to that one).

/usr/src/lib/librefuse/fuse.h:191:22: fatal error: fuse_opt.h:
No such file or directory
compilation terminated.

12 years agoBring in the "Port PUFFS from NetBSD/FreeBSD" GSoC 2011 project results.
Sascha Wildner [Sun, 5 Feb 2012 01:29:51 +0000 (02:29 +0100)]
Bring in the "Port PUFFS from NetBSD/FreeBSD" GSoC 2011 project results.

With some additional stuff done by me (properly hooking into the build,
add some manpages, and other missing bits here and there, nothing
functional).

What we get:

* puffs(3) and refuse(3) libraries
* puffs(4) and putter(9) kernel parts
* mount_psshfs(8) utility

Note that it still might crash or stop working, so it's still
experimental. We're bringing it anyway because several people showed
interest in continuing to work on it and so it doesn't rot outside
our tree, gets at least built with world/kernel, etc.

Submitted-by: Nick Prokharau <nickprok@gmail.com>
12 years agoCCVER=gcc46: Separate LDFLAGS meant for gcc and ld
John Marino [Sat, 4 Feb 2012 18:27:10 +0000 (19:27 +0100)]
CCVER=gcc46: Separate LDFLAGS meant for gcc and ld

The same LDFLAGS variable was being applied to gcc and ld.  Apparently
gcc 4.4 and below recognized and accepted the -m switch and passed it
on to the linker, but gcc 4.6 wasn't handling it.

A new variable COMPILER_LDFLAGS has been created alongside LDFLAGS.  The
former is meant to be passed to gcc and the latter is passed to ld.