Commit Graph

2311 Commits

Author SHA1 Message Date
Ralf S. Engelschall
ac08b88250 be more type correct and align local ckmalloc() with its underlying malloc(3) by using a "size_t" instead of an "int" argument 2009-06-01 10:50:17 +00:00
Jilles Tjoelker
fe40d6d3b1 sh: Make read's timeout (-t) apply to the entire line, not only the first
character.

This avoids using non-standard behaviour of the old (upto FreeBSD 7) TTY
layer: it reprocesses the input queue when switching to canonical mode. The
new TTY layer does not provide this functionality and so read -t worked
very poorly (first character is not echoed, cannot be backspaced but is
still read).

This also agrees with what most other shells with read -t do.

PR:		bin/129566
Reviewed by:	stefanf
Approved by:	ed (mentor)
2009-05-31 19:37:06 +00:00
Stefan Farfeleder
cb806389db Fix the eval command in combination with set -e. Before this change the shell
would always terminate if eval returned with a non-zero exit status regardless
if the status was actually tested.  Unfortunately a new file-scope variable
is needed, the alternative would only be to add a new parameter to all
built-ins.

PR:	134881
2009-05-31 12:36:14 +00:00
Jilles Tjoelker
6911f596a1 rm, find -delete: fix removing symlinks with uchg/uappnd set.
Formerly, this tried to clear the flags on the symlink's target
instead of the symlink itself.

As before, this only happens for root or for the unlink(1) variant of rm.

PR:		bin/111226 (part of)
Submitted by:	Martin Kammerhofer
Approved by:	ed (mentor)
MFC after:	3 weeks
2009-05-30 10:42:19 +00:00
Jilles Tjoelker
f2db75739c Preserve file flags on symlinks in cp -Rp.
This reported ENOSYS before.

PR:		bin/111226 (part of)
Submitted by:	Martin Kammerhofer
Approved by:	ed (mentor)
MFC after:	3 weeks
2009-05-30 10:36:14 +00:00
Jilles Tjoelker
00e8c94f25 Fix various cases with 3 or 4 parameters in test(1) to be POSIX compliant.
More precisely, this gives precedence to an interpretation not using the
'(', ')', '-a' and '-o' in their special meaning, if possible. For example,
it is now safe to write [ "$a" = "$b" ] and assume it compares the two
strings.

The man page already says that test(1) works this way, so does not need to
be changed.

Interpretation of input with more parameters tries a bit harder to find a
valid parse in some cases.

Add various additional test cases to TEST.sh.

PR:		standards/133369
Approved by:	ed (mentor)
2009-05-26 22:33:10 +00:00
Jilles Tjoelker
6dcfa92ee8 Fix elapsed (etime) field for swapped out processes in ps:
show '-' instead of time since the Epoch.

PR:		bin/123069
Submitted by:	Vladimir Kozbin
Approved by:	ed (mentor)
MFC after:	3 weeks
2009-05-24 15:32:34 +00:00
Jilles Tjoelker
a6412d5d4b Fix chflags -h in various cases: do not use link target's flags as original.
Patch slightly changed to align more with chmod.c.

PR:		bin/131999
Submitted by:	bde
Approved by:	ed (mentor)
MFC after:	3 weeks
2009-05-24 15:27:25 +00:00
Edward Tomasz Napierala
ae1add4e55 Make 'struct acl' larger, as required to support NFSv4 ACLs. Provide
compatibility interfaces in both kernel and libc.

Reviewed by:	rwatson
2009-05-22 15:56:43 +00:00
Brian Somers
8ba7efdad8 Remove redundant whitespace 2009-05-18 01:45:52 +00:00
Brian Somers
0a091aebde When finding processes, ignore ourself and our ancestors. It is almost
always surprising when you kill a 'sh -c ...' ancestor or when you kill
yourself when using -f.

Add a -a switch for backwards compatibility.

MFC after:	3 weeks
2009-05-17 04:34:14 +00:00
Brian Somers
044fce530f Add a -d option to ps to display descendant info with the output.
This is similar to linux's -H (or -f) switch.

