dragonfly.git
3 years agoatkbd/x86_64: Do the same AT controller check on x86_64 as on i386
Sepherosa Ziehau [Mon, 29 Aug 2011 07:18:16 +0000 (15:18 +0800)]
atkbd/x86_64: Do the same AT controller check on x86_64 as on i386

DragonFly-bug:
    http://bugs.dragonflybsd.org/issue2052
    http://bugs.dragonflybsd.org/issue2065

3 years agomfi(4): Fix a bug in the disk initialization code.
Sascha Wildner [Mon, 29 Aug 2011 03:19:54 +0000 (05:19 +0200)]
mfi(4): Fix a bug in the disk initialization code.

This ultimately caused a panic when kldunloading.

Reported-by: Tomi Juvonen <tomi.juvonen@kenou.biz>
3 years agokernel: Bring in safe(4), for SafeNet crypto accelerators.
Sascha Wildner [Sun, 28 Aug 2011 22:39:54 +0000 (00:39 +0200)]
kernel: Bring in safe(4), for SafeNet crypto accelerators.

Yet untested.

Taken-from: FreeBSD

3 years agodsched - increase max size of diskctx
Alex Hornung [Sun, 28 Aug 2011 21:57:45 +0000 (21:57 +0000)]
dsched - increase max size of diskctx

3 years agoadd missing DSCHED_BFQ option
Alex Hornung [Sun, 28 Aug 2011 21:51:26 +0000 (21:51 +0000)]
add missing DSCHED_BFQ option

 * fixes LINT build

Reported-by: Sascha Wildner
3 years agodm - Add device type for future raid1
Alex Hornung [Sun, 28 Aug 2011 08:45:12 +0000 (08:45 +0000)]
dm - Add device type for future raid1

Submitted-by: Adam Hoka
Sponsored-by: Google Summer of Code
3 years agodm - Move the target unbusy to the dm_table_destroy function
Adam Hoka [Tue, 21 Jun 2011 01:23:21 +0000 (03:23 +0200)]
dm - Move the target unbusy to the dm_table_destroy function

Sponsored-by: Google Summer of Code
3 years agodm - Add method to get inactive table size
Adam Hoka [Sun, 28 Aug 2011 08:37:19 +0000 (08:37 +0000)]
dm - Add method to get inactive table size

Sponsored-by: Google Summer of Code
3 years agosystat: Change the way ifstats are displayed.
Peter Avalos [Sun, 28 Aug 2011 04:00:29 +0000 (21:00 -0700)]
systat:  Change the way ifstats are displayed.

-Default to displaying bits/s for the rate, and bytes for the totals.
-kilo, mega, giga, tera are all powers of 1000, not 1024.
-Add two new commands: autobyte and autobit which will automatically
change the scale factor in bytes or bits, respectively.  auto defaults
to displaying bits.

3 years agosystat: Sync ifstat code with FreeBSD.
Peter Avalos [Sun, 28 Aug 2011 01:53:25 +0000 (18:53 -0700)]
systat:  Sync ifstat code with FreeBSD.

-Add a tera factor.
-Change factors from binary (1024) to SI (1000).
-Allow for larger scale factors.
-Drop useless initializers and includes.
-Use C99 initializers and enums.
-Remove trailing whitespace.

Obtained-from:   FreeBSD

3 years agodsched_bfq - Add documentation
Brills Peng [Sun, 28 Aug 2011 01:06:24 +0000 (01:06 +0000)]
dsched_bfq - Add documentation

Sponsored-by: Google Summer of Code
3 years agodsched_bfq - A budget fair-queuing dsched policy
Brills Peng [Sat, 27 Aug 2011 18:19:49 +0000 (18:19 +0000)]
dsched_bfq - A budget fair-queuing dsched policy

 * dsched_bfq is a budget fair queuing scheduling policy for the dsched
   framework.

 * NOTE: this scheduler is still highly experimental and
   work-in-progress, it's not recommended for widespread use (yet).
   There are several well-known issues, such as a possible deadlock on
   unloading the module.

Sponsored-by: Google Summer of Code
3 years agodsched_as - A simple & experimental AS
Brills Peng [Sat, 27 Aug 2011 17:27:04 +0000 (17:27 +0000)]
dsched_as - A simple & experimental AS

 * dsched_as is a purely experimental anticipatory scheduler. It serves
   no real-life purpose other than testing and experimenting.

 * Don't use this scheduling policy for anything other than
   experimentation!!!

Sponsored-By: Google Summer of Code
3 years agosystat: Don't revert to bits if >1024GB.
Peter Avalos [Sat, 27 Aug 2011 21:08:04 +0000 (14:08 -0700)]
systat:  Don't revert to bits if >1024GB.

