Commit Graph

3196 Commits

Author SHA1 Message Date
Thomas Quinot
cd1832fe92 Reorganize the handling all-zeroes terminal block in sparse mode
The intent of the previous code in that case was to force
an explicit write, but the implementation was incorrect, and
as a result the write was never performed. This new implementation
instead uses ftruncate(2) to extend the file with a trailing hole.

Also introduce regression tests for these cases.

PR: 189284
(original PR whose fix introduced this bug)

PR: 207092

Differential Revision:	D5248
Reviewed by:	sobomax,kib
MFC after:	2 weeks
2016-02-18 08:44:16 +00:00
Bryan Drewery
d3157f0915 Test directories can build in parallel fine.
Sponsored by:	EMC / Isilon Storage Division
2016-02-16 02:13:59 +00:00
Konstantin Belousov
db57c70a5b Rename P_KTHREAD struct proc p_flag to P_KPROC.
I left as is an apparent bug in ntoskrnl_var.h:AT_PASSIVE_LEVEL()
definition.

Suggested by:	jhb
Sponsored by:	The FreeBSD Foundation
2016-02-09 16:30:16 +00:00
Edward Tomasz Napierala
c075c8bb77 Improve comment to reflect recent changes.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-02-09 09:38:05 +00:00
Edward Tomasz Napierala
f30414423a Use a proper type for return value of postfix_to_mult(); the way it's
being used wouldn't work if the value returned didn't fit in intmax_t.

Submitted by:	bde@
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-02-09 09:37:04 +00:00
Edward Tomasz Napierala
d819236121 Use proper functions for parsing the numeric values.
Submitted by:	bde@
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-02-09 09:32:10 +00:00
Edward Tomasz Napierala
e53d0abf73 Add 't' and 'p' postfixes to dd(1).
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-02-04 15:21:01 +00:00
Edward Tomasz Napierala
66d082c84b Reduce code duplication.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-02-04 15:10:08 +00:00
Bryan Drewery
f408f6043a Don't link /usr/share/nls/de_DE.UTF-8/tcsh.cat to itself.
Sponsored by:	EMC / Isilon Storage Division
2016-02-03 23:37:24 +00:00
Hajimu UMEMOTO
e4b59b10f8 The charset of NLS catalogs were converted to UTF-8
since r231990.
2016-02-03 11:44:43 +00:00
Hajimu UMEMOTO
46c57c6794 Make dynamic link of libiconv from ports work again.
The symbols of libiconv from ports were changed to
have prefixed.
Since we have iconv in our libc these days, we don't
need it on 10.X and later.  However, 9.X still need
this.

Spotted by:	Yoshihiko Sarumaru
MFC after:	1 days
2016-02-02 11:51:18 +00:00
Jilles Tjoelker
bd9b38d1f7 sh: Don't allocate a redirtab if there are no redirections.
Builtins (including variable assignments without command word), function
calls and redirected compound commands need to restore file descriptors
to their original state after execution. This is handled by allocating a
redirtab structure. These mallocs and frees show up heavily in pmcstat.

Only allocate a redirtab if there are actually redirections and maintain a
count of how many levels of REDIR_PUSH there are without redirtabs.

A simple loop without external programs like

sh -c 'i=0; w=$(printf %0100d 7); while [ "$i" -lt 1000000 ]; do
    i=$((i+1)); done'

is over 25% faster on an amd64 bhyve VM.
2016-01-30 21:21:25 +00:00
Jilles Tjoelker
7b6779b66b sh(1): Document 'cd -'.
This reflects the changes in r294649 and can therefore not be MFCed by
itself.
2016-01-30 20:10:20 +00:00
Jilles Tjoelker
f1602fa511 test: Optimize operator lookup.
The linear search using strcmp() shows up in pmcstat for several percent.

Split the operators into lengths and whether they start with '-' and compare
bytes using == instead of strcmp().

A simple test

sh -c 'i=0; w=$(printf %0100d 7); while [ "$i" -lt 1000000 ]; do
    v=$(printf %sx%s "$w" "$w"); i=$((i+1)); done'

is over 4% faster on an amd64 bhyve VM.
2016-01-30 19:59:58 +00:00
Jilles Tjoelker
52d5897d50 sh: Constify internal representation in expand.c.
Forbid (temporary or permanent) modifications of the strings in NARG nodes
during expansion.