MFC after:	3 weeks
2009-05-17 04:00:43 +00:00
Warner Losh
b5260db685 Implement ^T support for rm: now it will report the next file it
removes when you hit ^T.  This is similar to what's done for cp.  The
signal handler and type definitions for "info" were borrowed directly
from cp.
2009-04-29 18:08:18 +00:00
Stefan Farfeleder
515c60105d Parse 'cmd1 && ! cmd2 | cmd3' correctly, the bang should apply to the entire
pipeline cmd2 | cmd3 and not just cmd2.

PR:		130298
Submitted by:	Jilles Tjoelker
2009-04-13 19:10:56 +00:00
Edward Tomasz Napierala
3f772eca32 Add reference to strmode(3). 2009-04-13 15:29:14 +00:00
Stefan Farfeleder
8403b16a59 Don't let trailing empty lines overwrite the result of the last command with 0.
This affects the built-ins eval, fc, and trap and also the string passed to sh
with the -c option.

Submitted by:	Jilles Tjoelker
2009-04-04 19:06:52 +00:00
Stefan Farfeleder
86d8da5d5b Fix the behaviour of the read built-in when IFS is unset.
Obtained from:	NetBSD
2009-03-22 22:57:53 +00:00
Stefan Farfeleder
b6748ec20c Improve the IFS handling of the read built-in.
Obtained from:	NetBSD
Submitted by:	Jilles Tjoelker
2009-03-22 22:09:12 +00:00
Stefan Farfeleder
d4b1e37429 - Apply the r190270 changes to printing of single aliases too.
- Sort the aliases before printing them.
2009-03-22 21:09:22 +00:00
Stefan Farfeleder
0de913c328 Make the output of the alias built-in POSIX-compliant: Drop the leading 'alias'
and suppress printing the trailing space which is added for internal purposes.
2009-03-22 17:20:42 +00:00
Dag-Erling Smørgrav
ed53753dac cat(1) compiles fine at WARNS level 6. 2009-03-16 12:16:17 +00:00
Ed Schouten
ae46d95884 Don't disable CR-to-NL translation when waiting for data to arrive.
A difference between the old and the new TTY layer is that the new
implementation does not perform any post-processing before returning
data back to userspace when calling read().

sh(1)'s read turns the TTY into a raw mode before calling select(). This
means that the first character will not receive any ICRNL processing.
Inherit this flag from the original terminal attributes.

Even though this issue is not present on RELENG_*, I'm MFCing it to make
sh(1) in jails behave better.

PR:		bin/129566
MFC after:	2 weeks
2009-03-08 19:09:55 +00:00
Attilio Rao
4610a8114d [1] When showing threads, the thread name just appears if the comm
label is choosen as last printout (ucomm suffers of this such bug
	too).  That bug is caused by the fact that the fixed size of
	printout doesn't leave enough space for them to be printed out.
	Implement ucomm and comm commands with a dynamic size lenght for
	buffers.

[2]	On AMD64 architecture pointers don't have enough chars space to
	be shown (8 chars while they need 16).  Fix them by providing
	a variadic space so that it fits well on both 64 and 32 bits
	architectures.

[3]	Check a return value of malloc() that wasn't checked before.

PR:		bin/128841, bin/128842
Reviewed by:	jhb, emaste
Sponsored by:	Sandvine Incorporated
2009-02-26 18:01:07 +00:00
Tim Kientzle
db77c5b943 Before this fix, pax would stop the restore sequence for
symlinks after setting the owner.  As a result, mode
and timestamp were not restored.  This patch corrects the
problem by simply removing the short-circuit for symlinks
and using lchown()/lchmod()/lutimes() always for restoring
metadata.

PR:		bin/91316
Submitted by:	Jaakko Heinonen
Reviewed by:	Joerg Sonnenberger
MFC after:	14 days
2009-02-01 06:15:46 +00:00
Giorgos Keramidas
74f13fb3b6 Bump .Dd for r187609 2009-01-30 16:23:57 +00:00
Tom Rhodes
1b1785d44c Make the Monty Python quote more google friendly instead of
hacking it apart.

