Commit Graph

2228 Commits

Author SHA1 Message Date
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