Tilde expansion now needs to copy the username for the terminating '\0'.
2016-01-24 22:26:25 +00:00
Jilles Tjoelker
d5119a2a9a sh: Remove a global variable from cd.c. 2016-01-24 17:01:34 +00:00
Jilles Tjoelker
7b40c6df95 sh: Use OLDPWD shell variable for 'cd -'.
Per POSIX, 'cd -' should use the OLDPWD shell variable, not internal state.
This variable is normally exported.

Also, if OLDPWD is not set, fail 'cd -' instead of changing to the current
directory.
2016-01-23 23:00:38 +00:00
Edward Tomasz Napierala
fe819ced32 Don't mention the "canonical six" in setfacl(1); it describes semantics
that's long gone.

MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-01-23 12:19:37 +00:00
Jilles Tjoelker
a9bdd616f9 sh: Clean a readonly local, even if the variable does not exist outside.
If a local variable has been made read-only, this should not prevent its
removal when the function returns.
2016-01-22 20:10:08 +00:00
Jilles Tjoelker
cce13d6539 sh: Add already working test for local-readonly interaction. 2016-01-22 18:10:36 +00:00
Jilles Tjoelker
6b8e48f45e sh: Simplify some code related to positional parameters. 2016-01-19 22:41:26 +00:00
Jilles Tjoelker
cf45f1240d sh: Update associated state when restoring locals while leaving a function.
Some variables like PATH call a function when modified. Make sure to call
this also when leaving a function where such a variable was made local.

Make sure to restore local variables before shellparam, so getopts state is
not clobbered.
2016-01-10 16:31:28 +00:00
Jilles Tjoelker
3da40d4a6b sh: Reduce size of options table. 2016-01-07 23:13:20 +00:00
Jilles Tjoelker
0e50eefbd5 sh: Add a test for 'cd -'.
Redirect 'cd -' output to /dev/null since POSIX requires it to write the new
directory name even if not interactive, but we currently only write it if
interactive.
2016-01-07 21:46:07 +00:00
Jilles Tjoelker
adba77a62e sh: Ensure OPTIND=1 in subshell without forking does not affect outer env.
Command substitutions containing a single simple command and here-document
expansion are performed in a subshell environment, but may not fork. Any
modified state of the shell environment should be restored afterward.

The state that OPTIND=1 had been done was not saved and restored here.

Note that the other parts of shellparam need not be saved and restored,
since they are not modified in these situations (a fork is done before such
modifications).
2016-01-07 20:48:24 +00:00
Jilles Tjoelker
ac4ecc78c1 sh: Link tests/builtins/getopts9.0 to the build.
This was forgotten in r273700.
2016-01-03 22:16:27 +00:00
Jilles Tjoelker
d3fa2c78f2 sh: Reduce size of builtins table. 2016-01-03 21:30:22 +00:00
Jilles Tjoelker
bc57b4d469 sh: Remove redundant CTLQUOTEMARK checks.
With the new expand.c code, the intermediate representation passed to the
pathname generation code only contains CTLESC, not CTLQUOTEMARK.

CTLQUOTEMARK now only occurs in the text of NARG nodes (output of the
parser).
2015-12-31 20:15:57 +00:00
Jilles Tjoelker
ee97d8648c sh: Reindent expandmeta(). 2015-12-31 18:56:11 +00:00
Jilles Tjoelker
0e39c931e2 sh: Perform pathname generation during the first expansion phases.
This avoids the need to add and remove CTLESC bytes if pathname generation
will not be performed (set -f).

Side effect: the order of operations is slightly different: pathname
generation in ${$+* $(CMD)} will not see filesystem changes from CMD.
2015-12-31 18:47:54 +00:00
Jilles Tjoelker
47d8814c7f sh: Perform IFS splitting during the first expansion phases.
This simplifies the code and should be faster in some cases.

Side effect: the order of operations is different so that the value of IFS
used when IFS is modified during expansion (${IFS:=...}, ${IFS=...} or
$((...IFS=...))) may be different. Note that this order is highly unportable
between shells.
2015-12-31 17:51:15 +00:00
Jilles Tjoelker
4f2f5faa62 sh: Split subevalvar() in #/##/%/%% and =/? parts. 2015-12-29 20:51:29 +00:00
Pedro F. Giffuni
1e00885aec pax: prevent possible buffer overflow
Or at least quiet down some static analyzers about it.