Discussed with:	Christoph Mallon <christoph.mallon@gmx.de>
2009-01-26 18:14:21 +00:00
Tom Rhodes
cb30dc5538 Note the implication of setting the 'w' permission on directories,
while here, expand the 'naughty bits' comment in BUGS.

PR:		84265 and 84268
Reviewed by:	keramida
Obtained from:	hints from ceri, keramida
2009-01-23 11:39:00 +00:00
Giorgos Keramidas
4dd47928b7 Add an example of using bs=2048 to duplicate data CD-ROMs.
This should be a bit useful for users who look at the manpage and
then try to copy data CD-ROM disks using dd.  A lot of us know
that bs=2048 is required, but it still manages to cause a bit of
grief to those who haven't heard about it.

PR:		bin/130857
Submitted by:	Tri Brotoharsono < mail at tribrotoharsono.net >
MFC after:	3 days
2009-01-23 03:46:44 +00:00
Maxim Konovalov
3ed338dde3 o Fix a typo. Bump .Dd for the previous delta. 2009-01-13 18:25:56 +00:00
Tom Rhodes
8b9e2a36cc Clean up a bit of confusing language and improve .Nd.
PR:		47818
Reviewed by:	keramida
2009-01-13 15:24:35 +00:00
Luigi Rizzo
7b300dd6e8 fix typo
Submitted by:	Colin Percival
2009-01-13 12:37:02 +00:00
Luigi Rizzo
f7fc4669a7 Document how kernel environment can be statically compiled in,
and reference a few related manpages.

MFC after:	3 days
2009-01-13 12:19:43 +00:00
Daniel Gerzo
8465a40443 - rename the RETURN VALUES section to EXIT STATUS
- not bumping a date as this is not a real content change

Approved by:	ru
MFC after:	3 days
2009-01-07 01:03:23 +00:00
Stefan Farfeleder
f7bbf3ffcf Report error messages of the builtins 'type' and 'command -V' to stderr instead
of stdout.

Noticed by:	Zajcev Evgeny
2008-11-28 18:55:42 +00:00
Stefan Farfeleder
94c53a0811 Fix $? at the first command of a function. The previous exit status was saved
twice and thus lost.
2008-11-23 20:23:57 +00:00
Pawel Jakub Dawidek
b56ca46588 Implement -T option as found in Linux df(1). When given, file system type
will be included in output.