3 years agokernel - Fix ptrace signal races between child and parent
Matthew Dillon [Sat, 27 Aug 2011 19:57:53 +0000 (12:57 -0700)]
kernel - Fix ptrace signal races between child and parent

* Fix several ptrace signal races which could cause the parent's wait()
  function to block forever (or until the parent is killed).  Generally
  speaking we have to use the process token to interlock the wakeup()/tsleep()
  sequence used by the ptrace code.

* Fix a MP race in the wait code, we must hold the child process's token
  when manipulating its p_flag field.

Reported-by: corecode, tuxillo
3 years agodsched - Bump maximum tdio size to 384 bytes
Brills Peng [Sat, 27 Aug 2011 11:42:08 +0000 (11:42 +0000)]
dsched - Bump maximum tdio size to 384 bytes

Sponsored-by: Google Summer of Code
3 years agodsched - Add request polling wrapper
Brills Peng [Sat, 27 Aug 2011 11:24:35 +0000 (11:24 +0000)]
dsched - Add request polling wrapper

 * Add a request polling emulation layer to dsched. This emulated
   request polling as if a disk driver would poll for requests instead
   of requests being actively pushed down.

 * The policy->polling_func() callback is called whenever a BIO
   completes.

 * A field in the diskctx that shows the current tag queue depth and the
   maximum tag queue depth (currently fixed value of 32) are used in the
   policies using request polling directly and is not enforced in the
   dsched layer. That is, a policy using request polling emulation
   should take care of not having (many) more BIOs in flight than
   max_tag_queue_depth.

Sponsored-by: Google Summer of Code
3 years agodsched - Add debugging & fix rare problem conditions
Alex Hornung [Sat, 27 Aug 2011 10:51:24 +0000 (10:51 +0000)]
dsched - Add debugging & fix rare problem conditions

 * Add a bunch of debugging to see whether a particular tdio was
   initialized and to which policy it belongs.

 * Reorder some locking to ensure the whole switch of policy is
   protected as expected.

 * Make sure the tdio from the newest policy is used when there
   are tdios for several scheduling policies in the tdctx->tdio_list.

Reported-by: Brills Peng
3 years agofq - fix a (possible) deadlock
Alex Hornung [Fri, 26 Aug 2011 00:29:17 +0000 (00:29 +0000)]
fq - fix a (possible) deadlock

 * A deadlock can occur if a lock is held around the strategy call when
   the completion is synchronous and ends up in the destruction of a
   tdio, as both will acquire the same diskctx lock.

 * Refactor the code around strategy calls so that the bios are first
   prepared, under the protection of the lock, and inserted into a local
   array. Once that is ready and the bios are ready and taken out of
   their respective queues, the locks are dropped and the strategy call
   occurs locklessly.

Reported-by: Antonio Huete (tuxillo@)
3 years agohammer(8): Adjust status message (Dedup-real -> Dedup).
Sascha Wildner [Thu, 25 Aug 2011 16:59:38 +0000 (18:59 +0200)]
hammer(8): Adjust status message (Dedup-real -> Dedup).

3 years agosh.1: Nuke unneeded .Pp
Sascha Wildner [Thu, 25 Aug 2011 16:31:57 +0000 (18:31 +0200)]
sh.1: Nuke unneeded .Pp

3 years agomfi(4): Add forgotten brace.
Sascha Wildner [Wed, 24 Aug 2011 15:13:09 +0000 (17:13 +0200)]
mfi(4): Add forgotten brace.

3 years agomfi(4): Add a panic to catch future mistakes.
Sascha Wildner [Wed, 24 Aug 2011 06:26:30 +0000 (08:26 +0200)]
mfi(4): Add a panic to catch future mistakes.

It is not reached with the current code but will prevent future
mistakes in case the mfi_identifiers[] array is not set up
properly.

3 years agomfi(4): Style fix.
Sascha Wildner [Wed, 24 Aug 2011 03:48:38 +0000 (05:48 +0200)]
mfi(4): Style fix.

3 years agoFrom NetBSD revision 1.11:
Justin C. Sherrill [Wed, 24 Aug 2011 01:48:15 +0000 (18:48 -0700)]
From NetBSD revision 1.11:

"Do proper input validation without penalizing performance."

Suggested-by: Joerg Sonnenberger <joerg@britannica.bec.de>
3 years agoFrom NetBSD revision 1.10:
Justin C. Sherrill [Wed, 24 Aug 2011 01:40:40 +0000 (18:40 -0700)]
From NetBSD revision 1.10:

"set errno on overflow return."