CID:	978835
MFC after:	1 week
Obtained from:	OpenBSD
2015-12-29 16:31:28 +00:00
Jilles Tjoelker
cf1330bef9 sh: Add tests for #/##/%/%% on $* and $@.
Although POSIX leaves things like ${*#X} unspecified, it occasionally occurs
in practice. Add some tests that seem to work sensibly.
2015-12-26 22:27:48 +00:00
Jilles Tjoelker
cc684f839e sh/mknodes: Close files and check for errors when writing.
This is a build tool only and does not affect run time.

PR:		204951
MFC after:	1 week
2015-12-20 16:40:36 +00:00
Pedro F. Giffuni
6e8ef9cbb0 ed(1): Prevent possible string overflows
Use strlcpy instead of strncpy to guarantee NULL termination.

Pointed out by:	imp
CID:		1007252
X-MFC with:	r292454
2015-12-18 23:05:36 +00:00
Pedro F. Giffuni
bebd99b272 ed(1): Prevent possible string overflows
CID:		1007252
MFC after:	2 weeks
2015-12-18 21:58:42 +00:00
Jilles Tjoelker
d41b2be159 sh: Fix use-after-free when attempting to modify a read-only variable.
Reported by:	bapt
MFC after:	1 week
2015-12-16 20:33:47 +00:00
Baptiste Daroussin
be90c1c6b5 Fix ls -l alignement with new locales
Latest update of locales introduced abbreviated month that follows the regionale
rules meaning that they can be of variable length instead of being arbitrary
truncated to top 3 characters.

To fix alignement, ls now computes the visible length of the abbreviated month,
pads the shorter month with spaces in order to make sure everything is properly
aligned

Reviewed by:	ache, ed, jilles
Differential Revision:	https://reviews.freebsd.org/D4239
2015-12-07 20:48:28 +00:00
Bryan Drewery
4d293dd8dc Add missing CLEANFILES.
MFC after:	1 week
Sponsored by:	EMC / Isilon Storage Division
2015-12-07 16:08:13 +00:00
Enji Cooper
7b0d44bcba Enable bin/ls testcases disabled previously because of issues with how
kyua 0.11's version of report-junit was rendering non-printable characters

Upgrade to kyua 0.12 to obtain a fixed version of the command

Output verified with python 2.7.10's xml.dom.minidom module

MFC after: 3 days
Sponsored by: EMC / Isilon Storage Division
2015-12-07 04:03:01 +00:00
Jilles Tjoelker
d253cfe3b2 sh: Add limited test for ${#@} and ${#*}.
POSIX leaves the result of expanding ${#@} and ${#*} unspecified, but ensure
it is numeric.
2015-12-06 14:09:31 +00:00
Jilles Tjoelker
fb6fa0a785 sh: Link tests/parameters/positional8.0 to the build.
This was forgotten in r291025.
2015-12-05 12:55:34 +00:00
Craig Rodrigues
5ef011150c Fix spelling, as recommended by igor tool. 2015-12-01 19:20:38 +00:00
Craig Rodrigues
06691045ba Add more text to explain --libxo flag. 2015-12-01 19:18:53 +00:00
Bryan Drewery
cf990407e1 Update dependencies after r291406 added libelf to libkvm.
Unfortunately filemon/meta mode tracks all indirect dependencies here
since ld(1) is reading libelf when linking in libkvm.  Churn would be
reduced if this was able to be limited to direct dependencies.

Sponsored by:	EMC / Isilon Storage Division
2015-12-01 05:18:48 +00:00
Bryan Drewery
b791fbe630 META MODE: Don't create .meta files when symlinking sources into the obj directory.
Tracking these leads to situations where meta mode will consider the
file to be out of date if /bin/sh or /bin/ln are newer than the source
file.  There's no reason for meta mode to do this as make is already
handling the rebuild dependency fine.

Sponsored by:	EMC / Isilon Storage Division
2015-11-25 19:44:43 +00:00
Jilles Tjoelker
a83f6e1ad9 sh: Remove global state from nodes.c.
No functional change is intended.
2015-11-24 22:47:19 +00:00
Bryan Drewery
6a270e17f3 Remove unneeded libutil dependency for sendmail.
It included libutil.h for setproctitle(3), which was moved from libutil to libc
in r65353 in 2000.

Reviewed by:	gshapiro [sendmail change]
Sponsored by:	EMC / Isilon Storage Division
Differential Revision:	https://reviews.freebsd.org/D4261
2015-11-24 04:19:55 +00:00
Jilles Tjoelker
a5cb58abc8 sh: Fix ""$@, which should not use the special case for "$@".
"$@" should expand to no words if there are no positional parameters, but
""$@ should always expand to at least an empty word.
2015-11-18 21:09:03 +00:00