Reviewed and tested by:		keramida
MFC after:	2 weeks
2008-11-23 13:03:44 +00:00
Ed Maste
160bda3652 Fix whitespace. 2008-11-13 15:06:34 +00:00
Joerg Wunsch
7f33c7dd6f When running a "chio return" operation using a physical source unit
rather than a voltag name, do not set the CESR_VOLTAGS flags in the
CHIOGSTATUS command requesting the current status.  As voltags are an
optional feature that must be handled as "reserved" by media changers
not implementing the feature, always setting CESR_VOLTAGS resulted in
the command being aborted with an `Invalid field in CDB', and
consequently the "chio return" failed, for media changers that do not
support voltags.

MFC after:	1 week
2008-10-30 19:51:02 +00:00
Ivan Voras
e9cbc9a770 Teach cat(1) and cp(1) to use a larger buffer if enough memory is present
in the system. A simple heuristics is used to detect what is "enough"
memory: if number of physmem pages is greater than 32k (equalling 128 MB
on machines with 4 kB pages).

Typical immediate result of these changes is reduction in context switches
and the goal is to increase efficiency by using large buffers:
before: /usr/bin/time -hlp cat file1 > file2
...
       163  voluntary context switches
     11194  involuntary context switches
after: /usr/bin/time -hlp ./cat file1 > file2
...
       417  voluntary context switches
       272  involuntary context switches

Reviewed by:    hackers@ (no objections to earlier version of cat patch)
Approved by:    gnn (mentor)
MFC after:      4 months
2008-10-30 14:05:57 +00:00
Roman Divacky
5c39c8cb65 Remove superfluous va_end which was left there in rev 1.38.
Approved by: kib (mentor)
2008-10-28 17:15:46 +00:00
Diomidis Spinellis
cce2092c73 Add fallback when mmap fails on regular files. Some filesystems,
like smbnetfs, do not support mmap.

Reported by:	Harti Brandt
MFC after:	1 month
2008-10-27 15:21:15 +00:00
Ed Schouten
18aa158f77 Improve the `pkill -t' handling, which I changed in my previous commit.
In my previous commit I disabled pkill(1)'s automatic prepending of the
"tty" string when `pkill -t' was being used. Re-enable it and stat()
both possible device names when called.

Requested by:	jhb, rwatson (MFC)
MFC after:	1 month
2008-09-30 17:30:39 +00:00
Ed Schouten
eb948eac0d Don't automatically prepend the "tty" prefix to `pkill -t' arguments.
Because we now enforce UNIX98-style PTY's, we now use a lot of TTY's
that don't have the traditional /dev/ttyXX naming scheme. pkill(1)'s -t
flag automatically prepended the word "tty" to each TTY that was passed
on the command line. This meant that `pkill -t pts/0' was actually
converted to /dev/ttypts/0. Disable this broken behaviour for now.

Reported by:	erwin
2008-09-28 16:44:15 +00:00
Edward Tomasz Napierala
70583fbb77 Remove redundant close(2).
Submitted by:	kensmith
Approved by:	rwatson (mentor)
2008-09-09 12:31:42 +00:00
Edward Tomasz Napierala
23f80af2ca Fix double free in setfacl(1). Description from the author:
Initially, 'acl' (an 'acl_t *') is allocated, and its ACCESS_ACL and
DEFAULT_ACL fields are passed to the 'libc' ACL routines for subsequent
allocation. If the '-m' option (merge existing ACL with a new one) is
specified, then 'set_acl_mask()' will be called and passed one of the
two ACLs. This function, in turn, replaces this given ACL structure by
another, freshly allocated. However, the pointer in the 'acl' variable
in the caller is not updated. The caller then proceeds to free the ACL,
incurring in a double free condition.

Submitted by:	Pedro Martelletto <pedro at ambientworks.net>
Approved by:	rwatson (mentor)
2008-09-06 13:17:35 +00:00
Yaroslav Tykhiy
21be3b3183 pkill(1) first appeared in /usr/bin, but later it was moved to /bin
for the convenience of rc.d.  Now it has happily lived there for quite
a while.  So move the pkill(1) source files from usr.bin to bin, too.

Approved by:	gad
2008-08-31 14:27:59 +00:00
Ed Schouten
331773cd07 Document the ulimit -p option in the sh(1) manual page.
When I imported the MPSAFE TTY code, I added the -p flag to sh(1)'s
ulimit, but I forgot to document it in the appropriate manual page.

Requested by:	stefanf
2008-08-30 22:35:21 +00:00
Stefan Farfeleder
9144fae127 Fix a bug in r177497 which caused the getopts state to be reset when 'set'
was used to set a shell option (and not to change the positional parameters).

Submitted by:	Martin Kammerhofer
2008-08-27 20:16:06 +00:00
Ed Schouten
f8f8c9f0d6 Make stty(1) use tab0 and tab3 to handle tab completion.
After the MPSAFE TTY import, we have support for the TAB0 and TAB3 flags
to handle tab expansion, while we only used to support OXTABS. Switch
stty(1) to use tab0 and tab3 to print whether tab expansion is turned on
or off. Implement the oxtabs and tabs switches by setting the
appropriate TABx value.

Even though POSIX only lists this as being XSI, we'd better follow it.
2008-08-23 13:28:55 +00:00
Ed Schouten
bc093719ca Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:

- Improved driver model:

  The old TTY layer has a driver model that is not abstract enough to
  make it friendly to use. A good example is the output path, where the
  device drivers directly access the output buffers. This means that an
  in-kernel PPP implementation must always convert network buffers into
  TTY buffers.

  If a PPP implementation would be built on top of the new TTY layer
  (still needs a hooks layer, though), it would allow the PPP
  implementation to directly hand the data to the TTY driver.

- Improved hotplugging:

  With the old TTY layer, it isn't entirely safe to destroy TTY's from
  the system. This implementation has a two-step destructing design,
  where the driver first abandons the TTY. After all threads have left
  the TTY, the TTY layer calls a routine in the driver, which can be
  used to free resources (unit numbers, etc).

  The pts(4) driver also implements this feature, which means
  posix_openpt() will now return PTY's that are created on the fly.

- Improved performance:

  One of the major improvements is the per-TTY mutex, which is expected
  to improve scalability when compared to the old Giant locking.
  Another change is the unbuffered copying to userspace, which is both
  used on TTY device nodes and PTY masters.

Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.

Obtained from:		//depot/projects/mpsafetty/...
Approved by:		philip (ex-mentor)
Discussed:		on the lists, at BSDCan, at the DevSummit
Sponsored by:		Snow B.V., the Netherlands
dcons(4) fixed by:	kan
2008-08-20 08:31:58 +00:00
Edward Tomasz Napierala
2aafc4d48c Fix ACL preservation, apparently broken in 1.47.
Approved by:	rwatson
MFC after:	3 weeks
2008-08-07 07:29:26 +00:00
Colin Percival
f9bcf9cabf Mark functions as __dead2 in order to help the LLVM static checker
understand which code paths aren't possible.

This commit eliminates 117 false positive bug reports of the form
"allocate memory; error out if pointer is NULL; use pointer".
2008-08-04 01:25:48 +00:00
Stefan Farfeleder
497157a78a Pass the correct flags to expandarg() for NFROMFD and NTOFD. This fixes a
segmentation fault when the argument expands to an empty string.

Reported by:	simon
MFC after:	3 weeks
2008-07-30 21:07:04 +00:00
Xin LI
95aaf2e8a4 Staticify symbols that will not be used in other
places.
2008-07-19 00:13:26 +00:00
Kevin Lo
0c025af962 Remove unnessasary cast 2008-07-18 14:55:22 +00:00
Ed Schouten
94a340ae73 Remove OTTYDISC, NETLDISC and NTTYDISC definitions.
When I ported most applications away from <sgtty.h>, I noticed none of
them were actually using these definitions. I kept them in place,
because I didn't want to touch tools like pstat(8) and stty(1).

In preparation for the MPSAFE TTY layer, remove these definitions. This
doesn't have any impact with respect to binary compatibility (see
tty_conf.c).

We couldn now add an #error to <sys/ioctl_compat.h> when included
outside the kernel. Unfortunately, kdump's mkioctls includes this file
unconditionally.

Approved by:	philip (mentor)
2008-07-16 11:20:04 +00:00
Christian S.J. Peron
f9655da0fb Add hard sentence breaks.
Pointed out by:	rwatson
MFC after:	1 week
2008-07-06 22:47:10 +00:00
Christian S.J. Peron
bc068d93d1 Document default ACLs and how to use them.
MFC after:	1 week
2008-07-06 20:29:35 +00:00
Ralf S. Engelschall
a65d88d15d use 'const' for the parameters of the two static functions unalias() and hashalias() 2008-06-07 16:28:20 +00:00
Ralf S. Engelschall
401b3c20cc remove an unnecessary include 2008-06-07 16:19:28 +00:00
Giorgos Keramidas
d605a06c6e Unbreak last commit to ln for amd64.
Cast string precision to `int'.  amd64 systems warn about the
field precision being `long int' if we don't, and pathnames are
normally short enough to fit in an `int'.