Suggested-by: Joerg Sonnenberger <joerg@britannica.bec.de>
3 years agoFrom NetBSD revision 1.9:
Justin C. Sherrill [Wed, 24 Aug 2011 01:37:29 +0000 (18:37 -0700)]
From NetBSD revision 1.9:

"provisional fix for CVS-2011-2895, buffer overflow when uncompressing"

Suggested-by: Joerg Sonnenberger <joerg@britannica.bec.de>
3 years agomly(4): Fix comment indentation.
Sascha Wildner [Mon, 22 Aug 2011 20:29:06 +0000 (22:29 +0200)]
mly(4): Fix comment indentation.

3 years agocam(4): Add a quirk to turn off SYNC CACHE for mly(4).
Sascha Wildner [Mon, 22 Aug 2011 20:22:41 +0000 (22:22 +0200)]
cam(4): Add a quirk to turn off SYNC CACHE for mly(4).

This fixes mounting a HAMMER file system from an mly(4) disk on
the AcceleRAID 160 I tried this with.

I think it will also fix the following issue that was reported
for the AcceleRAID 170 on FreeBSD:

http://lists.freebsd.org/pipermail/freebsd-hardware/2008-December/005676.html

The problem with fixing this was that the mly(4) driver modifies
the SCSI inquiry data and uses it for its own purposes (to show
the disk type and status). So I had to make these fields a bit
more recognizable to the quirks code because the previous strings
were too generic for my taste.

3 years agomly(4): Reduce diffs with FreeBSD and update CVS IDs.
Sascha Wildner [Mon, 22 Aug 2011 16:38:26 +0000 (18:38 +0200)]
mly(4): Reduce diffs with FreeBSD and update CVS IDs.

3 years agoLINT: Sort descriptions better than I did in the last commit.
Sascha Wildner [Mon, 22 Aug 2011 12:14:24 +0000 (14:14 +0200)]
LINT: Sort descriptions better than I did in the last commit.

3 years agolongrun(4): Remove from Makefile, it is not a module.
Sascha Wildner [Mon, 22 Aug 2011 11:37:04 +0000 (13:37 +0200)]
longrun(4): Remove from Makefile, it is not a module.

3 years agokernel: Bring back longrun(4) which was lost in 90e8a35b.
Sascha Wildner [Mon, 22 Aug 2011 11:31:42 +0000 (13:31 +0200)]
kernel: Bring back longrun(4) which was lost in 90e8a35b.

FreeBSD had moved it to its own file (from identcpu.c) but that wasn't
brought in.

3 years agomly(4): Perform some minor cleanup.
Sascha Wildner [Mon, 22 Aug 2011 07:17:49 +0000 (09:17 +0200)]
mly(4): Perform some minor cleanup.

* Add dependencies for pci and cam.

* Fix a typo (MHZ -> MHz)

* Cleanup debug printf.

* Remove unused define from the Makefile and add MLY_DEBUG.

3 years agosh(1): Extend documentation about subshells.
Peter Avalos [Sun, 21 Aug 2011 22:12:11 +0000 (15:12 -0700)]
sh(1): Extend documentation about subshells.

Because sh executes commands in subshell environments without forking in
more and more cases, it makes sense to describe subshell environments
more precisely using ideas from POSIX, together with some
DragonFly-specific items.

In particular, the hash and times builtins may not behave as if their
state is copied for a subshell environment while leaving the parent
shell environment unchanged.

Obtained-from:   FreeBSD 223909

3 years agosh: include <limits.h> instead of non-standard <sys/limits.h>
Peter Avalos [Sun, 21 Aug 2011 22:10:34 +0000 (15:10 -0700)]
sh:  include <limits.h> instead of non-standard <sys/limits.h>

Obtained-from:   FreeBSD 223580

3 years agosh(1): Improve documentation of shell patterns:
Peter Avalos [Sun, 21 Aug 2011 22:07:23 +0000 (15:07 -0700)]
sh(1): Improve documentation of shell patterns:

