process id, instead of using pid==0. Ie, `ps -p 12,' and `ps -p ,12'
are now errors (instead of being treated like `ps -p 0 -p 12').
Noticed by: Cyrille Lefevre on freebsd-arch
is treated like `ps -t p0', instead of changing it to `ps -T p0'.
Note that `ps t' is still changed to `ps -T', since that is one of
the main reasons for this kludge processing...
Noticed by: Jilles Tjoelker on freebsd-arch
more special situations. This is the code which process `ps blah',
when "blah" does not include a leading '-'.
This change also removes a long-undocumented BACKWARD_COMPATIBILITY
compile-time option, where:
ps -options arg1 arg2
(with no '-' on "arg1" and "arg2") was treated as:
ps -options -N arg1 -M arg2
This also changes `ps' to check for any additional arguments after
processing all the '-'-options, and attempt to use those arguments as
a pid or pidlist. If an extra argument is not a valid pidlist, then
`ps' will print an error and exit. This seems a more generally useful
extension of the kludge-option processing than the -N/-M behavior, and
has fewer confusing side-effects.
Reviewed by: freebsd-arch
(if trying to match only one real-group or one session-id), now that
those options are implemented in src/sys/kern/kern_proc.c (v1.203).
PR: bin/65803 (a very tiny piece of the PR)
Submitted by: Cyrille Lefevre
LC_CTYPE setting) when determining which characters are printable.
This is an often-requested feature.
Use wcwidth() to determine the number of column positions a character
takes up, although there are still a few places left where we assume
1 byte = 1 column position, e.g. line-wrapping when handling the -m option.
The error handling here is somewhat more complicated than usual: we do
our best to show what we can of a filename in the presence of conversion
errors, instead of simply aborting.
- Print a diagnostic if kdumpenv() fails. This can occur due to MAC
restrictions or lack of memory. Catch all kenv(2) failures as well.
- Just of the heck of it, DTRT if the kernel environment size changes
at the wrong time. The old code could fail silently or fail to
null-terminate a buffer if you got exceptionally unlucky.
- Sort and GC the #includes.
decoration. Further improvements are welcome, but at least this
is a separate of the various modes of operation date has, as well as
sectioning off the two deprecated options for settimeofday(tz) that
don't even apply to actual operation of date as such, anyway.
will print them (i.e., number of successful calls to acl_get_entry()
exceeds 3). This makes O(1) what was O(num_TYPE_ACCESS_ACLs).
This is a slightly modified version of submitter's patch.
PR: bin/65042
Submitted by: Christian S.J. Peron <maneo@bsdpro.com>
This corrects a problem of lost-precision for `-r' (sort-by-CPU). Also,
for sort-by-CPU and sort-by-memory, any processes which have the same
value CPU or MEMORY are now sorted by TTY and then (if needed) by pid.
(* - I just added the NODEV checks, after doing some testing of my own)
Submitted by: bde
MFC after: 1 week
(if any) and exit, thus matching the behavior on -stable and other OS's.
My earlier attempt to fix this (v1.65) only seemed to work because of a
lucky random value in nentries (which was not being initialized back
when I tested that earlier patch).
is compiled with LAZY_PS, so that there is only one PS_ARGS string to
modify when changing the option-list. Also get `-f' to show up in the
usage() statement when compiled with LAZY_PS.
- Change `-p' to allow a list of process IDs, and `-t' to allow a list
of terminal names, instead of only a single value for each.
- Add the `-A' option of SUSv3, which is exactly the same as `-ax'.
- Add the `-G gidlist' (group id).
- Allow any of these "selector options" to be specified multiple times,
and have `ps' keep adding to a given list -- instead of replacing the
previously-specified values.
- Fix interactions between selector-options, so that: "If any are
specified, ... ps shall select the processes represented by the
inclusive OR of all the selection-criteria options." (from SUSv3)
- Add a `-X' option, which is the reverse of the `-x' option.
- various minor improvements in parsing and error handling.
This does not get us to match POSIX/SUSv3, but it gets us closer. The
`-g pgidlist', `-R ruserlist' and `-s sidlist' options mentioned in
freebsd-standards are still under debate, so they skipped for now.
It should be true that this introduces no user-visible incompatible
changes, except to support "new stuff" that was not supported before.
sysctl(3) interface in kvm(3).
- Document the correct default when no -N is specified.
- Remove stale reference to /var/db/kvm_kernel.db.
- Remove stale reference to /var/run/dev.db.
just print the header (if any) and exit, thus matching the behavior on -stable
and other OS's.
Also adds support for <x> being a comma-separated list of processes, and does
a much better checking for invalid-values of <x>, such as 'ps -p someword'.
Reviewed by: mentioned on freebsd-current
MFC after: 10 days
using -m and -g switches and "available space" is negative (i.e. when
the file system is already using the root-reserved minimum free space).
Obtained from: Stefan Farfeleder <stefan@fafoe.narf.at>
PR: bin/62536
Submitted by: Peter van Dijk <peter@dataloss.nl>
Approved by: grog (mentor), bde
that this provokes. "Wherever possible" means "In the kernel OR NOT
C++" (implying C).
There are places where (void *) pointers are not valid, such as for
function pointers, but in the special case of (void *)0, agreement
settles on it being OK.
Most of the fixes were NULL where an integer zero was needed; many
of the fixes were NULL where ascii <nul> ('\0') was needed, and a
few were just "other".
Tested on: i386 sparc64
in the comment applies to a decision that needs to be made in relation
to the year 2000.
In fact, that statement probably should be changed to be
more generic (getting the year from the current time perhaps). Otherwise,
starting in 2069 two digit year conversions in date(1) will start assuming
1900 instead of 2000. hehe.
1. Sizes in the range 1000 -- 1023 units require four characters width
for the integer; increase the field width to accomodate this.
2. Sizes in the range 9.95 -- 10 units were being displayed as "10.0"
units; adjust the logic to fix this, and now that we've got an extra
character of field width, print fractional units if the size is less
than 99.95 units.
3. Don't display sub-byte precision.
This should mean that the following sizes are displayed:
0B .. 1023B
1.0U .. 9.9U
10.0U .. 99.9U
100U .. 1023U
for values of U in "KMGTPE".
PR: bin/63547
Pointy hat to: cperciva
Approved by: rwatson (mentor)
Only use return value from system call if system call succeeded.
Tested with `make world` and some of my own scripts.
This should be MFCed soon. While /bin/sh is hard to test the fix is
obviously correct and can be assumed not to break something else
(famous last words...).
Joe Marcus Clarke <marcus@FreeBSD.ORG>, subshells could lose a
non-zero exit status.
This commit is Joe's proposed patch. Thanks!
I verified that the problem Joe found is fixed and I ran a full world
with this patch.
I don't plan to ever commit language patches to /bin/sh again. It is
a minefield too big to navigate without a full-time committment, which
I am not willing to do on our /bin/sh.
Under normal circumstances I would recommend using NetBSD's sh which
has a lot of language fixes (like the ones what these patches were
about) but unfortunately they had implemented broken signal behaviour
for shellscript containing interactive programs. Similar issues apply
to pdksh which is OpenBSD's sh.
From my perspective bash2 is the only really working bourne sh out
there and that one is GPLed. Oh well.
from log[10](largest file size), but when outputting in human-friendly
format the width is always at most 4. (eg. "123K", " 12K", "1.2K".)
PR: bin/59320
Approved by: rwatson (mentor)
* Remove mention of '>', 'A', and 'S' states
* Mention 'W' state.
* List 'J' state in the correct location.
* Sync with flags in sys/proc.h
Approved by: rwatson (mentor)
MFC after: 7 days
should slightly reduce the number of system calls in critical portions of
the shell, and select a more efficient path through the fdalloc code.
Reviewed by: bde
- Unify the conditional assignments section so that architectural
exclusions come first, then options and !options, sorted by the
option name, also in directory order, then architecture specific
sections, sorted by the architecture name, with i386 being a
traditional exception.
Prodded by: bde
o When fts_read() cannot stat the file, it can't be unlinked. At
that case, don't display error message when -f flag is used.
Obtained from: bde
PR: kern/16815, bin/35842
Reported by: kuriyama, Aleksandr A. Babaylov <.@babolo.ru>
sh -e behaviour was incorrect when && and || statements where used in
"if" clauses.
This is the patch submitted by MORI Kouji <mori@tri.asanuma.co.jp>.
It fixes the issue at hand, but sh fixes like this are super-hard to
verify that they don't break anything else. I ran some of my old test
cases and a few big GNU configure scripts that detected mistakes
before, with the previous sh, patched sh and bash. No differences in
behaviour found. MFC recommended after longer than usual time.
Compiles on i386 and sledge.
to gcc have not been made for ia64, which means that executables still
have /usr/libexec/ld-elf.so.1 as the dynamic linker. This simply does
not work if /usr is a seperate filesystem not mounted when the kernel
tries to execute init(8).
Note that this is a temporary fix until a new gcc has been imported
that does have the required changes.
Approved: re@
dynamically linked. This has been a long time coming with the move of
critical libraries from /usr/lib to /lib. If you don't feel comfortable
with dynamically linked binaries in your root partition, now is the
time to define NO_DYNAMICROOT in your make.conf.
Approved by: re
accurate reporting of multi-terabyte filesystem sizes.
You should build and boot a new kernel BEFORE doing a `make world'
as the new kernel will know about binaries using the old statfs
structure, but an old kernel will not know about the new system
calls that support the new statfs structure. Running an old kernel
after a `make world' will cause programs such as `df' that do a
statfs system call to fail with a bad system call.
Reviewed by: Bruce Evans <bde@zeta.org.au>
Reviewed by: Tim Robbins <tjr@freebsd.org>
Reviewed by: Julian Elischer <julian@elischer.org>
Reviewed by: the hoards of <arch@freebsd.org>
Sponsored by: DARPA & NAI Labs.
do only unlink the file if we could indeed overwrite the file.
Old behaviour: rm -P /tmp/foo (foo mode 0444) would NOT overwrite foo,
but still delete it (with a warning: rm: foo: Permission denied)
New behaviour: Just the EPERM warning, but no deletion
Reviewed by: bde
rm_overwrite() (for rm -P).
2. Print the file name in the error message for (fatal) malloc() failures
in rm_overwrite(). I first thought that malloc() failures should be
non-fatal since they don't prevent proceeding the the next file, but
making them non-fatal would normally give too much output for rm -Pr
on a large tree in the unlikely event that even one occurs, since the
malloc()ed amounts are usually the same. Just print the file name since
the malloc()ed amounts are not always the same and it doesn't hurt to
know where rm was when it quit.
Submitted by: guido ((1) and original version of (2))
- Issue a single writev(2) call instead of multiple write(2)s.
This change improves the inefficiencies introduced when echo
went on an stdio diet.
The following figures are for echoing 1000 arguments.
original stdio-based echo:
0.01 real 0.01 user 0.00 sys
before:
0.05 real 0.00 user 0.04 sys
after:
0.01 real 0.00 user 0.00 sys
when grepping for JOBS. The recent style cleanup replaced the space with
a tab and broke job control detection. Little edits, disastrous consequences.
Submitted by: Peter Edwards <pmedwards@eircom.net>
X-MFC when: in about 5 weeks with the other sh arithmetic fixes.
WITH_DYNAMICROOT, which will toggle the generation of dynamically-linked
binaries for installation in /bin and /sbin. It is currently off,
meaning that /bin and /sbin are still statically linked by default.
If something goes wrong (which I hope doesn't), this is what /rescue is
all about. Please do not try to use WITH_DYNAMICROOT and NO_RESCUE to
save space or some other equally silly reason. If you do and end up
having problems, you have been warned.
tools such as chmod(1) and ls(1) when it comes to acting on objects
that have POSIX.1e extended ACLs. Specifically, discuss the
substitution of the mask entry for the group entry in the mode
representation of the ACL. Differently worded from the submission,
and could probably use further refinement.
PR: 55319
Submitted by: Grzegorz Czaplinski <G.Czaplinski@prioris.mini.pw.edu.pl>
- Removed dead declarations
- Made objects that should have been declared as static, static.
The changes use STATIC instead of static, following the existing
convention in the rest of the code.
Approved by: schweikh (mentor)
MFC after: 2 weeks
cat ${.ALLSRC} > ${.TARGET}
rather than
ln -sf ${.ALLSRC} ${.TARGET}
not to depends on absolute-path of symbolic links.
Commented by: marcel, obrien, bde
is a style bug at best. When the variable isn't a flag, it potentially
overflows after a large number of settings. Here the number of settings
is limited by ARG_MAX, but the variable is the exit code so it became
bogus after the second setting and effectively overflowed to 0 after
approx. 128 settings.
Fixed some style bugs involving comments in and near previous commit.
Clarification of previous commit message: df -t didn't give undefined
behaviour, and the behaviour used to conform perfectly with the man
page, since the buggy behaviour is documented in the BUGS section. -t
just worked when no files or file systems were specified, and was just
ignored if a file or file system was specified.
-t Only print out statistics for filesystems of the specified types.
Make the behavior of df(1) conform to its man page (behavior is otherwise
undefined).
Submitted by: Rob Braun <bbraun@apple.com>
Obtained from: Apple
output buffer, don't insert them at all. This prevents a buffer
*underrun* when the substitution consists completely of newlines
(e.g. `echo`) and the byte before the source buffer to which p
points is a '\n', in which case more characters would be removed
from the output buffer than were inserted.
This fixes certain port builds on sparc64.
Approved by: re (scottl)
Reviewed by: des, tjr
Due to the use of signed vs. unsigned chars on our various platforms, one gets
"warning: comparison is always true due to limited range of data type"
from GCC 3.3.
mutually exclusive. The fact that the most recent one specified on the
command line is the one that takes effect is an implementation detail and
users should not rely on this.
This option is present on most uuidgen(1) implementations even
though normal file redirection can be used to achieve the same.
Submitted by: Hiten Pandya <hiten@unixdaemons.com>
The initial stack_block is staticly allocated and will be aligned
according to the alignment requirements of pointers, which does not
necessarily match the alignment enforced by ALIGN. To solve this a
more involved change is required: remove the static initial stack
and deal with an initial condition of not having a stack at all. This
change is therefore more risky than the previous ones, but unavoidable
(other than not using the platform default alignment).
Discussed with: tjr
Approved and reviewed by: tjr
Tested on: alpha, i386, ia64 and sparc64
The problem with the previous attempt, as noticed by Marcel, was that
stacknxt was being aligned to a pointer boundary instead of an
ALIGNBYTES + 1 boundary, which broke sparc64.
using the alignment from sys/param.h (16) instead of the alignment
from machdep.h (8) tickled a nasty bug in the memory allocator that I
haven't been able to track down yet.
one that is already there. This is consistent with GNU ps(1)'s BSD mode, and
POLA.
Reported by: Andy Farkas <andyf@speednet.com.au>
Tested by: Andy Farkas <andyf@speednet.com.au>
similar to "-h" on chown, chmod, etc, causing the operation to occur
on a final symlink in the provided path, rather than its target.
Obtained from: TrustedBSD Project
determine whether a symlink has an ACL. Instead, assume that symbolic
links don't have ACLs and don't bother checking. Avoids spurious
ENOENT warnings when listing directories containing broken symlinks
on filesystems with ACLs enabled.
Pointed out by: rwatson, bde
do the wrong thing when the symlink doesn't have a target, by
considering !f_label in the construction of ch_options.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
is given as argument) that is not present in 4-Stable.
It was introduced when realpath(1) was split out of pwd(1).
The removed behavior is provided by pwd(1).
Reviewed by: mike
Revert to using the .Tn POSIX and .Tn ANSI instead of \*[Px] and \*[Ai]
strings; using these strings is unsafe in troff mode, as they include a
change in a font size.
Approved by: re
is reduced by 40k, dynamic by a few bytes.
Functional changes:
* "sleep -- arg" now returns usage() instead of ignoring the --
* "sleep -1" now returns immediately instead of returning usage()
Reviewed by: jmallett