Noticed by:	pav
2008-06-07 09:37:30 +00:00
Giorgos Keramidas
3595f21aae Add a -w warning flag to ln(1). When the -w option is enabled,
ln(1) checks to see if the source of a symlink, i.e. the file it
should point to actually exists.  The default is the old ln
behavior, that does not check, to avoid surprising people who may
be using ln(1) in scripts or other non-interactive places.

PR:		bin/7265
Submitted by:	Joel Ray Holveck, detlev!joelh at mail.camalott.com
MFC after:	2 weeks
2008-06-06 08:27:59 +00:00
Stefan Farfeleder
4f30f2993f Fix checking if a variable name is LINENO. As STPUTC changes the pointer if it
needs to enlarge the buffer, we must not keep a pointer to the beginning.

PR:	ports/123879
2008-05-28 21:44:32 +00:00
Stefan Farfeleder
b71085aacf Expand $LINENO to the current line number. This is required by SUSv3's "User
Portability Utilities" option.

Often configure scripts generated by the autotools test if $LINENO works and
refuse to use /bin/sh if not.

Package test run by:	pav
2008-05-15 19:55:27 +00:00
Stefan Farfeleder
d9d588d495 Sigh, when reapplying the patch to HEAD, I somehow forgot to commit this file.
Reported by:	Jaakko Heinonen
2008-04-28 07:26:34 +00:00
Stefan Farfeleder
39376f45e2 - Fix bugs where the value of arithmetic expansion$((...)) was trucated
to type int.
- Change the type used for arithmetic expansion to intmax_t (ie. 64 bit on all
  currently supported FreeBSD architectures).  SUSv3 requires at least type
  long but allows for larger types.  Other shells (eg. bash, zsh, NetBSD's sh)
  do that too.

PR:		122659
Submitted by:	Jaakko Heinonen (minor modifications by me)
2008-04-27 20:46:45 +00:00
Warner Losh
2af52e0724 Turn a tab into a space. This fixes a misalignment for ls -l.
Tabs Noticed by: Antoine Brodin
2008-04-05 21:26:25 +00:00
Ruslan Ermilov
5ffbd51eb0 - Add -D to usage().
- Bump document date for the addition of the -D option.
- Reformat a sentence to look like a real sentence.
2008-04-04 05:55:42 +00:00
Greg Lehey
2269fa5765 Add -D option to specify exact format of date and time output with ls -l. 2008-04-04 03:57:46 +00:00
Stefan Farfeleder
f9ec075e88 Reset the internal state used for the 'getopts' built-in when 'shift' or 'set'
are used to modify the arguments.  Not doing so caused random memory reads or
null pointer dereferences when 'getopts' was called again later (SUSv3 says
getopts produces unspecified results in this case).

PR:	48318
2008-03-22 14:06:01 +00:00
David E. O'Brien
8757b00e1e uuidgen has been repo-copied from usr.bin/ to bin/ to match its "new"
(2007/04/09) installation location.
2008-03-13 17:38:06 +00:00
Jeff Roberson
7f77f84497 - P_SA has been removed. 2008-03-12 10:01:34 +00:00
John Baldwin
d140946cf3 Add an '-a' option which is identical to specifying '-RpP' for
compatibility with other implementations.

MFC after:	1 month
2008-03-10 19:58:41 +00:00
Robert Watson
08995e292e Enhance realpath(1) in a number of ways:
- Allow realpath to accept multiple paths on the command line.
- Add -q to suppress warnings if some paths can't be processed, and use
  getopt(3) to process flags.
- Print the path being requested rather than a possibly partially
  processed path when a failure occurs so that you can tell which of
  several passed paths did fail.

MFC after:	1 week
PR:		112920
Submitted by:	Ighighi <ighighi@gmail.com>
2008-03-09 12:46:39 +00:00
Robert Watson
1b21ffa615 Make chflags(1) more chmod(1)-like (and more feature complete):
- Add -v to print file names as they are processed; -vv prints the flags
  change as well.
- Add -f to ignore failures with the same semantics as chflags(1), neither
  printing an error nor affecting the return code.
- Don't try to set the flags if they won't change.

I made minor cosmetic tweaks to the code in the patch.

MFC after:	1 week
PR:		112827
Submitted by:	Ighighi <ighighi at gmail.com>
2008-03-09 12:10:24 +00:00
Stefan Farfeleder
55d2c5b573 Split updatepwd() into two smaller functions. The first one, findpwd(),
computes the new path and the second one, updatepwd(), updates the variables
PWD, OLDPWD and the path used for the pwd builtin according to the new
directory.  For a logical directory change, chdir() is now called between
those two functions, no longer causing wrong values to be stored in PWD etc. if
it fails.

PR:	64990, 101316, 120571
2008-02-24 16:50:55 +00:00
Marcel Moolenaar
2912059a85 Fix "warning: comparison is always false due to limited range of data type"
on platforms with unsigned chars. The comparison in question is there to
determine whether chars are unsigned or not and is based on comparing a
char, initialized to -1, for less than 0. Change the comparison to check
for geater than 0 instead...
2008-02-18 20:01:33 +00:00
Ruslan Ermilov
a65550812a Don't reset DST computed by strptime() (when e.g. setting the
date via -f %s).