* Shell patterns are also for ${var#pat} and the like.
* An '!' by itself will not trigger pathname generation so do not call
  it a meta-character, even though it has a special meaning directly
  after an '['.
* Character ranges are locale-dependent.
* A '^' will complement a character class like '!' but is non-standard.

Obtained-from:   FreeBSD 223522

3 years agosh(1): Document the case command better.
Peter Avalos [Sun, 21 Aug 2011 22:02:29 +0000 (15:02 -0700)]
sh(1): Document the case command better.

Obtained-from:  FreeBSD 223517

3 years agosh: Remove unneeded include file.
Peter Avalos [Sun, 21 Aug 2011 22:00:54 +0000 (15:00 -0700)]
sh:  Remove unneeded include file.

Obtained-from:   FreeBSD 223494

3 years agosh: Remove special support for background simple commands.
Peter Avalos [Sun, 21 Aug 2011 21:55:15 +0000 (14:55 -0700)]
sh: Remove special support for background simple commands.

It expands the arguments in the parent shell process, which is
incorrect.

Obtained-from:   FreeBSD 223282

3 years agosh: Add do-nothing -h option.
Peter Avalos [Sun, 21 Aug 2011 21:52:20 +0000 (14:52 -0700)]
sh: Add do-nothing -h option.

POSIX requires a -h option to sh and set, to locate and remember
utilities invoked by functions as they are defined. Given that this
locate-and-remember process is optional elsewhere, it seems safe enough
to make this option do nothing.

POSIX does not specify a long name for this option. Follow ksh in
calling it "trackall".

Obtained-from:   FreeBSD 223281

3 years agosh: Add case statement fallthrough (with ';&' instead of ';;').
Peter Avalos [Sun, 21 Aug 2011 21:45:13 +0000 (14:45 -0700)]
sh: Add case statement fallthrough (with ';&' instead of ';;').

Replacing ;; with the new control operator ;& will cause the next list
to be executed as well without checking its pattern, continuing until
a list ends with ;; or until the end of the case statement. This is
like omitting "break" in a C "switch" statement.

The sequence ;& was formerly invalid.

This feature is proposed for the next POSIX issue in Austin Group
issue #449.

Obtained-from:   FreeBSD 223186

3 years agosh: Skip vars with invalid names in "set", "export -p", "readonly -p".
Peter Avalos [Sun, 21 Aug 2011 21:39:50 +0000 (14:39 -0700)]
sh: Skip vars with invalid names in "set", "export -p", "readonly -p".

This ensures the output of these commands is valid shell input.

Obtained-from:   FreeBSD 223183

3 years agosh: Reduce unnecessary forks with eval.
Peter Avalos [Sun, 21 Aug 2011 21:36:38 +0000 (14:36 -0700)]
sh: Reduce unnecessary forks with eval.

The eval special builtin now runs the code with EV_EXIT if it was run
with EV_EXIT itself.

In particular, this eliminates one fork when a command substitution
contains an eval command that ends with an external program or a
subshell.

Obtained-from:   FreeBSD 223163

3 years agosh: Add support for named character classes in bracket expressions.
Peter Avalos [Sun, 21 Aug 2011 21:33:45 +0000 (14:33 -0700)]
sh: Add support for named character classes in bracket expressions.

Example:
  case x in [[:alpha:]]) echo yes ;; esac

Obtained-from:   FreeBSD 223120

3 years agosh: Fix duplicate prototypes for builtins.
Peter Avalos [Sun, 21 Aug 2011 21:21:56 +0000 (14:21 -0700)]
sh: Fix duplicate prototypes for builtins.

Have mkbuiltins write the prototypes for the *cmd functions to
builtins.h instead of builtins.c and include builtins.h in more
.c files instead of duplicating prototypes for *cmd functions in
other headers.

Obtained-from:   FreeBSD 223060

3 years agosh: Save/restore changed variables in optimized command substitution.
Peter Avalos [Sun, 21 Aug 2011 20:54:19 +0000 (13:54 -0700)]
sh: Save/restore changed variables in optimized command substitution.

In optimized command substitution, save and restore any variables
changed by expansions (${var=value} and $((var=assigned))), instead of
trying to determine if an expansion may cause such changes.

If $! is referenced in optimized command substitution, do not cause jobs
to be remembered longer.

This fixes $(jobs $!) again, simplifies the man page and shortens the
code.

Obtained-from:   FreeBSD 223024

3 years agosh: Read .profile from the home directory (or / if HOME is not set).
Peter Avalos [Sun, 21 Aug 2011 20:42:26 +0000 (13:42 -0700)]
sh: Read .profile from the home directory (or / if HOME is not set).

In most cases, login shells are started from the home directory, but not
in all, such as xterm -ls.

Obtained-from:   FreeBSD 223005

3 years agosh: Do parameter expansion on ENV before using it.
Peter Avalos [Sun, 21 Aug 2011 20:38:33 +0000 (13:38 -0700)]
sh: Do parameter expansion on ENV before using it.

This is required by POSIX, and allows things like ENV=\$HOME/.shrc.

Obtained-from:   FreeBSD 222957

3 years agosh: Do parameter expansion before printing PS4 (set -x).
Peter Avalos [Sun, 21 Aug 2011 20:26:53 +0000 (13:26 -0700)]
sh: Do parameter expansion before printing PS4 (set -x).

Obtained-from:   FreeBSD 222907

3 years agosh: Fix $? in heredocs on simple commands.
Peter Avalos [Sun, 21 Aug 2011 20:10:39 +0000 (13:10 -0700)]
sh: Fix $? in heredocs on simple commands.