Reported by:	Eugene Grosbein
Diagnosed by:	Miguel Lopes Santos Ramos
2008-02-07 16:04:24 +00:00
Diomidis Spinellis
961fdc4fac - Roll-back attempts to mimic rename(2) atomicity introduced in 1.47,
and follow the letter of the POSIX specification.

- Moving a directory to an existing non-empty directory will now fail,
  as required.

- Improve consistency and remove some style bugs of earlier versions.

This version passes all tests of tools/regression/bin/mv/regress.sh 1.6

Reviewed by:	bde
MFC after:	1 month
2007-12-27 11:33:42 +00:00
Edwin Groothuis
a76b9b6973 As suggested, replace earlier changed warnx() / exit() with an errx()
Submitted by:	Peter Jeremy <peterjeremy@optushome.com.au>
2007-12-26 08:32:20 +00:00
Edwin Groothuis
0d5ee457ad When copying multiple files to a directory, make sure that a proper
warning is given when the directory doesn't exist.

PR:		bin/50656
Submitted by:	Edwin Groothuis <edwin@mavetju.org>
Approved by:	grog@
Not reviewed by: grog@
2007-12-25 00:40:32 +00:00
Diomidis Spinellis
3db8241bb4 Calling any function from vfork other than exec* and _exit yields
undefined behavior.