Obtained-from:   FreeBSD 222716

3 years agosh: Improve error message if the script cannot be opened.
Peter Avalos [Sun, 21 Aug 2011 20:05:22 +0000 (13:05 -0700)]
sh: Improve error message if the script cannot be opened.

Avoid "<nosuchfile>: cannot open <nosuchfile>: ...".

Obtained-from:   FreeBSD 222699

3 years agosh: Reduce more needless differences between error messages.
Peter Avalos [Sun, 21 Aug 2011 19:58:01 +0000 (12:58 -0700)]
sh: Reduce more needless differences between error messages.

Obtained-from:   FreeBSD 222684

3 years agosh: Honor -n while processing -c string.
Peter Avalos [Sun, 21 Aug 2011 19:52:25 +0000 (12:52 -0700)]
sh: Honor -n while processing -c string.

Obtained-from:   FreeBSD 222676

3 years agosh: Remove the "exp" builtin.
Peter Avalos [Sun, 21 Aug 2011 19:50:34 +0000 (12:50 -0700)]
sh: Remove the "exp" builtin.

The "exp" builtin is undocumented, non-standard and not very useful.

Obtained-from:   FreeBSD 222386

3 years agosh: Correct criterion for using CDPATH in cd.
Peter Avalos [Sun, 21 Aug 2011 19:46:44 +0000 (12:46 -0700)]
sh: Correct criterion for using CDPATH in cd.

CDPATH should be ignored not only for pathnames starting with '/' but
also for pathnames whose first component is '.' or '..'.

Obtained-from:   FreeBSD 222381

3 years agosh: Various updates to the TOUR document.
Peter Avalos [Sun, 21 Aug 2011 19:41:55 +0000 (12:41 -0700)]
sh: Various updates to the TOUR document.

Obtained-From:   FreeBSD 222362

3 years agosh: Fix unquoted $@/$* if IFS=''.
Peter Avalos [Sun, 21 Aug 2011 19:39:23 +0000 (12:39 -0700)]
sh: Fix unquoted $@/$* if IFS=''.

If IFS is null, unquoted $@/$* should still expand to separate words.
This differs from quoted $@ (which does not depend on IFS) in that
pathname generation is performed and empty words are removed.

Obtained-from:   FreeBSD 222361

3 years agosh: Show errno messages in cd.
Peter Avalos [Sun, 21 Aug 2011 19:34:40 +0000 (12:34 -0700)]
sh: Show errno messages in cd.

Obtained-from:   FreeBSD 222292

3 years agosh: Remove obsolete token type TENDBQUOTE.
Peter Avalos [Sun, 21 Aug 2011 19:32:57 +0000 (12:32 -0700)]
sh: Remove obsolete token type TENDBQUOTE.

Obtained-from:   FreeBSD 222182

3 years agosh: Fix typo in comment.
Peter Avalos [Sun, 21 Aug 2011 19:31:07 +0000 (12:31 -0700)]
sh: Fix typo in comment.

Obtained-from:   FreeBSD 222178

3 years agosh: Fix bss-based buffer overflow in . builtin.
Peter Avalos [Sun, 21 Aug 2011 19:27:39 +0000 (12:27 -0700)]
sh: Fix bss-based buffer overflow in . builtin.

If the length of a directory in PATH together with the given filename
exceeded FILENAME_MAX (which may happen even for pathnames that work), a
static buffer was overflown.

The static buffer is unnecessary, we can use the stalloc() stack.

Obtained-from:     FreeBSD 222173

3 years agosh: Expand aliases after assignments and redirections.
Peter Avalos [Sun, 21 Aug 2011 19:23:11 +0000 (12:23 -0700)]
sh: Expand aliases after assignments and redirections.

Obtained-from:     FreeBSD 222165

3 years agosh: Implement the cd -e flag proposed for the next POSIX issue.
Peter Avalos [Tue, 5 Jul 2011 03:40:08 +0000 (17:40 -1000)]
sh: Implement the cd -e flag proposed for the next POSIX issue.

This reflects failure to determine the pathname of the new directory in
the exit status (1). Normally, cd returns successfully if it did
chdir() and the call was successful.

In POSIX, -e only has meaning with -P; because our -L is not entirely
compliant and may fall back to -P mode, -e has some effect with -L as
well.

Obtained-from:   FreeBSD SVN rev 222154

3 years agosh: Allow terminating a heredoc with a terminator at EOF w/o newline.
Peter Avalos [Tue, 5 Jul 2011 03:35:34 +0000 (17:35 -1000)]
sh: Allow terminating a heredoc with a terminator at EOF w/o newline.

Obtained-from:   FreeBSD SVN rev 222134