Noted by:	alfred
2007-12-17 09:02:42 +00:00
Diomidis Spinellis
2ec43f35f4 Eliminate gcc "variable clobbered" warnings by declaring the variables
living across the vfork as volatile.

Noted by:	kan
2007-12-16 17:47:34 +00:00
Diomidis Spinellis
3a44a28835 When moving a directory across devices to a place where a directory
with the same name exists, delete that directory first, before performing
the copy.  This ensures that mv(1) across devices follows the semantics
of rename(2), as required by POSIX.

This change could introduce the potential of data loss, even if the
copy fails, violating the atomicity properties of rename(2).  This is
(mostly) mitigated by first renaming the destination and obliterating
it only after a succesfull copy.

The above logic also led to the introduction of code that will cleanup
the results of a partial copy, if a cross-device copy fails.

PR:		bin/118367
MFC after:	1 month
2007-12-16 14:14:31 +00:00
Marius Strobl
ea7f7bdef3 Move WARNS as ed(1) also is only WARNS = 2 clean in the !DES case.
This fixes its compilation if MK_OPENSSL == no and also obsoletes
release/Makefile rev. 1.192. The latter isn't reverted though as
support for the fixit floppy and the rest of the boot floppies is
scheduled to be deorbited anyway.

Discussed with:	kensmith
2007-12-09 00:14:27 +00:00
Ruslan Ermilov
dfe302ab34 Revise the markup. 2007-12-05 12:29:26 +00:00
John Birrell
78a5dd56cd Reduce the WARNS level to avoid a compiler warning about a variable
possibly being clobbered by a longjmp or a fork with gcc4.
2007-11-18 01:53:07 +00:00
Ruslan Ermilov
8090694427 Express in the usage() and SYNOPSIS that -F depends on -s, and
that -f and -i are exclusive.
2007-11-17 21:01:22 +00:00
Ruslan Ermilov
cadf8ad71c Swap "source"/"target" where appropriate, to match documentation. 2007-11-17 20:24:58 +00:00
John Baldwin
8a529f590f Teach ps(1) to parse pts TT values (i.e. '0', '1') for the -t flag.
MFC after:	1 week
Reported by:	kris
2007-11-08 22:31:28 +00:00
Ruslan Ermilov
c930322c40 Bump document date on behalf of previous revision. 2007-11-01 09:49:45 +00:00
Julian Elischer
c36b9f6253 fix sorting of 'tdnam' keyword in keyword list. 2007-10-28 17:10:36 +00:00
Julian Elischer
7ab24ea3b9 Introduce a way to make pure kernal threads.
kthread_add() takes the same parameters as the old kthread_create()
plus a pointer to a process structure, and adds a kernel thread
to that process.

kproc_kthread_add() takes the parameters for kthread_add,
plus a process name and a pointer to a pointer to a process instead of just
a pointer, and if the proc * is NULL, it creates the process to the
specifications required, before adding the thread to it.

All other old kthread_xxx() calls return, but act on (struct thread *)
instead of (struct proc *). One reason to change the name is so that
any old kernel modules that are lying around and expect kthread_create()
to make a process will not just accidentally link.

fix top to show  kernel threads by their thread name in -SH mode
add a tdnam formatting option to ps to show thread names.

make all idle threads actual kthreads and put them into their own idled process.
make all interrupt threads kthreads and put them in an interd process
(mainly for aesthetic and accounting reasons)
rename proc 0 to be 'kernel' and it's swapper thread is now 'swapper'

man page fixes to follow.
2007-10-26 08:00:41 +00:00
Stefan Farfeleder
aafd6a87a6 The exit status of a case statement where none of the patterns is matched
is supposed to be 0, not the status of the previous command.

Reported by:	Eygene Ryabinkin
PR:		116559
Approved by:	re (gnn)
2007-10-04 16:14:48 +00:00
Kevin Lo
c577145195 Use owner name and owning group name instead of uid and gid
for displaying the three-line comment header by default.

Reviewed by: kientzle
Approved by: re (bmah)
2007-09-19 02:04:47 +00:00
Jeff Roberson
b61ce5b0e6 - Move all of the PS_ flags into either p_flag or td_flags.
- p_sflag was mostly protected by PROC_LOCK rather than the PROC_SLOCK or
   previously the sched_lock.  These bugs have existed for some time.
 - Allow swapout to try each thread in a process individually and then
   swapin the whole process if any of these fail.  This allows us to move
   most scheduler related swap flags into td_flags.
 - Keep ki_sflag for backwards compat but change all in source tools to
   use the new and more correct location of P_INMEM.

Reported by:	pho
Reviewed by:	attilio, kib
Approved by:	re (kensmith)
2007-09-17 05:31:39 +00:00
Sean Farley
5b78c6c247 Take care that the input to setenv() may actually be a pointer straight
from environ; make a copy before manipulating it and passing it to
setenv().

Approved by:	wes
Approved by:	re (kensmith)
2007-07-06 04:04:58 +00:00
Sean Farley
2966d28c32 Significantly reduce the memory leak as noted in BUGS section for
setenv(3) by tracking the size of the memory allocated instead of using
strlen() on the current value.

Convert all calls to POSIX from historic BSD API:
 - unsetenv returns an int.
 - putenv takes a char * instead of const char *.
 - putenv no longer makes a copy of the input string.
 - errno is set appropriately for POSIX.  Exceptions involve bad environ
   variable and internal initialization code.  These both set errno to
   EFAULT.

Several patches to base utilities to handle the POSIX changes from
Andrey Chernov's previous commit.  A few I re-wrote to use setenv()
instead of putenv().

New regression module for tools/regression/environ to test these
functions.  It also can be used to test the performance.

Bump __FreeBSD_version to 700050 due to API change.

PR:		kern/99826
Approved by:	wes
Approved by:	re (kensmith)
2007-07-04 00:00:41 +00:00
Ken Smith
0c0146f019 Don't include encryption features of ed(1) when building for the
"rescue media" bundled with releases.

Suggested by:	ru
Approved by:	re (hrs)
2007-07-02 14:00:25 +00:00
Remko Lodder
a1f6cb79d9 Correct the referenced securelevel document, it's now securelevel 7.
Pointed out by:	ru
2007-06-02 20:15:59 +00:00