3 years agosh: Minor optimization to output from ulimit/export/readonly.
Peter Avalos [Tue, 5 Jul 2011 03:32:26 +0000 (17:32 -1000)]
sh: Minor optimization to output from ulimit/export/readonly.

Obtained-from:   FreeBSD SVN rev 221975

3 years agosh: Avoid close(-1) when evaluating a multi-command pipeline.
Peter Avalos [Tue, 5 Jul 2011 03:30:11 +0000 (17:30 -1000)]
sh: Avoid close(-1) when evaluating a multi-command pipeline.

Obtained-from:   FreeBSD SVN rev 221970

3 years agosh: Add \u/\U support (in $'...') for UTF-8.
Peter Avalos [Sun, 3 Jul 2011 07:44:12 +0000 (21:44 -1000)]
sh: Add \u/\U support (in $'...') for UTF-8.

Note that \u/\U are processed using the locale that was active when the
shell started. This is necessary to avoid behaviour that depends on the
parse/execute split (for example when placing braces around an entire
script). Therefore, UTF-8 encoding is implemented manually.

Obtained-from:   FreeBSD SVN rev 221669

3 years agosh: Fix typos in comments.
Peter Avalos [Sun, 3 Jul 2011 07:31:51 +0000 (21:31 -1000)]
sh:  Fix typos in comments.

3 years agosh: Optimize variable code by storing the length of the name.
Peter Avalos [Sun, 3 Jul 2011 07:29:43 +0000 (21:29 -1000)]
sh: Optimize variable code by storing the length of the name.

Obtained-from:   FreeBSD SVN rev 221668

3 years agosh(1): Update BUGS section for UTF-8 support.
Peter Avalos [Sun, 3 Jul 2011 07:11:50 +0000 (21:11 -1000)]
sh(1): Update BUGS section for UTF-8 support.

Obtained-from:   FreeBSD SVN rev 221660

3 years agosh: Add UTF-8 support to pattern matching.
Peter Avalos [Sun, 21 Aug 2011 20:48:41 +0000 (13:48 -0700)]
sh: Add UTF-8 support to pattern matching.

?, [...] patterns match codepoints instead of bytes. They do not match
invalid sequences. [...] patterns must not contain invalid sequences
otherwise they will not match anything. This is so that ${var#?} removes
the first codepoint, not the first byte, without putting UTF-8 knowledge
into the ${var#pattern} code. However, * continues to match any string
and an invalid sequence matches an identical invalid sequence. (This
differs from fnmatch(3).)

Obtained-from:   FreeBSD SVN rev 221646 & 223010

3 years agosh: Add UTF-8 support to ${#var}.
Peter Avalos [Sun, 3 Jul 2011 02:31:33 +0000 (16:31 -1000)]
sh: Add UTF-8 support to ${#var}.

If the current locale uses UTF-8, ${#var} counts codepoints (more
precisely, bytes b with (b & 0xc0) != 0x80).

Obtained-from:   FreeBSD SVN rev 221602

3 years agosh: Track if the current locale's charset is UTF-8 or not.
Peter Avalos [Sun, 3 Jul 2011 02:28:16 +0000 (16:28 -1000)]
sh: Track if the current locale's charset is UTF-8 or not.

Obtained-from:   FreeBSD SVN rev 221559

3 years agosh: Change the CTL* bytes to ones invalid in UTF-8.
Peter Avalos [Sun, 3 Jul 2011 02:15:36 +0000 (16:15 -1000)]
sh: Change the CTL* bytes to ones invalid in UTF-8.

This ensures that mbrtowc(3) can be used directly once it has been
verified that there is no CTL* byte. Dealing with a CTLESC byte
within a multibyte character would be complicated.

Obtained-from:   FreeBSD SVN rev 221551

3 years agosh: Add $'quoting' (C-style escape sequences).
Peter Avalos [Sun, 3 Jul 2011 00:29:49 +0000 (14:29 -1000)]
sh: Add $'quoting' (C-style escape sequences).

A string between $' and ' may contain backslash escape sequences similar
to the ones in a C string constant (except that a single-quote must be
escaped and a double-quote need not be). Details are in the sh(1) man
page.

This construct is useful to include unprintable characters, tabs and
newlines in strings; while this can be done with a command substitution
containing a printf command, that needs ugly workarounds if the result
is to end with a newline as command substitution removes all trailing
newlines.

The construct may also be useful in future to describe unprintable
characters without needing to write those characters themselves in 'set
-x', 'export -p' and the like.

The implementation attempts to comply to the proposal for the next issue
of the POSIX specification. Because this construct is not in
POSIX.1-2008, using it in scripts intended to be portable is unwise.

Matching the minimal locale support in the rest of sh, the \u and \U
sequences are currently not useful.

Obtained-from:   FreeBSD SVN rev 221513

3 years agosh: Apply set -u to variables in arithmetic.
Peter Avalos [Sun, 3 Jul 2011 00:07:08 +0000 (14:07 -1000)]
sh: Apply set -u to variables in arithmetic.

Note that this only applies to variables that are actually used.
Things like (0 && unsetvar) do not cause an error.

Obtained-from:   FreeBSD SVN rev 221463

3 years agosh: Detect an error for ${#var<GARBAGE>}.
Peter Avalos [Sun, 3 Jul 2011 00:03:42 +0000 (14:03 -1000)]
sh: Detect an error for ${#var<GARBAGE>}.

In particular, this makes things like ${#foo[0]} and ${#foo[@]} errors
rather than silent equivalents of ${#foo}.

Obtained-from:   FreeBSD SVN rev 221461

3 years agosh: Set $? to 0 for background commands.
Peter Avalos [Sat, 2 Jul 2011 23:59:09 +0000 (13:59 -1000)]
sh: Set $? to 0 for background commands.

For backgrounded pipelines and subshells, the previous value of $? was
being preserved, which is incorrect.

For backgrounded simple commands containing a command substitution, the
status of the last command substitution was returned instead of 0.

If fork() fails, this is an error.

Obtained-from:   FreeBSD SVN rev 221027

3 years agosh: Remove duplicate code resetting uid/gid for set +p/+o privileged.
Peter Avalos [Sat, 2 Jul 2011 23:47:49 +0000 (13:47 -1000)]
sh: Remove duplicate code resetting uid/gid for set +p/+o privileged.

sh: Check setuid()/setgid() return values.

If the -p option is turned off, privileges from a setuid or setgid
binary are dropped. Make sure to check if this succeeds. If it
fails, this is an error which will cause the shell to abort except
in interactive mode or if 'command' was used to make 'set' or an
outer 'eval' or '.' non-special.

Obtained-from:   FreeBSD SVN rev 221011 & 221012

3 years agosh: Allow EV_EXIT through function calls.
Peter Avalos [Sat, 2 Jul 2011 23:38:15 +0000 (13:38 -1000)]
sh: Allow EV_EXIT through function calls.

make {...} <redir more consistent.

If EV_EXIT causes an exit, use the exception mechanism to unwind
redirections and local variables. This way, if the final command is a
redirected command, an EXIT trap now executes without the redirections.

Because of these changes, EV_EXIT can now be inherited by the body of a
function, so do so. This means that a function no longer prevents a fork
before an exec being skipped, such as in
  f() { head -1 /etc/passwd; }; echo $(f)

Wrapping a single builtin in a function may still cause an otherwise
unnecessary fork with command substitution, however.

An exit command or -e failure still invokes the EXIT trap with the
original redirections and local variables in place.

Note: this depends on SHELLPROC being gone. A SHELLPROC depended on
keeping the redirections and local variables and only cleaning up the
state to restore them.

Obtained-from:   FreeBSD SVN rev 220978

3 years agosh: Do not word split "${#parameter}".
Peter Avalos [Sat, 2 Jul 2011 23:28:01 +0000 (13:28 -1000)]
sh: Do not word split "${#parameter}".

This is only a problem if IFS contains digits, which is unusual but
valid.

Obtained-from:   FreeBSD SVN rev 221522

3 years agohptiop(4): Sync with FreeBSD (adds IDs for two more cards).
Sascha Wildner [Sun, 21 Aug 2011 17:45:09 +0000 (19:45 +0200)]
hptiop(4): Sync with FreeBSD (adds IDs for two more cards).

3 years agointr/i386: Define IDT_HWI_VECTORS
Sepherosa Ziehau [Sun, 21 Aug 2011 13:02:48 +0000 (21:02 +0800)]
intr/i386: Define IDT_HWI_VECTORS

This macro defines how many IDT vectors that could be setup as hardware
interrupts.  Use this macro instead of MAX_HARDINTS and APIC_INTMAPSIZE.

3 years agoicu/i386: Remove unnecessary header inclusion
Sepherosa Ziehau [Sun, 21 Aug 2011 11:33:54 +0000 (19:33 +0800)]
icu/i386: Remove unnecessary header inclusion

3 years agoadd more information to a failing assertion's panic message
Adam Hoka [Thu, 11 Aug 2011 16:52:59 +0000 (18:52 +0200)]
add more information to a failing assertion's panic message

Signed-off-by: Venkatesh Srinivas <me@endeavour.zapto.org>
3 years agokernel - Fix vm_object leak which could exhaust swap space
Matthew Dillon [Sat, 20 Aug 2011 20:38:42 +0000 (13:38 -0700)]
kernel - Fix vm_object leak which could exhaust swap space

* Fix a recently introduced vm_object leak.  When deallocating a vm_object
  ref_count must be decremented prior to calling vm_object_collapse() or
  we can wind up leaving an object sitting around with 0 refs on it.

Reported-by: ftigeot, others
3 years agotcp: Enable tcp_lport_extension by default
Sepherosa Ziehau [Fri, 19 Aug 2011 02:42:17 +0000 (10:42 +0800)]
tcp: Enable tcp_lport_extension by default

3 years agoinpcb: Don't choose lport which could render same addr/port pair
Sepherosa Ziehau [Fri, 19 Aug 2011 02:05:47 +0000 (10:05 +0800)]
inpcb: Don't choose lport which could render same addr/port pair

A TCP connect to 127.0.0.1:PORT_A could be successful even if there is
no process listening on PORT_A:
127.0.0.1:PORT_A <---> 127.0.0.1:PORT_A

The problem here is that PORT_A is chosen as the lport for the socket
to be connected to PORT_A, and this actually creates simultaneous connect
on 127.0.0.1 but with only one inpcb.  Socket connected in this way is
useless and could break connect retry for the service listens on the
loopback interface.  Therefore, we skip the lport if the result will be:
(lport == fport && laddr == faddr)

NOTE: This still does not guard against explicit local port and address
chosen using bind(2) and then calling connect(2)

3 years agobrgphy: Recognize more Broadcom PHYs
Sepherosa Ziehau [Thu, 18 Aug 2011 13:44:03 +0000 (21:44 +0800)]
brgphy: Recognize more Broadcom PHYs

Obtained-from: OpenBSD, FreeBSD

3 years agomiidevs.h: regen
Sepherosa Ziehau [Thu, 18 Aug 2011 13:43:37 +0000 (21:43 +0800)]
miidevs.h: regen

3 years agomiidevs: Add more Broadcom PHY IDs
Sepherosa Ziehau [Thu, 18 Aug 2011 13:42:55 +0000 (21:42 +0800)]
miidevs: Add more Broadcom PHY IDs

Obtained-from: OpenBSD, FreeBSD

3 years agokernel: Fix alignment problem for sendmsg ancillary message data.
Venkatesh Srinivas [Wed, 17 Aug 2011 17:22:56 +0000 (10:22 -0700)]
kernel: Fix alignment problem for sendmsg ancillary message data.

Closes bug 2116; sending file descriptors is broken on amd64.

From: Darwin xnu-123.5, NetBSD socket.h 1.50

3 years agoinstaller: Tone down the comments around the installer's rc.conf settings.
Sascha Wildner [Tue, 16 Aug 2011 15:57:32 +0000 (17:57 +0200)]
installer: Tone down the comments around the installer's rc.conf settings.

dumpdev is the only thing that is written by default and it tended to
get lost among the rather verbose comments.

3 years agoLINT/LINT64: Add KTR_TSLEEP.
Sascha Wildner [Tue, 16 Aug 2011 14:18:44 +0000 (16:18 +0200)]
LINT/LINT64: Add KTR_TSLEEP.

3 years agobrgphy: Bring in changes from OpenBSD
Sepherosa Ziehau [Tue, 16 Aug 2011 09:45:30 +0000 (17:45 +0800)]
brgphy: Bring in changes from OpenBSD

- Link status is now detected using BMSR
- Extra link status detection based on AUXSTS is used for 5906
- Shuffle 5906 EPHY setting around
- brgphy_loop() is not necessary to start auto-negotiation

3 years agoFix crossbuilding x86_64 on i386.
Sascha Wildner [Tue, 16 Aug 2011 07:40:02 +0000 (09:40 +0200)]
Fix crossbuilding x86_64 on i386.

Brings back two things from cdefb602 and a262c465.

3 years agomsk(4): Add support for Yukon Supreme
Sepherosa Ziehau [Mon, 15 Aug 2011 11:31:06 +0000 (19:31 +0800)]
msk(4): Add support for Yukon Supreme

Obtained-from: FreeBSD 222230

3 years agomsk(4): Disable ASF on the chips that have it
Sepherosa Ziehau [Mon, 15 Aug 2011 11:23:14 +0000 (19:23 +0800)]
msk(4): Disable ASF on the chips that have it

Obtained-from: FreeBSD 222227

3 years agomsk(4): Make sure to enable all clocks before accessing registers.
Sepherosa Ziehau [Mon, 15 Aug 2011 11:17:49 +0000 (19:17 +0800)]
msk(4): Make sure to enable all clocks before accessing registers.

Obtained-from: FreeBSD 222226