mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-29 03:45:02 +01:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c37538200e |
No files matched your search
@@ -1,4 +1,4 @@
|
||||
# $FreeBSD$
|
||||
# $Id:$
|
||||
# @(#)COPYRIGHT 8.2 (Berkeley) 3/21/94
|
||||
|
||||
All of the documentation and software included in the 4.4BSD and 4.4BSD-Lite
|
||||
@@ -63,35 +63,3 @@ The views and conclusions contained in the software and documentation are
|
||||
those of the authors and should not be interpreted as representing official
|
||||
policies, either expressed or implied, of the Regents of the University
|
||||
of California.
|
||||
|
||||
|
||||
NOTE: The copyright of UC Berkeley's Berkeley Software Distribution ("BSD")
|
||||
source has been updated. The copyright addendum may be found at
|
||||
ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change and is
|
||||
included below.
|
||||
|
||||
July 22, 1999
|
||||
|
||||
To All Licensees, Distributors of Any Version of BSD:
|
||||
|
||||
As you know, certain of the Berkeley Software Distribution ("BSD") source
|
||||
code files require that further distributions of products containing all or
|
||||
portions of the software, acknowledge within their advertising materials
|
||||
that such products contain software developed by UC Berkeley and its
|
||||
contributors.
|
||||
|
||||
Specifically, the provision reads:
|
||||
|
||||
" * 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors."
|
||||
|
||||
Effective immediately, licensees and distributors are no longer required to
|
||||
include the acknowledgement within advertising materials. Accordingly, the
|
||||
foregoing paragraph of those BSD Unix files containing it is hereby deleted
|
||||
in its entirety.
|
||||
|
||||
William Hoskins
|
||||
Director, Office of Technology Licensing
|
||||
University of California, Berkeley
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# $FreeBSD$
|
||||
# $Id: Makefile,v 1.222.2.3 1999/03/24 04:26:19 jkh Exp $
|
||||
#
|
||||
# The user-driven targets are:
|
||||
#
|
||||
|
||||
+2
-4
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# $FreeBSD$
|
||||
# $Id: Makefile.inc0,v 1.14 1999/01/14 06:45:53 jhay Exp $
|
||||
#
|
||||
# This makefile ensures that the object directory is set according to the
|
||||
# object format to avoid mixing aout and elf formatted files during the
|
||||
@@ -59,7 +59,6 @@ LEGACY_ENV= PATH=${ELFTMPPATH} OBJFORMAT=aout NOTOOLS=1 TOOLROOT=${ELFTMP} \
|
||||
MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/aout
|
||||
XMAKE= ${ELFTMP}/usr/bin/${MAKE}
|
||||
|
||||
STARTTIME!= LC_TIME=C date
|
||||
#
|
||||
# world
|
||||
#
|
||||
@@ -69,7 +68,7 @@ STARTTIME!= LC_TIME=C date
|
||||
#
|
||||
world:
|
||||
@echo "--------------------------------------------------------------"
|
||||
@echo ">>> ${OBJFORMAT} make world started on ${STARTTIME}"
|
||||
@echo ">>> ${OBJFORMAT} make world started on `LC_TIME=C date`"
|
||||
@echo "--------------------------------------------------------------"
|
||||
.if target(pre-world)
|
||||
@echo
|
||||
@@ -95,7 +94,6 @@ world:
|
||||
.endif
|
||||
@echo
|
||||
@echo "--------------------------------------------------------------"
|
||||
@echo ">>> ${OBJFORMAT} make world started on ${STARTTIME}"
|
||||
@echo ">>> ${OBJFORMAT} make world completed on `LC_TIME=C date`"
|
||||
@echo "--------------------------------------------------------------"
|
||||
|
||||
|
||||
+3
-7
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# $FreeBSD$
|
||||
# $Id: Makefile.inc1,v 1.59.2.3 1999/04/11 21:52:42 des Exp $
|
||||
#
|
||||
# Make command line options:
|
||||
# -DCLOBBER will remove /usr/include
|
||||
@@ -183,8 +183,6 @@ TMPPATH= ${STRICTTMPPATH}:${PATH}
|
||||
COMPILER_ENV= BISON_SIMPLE=${TOOLROOT}/usr/share/misc/bison.simple \
|
||||
COMPILER_PATH=${TOOLROOT}/usr/libexec:${TOOLROOT}/usr/bin \
|
||||
GCC_EXEC_PREFIX=${WORLDTMP}${SHLIBDIR}:${WORLDTMP}/usr/lib/ \
|
||||
GROFF_FONT_PATH=${WORLDTMP}/usr/share/groff_font \
|
||||
GROFF_TMAC_PATH=${WORLDTMP}/usr/share/tmac \
|
||||
LD_LIBRARY_PATH=${TOOLROOT}${SHLIBDIR} \
|
||||
LIBRARY_PATH=${WORLDTMP}${SHLIBDIR}:${WORLDTMP}/usr/lib
|
||||
|
||||
@@ -398,7 +396,7 @@ update:
|
||||
@echo "--------------------------------------------------------------"
|
||||
@echo ">>> Updating /usr/src from cvs repository" ${CVSROOT}
|
||||
@echo "--------------------------------------------------------------"
|
||||
cd ${.CURDIR}; cvs -q update -rRELENG_3 -P -d
|
||||
cd ${.CURDIR}; cvs -q update -P -d
|
||||
.endif
|
||||
|
||||
#
|
||||
@@ -554,11 +552,10 @@ includes:
|
||||
cd ${.CURDIR}/lib/libftpio; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libmd; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libmytinfo; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libncurses; ${MAKE} beforeinstall
|
||||
.if !defined(WANT_CSRG_LIBM)
|
||||
cd ${.CURDIR}/lib/msun; ${MAKE} beforeinstall
|
||||
.endif
|
||||
cd ${.CURDIR}/lib/libncurses; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libnetgraph; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libopie; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libpam/libpam; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libpcap; ${MAKE} beforeinstall
|
||||
@@ -572,7 +569,6 @@ includes:
|
||||
cd ${.CURDIR}/lib/libss; ${MAKE} -B hdrs beforeinstall
|
||||
cd ${.CURDIR}/lib/libutil; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libvgl; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libwrap; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libz; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/usr.bin/f2c; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/usr.bin/lex; ${MAKE} beforeinstall
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# $FreeBSD$
|
||||
# $Id: Makefile.upgrade,v 1.9.2.9 1999/02/17 21:04:44 msmith Exp $
|
||||
#
|
||||
# This makefile contains rules for preforming upgrades that are outside
|
||||
# the scope of the normal build world process.
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
This is the top level of the FreeBSD source directory. This file
|
||||
was last revised on:
|
||||
$FreeBSD$
|
||||
was last revised on: $Id: README,v 1.13 1998/09/13 09:38:34 markm Exp $
|
||||
|
||||
For copyright information, please see the file COPYRIGHT in this
|
||||
directory (additional copyright information also exists for some
|
||||
@@ -35,7 +34,7 @@ bin System/User commands.
|
||||
|
||||
contrib Packages contributed by 3rd parties.
|
||||
|
||||
crypto Cryptography stuff (see crypto/README).
|
||||
crypto Export controlled stuff (see crypto/README).
|
||||
|
||||
etc Template files for /etc
|
||||
|
||||
|
||||
@@ -1,6 +1,137 @@
|
||||
Updating Information for FreeBSD Stable users
|
||||
Updating Information for FreeBSD current users
|
||||
|
||||
When updating to 4.x-stable from 3.x-stable, please read src/UPDATING
|
||||
after updating to the new sources for important information.
|
||||
This file is maintained by [email protected]. Please send new entries
|
||||
directly to him. See end of file for further details.
|
||||
|
||||
$FreeBSD$
|
||||
19990510:
|
||||
Previously, one would define "NOAOUT" to keep from building
|
||||
the legacy a.out bits. Now one would define "WANT_AOUT" to
|
||||
build them.
|
||||
|
||||
19990507:
|
||||
New devstat API requires recompilation of libdevstat, systat,
|
||||
iostat, vmstat and rpc.rstatd. A new kernel is also required.
|
||||
make world + building a kernel should do all of this. Any
|
||||
ports that use devstat need to be recompiled as well.
|
||||
|
||||
19990424:
|
||||
The 'nlpt' driver has changed names to become the 'lpt' driver.
|
||||
See ppbus(4) or http://www.freebsd.org/~nsouch/ppbus.html
|
||||
for proper configuration details.
|
||||
|
||||
19990209:
|
||||
New devstat API requires recompilation of libdevstat, systat,
|
||||
iostat, vmstat and rpc.rstatd. A new kernel is also required.
|
||||
make world + building a kernel should do all of this. Any
|
||||
ports that use devstat need to be recompiled as well.
|
||||
|
||||
19990125:
|
||||
Linux threads options has gone away (they are now standard in
|
||||
the FreeBSD kernel). A recompile of all libkvm using programs
|
||||
is in order (or better yet a make world).
|
||||
|
||||
19990122:
|
||||
On or about this date there was a small window when the boot
|
||||
blocks had some minor problems which seemed to force one to
|
||||
edit /etc/fstab. This has been corrected, if you are seeing this
|
||||
problem, please rebuild and reinstall your boot blocks.
|
||||
|
||||
19990121:
|
||||
Vinum has changed. The "vinum read" command has changed. For
|
||||
updates, please see
|
||||
|
||||
http://www.freebsd.org/cgi/getmsg.cgi?fetch=800363+0+current/freebsd-current
|
||||
|
||||
for details.
|
||||
|
||||
19990120:
|
||||
Stable branch created. You might want to consider using this
|
||||
branch. It is tagged with RELENG_3.
|
||||
|
||||
19990119:
|
||||
More work on the syscons driver has been committed. Since
|
||||
files moved around, you will need to reconfigure your kernel,
|
||||
and make clean; make depend before rebuilding the kernel. No
|
||||
config file changes are needed.
|
||||
|
||||
19990111:
|
||||
New keyboard and video card drivers are introduced as the first
|
||||
stage of console driver reorganization. You are required to
|
||||
update the kernel configuration file and rebuild the kernel.
|
||||
kbdcontrol, vidcontrol, and screen savers also need recompilation.
|
||||
The instruction can be found in
|
||||
|
||||
http://www.freebsd.org/~yokota/sc_update.txt
|
||||
|
||||
It has notes on splash screen too.
|
||||
|
||||
19990106:
|
||||
Robert Nordier was kind enough to make this page to enable people to
|
||||
install the new bootblocks:
|
||||
|
||||
http://www.freebsd.org/~rnordier/boot.txt
|
||||
|
||||
When updating to ELF, make sure that you have updated your
|
||||
/etc/rc files which have different ldconfig invocations for
|
||||
elf and aout. Otherwise things like X will stop working with
|
||||
messages about being unable to find library files. The
|
||||
mergemaster utility in ports/sysutils/mergemaster helps to
|
||||
keep critical files like this in sync, and its use is
|
||||
recommended.
|
||||
|
||||
19990104:
|
||||
Information about ELF day (see 19981230) can be found in
|
||||
|
||||
http://www.freebsd.org/~peter/elfday.html
|
||||
|
||||
about the upcoming change, its motivations and instructions
|
||||
for doing the upgrade.
|
||||
|
||||
19981230:
|
||||
You should install new bootblocks now. The ELF kernel will
|
||||
become default soon. In addition, you'll need to upgrade
|
||||
your userland programs to ELF before then as well. Use
|
||||
make aout-to-elf to upgrade your userland programs (old
|
||||
a.out programs in, for example, /usr/local/bin will
|
||||
continue to work, even after the upgrade). See src/Makefile
|
||||
for more details.
|
||||
|
||||
19981224:
|
||||
The old wcd driver has been deleted from the kernel. The
|
||||
driver that replaces it is named acd. You'll need to change
|
||||
this in your configuration files.
|
||||
|
||||
Failure to do this will result in "ATAPI CD-ROMs not
|
||||
configured" at boot time.
|
||||
|
||||
The floppy tape driver (ft) has been removed from the kernel,
|
||||
with no replacement driver.
|
||||
|
||||
19981202:
|
||||
New groups from 19981201 commented out of mtree, so they
|
||||
aren't strictly needed, but still a good idea to have.
|
||||
|
||||
19981201:
|
||||
New user/group added: bind. From src/etc/master.passwd and
|
||||
src/etc/group:
|
||||
% grep <newstuff> /usr/src/etc/group
|
||||
bind:*:53:
|
||||
% grep <newstuff> /usr/src/etc/master.passwd
|
||||
tty:*:4:65533::0:0:Tty Sandbox:/:/sbin/nologin
|
||||
kmem:*:5:65533::0:0:KMem Sandbox:/:/sbin/nologin
|
||||
bind:*:53:53::0:0:Bind Sandbox:/:/sbin/nologin
|
||||
|
||||
19981118:
|
||||
PAM integrated into the tree. Requires new /etc/pam.conf file
|
||||
to silence warnings from authentication programs (login, etc).
|
||||
See src/etc/pam.conf for a sample.
|
||||
|
||||
This file contains a list, in reverse chronologocal order, of major
|
||||
breakages in tracking -stable. Not all things will be listed here,
|
||||
and it only starts on Novemeber 18, 1998. If you have an earlier
|
||||
version of FreeBSD, you are on your own to get to November 18, 1998.
|
||||
|
||||
Please filter your entries through Warner ([email protected]) so that
|
||||
the style, formatting, etc of this file can be maintained.
|
||||
|
||||
$Id: UPDATING,v 1.14.2.1 1999/05/10 09:22:47 jkh Exp $
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
# From: @(#)Makefile 8.1 (Berkeley) 5/31/93
|
||||
# $FreeBSD$
|
||||
# $Id: Makefile,v 1.13 1998/08/15 12:27:23 jb Exp $
|
||||
|
||||
SUBDIR= cat \
|
||||
chio \
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
# @(#)Makefile.inc 8.1 (Berkeley) 5/31/93
|
||||
# $FreeBSD$
|
||||
# $Id: Makefile.inc,v 1.9 1997/02/22 14:01:23 peter Exp $
|
||||
|
||||
BINDIR?= /bin
|
||||
CFLAGS+= -Wall -Wformat
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
# @(#)Makefile 8.1 (Berkeley) 5/31/93
|
||||
# $FreeBSD$
|
||||
# $Id$
|
||||
|
||||
PROG= cat
|
||||
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)cat.1 8.3 (Berkeley) 5/2/95
|
||||
.\" $FreeBSD$
|
||||
.\" $Id: cat.1,v 1.8 1998/05/13 07:16:36 charnier Exp $
|
||||
.\"
|
||||
.Dd May 2, 1995
|
||||
.Dt CAT 1
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ static char const copyright[] =
|
||||
static char sccsid[] = "@(#)cat.c 8.2 (Berkeley) 4/27/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
"$Id: cat.c,v 1.12 1998/09/11 05:48:06 imp Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
# $FreeBSD$
|
||||
# $Id: Makefile,v 1.2 1997/09/12 15:00:06 jkh Exp $
|
||||
# @(#)Makefile 8.1 (Berkeley) 6/6/93
|
||||
|
||||
CFLAGS+=-I${.CURDIR}/../../sys
|
||||
|
||||
+2
-2
@@ -30,7 +30,7 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Id: chio.1,v 1.7 1998/09/15 07:48:51 gibbs Exp $
|
||||
.\"
|
||||
.Dd May 14, 1998
|
||||
.Dt CHIO 1
|
||||
@@ -135,7 +135,7 @@ respectively.
|
||||
.Pp
|
||||
Note that not all medium changers support the
|
||||
.Ic exchange
|
||||
operation; the changer must have multiple free pickers or emulate
|
||||
operation; The changer must have multiple free pickers or emulate
|
||||
multiple free pickers with transient storage.
|
||||
.It Xo Nm position
|
||||
.Ar <to ET> <to EU>
|
||||
|
||||
+57
-100
@@ -34,12 +34,11 @@
|
||||
* Additional Copyright (c) 1997, by Matthew Jacob, for NASA/Ames Research Ctr.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
static const char copyright[] =
|
||||
"@(#) Copyright (c) 1996 Jason R. Thorpe. All rights reserved.";
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
__COPYRIGHT("@(#) Copyright (c) 1996 Jason R. Thorpe. All rights reserved.");
|
||||
__RCSID("$NetBSD: chio.c,v 1.6 1998/01/04 23:53:58 thorpej Exp $");
|
||||
#endif
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/chio.h>
|
||||
@@ -56,44 +55,45 @@ static const char rcsid[] =
|
||||
extern char *__progname; /* from crt0.o */
|
||||
extern int optreset; /* from getopt.o */
|
||||
|
||||
static void usage __P((void));
|
||||
static void cleanup __P((void));
|
||||
static int parse_element_type __P((char *));
|
||||
static int parse_element_unit __P((char *));
|
||||
static const char * element_type_name __P((int et));
|
||||
static int parse_special __P((char *));
|
||||
static int is_special __P((char *));
|
||||
static const char *bits_to_string __P((int, const char *));
|
||||
int main(int, char *[]);
|
||||
static void usage(void);
|
||||
static void cleanup(void);
|
||||
static int parse_element_type(char *);
|
||||
static int parse_element_unit(char *);
|
||||
static const char * element_type_name(int et);
|
||||
static int parse_special(char *);
|
||||
static int is_special(char *);
|
||||
static char *bits_to_string(int, const char *);
|
||||
|
||||
static int do_move __P((char *, int, char **));
|
||||
static int do_exchange __P((char *, int, char **));
|
||||
static int do_position __P((char *, int, char **));
|
||||
static int do_params __P((char *, int, char **));
|
||||
static int do_getpicker __P((char *, int, char **));
|
||||
static int do_setpicker __P((char *, int, char **));
|
||||
static int do_status __P((char *, int, char **));
|
||||
static int do_ielem __P((char *, int, char **));
|
||||
static int do_voltag __P((char *, int, char **));
|
||||
static int do_move(char *, int, char **);
|
||||
static int do_exchange(char *, int, char **);
|
||||
static int do_position(char *, int, char **);
|
||||
static int do_params(char *, int, char **);
|
||||
static int do_getpicker(char *, int, char **);
|
||||
static int do_setpicker(char *, int, char **);
|
||||
static int do_status(char *, int, char **);
|
||||
static int do_ielem(char *, int, char **);
|
||||
static int do_voltag(char *, int, char **);
|
||||
|
||||
/* Valid changer element types. */
|
||||
const struct element_type elements[] = {
|
||||
{ "drive", CHET_DT },
|
||||
{ "picker", CHET_MT },
|
||||
{ "portal", CHET_IE },
|
||||
{ "slot", CHET_ST },
|
||||
{ "portal", CHET_IE },
|
||||
{ "drive", CHET_DT },
|
||||
{ NULL, 0 },
|
||||
};
|
||||
|
||||
/* Valid commands. */
|
||||
const struct changer_command commands[] = {
|
||||
{ "exchange", do_exchange },
|
||||
{ "getpicker", do_getpicker },
|
||||
{ "ielem", do_ielem },
|
||||
{ "move", do_move },
|
||||
{ "params", do_params },
|
||||
{ "exchange", do_exchange },
|
||||
{ "position", do_position },
|
||||
{ "params", do_params },
|
||||
{ "getpicker", do_getpicker },
|
||||
{ "setpicker", do_setpicker },
|
||||
{ "status", do_status },
|
||||
{ "ielem", do_ielem },
|
||||
{ "voltag", do_voltag },
|
||||
{ NULL, 0 },
|
||||
};
|
||||
@@ -107,12 +107,10 @@ const struct special_word specials[] = {
|
||||
};
|
||||
|
||||
static int changer_fd;
|
||||
static const char *changer_name;
|
||||
static char *changer_name;
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int ch, i;
|
||||
|
||||
@@ -149,26 +147,15 @@ main(argc, argv)
|
||||
for (i = 0; commands[i].cc_name != NULL; ++i)
|
||||
if (strcmp(*argv, commands[i].cc_name) == 0)
|
||||
break;
|
||||
if (commands[i].cc_name == NULL) {
|
||||
/* look for abbreviation */
|
||||
for (i = 0; commands[i].cc_name != NULL; ++i)
|
||||
if (strncmp(*argv, commands[i].cc_name,
|
||||
strlen(*argv)) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (commands[i].cc_name == NULL)
|
||||
errx(1, "unknown command: %s", *argv);
|
||||
|
||||
exit ((*commands[i].cc_handler)(commands[i].cc_name, argc, argv));
|
||||
exit((*commands[i].cc_handler)(commands[i].cc_name, argc, argv));
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
static int
|
||||
do_move(cname, argc, argv)
|
||||
char *cname;
|
||||
int argc;
|
||||
char **argv;
|
||||
do_move(char *cname, int argc, char **argv)
|
||||
{
|
||||
struct changer_move cmd;
|
||||
int val;
|
||||
@@ -236,10 +223,7 @@ do_move(cname, argc, argv)
|
||||
}
|
||||
|
||||
static int
|
||||
do_exchange(cname, argc, argv)
|
||||
char *cname;
|
||||
int argc;
|
||||
char **argv;
|
||||
do_exchange(char *cname, int argc, char **argv)
|
||||
{
|
||||
struct changer_exchange cmd;
|
||||
int val;
|
||||
@@ -334,10 +318,7 @@ do_exchange(cname, argc, argv)
|
||||
}
|
||||
|
||||
static int
|
||||
do_position(cname, argc, argv)
|
||||
char *cname;
|
||||
int argc;
|
||||
char **argv;
|
||||
do_position(char *cname, int argc, char **argv)
|
||||
{
|
||||
struct changer_position cmd;
|
||||
int val;
|
||||
@@ -398,10 +379,7 @@ do_position(cname, argc, argv)
|
||||
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
do_params(cname, argc, argv)
|
||||
char *cname;
|
||||
int argc;
|
||||
char **argv;
|
||||
do_params(char *cname, int argc, char **argv)
|
||||
{
|
||||
struct changer_params data;
|
||||
int picker;
|
||||
@@ -444,10 +422,7 @@ do_params(cname, argc, argv)
|
||||
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
do_getpicker(cname, argc, argv)
|
||||
char *cname;
|
||||
int argc;
|
||||
char **argv;
|
||||
do_getpicker(char *cname, int argc, char **argv)
|
||||
{
|
||||
int picker;
|
||||
|
||||
@@ -474,10 +449,7 @@ do_getpicker(cname, argc, argv)
|
||||
}
|
||||
|
||||
static int
|
||||
do_setpicker(cname, argc, argv)
|
||||
char *cname;
|
||||
int argc;
|
||||
char **argv;
|
||||
do_setpicker(char *cname, int argc, char **argv)
|
||||
{
|
||||
int picker;
|
||||
|
||||
@@ -505,10 +477,7 @@ do_setpicker(cname, argc, argv)
|
||||
}
|
||||
|
||||
static int
|
||||
do_status(cname, argc, argv)
|
||||
char *cname;
|
||||
int argc;
|
||||
char **argv;
|
||||
do_status(char *cname, int argc, char **argv)
|
||||
{
|
||||
struct changer_params cp;
|
||||
struct changer_element_status_request cesr;
|
||||
@@ -527,7 +496,7 @@ do_status(cname, argc, argv)
|
||||
description = NULL;
|
||||
|
||||
optind = optreset = 1;
|
||||
while ((c = getopt(argc, argv, "vVsSbaI")) != -1) {
|
||||
while ((c = getopt(argc, argv, "vVsSbaI")) != EOF) {
|
||||
switch (c) {
|
||||
case 'v':
|
||||
pvoltag = 1;
|
||||
@@ -687,7 +656,7 @@ do_status(cname, argc, argv)
|
||||
printf(" avoltag: <%s:%d>",
|
||||
ces->ces_avoltag.cv_volid,
|
||||
ces->ces_avoltag.cv_serial);
|
||||
if (source) {
|
||||
if (source)
|
||||
if (ces->ces_flags & CES_SOURCE_VALID)
|
||||
printf(" source: <%s %d>",
|
||||
element_type_name(
|
||||
@@ -695,7 +664,6 @@ do_status(cname, argc, argv)
|
||||
ces->ces_source_addr);
|
||||
else
|
||||
printf(" source: <>");
|
||||
}
|
||||
if (intaddr)
|
||||
printf(" intaddr: <%d>", ces->ces_int_addr);
|
||||
if (scsi) {
|
||||
@@ -727,10 +695,7 @@ do_status(cname, argc, argv)
|
||||
}
|
||||
|
||||
static int
|
||||
do_ielem(cname, argc, argv)
|
||||
char *cname;
|
||||
int argc;
|
||||
char **argv;
|
||||
do_ielem(char *cname, int argc, char **argv)
|
||||
{
|
||||
int timeout = 0;
|
||||
|
||||
@@ -753,10 +718,7 @@ do_ielem(cname, argc, argv)
|
||||
}
|
||||
|
||||
static int
|
||||
do_voltag(cname, argc, argv)
|
||||
char *cname;
|
||||
int argc;
|
||||
char **argv;
|
||||
do_voltag(char *cname, int argc, char **argv)
|
||||
{
|
||||
int force = 0;
|
||||
int clear = 0;
|
||||
@@ -767,7 +729,7 @@ do_voltag(cname, argc, argv)
|
||||
bzero(&csvr, sizeof(csvr));
|
||||
|
||||
optind = optreset = 1;
|
||||
while ((c = getopt(argc, argv, "fca")) != -1) {
|
||||
while ((c = getopt(argc, argv, "fca")) != EOF) {
|
||||
switch (c) {
|
||||
case 'f':
|
||||
force = 1;
|
||||
@@ -841,8 +803,7 @@ do_voltag(cname, argc, argv)
|
||||
}
|
||||
|
||||
static int
|
||||
parse_element_type(cp)
|
||||
char *cp;
|
||||
parse_element_type(char *cp)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -855,8 +816,7 @@ parse_element_type(cp)
|
||||
}
|
||||
|
||||
static const char *
|
||||
element_type_name(et)
|
||||
int et;
|
||||
element_type_name(int et)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -868,8 +828,7 @@ element_type_name(et)
|
||||
}
|
||||
|
||||
static int
|
||||
parse_element_unit(cp)
|
||||
char *cp;
|
||||
parse_element_unit(char *cp)
|
||||
{
|
||||
int i;
|
||||
char *p;
|
||||
@@ -882,8 +841,7 @@ parse_element_unit(cp)
|
||||
}
|
||||
|
||||
static int
|
||||
parse_special(cp)
|
||||
char *cp;
|
||||
parse_special(char *cp)
|
||||
{
|
||||
int val;
|
||||
|
||||
@@ -896,8 +854,7 @@ parse_special(cp)
|
||||
}
|
||||
|
||||
static int
|
||||
is_special(cp)
|
||||
char *cp;
|
||||
is_special(char *cp)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -908,10 +865,8 @@ is_special(cp)
|
||||
return (0);
|
||||
}
|
||||
|
||||
static const char *
|
||||
bits_to_string(v, cp)
|
||||
int v;
|
||||
const char *cp;
|
||||
static char *
|
||||
bits_to_string(int v, const char *cp)
|
||||
{
|
||||
const char *np;
|
||||
char f, sep, *bp;
|
||||
@@ -925,9 +880,7 @@ bits_to_string(v, cp)
|
||||
np++;
|
||||
if ((v & (1 << (f - 1))) == 0)
|
||||
continue;
|
||||
(void) snprintf(bp, sizeof(buf) - (bp - &buf[0]),
|
||||
"%c%.*s", sep, (int)(long)(np - cp), cp);
|
||||
bp += strlen(bp);
|
||||
bp += sprintf(bp, "%c%.*s", sep, (int)(long)(np - cp), cp);
|
||||
sep = ',';
|
||||
}
|
||||
if (sep != '<')
|
||||
@@ -946,7 +899,11 @@ cleanup()
|
||||
static void
|
||||
usage()
|
||||
{
|
||||
(void) fprintf(stderr, "usage: %s [-f changer] command [-<flags>] "
|
||||
"arg1 arg2 [arg3 [...]]\n", __progname);
|
||||
|
||||
(void) fprintf(stderr, "usage: %s command arg1 arg2 ...\n", __progname);
|
||||
(void) fprintf(stderr, "Examples:\n");
|
||||
(void) fprintf(stderr, "\tchio -f /dev/ch0 move slot 1 drive 0\n");
|
||||
(void) fprintf(stderr, "\tchio ielem\n");
|
||||
(void) fprintf(stderr, "\tchio -f /dev/ch1 status\n");
|
||||
exit(1);
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
/* $FreeBSD$ */
|
||||
/* $Id: $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Jason R. Thorpe <[email protected]>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $FreeBSD$ */
|
||||
/* $Id: $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Jason R. Thorpe <[email protected]>
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
# @(#)Makefile 8.1 (Berkeley) 5/31/93
|
||||
# $FreeBSD$
|
||||
# $Id$
|
||||
|
||||
PROG= chmod
|
||||
|
||||
|
||||
+6
-21
@@ -33,7 +33,7 @@
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)chmod.1 8.4 (Berkeley) 3/31/94
|
||||
.\" $FreeBSD$
|
||||
.\" $Id: chmod.1,v 1.10 1998/05/19 06:24:50 jkoshy Exp $
|
||||
.\"
|
||||
.Dd March 31, 1994
|
||||
.Dt CHMOD 1
|
||||
@@ -44,10 +44,8 @@
|
||||
.Sh SYNOPSIS
|
||||
.Nm chmod
|
||||
.Oo
|
||||
.Fl f
|
||||
.Fl R
|
||||
.Op Fl H | Fl L | Fl P
|
||||
.Fl v
|
||||
.Oc
|
||||
.Ar mode
|
||||
.Ar file ...
|
||||
@@ -65,8 +63,7 @@ The options are as follows:
|
||||
If the
|
||||
.Fl R
|
||||
option is specified, symbolic links on the command line are followed.
|
||||
(Symbolic links encountered in the tree traversal are not followed by
|
||||
default.)
|
||||
(Symbolic links encountered in the tree traversal are not followed.)
|
||||
.It Fl L
|
||||
If the
|
||||
.Fl R
|
||||
@@ -78,15 +75,6 @@ option is specified, no symbolic links are followed.
|
||||
.It Fl R
|
||||
Change the modes of the file hierarchies rooted in the files
|
||||
instead of just the files themselves.
|
||||
.It Fl f
|
||||
Do not display a diagnostic message if
|
||||
.Nm
|
||||
could not modify the mode for
|
||||
.Va file .
|
||||
.It Fl v
|
||||
Cause
|
||||
.Nm
|
||||
to be verbose, showing files as the mode is modified.
|
||||
.El
|
||||
.Pp
|
||||
Symbolic links do not have modes, so unless the
|
||||
@@ -130,7 +118,7 @@ system supports this feature: see
|
||||
and the
|
||||
.Ar suiddir
|
||||
option to
|
||||
.Xr mount 8 .
|
||||
.Xr mount 1 .
|
||||
.It Li 2000
|
||||
(the set-group-ID-on-execution bit) Executable files with this bit set
|
||||
will run with effective gid set to the gid of the file owner.
|
||||
@@ -172,8 +160,9 @@ others, and no set-uid or set-gid behaviour is 755
|
||||
The symbolic mode is described by the following grammar:
|
||||
.Bd -literal -offset indent
|
||||
mode ::= clause [, clause ...]
|
||||
clause ::= [who ...] [action ...] action
|
||||
clause ::= [who ...] [action ...] last_action
|
||||
action ::= op [perm ...]
|
||||
last_action ::= op [perm ...]
|
||||
who ::= a | u | g | o
|
||||
op ::= + | \- | =
|
||||
perm ::= r | s | t | w | x | X | u | g | o
|
||||
@@ -312,13 +301,10 @@ set the group bits equal to the user bits, but clear the group write bit.
|
||||
There's no
|
||||
.Ar perm
|
||||
option for the naughty bits.
|
||||
.Sh COMPATIBILITY
|
||||
The
|
||||
.Fl v
|
||||
option is non-standard and its use in scripts is not recommended.
|
||||
.Sh SEE ALSO
|
||||
.Xr chflags 1 ,
|
||||
.Xr install 1 ,
|
||||
.Xr mount 1 ,
|
||||
.Xr chmod 2 ,
|
||||
.Xr stat 2 ,
|
||||
.Xr umask 2 ,
|
||||
@@ -326,7 +312,6 @@ option is non-standard and its use in scripts is not recommended.
|
||||
.Xr setmode 3 ,
|
||||
.Xr symlink 7 ,
|
||||
.Xr chown 8 ,
|
||||
.Xr mount 8 ,
|
||||
.Xr sticky 8
|
||||
.Sh STANDARDS
|
||||
The
|
||||
|
||||
+5
-12
@@ -42,7 +42,7 @@ static char const copyright[] =
|
||||
static char sccsid[] = "@(#)chmod.c 8.8 (Berkeley) 4/1/94";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
"$Id: chmod.c,v 1.11 1998/05/13 07:22:11 charnier Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
@@ -70,13 +70,12 @@ main(argc, argv)
|
||||
long val;
|
||||
int oct, omode;
|
||||
int Hflag, Lflag, Pflag, Rflag, ch, fflag, fts_options, hflag, rval;
|
||||
int vflag;
|
||||
char *ep, *mode;
|
||||
|
||||
set = NULL;
|
||||
omode = 0;
|
||||
Hflag = Lflag = Pflag = Rflag = fflag = hflag = vflag = 0;
|
||||
while ((ch = getopt(argc, argv, "HLPRXfgorstuvwx")) != -1)
|
||||
Hflag = Lflag = Pflag = Rflag = fflag = hflag = 0;
|
||||
while ((ch = getopt(argc, argv, "HLPRXfgorstuwx")) != -1)
|
||||
switch (ch) {
|
||||
case 'H':
|
||||
Hflag = 1;
|
||||
@@ -93,7 +92,7 @@ main(argc, argv)
|
||||
case 'R':
|
||||
Rflag = 1;
|
||||
break;
|
||||
case 'f':
|
||||
case 'f': /* XXX: undocumented. */
|
||||
fflag = 1;
|
||||
break;
|
||||
case 'h':
|
||||
@@ -119,9 +118,6 @@ main(argc, argv)
|
||||
argv[optind - 1][2] == '\0')
|
||||
--optind;
|
||||
goto done;
|
||||
case 'v':
|
||||
vflag = 1;
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
usage();
|
||||
@@ -195,9 +191,6 @@ done: argv += optind;
|
||||
getmode(set, p->fts_statp->st_mode)) && !fflag) {
|
||||
warn(p->fts_path);
|
||||
rval = 1;
|
||||
} else {
|
||||
if (vflag)
|
||||
(void)printf("%s\n", p->fts_accpath);
|
||||
}
|
||||
}
|
||||
if (errno)
|
||||
@@ -210,6 +203,6 @@ void
|
||||
usage()
|
||||
{
|
||||
(void)fprintf(stderr,
|
||||
"usage: chmod [-fv] [-R [-H | -L | -P]] mode file ...\n");
|
||||
"usage: chmod [-R [-H | -L | -P]] mode file ...\n");
|
||||
exit(1);
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
# @(#)Makefile 8.1 (Berkeley) 5/31/93
|
||||
# $FreeBSD$
|
||||
# $Id: Makefile,v 1.4 1997/02/22 14:01:32 peter Exp $
|
||||
|
||||
PROG= cp
|
||||
SRCS= cp.c utils.c
|
||||
|
||||
+3
-11
@@ -33,7 +33,7 @@
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)cp.1 8.3 (Berkeley) 4/18/94
|
||||
.\" $FreeBSD$
|
||||
.\" $Id: cp.1,v 1.11 1998/10/13 08:52:29 jkoshy Exp $
|
||||
.\"
|
||||
.Dd April 18, 1994
|
||||
.Dt CP 1
|
||||
@@ -48,7 +48,7 @@
|
||||
.Op Fl H | Fl L | Fl P
|
||||
.Oc
|
||||
.Op Fl f | i
|
||||
.Op Fl pv
|
||||
.Op Fl p
|
||||
.Ar source_file target_file
|
||||
.Nm cp
|
||||
.Oo
|
||||
@@ -56,7 +56,7 @@
|
||||
.Op Fl H | Fl L | Fl P
|
||||
.Oc
|
||||
.Op Fl f | i
|
||||
.Op Fl pv
|
||||
.Op Fl p
|
||||
.Ar source_file ... target_directory
|
||||
.Sh DESCRIPTION
|
||||
In the first synopsis form, the
|
||||
@@ -145,10 +145,6 @@ If the source file has both its set user ID and set group ID bits on,
|
||||
and either the user ID or group ID cannot be preserved, neither
|
||||
the set user ID nor set group ID bits are preserved in the copy's
|
||||
permissions.
|
||||
.It Fl v
|
||||
Cause
|
||||
.Nm
|
||||
to be verbose, showing files as they are copied.
|
||||
.El
|
||||
.Pp
|
||||
For each destination file that already exists, its contents are
|
||||
@@ -214,10 +210,6 @@ option.
|
||||
This implementation supports that option, however, its use is strongly
|
||||
discouraged, as it does not correctly copy special files, symbolic links
|
||||
or fifo's.
|
||||
.Pp
|
||||
The
|
||||
.Fl v
|
||||
option is non-standard and its use in scripts is not recommended.
|
||||
.Sh SEE ALSO
|
||||
.Xr mv 1 ,
|
||||
.Xr rcp 1 ,
|
||||
|
||||
+20
-27
@@ -45,7 +45,7 @@ static char const copyright[] =
|
||||
static char sccsid[] = "@(#)cp.c 8.2 (Berkeley) 4/1/94";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
"$Id: cp.c,v 1.17 1998/06/09 13:42:51 dt Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@@ -69,7 +69,6 @@ static const char rcsid[] =
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <fts.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@@ -80,10 +79,10 @@ static const char rcsid[] =
|
||||
*--(p).p_end = 0; \
|
||||
}
|
||||
|
||||
PATH_T to = { to.p_path, "", "" };
|
||||
PATH_T to = { to.p_path, "" };
|
||||
|
||||
uid_t myuid;
|
||||
int Rflag, iflag, pflag, rflag, fflag, vflag;
|
||||
int Rflag, iflag, pflag, rflag, fflag;
|
||||
int myumask;
|
||||
|
||||
enum op { FILE_TO_FILE, FILE_TO_DIR, DIR_TO_DNE };
|
||||
@@ -102,7 +101,7 @@ main(argc, argv)
|
||||
char *target;
|
||||
|
||||
Hflag = Lflag = Pflag = 0;
|
||||
while ((ch = getopt(argc, argv, "HLPRfiprv")) != -1)
|
||||
while ((ch = getopt(argc, argv, "HLPRfipr")) != -1)
|
||||
switch (ch) {
|
||||
case 'H':
|
||||
Hflag = 1;
|
||||
@@ -133,9 +132,6 @@ main(argc, argv)
|
||||
case 'r':
|
||||
rflag = 1;
|
||||
break;
|
||||
case 'v':
|
||||
vflag = 1;
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
break;
|
||||
@@ -253,23 +249,23 @@ copy(argv, type, fts_options)
|
||||
struct stat to_stat;
|
||||
FTS *ftsp;
|
||||
FTSENT *curr;
|
||||
int base = 0, dne, badcp, nlen, rval;
|
||||
int base = 0, dne, nlen, rval;
|
||||
char *p, *target_mid;
|
||||
|
||||
if ((ftsp = fts_open(argv, fts_options, mastercmp)) == NULL)
|
||||
err(1, NULL);
|
||||
for (badcp = rval = 0; (curr = fts_read(ftsp)) != NULL; badcp = 0) {
|
||||
for (rval = 0; (curr = fts_read(ftsp)) != NULL;) {
|
||||
switch (curr->fts_info) {
|
||||
case FTS_NS:
|
||||
case FTS_DNR:
|
||||
case FTS_ERR:
|
||||
warnx("%s: %s",
|
||||
curr->fts_path, strerror(curr->fts_errno));
|
||||
badcp = rval = 1;
|
||||
rval = 1;
|
||||
continue;
|
||||
case FTS_DC: /* Warn, continue. */
|
||||
warnx("%s: directory causes a cycle", curr->fts_path);
|
||||
badcp = rval = 1;
|
||||
rval = 1;
|
||||
continue;
|
||||
case FTS_DP: /* Ignore, continue. */
|
||||
continue;
|
||||
@@ -299,7 +295,7 @@ copy(argv, type, fts_options)
|
||||
* Since the first level MUST be FTS_ROOTLEVEL, base
|
||||
* is always initialized.
|
||||
*/
|
||||
if (curr->fts_level == FTS_ROOTLEVEL) {
|
||||
if (curr->fts_level == FTS_ROOTLEVEL)
|
||||
if (type != DIR_TO_DNE) {
|
||||
p = strrchr(curr->fts_path, '/');
|
||||
base = (p == NULL) ? 0 :
|
||||
@@ -310,7 +306,6 @@ copy(argv, type, fts_options)
|
||||
base += 1;
|
||||
} else
|
||||
base = curr->fts_pathlen;
|
||||
}
|
||||
|
||||
p = &curr->fts_path[base];
|
||||
nlen = curr->fts_pathlen - base;
|
||||
@@ -321,7 +316,7 @@ copy(argv, type, fts_options)
|
||||
if (target_mid - to.p_path + nlen > MAXPATHLEN) {
|
||||
warnx("%s%s: name too long (not copied)",
|
||||
to.p_path, p);
|
||||
badcp = rval = 1;
|
||||
rval = 1;
|
||||
continue;
|
||||
}
|
||||
(void)strncat(target_mid, p, nlen);
|
||||
@@ -338,7 +333,7 @@ copy(argv, type, fts_options)
|
||||
to_stat.st_ino == curr->fts_statp->st_ino) {
|
||||
warnx("%s and %s are identical (not copied).",
|
||||
to.p_path, curr->fts_path);
|
||||
badcp = rval = 1;
|
||||
rval = 1;
|
||||
if (S_ISDIR(curr->fts_statp->st_mode))
|
||||
(void)fts_set(ftsp, curr, FTS_SKIP);
|
||||
continue;
|
||||
@@ -347,7 +342,7 @@ copy(argv, type, fts_options)
|
||||
S_ISDIR(to_stat.st_mode)) {
|
||||
warnx("cannot overwrite directory %s with non-directory %s",
|
||||
to.p_path, curr->fts_path);
|
||||
badcp = rval = 1;
|
||||
rval = 1;
|
||||
continue;
|
||||
}
|
||||
dne = 0;
|
||||
@@ -356,14 +351,14 @@ copy(argv, type, fts_options)
|
||||
switch (curr->fts_statp->st_mode & S_IFMT) {
|
||||
case S_IFLNK:
|
||||
if (copy_link(curr, !dne))
|
||||
badcp = rval = 1;
|
||||
rval = 1;
|
||||
break;
|
||||
case S_IFDIR:
|
||||
if (!Rflag && !rflag) {
|
||||
warnx("%s is a directory (not copied).",
|
||||
curr->fts_path);
|
||||
(void)fts_set(ftsp, curr, FTS_SKIP);
|
||||
badcp = rval = 1;
|
||||
rval = 1;
|
||||
break;
|
||||
}
|
||||
/*
|
||||
@@ -389,7 +384,7 @@ copy(argv, type, fts_options)
|
||||
* forever.
|
||||
*/
|
||||
if (pflag && setfile(curr->fts_statp, 0))
|
||||
badcp = rval = 1;
|
||||
rval = 1;
|
||||
else if (dne)
|
||||
(void)chmod(to.p_path,
|
||||
curr->fts_statp->st_mode);
|
||||
@@ -398,28 +393,26 @@ copy(argv, type, fts_options)
|
||||
case S_IFCHR:
|
||||
if (Rflag) {
|
||||
if (copy_special(curr->fts_statp, !dne))
|
||||
badcp = rval = 1;
|
||||
rval = 1;
|
||||
} else {
|
||||
if (copy_file(curr, dne))
|
||||
badcp = rval = 1;
|
||||
rval = 1;
|
||||
}
|
||||
break;
|
||||
case S_IFIFO:
|
||||
if (Rflag) {
|
||||
if (copy_fifo(curr->fts_statp, !dne))
|
||||
badcp = rval = 1;
|
||||
rval = 1;
|
||||
} else {
|
||||
if (copy_file(curr, dne))
|
||||
badcp = rval = 1;
|
||||
rval = 1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (copy_file(curr, dne))
|
||||
badcp = rval = 1;
|
||||
rval = 1;
|
||||
break;
|
||||
}
|
||||
if (vflag && !badcp)
|
||||
(void)printf("%s -> %s\n", curr->fts_path, to.p_path);
|
||||
}
|
||||
if (errno)
|
||||
err(1, "fts_read");
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)extern.h 8.2 (Berkeley) 4/1/94
|
||||
* $FreeBSD$
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
|
||||
+5
-8
@@ -36,7 +36,7 @@
|
||||
static char sccsid[] = "@(#)utils.c 8.3 (Berkeley) 4/1/94";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
"$Id: utils.c,v 1.21 1998/11/18 11:47:45 bde Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@@ -50,7 +50,6 @@ static const char rcsid[] =
|
||||
#include <fcntl.h>
|
||||
#include <fts.h>
|
||||
#include <stdio.h>
|
||||
#include <sysexits.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "extern.h"
|
||||
@@ -184,7 +183,7 @@ copy_file(entp, dne)
|
||||
*/
|
||||
#define RETAINBITS \
|
||||
(S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO)
|
||||
else if (fs->st_mode & (S_ISUID | S_ISGID) && fs->st_uid == myuid) {
|
||||
else if (fs->st_mode & (S_ISUID | S_ISGID) && fs->st_uid == myuid)
|
||||
if (fstat(to_fd, &to_stat)) {
|
||||
warn("%s", to.p_path);
|
||||
rval = 1;
|
||||
@@ -193,7 +192,6 @@ copy_file(entp, dne)
|
||||
warn("%s", to.p_path);
|
||||
rval = 1;
|
||||
}
|
||||
}
|
||||
(void)close(from_fd);
|
||||
if (close(to_fd)) {
|
||||
warn("%s", to.p_path);
|
||||
@@ -321,9 +319,8 @@ setfile(fs, fd)
|
||||
void
|
||||
usage()
|
||||
{
|
||||
|
||||
(void)fprintf(stderr, "%s\n%s\n",
|
||||
"usage: cp [-R [-H | -L | -P]] [-f | -i] [-pv] src target",
|
||||
" cp [-R [-H | -L | -P]] [-f | -i] [-pv] src1 ... srcN directory");
|
||||
exit(EX_USAGE);
|
||||
"usage: cp [-R [-H | -L | -P]] [-f | -i] [-p] src target",
|
||||
" cp [-R [-H | -L | -P]] [-f | -i] [-p] src1 ... srcN directory");
|
||||
exit(1);
|
||||
}
|
||||
+5
-5
@@ -1,4 +1,4 @@
|
||||
# $FreeBSD$
|
||||
# $Id: Makefile,v 1.8 1997/08/07 21:42:01 steve Exp $
|
||||
# @(#)Makefile 8.1 (Berkeley) 5/31/93
|
||||
#
|
||||
# C Shell with process control; VM/UNIX VAX Makefile
|
||||
@@ -15,10 +15,10 @@ SRCS= alloc.c char.c const.c csh.c dir.c dol.c err.c exec.c exp.c file.c \
|
||||
.PATH: ${.CURDIR}/../../usr.bin/printf
|
||||
|
||||
MAN1= csh.1
|
||||
# MLINKS for Shell built in commands for which there are no userland
|
||||
# utilities of the same name are handled with the associated manpage,
|
||||
# builtin.1 in share/man/man1/.
|
||||
|
||||
MLINKS= csh.1 limit.1 csh.1 alias.1 csh.1 bg.1 csh.1 dirs.1 csh.1 fg.1 \
|
||||
csh.1 foreach.1 csh.1 history.1 csh.1 jobs.1 csh.1 popd.1 \
|
||||
csh.1 pushd.1 csh.1 rehash.1 csh.1 repeat.1 csh.1 suspend.1 \
|
||||
csh.1 stop.1 csh.1 source.1
|
||||
CLEANFILES+=const.h errnum.h
|
||||
|
||||
const.h: errnum.h
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# @(#)Makefile 8.1 (Berkeley) 8/14/93
|
||||
# $FreeBSD$
|
||||
# $Id$
|
||||
|
||||
DIR= usd/04.csh
|
||||
SRCS= tabs csh.1 csh.2 csh.3 csh.4 csh.a csh.g
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)csh.1 8.1 (Berkeley) 6/8/93
|
||||
.\" $FreeBSD$
|
||||
.\" $Id$
|
||||
.\"
|
||||
.EH 'USD:4-%''An Introduction to the C shell'
|
||||
.OH 'An Introduction to the C shell''USD:4-%'
|
||||
@@ -875,8 +875,7 @@ to remind you which command is being continued, and cause the command
|
||||
to resume execution. Unless any input files in use by the suspended
|
||||
command have been changed in the meantime, the suspension has no effect
|
||||
whatsoever on the execution of the command. This feature can be very useful
|
||||
during editing, when you need to look at another file before continuing.
|
||||
An
|
||||
during editing, when you need to look at another file before continuing. An
|
||||
example of command suspension follows.
|
||||
.DS
|
||||
% mail harold
|
||||
@@ -904,8 +903,7 @@ suspended, it typed `Stopped' and prompted for a new command. Then the
|
||||
.I ls
|
||||
command was typed to find out the name of the file. The
|
||||
.I jobs
|
||||
command was run to find out which command was suspended.
|
||||
At this time the
|
||||
command was run to find out which command was suspended. At this time the
|
||||
.I fg
|
||||
command was typed to continue execution of the mail program. Input
|
||||
to the mail program was then continued and ended with a ^D
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)csh.2 8.1 (Berkeley) 6/8/93
|
||||
.\" $FreeBSD$
|
||||
.\" $Id$
|
||||
.\"
|
||||
.nr H1 1
|
||||
.NH
|
||||
@@ -678,8 +678,7 @@ the same until the job terminates and then are re-used.
|
||||
.PP
|
||||
When a job is started in the backgound using `&', its number, as well
|
||||
as the process numbers of all its (top level) commands, is typed by the shell
|
||||
before prompting you for another command.
|
||||
For example,
|
||||
before prompting you for another command. For example,
|
||||
.DS
|
||||
% ls \-s | sort \-n > usage &
|
||||
[2] 2034 2035
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)csh.3 8.1 (Berkeley) 6/8/93
|
||||
.\" $FreeBSD$
|
||||
.\" $Id$
|
||||
.\"
|
||||
.nr H1 2
|
||||
.NH
|
||||
@@ -224,8 +224,7 @@ is quite special and is replaced by the next line of input read from
|
||||
the shell's standard input (not the script it is reading). This is
|
||||
useful for writing shell scripts that are interactive, reading
|
||||
commands from the terminal, or even writing a shell script that
|
||||
acts as a filter, reading lines from its input file.
|
||||
Thus the sequence
|
||||
acts as a filter, reading lines from its input file. Thus the sequence
|
||||
.DS
|
||||
echo 'yes or no?\ec'
|
||||
set a=($<)
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)csh.4 8.1 (Berkeley) 6/8/93
|
||||
.\" $FreeBSD$
|
||||
.\" $Id$
|
||||
.\"
|
||||
.nr H1 3
|
||||
.NH
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)csh.a 8.1 (Berkeley) 6/8/93
|
||||
.\" $FreeBSD$
|
||||
.\" $Id$
|
||||
.\"
|
||||
.SH
|
||||
Appendix \- Special characters
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)csh.g 8.1 (Berkeley) 6/8/93
|
||||
.\" $FreeBSD$
|
||||
.\" $Id$
|
||||
.\"
|
||||
.SH
|
||||
Glossary
|
||||
|
||||
@@ -30,6 +30,6 @@
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)tabs 8.1 (Berkeley) 6/8/93
|
||||
.\" $FreeBSD$
|
||||
.\" $Id$
|
||||
.\"
|
||||
.ta 5n 10n 15n 20n 25n 30n 35n 40n 45n 50n 55n 60n 65n 70n 75n 80n
|
||||
+1
-1
@@ -36,7 +36,7 @@
|
||||
static char sccsid[] = "@(#)alloc.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
"$Id: alloc.c,v 1.8 1998/05/06 06:50:37 charnier Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@
|
||||
static char sccsid[] = "@(#)char.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
"$Id: char.c,v 1.4 1997/02/22 14:01:37 peter Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)char.h 8.1 (Berkeley) 5/31/93
|
||||
* $FreeBSD$
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@
|
||||
static char sccsid[] = "@(#)const.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
"$Id: const.c,v 1.6 1997/02/22 14:01:39 peter Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
||||
+20
-34
@@ -30,7 +30,7 @@
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)csh.1 8.2 (Berkeley) 1/21/94
|
||||
.\" $FreeBSD$
|
||||
.\" $Id: csh.1,v 1.11 1998/07/27 21:31:19 nectar Exp $
|
||||
.\"
|
||||
.Dd January 21, 1994
|
||||
.Dt CSH 1
|
||||
@@ -55,11 +55,10 @@ job control facilities (see
|
||||
interactive file name
|
||||
and user name completion (see
|
||||
.Sx File Name Completion ) ,
|
||||
and a C-like syntax.
|
||||
It is used both as an interactive login shell and
|
||||
a shell script command processor.
|
||||
and a C-like syntax. It is used both as an interactive
|
||||
login shell and a shell script command processor.
|
||||
.Ss Argument list processing
|
||||
If the shell is executed with a program name starting with
|
||||
If the first argument (argument 0) to the shell is
|
||||
.Ql Fl \& ,
|
||||
then this is a login shell.
|
||||
A login shell also can be specified by invoking the shell with the
|
||||
@@ -132,11 +131,12 @@ variable to be set even before
|
||||
.Pa .cshrc
|
||||
is executed.
|
||||
.It Fl X
|
||||
Cause the
|
||||
.Ar echo
|
||||
variable to be set even before
|
||||
.Pa .cshrc
|
||||
is executed.
|
||||
Is to
|
||||
.Fl x
|
||||
as
|
||||
.Fl V
|
||||
is to
|
||||
.Fl v .
|
||||
.El
|
||||
.Pp
|
||||
After processing of flag arguments, if arguments remain but none of the
|
||||
@@ -236,9 +236,8 @@ may be a component of a pipeline, etc.).
|
||||
It is also possible to separate pipelines with `\&|\&|' or `&&' showing,
|
||||
as in the C language,
|
||||
that the second is to be executed only if the first fails or succeeds
|
||||
respectively.
|
||||
See
|
||||
.Sx Expressions .
|
||||
respectively. (See
|
||||
.Em Expressions . )
|
||||
.Ss Jobs
|
||||
The shell associates a
|
||||
.Ar job
|
||||
@@ -318,15 +317,12 @@ The job control mechanism requires that the
|
||||
.Xr stty 1
|
||||
option
|
||||
.Ic new
|
||||
be set.
|
||||
It is an artifact from a
|
||||
be set. It is an artifact from a
|
||||
.Em new
|
||||
implementation
|
||||
of the
|
||||
tty driver that allows generation of interrupt characters from
|
||||
the keyboard to tell jobs to stop. See
|
||||
.Xr stty 1
|
||||
for details
|
||||
the keyboard to tell jobs to stop. See stty(1) for details
|
||||
on setting options in the new tty driver.
|
||||
.Ss Status reporting
|
||||
This shell learns immediately whenever a process changes state.
|
||||
@@ -570,8 +566,8 @@ Repeat the previous substitution.
|
||||
Apply the change once on each word, prefixing the above, e.g., `g&'.
|
||||
.It a
|
||||
Apply the change as many times as possible on a single word, prefixing
|
||||
the above.
|
||||
It can be used together with `g' to apply a substitution globally.
|
||||
the above. It can be used together with `g' to apply a substitution
|
||||
globally.
|
||||
.It p
|
||||
Print the new command line but do not execute it.
|
||||
.It q
|
||||
@@ -1491,7 +1487,7 @@ entry in the stack.
|
||||
The members of the directory stack are numbered from the top starting at 0.
|
||||
.Pp
|
||||
.It Ic printf Ar format-string values
|
||||
Invokes a builtin version of
|
||||
Invokes a built-in version of
|
||||
.Ic printf
|
||||
after evaluating the
|
||||
.Ar format-string
|
||||
@@ -2138,18 +2134,9 @@ To detect looping, the shell restricts the number of
|
||||
.Ic alias
|
||||
substitutions on a single line to 20.
|
||||
.Sh SEE ALSO
|
||||
.Xr builtin 1 ,
|
||||
.Xr echo 1 ,
|
||||
.Xr kill 1 ,
|
||||
.Xr login 1 ,
|
||||
.Xr nice 1 ,
|
||||
.Xr nohup 1 ,
|
||||
.Xr printenv 1 ,
|
||||
.Xr printf 1 ,
|
||||
.Xr sh 1 ,
|
||||
.Xr su 1 ,
|
||||
.Xr time 1 ,
|
||||
.Xr which 1 ,
|
||||
.Xr access 2 ,
|
||||
.Xr execve 2 ,
|
||||
.Xr fork 2 ,
|
||||
@@ -2162,9 +2149,8 @@ substitutions on a single line to 20.
|
||||
.Xr tty 4 ,
|
||||
.Xr a.out 5 ,
|
||||
.Xr environ 7
|
||||
.Rs
|
||||
.%T "An introduction to the C shell"
|
||||
.Re
|
||||
.br
|
||||
.Em An introduction to the C shell
|
||||
.Sh HISTORY
|
||||
.Nm Csh
|
||||
appeared in
|
||||
@@ -2208,7 +2194,7 @@ shell procedures should be provided instead of aliases.
|
||||
Commands within loops, prompted for by `?', are not placed on the
|
||||
.Ic history
|
||||
list.
|
||||
Control structure should be parsed instead of being recognized as builtin
|
||||
Control structure should be parsed instead of being recognized as built-in
|
||||
commands. This would allow control commands to be placed anywhere,
|
||||
to be combined with `\&|', and to be used with `&' and `;' metasyntax.
|
||||
.Pp
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ static const char copyright[] =
|
||||
static char sccsid[] = "@(#)csh.c 8.2 (Berkeley) 10/12/93";
|
||||
#else
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
"$Id: csh.c,v 1.13 1998/02/28 10:49:52 jraynard Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)csh.h 8.1 (Berkeley) 5/31/93
|
||||
* $FreeBSD$
|
||||
* $Id: csh.h,v 1.6 1997/08/08 00:53:59 steve Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@
|
||||
static char sccsid[] = "@(#)dir.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
"$Id: dir.c,v 1.8 1998/06/09 03:38:37 imp Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)dir.h 8.1 (Berkeley) 5/31/93
|
||||
* $FreeBSD$
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
+6
-14
@@ -36,11 +36,10 @@
|
||||
static char sccsid[] = "@(#)dol.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
"$Id: dol.c,v 1.7 1998/05/06 06:50:39 charnier Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
@@ -851,20 +850,13 @@ heredoc(term)
|
||||
Char **vp;
|
||||
bool quoted;
|
||||
char *tmp;
|
||||
struct timeval tv;
|
||||
|
||||
again:
|
||||
tmp = short2str(shtemp);
|
||||
if (open(tmp, O_RDWR|O_CREAT|O_TRUNC|O_EXCL, 0600) < 0) {
|
||||
if (creat(tmp = short2str(shtemp), 0600) < 0)
|
||||
stderror(ERR_SYSTEM, tmp, strerror(errno));
|
||||
(void) close(0);
|
||||
if (open(tmp, O_RDWR) < 0) {
|
||||
int oerrno = errno;
|
||||
if (errno == EEXIST) {
|
||||
if (unlink(tmp) == -1) {
|
||||
(void) gettimeofday(&tv, NULL);
|
||||
shtemp = Strspl(STRtmpsh, putn((((int)tv.tv_sec) ^
|
||||
((int)tv.tv_usec) ^ ((int)getpid())) & 0x00ffffff));
|
||||
}
|
||||
goto again;
|
||||
}
|
||||
|
||||
(void) unlink(tmp);
|
||||
errno = oerrno;
|
||||
stderror(ERR_SYSTEM, tmp, strerror(errno));
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@
|
||||
static char sccsid[] = "@(#)err.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
"$Id: err.c,v 1.8 1998/05/13 07:28:55 charnier Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@
|
||||
static char sccsid[] = "@(#)exec.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
"$Id: exec.c,v 1.9 1998/02/28 10:49:54 jraynard Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@
|
||||
static char sccsid[] = "@(#)exp.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
"$Id: exp.c,v 1.6 1998/05/06 06:50:44 charnier Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)extern.h 8.1 (Berkeley) 5/31/93
|
||||
* $FreeBSD$
|
||||
* $Id: extern.h,v 1.4 1997/02/22 14:01:53 peter Exp $
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@
|
||||
static char sccsid[] = "@(#)file.c 8.2 (Berkeley) 3/19/94";
|
||||
#else
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
"$Id: file.c,v 1.8 1998/02/01 17:11:01 steve Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@
|
||||
static char sccsid[] = "@(#)func.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
"$Id: func.c,v 1.11 1998/07/27 21:15:52 nectar Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@
|
||||
static char sccsid[] = "@(#)glob.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
"$Id: glob.c,v 1.10 1997/08/08 00:54:03 steve Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@
|
||||
static char sccsid[] = "@(#)hist.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
"$Id: hist.c,v 1.7 1998/05/06 06:50:50 charnier Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@
|
||||
static char sccsid[] = "@(#)init.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
"$Id: init.c,v 1.4 1997/02/22 14:02:00 peter Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@
|
||||
static char sccsid[] = "@(#)lex.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
"$Id: lex.c,v 1.10 1998/05/13 07:29:05 charnier Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@
|
||||
static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
"$Id: misc.c,v 1.7 1998/05/06 06:50:53 charnier Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@
|
||||
static char sccsid[] = "@(#)parse.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
"$Id: parse.c,v 1.7 1998/05/06 06:50:56 charnier Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)pathnames.h 8.1 (Berkeley) 5/31/93
|
||||
* $FreeBSD$
|
||||
* $Id: pathnames.h,v 1.4 1997/02/22 14:02:05 peter Exp $
|
||||
*/
|
||||
|
||||
#define _PATH_BIN "/bin"
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@
|
||||
static char sccsid[] = "@(#)proc.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
"$Id: proc.c,v 1.9 1998/05/06 06:50:58 charnier Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)proc.h 8.1 (Berkeley) 5/31/93
|
||||
* $FreeBSD$
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@
|
||||
static char sccsid[] = "@(#)sem.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
"$Id: sem.c,v 1.8 1998/05/06 06:51:00 charnier Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@
|
||||
static char sccsid[] = "@(#)set.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
"$Id: set.c,v 1.10 1998/05/13 07:29:15 charnier Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@
|
||||
static char sccsid[] = "@(#)str.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
"$Id: str.c,v 1.5 1997/02/22 14:02:09 peter Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@
|
||||
static char sccsid[] = "@(#)time.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
"$Id: time.c,v 1.8 1997/08/07 21:42:17 steve Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
# @(#)Makefile 8.1 (Berkeley) 5/31/93
|
||||
# $FreeBSD$
|
||||
# $Id: Makefile,v 1.6 1997/08/09 22:34:01 brian Exp $
|
||||
|
||||
PROG= date
|
||||
SRCS= date.c netdate.c vary.c
|
||||
|
||||
+6
-36
@@ -33,7 +33,7 @@
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)date.1 8.3 (Berkeley) 4/28/95
|
||||
.\" $FreeBSD$
|
||||
.\" $Id: date.1,v 1.26.2.1 1999/05/02 06:28:06 kris Exp $
|
||||
.\"
|
||||
.Dd November 17, 1993
|
||||
.Dt DATE 1
|
||||
@@ -49,7 +49,7 @@
|
||||
.Op Fl t Ar minutes_west
|
||||
.Op Fl v Ns Ar [+|-]val Ns Op ymwdHMS
|
||||
.Ar ...
|
||||
.Op Fl f Ar fmt Ar date | [[[[[cc]yy]mm]dd]HH]MM[\&.ss]
|
||||
.Op Fl f Ar fmt Ar date | [[[[yy]mm]dd]HH]MM[\&.ss]
|
||||
.Op Cm + Ns Ar format
|
||||
.Sh DESCRIPTION
|
||||
.Nm Date
|
||||
@@ -74,7 +74,7 @@ Use
|
||||
.Ar fmt
|
||||
as the format string to parse the date provided rather than using
|
||||
the default
|
||||
.Ar [[[[[cc]yy]mm]dd]HH]MM[.ss]
|
||||
.Ar [[[[yy]mm]dd]HH]MM[.ss]
|
||||
format. Parsing is done using
|
||||
.Xr strptime 3 .
|
||||
.It Fl n
|
||||
@@ -92,14 +92,9 @@ option stops
|
||||
.Nm
|
||||
from setting the time for other than the current machine.
|
||||
.It Fl r
|
||||
Print out the date and time that is
|
||||
Print out the date and time in
|
||||
.Ar seconds
|
||||
from the Epoch
|
||||
.Po
|
||||
00:00:00 UTC, January 1, 1970;
|
||||
see
|
||||
.Xr time 3
|
||||
.Pc .
|
||||
from the Epoch.
|
||||
.It Fl t
|
||||
Set the kernel's value for minutes west of
|
||||
.Tn GMT .
|
||||
@@ -122,9 +117,7 @@ or backwards according to the remaining string, otherwise the relevant
|
||||
part of the date is set. The date can be adjusted as many times as
|
||||
required using these flags. Flags are processed in the order given.
|
||||
.Pp
|
||||
When setting values
|
||||
.Pq rather than adjusting them ,
|
||||
seconds are in the range 0-59, minutes are in the range 0-59, hours are
|
||||
Seconds are in the range 0-59, minutes are in the range 0-59, hours are
|
||||
in the range 1-12, month days are in the range 1-31, week days are in the
|
||||
range 0-6 (Sun-Sat), months are in the range 1-12 (Jan-Dec) and years are
|
||||
in the range 80-38 or 1980-2038.
|
||||
@@ -148,27 +141,6 @@ will be put forwards (or backwards) to the next (previous) date that
|
||||
matches the given week day or month. This will not adjust the date
|
||||
if the given week day or month is the same as the current one.
|
||||
.Pp
|
||||
When a date is adjusted to a specific value or in units greater than hours,
|
||||
daylight savings time considerations are ignored.
|
||||
Adjustments in units of hours or less honour daylight savings time.
|
||||
So, assuming the current date is March 26, 0:30 and that the DST adjustment
|
||||
means that the clock goes forward at 01:00 to 02:00, using
|
||||
.Fl v No +1H
|
||||
will adjust the date to March 26, 2:30.
|
||||
Likewise, if the date is October 29, 0:30 and the DST adjustment means that
|
||||
the clock goes back at 02:00 to 01:00, using
|
||||
.Fl v No +3H
|
||||
will be necessary to reach October 20, 2:30.
|
||||
.Pp
|
||||
When the date is adjusted to a specific value that doesn't actually exist
|
||||
.Pq for example March 26, 1:30 BST 2000 ,
|
||||
the date will be silently adjusted forwards in units of one hour until it
|
||||
reaches a valid time.
|
||||
When the date is adjusted to a specific value that occurs twice
|
||||
.Pq for example October 29, 1:30 2000 ,
|
||||
the resulting timezone will be set so that the date matches the earlier of
|
||||
the two times.
|
||||
.Pp
|
||||
Refer to the examples below for further details.
|
||||
.El
|
||||
.Pp
|
||||
@@ -190,8 +162,6 @@ a value for setting the system's notion of the current date and time.
|
||||
The canonical representation for setting the date and time is:
|
||||
.Pp
|
||||
.Bl -tag -width Ds -compact -offset indent
|
||||
.It Ar cc
|
||||
Century (either 19 or 20) prepended to the abbreviated year.
|
||||
.It Ar yy
|
||||
Year in abbreviated form (e.g. 89 for 1989, 06 for 2006).
|
||||
.It Ar mm
|
||||
|
||||
+5
-12
@@ -42,7 +42,7 @@ static char const copyright[] =
|
||||
static char sccsid[] = "@(#)date.c 8.2 (Berkeley) 4/28/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
"$Id: date.c,v 1.27 1999/03/09 09:38:54 brian Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@@ -170,8 +170,6 @@ main(argc, argv)
|
||||
}
|
||||
|
||||
#define ATOI2(ar) ((ar)[0] - '0') * 10 + ((ar)[1] - '0'); (ar) += 2;
|
||||
#define ATOI4(ar) ((ar)[0] - '0') * 1000 + ((ar)[1] - '0') * 100 + \
|
||||
((ar)[2] - '0') * 10 + ((ar)[3] - '0'); (ar) += 4;
|
||||
void
|
||||
setthetime(fmt, p)
|
||||
const char *fmt;
|
||||
@@ -187,7 +185,8 @@ setthetime(fmt, p)
|
||||
if (t == NULL) {
|
||||
fprintf(stderr, "Failed conversion of ``%s''"
|
||||
" using format ``%s''\n", p, fmt);
|
||||
badformat();
|
||||
lt = localtime(&tval);
|
||||
return;
|
||||
} else if (*t != '\0')
|
||||
fprintf(stderr, "Warning: Ignoring %ld extraneous"
|
||||
" characters in date string (%s)\n",
|
||||
@@ -217,16 +216,11 @@ setthetime(fmt, p)
|
||||
|
||||
/* if p has a ".ss" field then let's pretend it's not there */
|
||||
switch (strlen(p) - ((dot != NULL) ? 3 : 0)) {
|
||||
case 12: /* cc */
|
||||
lt->tm_year = -1900 + ATOI4(p);
|
||||
if (lt->tm_year < 0)
|
||||
badformat();
|
||||
goto year_done;
|
||||
case 10: /* yy */
|
||||
lt->tm_year = ATOI2(p);
|
||||
if (lt->tm_year < 69) /* hack for 2000 ;-} */
|
||||
lt->tm_year += 100;
|
||||
year_done: /* FALLTHROUGH */
|
||||
/* FALLTHROUGH */
|
||||
case 8: /* mm */
|
||||
lt->tm_mon = ATOI2(p);
|
||||
if (lt->tm_mon > 12)
|
||||
@@ -285,7 +279,6 @@ usage()
|
||||
(void)fprintf(stderr, "%s\n%s\n",
|
||||
"usage: date [-nu] [-d dst] [-r seconds] [-t west] "
|
||||
"[-v[+|-]val[ymwdHMS]] ... ",
|
||||
" "
|
||||
"[-f fmt date | [[[[[cc]yy]mm]dd]HH]MM[.ss]] [+format]");
|
||||
" [-f fmt date | [[[[yy]mm]dd]HH]MM[.ss]] [+format]");
|
||||
exit(1);
|
||||
}
|
||||
+1
-1
@@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)extern.h 8.1 (Berkeley) 5/31/93
|
||||
* $FreeBSD$
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
int netsettime __P((time_t));
|
||||
+1
-1
@@ -36,7 +36,7 @@
|
||||
static char sccsid[] = "@(#)netdate.c 8.1 (Berkeley) 5/31/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
"$Id: netdate.c,v 1.9 1998/05/06 06:51:18 charnier Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
+89
-132
@@ -26,7 +26,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
"$Id: vary.c,v 1.5 1999/03/09 09:38:54 brian Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <time.h>
|
||||
@@ -41,8 +41,8 @@ struct trans {
|
||||
|
||||
static struct trans trans_mon[] = {
|
||||
{ 1, "january" }, { 2, "february" }, { 3, "march" }, { 4, "april" },
|
||||
{ 5, "may"}, { 6, "june" }, { 7, "july" }, { 8, "august" },
|
||||
{ 9, "september" }, { 10, "october" }, { 11, "november" }, { 12, "december" },
|
||||
{ 6, "june" }, { 7, "july" }, { 8, "august" }, { 9, "september" },
|
||||
{ 10, "october" }, { 11, "november" }, { 12, "december" },
|
||||
{ -1, NULL }
|
||||
};
|
||||
|
||||
@@ -53,19 +53,6 @@ static struct trans trans_wday[] = {
|
||||
};
|
||||
|
||||
static char digits[] = "0123456789";
|
||||
static int adjhour(struct tm *, char, int, int);
|
||||
|
||||
static int
|
||||
domktime(struct tm *t, char type)
|
||||
{
|
||||
time_t ret;
|
||||
|
||||
while ((ret = mktime(t)) == -1 && t->tm_year > 68 && t->tm_year < 138)
|
||||
/* While mktime() fails, adjust by an hour */
|
||||
adjhour(t, type == '-' ? type : '+', 1, 0);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
trans(const struct trans t[], const char *arg)
|
||||
@@ -125,7 +112,7 @@ daysinmonth(const struct tm *t)
|
||||
|
||||
|
||||
static int
|
||||
adjyear(struct tm *t, char type, int val, int mk)
|
||||
adjyear(struct tm *t, char type, int val)
|
||||
{
|
||||
switch (type) {
|
||||
case '+':
|
||||
@@ -142,51 +129,45 @@ adjyear(struct tm *t, char type, int val, int mk)
|
||||
t->tm_year -= 1900; /* struct tm holds years since 1900 */
|
||||
break;
|
||||
}
|
||||
return !mk || domktime(t, type) != -1;
|
||||
return mktime(t) != -1;
|
||||
}
|
||||
|
||||
static int
|
||||
adjmon(struct tm *t, char type, int val, int istext, int mk)
|
||||
adjmon(struct tm *t, char type, int val, int istext)
|
||||
{
|
||||
if (val < 0)
|
||||
return 0;
|
||||
|
||||
switch (type) {
|
||||
case '+':
|
||||
if (istext) {
|
||||
if (istext)
|
||||
if (val <= t->tm_mon)
|
||||
val += 11 - t->tm_mon; /* early next year */
|
||||
else
|
||||
val -= t->tm_mon + 1; /* later this year */
|
||||
}
|
||||
if (val) {
|
||||
if (!adjyear(t, '+', (t->tm_mon + val) / 12, 0))
|
||||
return 0;
|
||||
val %= 12;
|
||||
t->tm_mon += val;
|
||||
if (t->tm_mon > 11)
|
||||
t->tm_mon -= 12;
|
||||
}
|
||||
if (!adjyear(t, '+', (t->tm_mon + val) / 12))
|
||||
return 0;
|
||||
val %= 12;
|
||||
t->tm_mon += val;
|
||||
if (t->tm_mon > 11)
|
||||
t->tm_mon -= 12;
|
||||
break;
|
||||
|
||||
case '-':
|
||||
if (istext) {
|
||||
if (istext)
|
||||
if (val-1 > t->tm_mon)
|
||||
val = 13 - val + t->tm_mon; /* later last year */
|
||||
else
|
||||
val = t->tm_mon - val + 1; /* early this year */
|
||||
}
|
||||
if (val) {
|
||||
if (!adjyear(t, '-', val / 12, 0))
|
||||
if (!adjyear(t, '-', val / 12))
|
||||
return 0;
|
||||
val %= 12;
|
||||
if (val > t->tm_mon) {
|
||||
if (!adjyear(t, '-', 1))
|
||||
return 0;
|
||||
val %= 12;
|
||||
if (val > t->tm_mon) {
|
||||
if (!adjyear(t, '-', 1, 0))
|
||||
return 0;
|
||||
val -= 12;
|
||||
}
|
||||
t->tm_mon -= val;
|
||||
val -= 12;
|
||||
}
|
||||
t->tm_mon -= val;
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -195,14 +176,13 @@ adjmon(struct tm *t, char type, int val, int istext, int mk)
|
||||
t->tm_mon = --val;
|
||||
}
|
||||
|
||||
return !mk || domktime(t, type) != -1;
|
||||
return mktime(t) != -1;
|
||||
}
|
||||
|
||||
static int
|
||||
adjday(struct tm *t, char type, int val, int mk)
|
||||
adjday(struct tm *t, char type, int val)
|
||||
{
|
||||
int mdays;
|
||||
|
||||
switch (type) {
|
||||
case '+':
|
||||
while (val) {
|
||||
@@ -210,7 +190,7 @@ adjday(struct tm *t, char type, int val, int mk)
|
||||
if (val > mdays - t->tm_mday) {
|
||||
val -= mdays - t->tm_mday + 1;
|
||||
t->tm_mday = 1;
|
||||
if (!adjmon(t, '+', 1, 0, 0))
|
||||
if (!adjmon(t, '+', 1, 0))
|
||||
return 0;
|
||||
} else {
|
||||
t->tm_mday += val;
|
||||
@@ -223,7 +203,7 @@ adjday(struct tm *t, char type, int val, int mk)
|
||||
if (val >= t->tm_mday) {
|
||||
val -= t->tm_mday;
|
||||
t->tm_mday = 1;
|
||||
if (!adjmon(t, '-', 1, 0, 0))
|
||||
if (!adjmon(t, '-', 1, 0))
|
||||
return 0;
|
||||
t->tm_mday = daysinmonth(t);
|
||||
} else {
|
||||
@@ -239,11 +219,11 @@ adjday(struct tm *t, char type, int val, int mk)
|
||||
break;
|
||||
}
|
||||
|
||||
return !mk || domktime(t, type) != -1;
|
||||
return mktime(t) != -1;
|
||||
}
|
||||
|
||||
static int
|
||||
adjwday(struct tm *t, char type, int val, int istext, int mk)
|
||||
adjwday(struct tm *t, char type, int val, int istext)
|
||||
{
|
||||
if (val < 0)
|
||||
return 0;
|
||||
@@ -256,62 +236,54 @@ adjwday(struct tm *t, char type, int val, int istext, int mk)
|
||||
else
|
||||
val -= t->tm_wday; /* later this week */
|
||||
else
|
||||
val *= 7; /* "-v+5w" == "5 weeks in the future" */
|
||||
return !val || adjday(t, '+', val, mk);
|
||||
val *= 7; /* "-W +5" == "5 weeks in the future" */
|
||||
return adjday(t, '+', val);
|
||||
case '-':
|
||||
if (istext) {
|
||||
if (istext)
|
||||
if (val > t->tm_wday)
|
||||
val = 7 - val + t->tm_wday; /* later last week */
|
||||
else
|
||||
val = t->tm_wday - val; /* early this week */
|
||||
} else
|
||||
val *= 7; /* "-v-5w" == "5 weeks ago" */
|
||||
return !val || adjday(t, '-', val, mk);
|
||||
else
|
||||
val *= 7; /* "-W -5" == "5 weeks ago" */
|
||||
return adjday(t, '-', val);
|
||||
default:
|
||||
if (val < t->tm_wday)
|
||||
return adjday(t, '-', t->tm_wday - val, mk);
|
||||
return adjday(t, '-', t->tm_wday - val);
|
||||
else if (val > 6)
|
||||
return 0;
|
||||
else if (val > t->tm_wday)
|
||||
return adjday(t, '+', val - t->tm_wday, mk);
|
||||
return adjday(t, '+', val - t->tm_wday);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
adjhour(struct tm *t, char type, int val, int mk)
|
||||
adjhour(struct tm *t, char type, int val)
|
||||
{
|
||||
if (val < 0)
|
||||
return 0;
|
||||
|
||||
switch (type) {
|
||||
case '+':
|
||||
if (val) {
|
||||
int days;
|
||||
|
||||
days = (t->tm_hour + val) / 24;
|
||||
val %= 24;
|
||||
t->tm_hour += val;
|
||||
t->tm_hour %= 24;
|
||||
if (!adjday(t, '+', days, 0))
|
||||
return 0;
|
||||
}
|
||||
if (!adjday(t, '+', (t->tm_hour + val) / 24))
|
||||
return 0;
|
||||
val %= 24;
|
||||
t->tm_hour += val;
|
||||
if (t->tm_hour > 23)
|
||||
t->tm_hour -= 24;
|
||||
break;
|
||||
|
||||
case '-':
|
||||
if (val) {
|
||||
int days;
|
||||
|
||||
days = val / 24;
|
||||
val %= 24;
|
||||
if (val > t->tm_hour) {
|
||||
days++;
|
||||
val -= 24;
|
||||
}
|
||||
t->tm_hour -= val;
|
||||
if (!adjday(t, '-', days, 0))
|
||||
if (!adjday(t, '-', val / 24))
|
||||
return 0;
|
||||
val %= 24;
|
||||
if (val > t->tm_hour) {
|
||||
if (!adjday(t, '-', 1))
|
||||
return 0;
|
||||
val -= 24;
|
||||
}
|
||||
t->tm_hour -= val;
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -320,39 +292,35 @@ adjhour(struct tm *t, char type, int val, int mk)
|
||||
t->tm_hour = val;
|
||||
}
|
||||
|
||||
return !mk || domktime(t, type) != -1;
|
||||
return mktime(t) != -1;
|
||||
}
|
||||
|
||||
static int
|
||||
adjmin(struct tm *t, char type, int val, int mk)
|
||||
adjmin(struct tm *t, char type, int val)
|
||||
{
|
||||
if (val < 0)
|
||||
return 0;
|
||||
|
||||
switch (type) {
|
||||
case '+':
|
||||
if (val) {
|
||||
if (!adjhour(t, '+', (t->tm_min + val) / 60, 0))
|
||||
return 0;
|
||||
val %= 60;
|
||||
t->tm_min += val;
|
||||
if (t->tm_min > 59)
|
||||
t->tm_min -= 60;
|
||||
}
|
||||
if (!adjhour(t, '+', (t->tm_min + val) / 60))
|
||||
return 0;
|
||||
val %= 60;
|
||||
t->tm_min += val;
|
||||
if (t->tm_min > 59)
|
||||
t->tm_min -= 60;
|
||||
break;
|
||||
|
||||
case '-':
|
||||
if (val) {
|
||||
if (!adjhour(t, '-', val / 60, 0))
|
||||
if (!adjhour(t, '-', val / 60))
|
||||
return 0;
|
||||
val %= 60;
|
||||
if (val > t->tm_min) {
|
||||
if (!adjhour(t, '-', 1))
|
||||
return 0;
|
||||
val %= 60;
|
||||
if (val > t->tm_min) {
|
||||
if (!adjhour(t, '-', 1, 0))
|
||||
return 0;
|
||||
val -= 60;
|
||||
}
|
||||
t->tm_min -= val;
|
||||
val -= 60;
|
||||
}
|
||||
t->tm_min -= val;
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -361,39 +329,35 @@ adjmin(struct tm *t, char type, int val, int mk)
|
||||
t->tm_min = val;
|
||||
}
|
||||
|
||||
return !mk || domktime(t, type) != -1;
|
||||
return mktime(t) != -1;
|
||||
}
|
||||
|
||||
static int
|
||||
adjsec(struct tm *t, char type, int val, int mk)
|
||||
adjsec(struct tm *t, char type, int val)
|
||||
{
|
||||
if (val < 0)
|
||||
return 0;
|
||||
|
||||
switch (type) {
|
||||
case '+':
|
||||
if (val) {
|
||||
if (!adjmin(t, '+', (t->tm_sec + val) / 60, 0))
|
||||
return 0;
|
||||
val %= 60;
|
||||
t->tm_sec += val;
|
||||
if (t->tm_sec > 59)
|
||||
t->tm_sec -= 60;
|
||||
}
|
||||
if (!adjmin(t, '+', (t->tm_sec + val) / 60))
|
||||
return 0;
|
||||
val %= 60;
|
||||
t->tm_sec += val;
|
||||
if (t->tm_sec > 59)
|
||||
t->tm_sec -= 60;
|
||||
break;
|
||||
|
||||
case '-':
|
||||
if (val) {
|
||||
if (!adjmin(t, '-', val / 60, 0))
|
||||
if (!adjmin(t, '-', val / 60))
|
||||
return 0;
|
||||
val %= 60;
|
||||
if (val > t->tm_sec) {
|
||||
if (!adjmin(t, '-', 1))
|
||||
return 0;
|
||||
val %= 60;
|
||||
if (val > t->tm_sec) {
|
||||
if (!adjmin(t, '-', 1, 0))
|
||||
return 0;
|
||||
val -= 60;
|
||||
}
|
||||
t->tm_sec -= val;
|
||||
val -= 60;
|
||||
}
|
||||
t->tm_sec -= val;
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -402,7 +366,7 @@ adjsec(struct tm *t, char type, int val, int mk)
|
||||
t->tm_sec = val;
|
||||
}
|
||||
|
||||
return !mk || domktime(t, type) != -1;
|
||||
return mktime(t) != -1;
|
||||
}
|
||||
|
||||
const struct vary *
|
||||
@@ -425,18 +389,15 @@ vary_apply(const struct vary *v, struct tm *t)
|
||||
if (len < 2)
|
||||
return v;
|
||||
|
||||
if (type == '\0')
|
||||
t->tm_isdst = -1;
|
||||
|
||||
if (strspn(arg, digits) != len-1) {
|
||||
val = trans(trans_wday, arg);
|
||||
if (val != -1) {
|
||||
if (!adjwday(t, type, val, 1, 1))
|
||||
if (!adjwday(t, type, val, 1))
|
||||
return v;
|
||||
} else {
|
||||
val = trans(trans_mon, arg);
|
||||
if (val != -1) {
|
||||
if (!adjmon(t, type, val, 1, 1))
|
||||
if (!adjmon(t, type, val, 1))
|
||||
return v;
|
||||
} else
|
||||
return v;
|
||||
@@ -447,35 +408,31 @@ vary_apply(const struct vary *v, struct tm *t)
|
||||
|
||||
switch (which) {
|
||||
case 'S':
|
||||
if (!adjsec(t, type, val, 1))
|
||||
if (!adjsec(t, type, val))
|
||||
return v;
|
||||
break;
|
||||
case 'M':
|
||||
if (!adjmin(t, type, val, 1))
|
||||
if (!adjmin(t, type, val))
|
||||
return v;
|
||||
break;
|
||||
case 'H':
|
||||
if (!adjhour(t, type, val, 1))
|
||||
if (!adjhour(t, type, val))
|
||||
return v;
|
||||
break;
|
||||
case 'd':
|
||||
t->tm_isdst = -1;
|
||||
if (!adjday(t, type, val, 1))
|
||||
if (!adjday(t, type, val))
|
||||
return v;
|
||||
break;
|
||||
case 'w':
|
||||
t->tm_isdst = -1;
|
||||
if (!adjwday(t, type, val, 0, 1))
|
||||
if (!adjwday(t, type, val, 0))
|
||||
return v;
|
||||
break;
|
||||
case 'm':
|
||||
t->tm_isdst = -1;
|
||||
if (!adjmon(t, type, val, 0, 1))
|
||||
if (!adjmon(t, type, val, 0))
|
||||
return v;
|
||||
break;
|
||||
case 'y':
|
||||
t->tm_isdst = -1;
|
||||
if (!adjyear(t, type, val, 1))
|
||||
if (!adjyear(t, type, val))
|
||||
return v;
|
||||
break;
|
||||
default:
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
struct vary {
|
||||
|
||||
+1
-3
@@ -1,9 +1,7 @@
|
||||
# @(#)Makefile 8.1 (Berkeley) 5/31/93
|
||||
# $FreeBSD$
|
||||
# $Id: Makefile,v 1.5 1998/01/07 22:31:17 joerg Exp $
|
||||
|
||||
PROG= dd
|
||||
SRCS= args.c conv.c conv_tab.c dd.c misc.c position.c
|
||||
|
||||
MAINTAINER= [email protected]
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
+58
-97
@@ -40,7 +40,7 @@
|
||||
static char sccsid[] = "@(#)args.c 8.3 (Berkeley) 4/2/94";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
"$Id: args.c,v 1.13 1998/05/13 07:33:36 charnier Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
@@ -67,11 +67,10 @@ static void f_obs __P((char *));
|
||||
static void f_of __P((char *));
|
||||
static void f_seek __P((char *));
|
||||
static void f_skip __P((char *));
|
||||
static quad_t get_num __P((char *));
|
||||
static off_t get_offset __P((char *));
|
||||
static u_long get_bsz __P((char *));
|
||||
|
||||
static const struct arg {
|
||||
const char *name;
|
||||
static struct arg {
|
||||
char *name;
|
||||
void (*f) __P((char *));
|
||||
u_int set, noset;
|
||||
} args[] = {
|
||||
@@ -142,14 +141,14 @@ jcl(argv)
|
||||
* Ascii/ebcdic and cbs implies block/unblock.
|
||||
* Block/unblock requires cbs and vice-versa.
|
||||
*/
|
||||
if (ddflags & (C_BLOCK | C_UNBLOCK)) {
|
||||
if (ddflags & (C_BLOCK|C_UNBLOCK)) {
|
||||
if (!(ddflags & C_CBS))
|
||||
errx(1, "record operations require cbs");
|
||||
if (cbsz == 0)
|
||||
errx(1, "cbs cannot be zero");
|
||||
cfunc = ddflags & C_BLOCK ? block : unblock;
|
||||
} else if (ddflags & C_CBS) {
|
||||
if (ddflags & (C_ASCII | C_EBCDIC)) {
|
||||
if (ddflags & (C_ASCII|C_EBCDIC)) {
|
||||
if (ddflags & C_ASCII) {
|
||||
ddflags |= C_UNBLOCK;
|
||||
cfunc = unblock;
|
||||
@@ -159,14 +158,23 @@ jcl(argv)
|
||||
}
|
||||
} else
|
||||
errx(1, "cbs meaningless if not doing record operations");
|
||||
if (cbsz == 0)
|
||||
errx(1, "cbs cannot be zero");
|
||||
} else
|
||||
cfunc = def;
|
||||
|
||||
if (in.dbsz == 0 || out.dbsz == 0)
|
||||
errx(1, "buffer sizes cannot be zero");
|
||||
|
||||
/*
|
||||
* Bail out if the calculation of a file offset would overflow.
|
||||
* Read, write and seek calls take ints as arguments. Seek sizes
|
||||
* could be larger if we wanted to do it in stages or check only
|
||||
* regular files, but it's probably not worth it.
|
||||
*/
|
||||
if (in.offset > QUAD_MAX / in.dbsz || out.offset > QUAD_MAX / out.dbsz)
|
||||
errx(1, "seek offsets cannot be larger than %qd", QUAD_MAX);
|
||||
if (in.dbsz > INT_MAX || out.dbsz > INT_MAX)
|
||||
errx(1, "buffer sizes cannot be greater than %d", INT_MAX);
|
||||
if (in.offset > INT_MAX / in.dbsz || out.offset > INT_MAX / out.dbsz)
|
||||
errx(1, "seek offsets cannot be larger than %d", INT_MAX);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -174,32 +182,23 @@ c_arg(a, b)
|
||||
const void *a, *b;
|
||||
{
|
||||
|
||||
return (strcmp(((const struct arg *)a)->name,
|
||||
((const struct arg *)b)->name));
|
||||
return (strcmp(((struct arg *)a)->name, ((struct arg *)b)->name));
|
||||
}
|
||||
|
||||
static void
|
||||
f_bs(arg)
|
||||
char *arg;
|
||||
{
|
||||
quad_t res;
|
||||
|
||||
res = get_num(arg);
|
||||
if (res < 1 || res > SSIZE_MAX)
|
||||
errx(1, "bs must be between 1 and %d", SSIZE_MAX);
|
||||
in.dbsz = out.dbsz = (size_t)res;
|
||||
in.dbsz = out.dbsz = (int)get_bsz(arg);
|
||||
}
|
||||
|
||||
static void
|
||||
f_cbs(arg)
|
||||
char *arg;
|
||||
{
|
||||
quad_t res;
|
||||
|
||||
res = get_num(arg);
|
||||
if (res < 1 || res > SSIZE_MAX)
|
||||
errx(1, "cbs must be between 1 and %d", SSIZE_MAX);
|
||||
cbsz = (size_t)res;
|
||||
cbsz = (int)get_bsz(arg);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -207,11 +206,9 @@ f_count(arg)
|
||||
char *arg;
|
||||
{
|
||||
|
||||
cpy_cnt = get_num(arg);
|
||||
if (cpy_cnt < 0)
|
||||
errx(1, "count cannot be negative");
|
||||
if (cpy_cnt == 0)
|
||||
cpy_cnt = -1;
|
||||
cpy_cnt = (u_int)get_bsz(arg);
|
||||
if (!cpy_cnt)
|
||||
terminate(0);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -219,23 +216,16 @@ f_files(arg)
|
||||
char *arg;
|
||||
{
|
||||
|
||||
files_cnt = get_num(arg);
|
||||
if (files_cnt < 1)
|
||||
errx(1, "files must be between 1 and %qd", QUAD_MAX);
|
||||
files_cnt = (int)get_bsz(arg);
|
||||
}
|
||||
|
||||
static void
|
||||
f_ibs(arg)
|
||||
char *arg;
|
||||
{
|
||||
quad_t res;
|
||||
|
||||
if (!(ddflags & C_BS)) {
|
||||
res = get_num(arg);
|
||||
if (res < 1 || res > SSIZE_MAX)
|
||||
errx(1, "ibs must be between 1 and %d", SSIZE_MAX);
|
||||
in.dbsz = (size_t)res;
|
||||
}
|
||||
if (!(ddflags & C_BS))
|
||||
in.dbsz = (int)get_bsz(arg);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -250,14 +240,9 @@ static void
|
||||
f_obs(arg)
|
||||
char *arg;
|
||||
{
|
||||
quad_t res;
|
||||
|
||||
if (!(ddflags & C_BS)) {
|
||||
res = get_num(arg);
|
||||
if (res < 1 || res > SSIZE_MAX)
|
||||
errx(1, "obs must be between 1 and %d", SSIZE_MAX);
|
||||
out.dbsz = (size_t)res;
|
||||
}
|
||||
if (!(ddflags & C_BS))
|
||||
out.dbsz = (int)get_bsz(arg);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -273,7 +258,7 @@ f_seek(arg)
|
||||
char *arg;
|
||||
{
|
||||
|
||||
out.offset = get_offset(arg);
|
||||
out.offset = (u_int)get_bsz(arg);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -281,13 +266,13 @@ f_skip(arg)
|
||||
char *arg;
|
||||
{
|
||||
|
||||
in.offset = get_offset(arg);
|
||||
in.offset = (u_int)get_bsz(arg);
|
||||
}
|
||||
|
||||
static const struct conv {
|
||||
const char *name;
|
||||
static struct conv {
|
||||
char *name;
|
||||
u_int set, noset;
|
||||
const u_char *ctab;
|
||||
u_char *ctab;
|
||||
} clist[] = {
|
||||
{ "ascii", C_ASCII, C_EBCDIC, e2a_POSIX },
|
||||
{ "block", C_BLOCK, C_UNBLOCK, NULL },
|
||||
@@ -315,9 +300,9 @@ f_conv(arg)
|
||||
|
||||
while (arg != NULL) {
|
||||
tmp.name = strsep(&arg, ",");
|
||||
cp = bsearch(&tmp, clist, sizeof(clist) / sizeof(struct conv),
|
||||
sizeof(struct conv), c_conv);
|
||||
if (cp == NULL)
|
||||
if (!(cp = (struct conv *)bsearch(&tmp, clist,
|
||||
sizeof(clist)/sizeof(struct conv), sizeof(struct conv),
|
||||
c_conv)))
|
||||
errx(1, "unknown conversion %s", tmp.name);
|
||||
if (ddflags & cp->noset)
|
||||
errx(1, "%s: illegal conversion combination", tmp.name);
|
||||
@@ -332,38 +317,34 @@ c_conv(a, b)
|
||||
const void *a, *b;
|
||||
{
|
||||
|
||||
return (strcmp(((const struct conv *)a)->name,
|
||||
((const struct conv *)b)->name));
|
||||
return (strcmp(((struct conv *)a)->name, ((struct conv *)b)->name));
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert an expression of the following forms to a quad_t.
|
||||
* Convert an expression of the following forms to an unsigned long.
|
||||
* 1) A positive decimal number.
|
||||
* 2) A positive decimal number followed by a b (mult by 512.)
|
||||
* 3) A positive decimal number followed by a k (mult by 1 << 10.)
|
||||
* 4) A positive decimal number followed by a m (mult by 1 << 20.)
|
||||
* 5) A positive decimal number followed by a g (mult by 1 << 30.)
|
||||
* 5) A positive decimal number followed by a w (mult by sizeof int.)
|
||||
* 6) Two or more positive decimal numbers (with/without [bkmgw])
|
||||
* 2) A positive decimal number followed by a b (mult by 512).
|
||||
* 3) A positive decimal number followed by a k (mult by 1024).
|
||||
* 4) A positive decimal number followed by a m (mult by 512).
|
||||
* 5) A positive decimal number followed by a w (mult by sizeof int)
|
||||
* 6) Two or more positive decimal numbers (with/without k,b or w).
|
||||
* separated by x (also * for backwards compatibility), specifying
|
||||
* the product of the indicated values.
|
||||
*/
|
||||
static quad_t
|
||||
get_num(val)
|
||||
static u_long
|
||||
get_bsz(val)
|
||||
char *val;
|
||||
{
|
||||
quad_t num, t;
|
||||
u_long num, t;
|
||||
char *expr;
|
||||
|
||||
errno = 0;
|
||||
num = strtoq(val, &expr, 0);
|
||||
if (errno != 0) /* Overflow or underflow. */
|
||||
num = strtoul(val, &expr, 0);
|
||||
if (num == ULONG_MAX) /* Overflow. */
|
||||
err(1, "%s", oper);
|
||||
|
||||
if (expr == val) /* No valid digits. */
|
||||
if (expr == val) /* No digits. */
|
||||
errx(1, "%s: illegal numeric value", oper);
|
||||
|
||||
switch (*expr) {
|
||||
switch(*expr) {
|
||||
case 'b':
|
||||
t = num;
|
||||
num *= 512;
|
||||
@@ -373,21 +354,14 @@ get_num(val)
|
||||
break;
|
||||
case 'k':
|
||||
t = num;
|
||||
num *= 1 << 10;
|
||||
num *= 1024;
|
||||
if (t > num)
|
||||
goto erange;
|
||||
++expr;
|
||||
break;
|
||||
case 'm':
|
||||
t = num;
|
||||
num *= 1 << 20;
|
||||
if (t > num)
|
||||
goto erange;
|
||||
++expr;
|
||||
break;
|
||||
case 'g':
|
||||
t = num;
|
||||
num *= 1 << 30;
|
||||
num *= 1048576;
|
||||
if (t > num)
|
||||
goto erange;
|
||||
++expr;
|
||||
@@ -401,31 +375,18 @@ get_num(val)
|
||||
break;
|
||||
}
|
||||
|
||||
switch (*expr) {
|
||||
switch(*expr) {
|
||||
case '\0':
|
||||
break;
|
||||
case '*': /* Backward compatible. */
|
||||
case 'x':
|
||||
t = num;
|
||||
num *= get_num(expr + 1);
|
||||
if (t <= num)
|
||||
break;
|
||||
erange:
|
||||
errx(1, "%s: %s", oper, strerror(ERANGE));
|
||||
num *= get_bsz(expr + 1);
|
||||
if (t > num)
|
||||
erange: errx(1, "%s: %s", oper, strerror(ERANGE));
|
||||
break;
|
||||
default:
|
||||
errx(1, "%s: illegal numeric value", oper);
|
||||
}
|
||||
return (num);
|
||||
}
|
||||
|
||||
static off_t
|
||||
get_offset(val)
|
||||
char *val;
|
||||
{
|
||||
quad_t num;
|
||||
|
||||
num = get_num(val);
|
||||
if (num > QUAD_MAX || num < 0) /* XXX quad_t != off_t */
|
||||
errx(1, "%s: illegal offset", oper); /* Too big/negative. */
|
||||
return ((off_t)num);
|
||||
}
|
||||
+25
-30
@@ -40,7 +40,7 @@
|
||||
static char sccsid[] = "@(#)conv.c 8.3 (Berkeley) 4/2/94";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
"$Id: conv.c,v 1.9 1998/05/06 06:51:30 charnier Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@@ -60,9 +60,8 @@ static const char rcsid[] =
|
||||
void
|
||||
def()
|
||||
{
|
||||
u_char *inp;
|
||||
const u_char *t;
|
||||
size_t cnt;
|
||||
int cnt;
|
||||
u_char *inp, *t;
|
||||
|
||||
if ((t = ctab) != NULL)
|
||||
for (inp = in.dbp - (cnt = in.dbrcnt); cnt--; ++inp)
|
||||
@@ -104,11 +103,9 @@ def_close()
|
||||
void
|
||||
block()
|
||||
{
|
||||
u_char *inp, *outp;
|
||||
const u_char *t;
|
||||
size_t cnt, maxlen;
|
||||
static int intrunc;
|
||||
int ch;
|
||||
int ch, cnt, maxlen;
|
||||
u_char *inp, *outp, *t;
|
||||
|
||||
/*
|
||||
* Record truncation can cross block boundaries. If currently in a
|
||||
@@ -117,8 +114,8 @@ block()
|
||||
* left empty.
|
||||
*/
|
||||
if (intrunc) {
|
||||
for (inp = in.db, cnt = in.dbrcnt; cnt && *inp++ != '\n'; --cnt)
|
||||
;
|
||||
for (inp = in.db, cnt = in.dbrcnt;
|
||||
cnt && *inp++ != '\n'; --cnt);
|
||||
if (!cnt) {
|
||||
in.dbcnt = 0;
|
||||
in.dbp = in.db;
|
||||
@@ -138,19 +135,19 @@ block()
|
||||
for (inp = in.dbp - in.dbcnt, outp = out.dbp; in.dbcnt;) {
|
||||
maxlen = MIN(cbsz, in.dbcnt);
|
||||
if ((t = ctab) != NULL)
|
||||
for (cnt = 0; cnt < maxlen && (ch = *inp++) != '\n';
|
||||
++cnt)
|
||||
for (cnt = 0;
|
||||
cnt < maxlen && (ch = *inp++) != '\n'; ++cnt)
|
||||
*outp++ = t[ch];
|
||||
else
|
||||
for (cnt = 0; cnt < maxlen && (ch = *inp++) != '\n';
|
||||
++cnt)
|
||||
for (cnt = 0;
|
||||
cnt < maxlen && (ch = *inp++) != '\n'; ++cnt)
|
||||
*outp++ = ch;
|
||||
/*
|
||||
* Check for short record without a newline. Reassemble the
|
||||
* input block.
|
||||
*/
|
||||
if (ch != '\n' && in.dbcnt < cbsz) {
|
||||
(void)memmove(in.db, in.dbp - in.dbcnt, in.dbcnt);
|
||||
memmove(in.db, in.dbp - in.dbcnt, in.dbcnt);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -200,9 +197,9 @@ block_close()
|
||||
*/
|
||||
if (in.dbcnt) {
|
||||
++st.trunc;
|
||||
(void)memmove(out.dbp, in.dbp - in.dbcnt, in.dbcnt);
|
||||
(void)memset(out.dbp + in.dbcnt, ctab ? ctab[' '] : ' ',
|
||||
cbsz - in.dbcnt);
|
||||
memmove(out.dbp, in.dbp - in.dbcnt, in.dbcnt);
|
||||
(void)memset(out.dbp + in.dbcnt,
|
||||
ctab ? ctab[' '] : ' ', cbsz - in.dbcnt);
|
||||
out.dbcnt += cbsz;
|
||||
}
|
||||
}
|
||||
@@ -217,9 +214,8 @@ block_close()
|
||||
void
|
||||
unblock()
|
||||
{
|
||||
u_char *inp;
|
||||
const u_char *t;
|
||||
size_t cnt;
|
||||
int cnt;
|
||||
u_char *inp, *t;
|
||||
|
||||
/* Translation and case conversion. */
|
||||
if ((t = ctab) != NULL)
|
||||
@@ -231,36 +227,35 @@ unblock()
|
||||
* spaces.
|
||||
*/
|
||||
for (inp = in.db; in.dbcnt >= cbsz; inp += cbsz, in.dbcnt -= cbsz) {
|
||||
for (t = inp + cbsz - 1; t >= inp && *t == ' '; --t)
|
||||
;
|
||||
for (t = inp + cbsz - 1; t >= inp && *t == ' '; --t);
|
||||
if (t >= inp) {
|
||||
cnt = t - inp + 1;
|
||||
(void)memmove(out.dbp, inp, cnt);
|
||||
memmove(out.dbp, inp, cnt);
|
||||
out.dbp += cnt;
|
||||
out.dbcnt += cnt;
|
||||
}
|
||||
++out.dbcnt;
|
||||
*out.dbp++ = '\n';
|
||||
if (++out.dbcnt >= out.dbsz)
|
||||
if (out.dbcnt >= out.dbsz)
|
||||
dd_out(0);
|
||||
}
|
||||
if (in.dbcnt)
|
||||
(void)memmove(in.db, in.dbp - in.dbcnt, in.dbcnt);
|
||||
memmove(in.db, in.dbp - in.dbcnt, in.dbcnt);
|
||||
in.dbp = in.db + in.dbcnt;
|
||||
}
|
||||
|
||||
void
|
||||
unblock_close()
|
||||
{
|
||||
int cnt;
|
||||
u_char *t;
|
||||
size_t cnt;
|
||||
|
||||
if (in.dbcnt) {
|
||||
warnx("%s: short input record", in.name);
|
||||
for (t = in.db + in.dbcnt - 1; t >= in.db && *t == ' '; --t)
|
||||
;
|
||||
for (t = in.db + in.dbcnt - 1; t >= in.db && *t == ' '; --t);
|
||||
if (t >= in.db) {
|
||||
cnt = t - in.db + 1;
|
||||
(void)memmove(out.dbp, in.db, cnt);
|
||||
memmove(out.dbp, in.db, cnt);
|
||||
out.dbp += cnt;
|
||||
out.dbcnt += cnt;
|
||||
}
|
||||
|
||||
+16
-9
@@ -40,13 +40,16 @@
|
||||
static char sccsid[] = "@(#)conv_tab.c 8.1 (Berkeley) 5/31/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
"$Id: conv_tab.c,v 1.7 1998/05/06 06:51:32 charnier Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
/*
|
||||
* There are currently six tables:
|
||||
* There are currently eight tables:
|
||||
*
|
||||
* lower-case -> upper-case conv=upper
|
||||
* upper-case -> lower-case conv=lower
|
||||
*
|
||||
* ebcdic -> ascii 32V conv=oldascii
|
||||
* ascii -> ebcdic 32V conv=oldebcdic
|
||||
@@ -69,10 +72,14 @@ static const char rcsid[] =
|
||||
* ACM, Volume 11, Number 11, November 1968, pp. 783-789.
|
||||
*/
|
||||
|
||||
u_char casetab[256];
|
||||
/* Lower-case to upper-case */
|
||||
u_char l2u[256];
|
||||
|
||||
/* Upper-case to lower-case */
|
||||
u_char u2l[256];
|
||||
|
||||
/* EBCDIC to ASCII -- 32V compatible. */
|
||||
const u_char e2a_32V[] = {
|
||||
u_char e2a_32V[] = {
|
||||
0000, 0001, 0002, 0003, 0234, 0011, 0206, 0177, /* 0000 */
|
||||
0227, 0215, 0216, 0013, 0014, 0015, 0016, 0017, /* 0010 */
|
||||
0020, 0021, 0022, 0023, 0235, 0205, 0010, 0207, /* 0020 */
|
||||
@@ -108,7 +115,7 @@ const u_char e2a_32V[] = {
|
||||
};
|
||||
|
||||
/* ASCII to EBCDIC -- 32V compatible. */
|
||||
const u_char a2e_32V[] = {
|
||||
u_char a2e_32V[] = {
|
||||
0000, 0001, 0002, 0003, 0067, 0055, 0056, 0057, /* 0000 */
|
||||
0026, 0005, 0045, 0013, 0014, 0015, 0016, 0017, /* 0010 */
|
||||
0020, 0021, 0022, 0023, 0074, 0075, 0062, 0046, /* 0020 */
|
||||
@@ -144,7 +151,7 @@ const u_char a2e_32V[] = {
|
||||
};
|
||||
|
||||
/* ASCII to IBM EBCDIC -- 32V compatible. */
|
||||
const u_char a2ibm_32V[] = {
|
||||
u_char a2ibm_32V[] = {
|
||||
0000, 0001, 0002, 0003, 0067, 0055, 0056, 0057, /* 0000 */
|
||||
0026, 0005, 0045, 0013, 0014, 0015, 0016, 0017, /* 0010 */
|
||||
0020, 0021, 0022, 0023, 0074, 0075, 0062, 0046, /* 0020 */
|
||||
@@ -180,7 +187,7 @@ const u_char a2ibm_32V[] = {
|
||||
};
|
||||
|
||||
/* EBCDIC to ASCII -- POSIX and System V compatible. */
|
||||
const u_char e2a_POSIX[] = {
|
||||
u_char e2a_POSIX[] = {
|
||||
0000, 0001, 0002, 0003, 0234, 0011, 0206, 0177, /* 0000 */
|
||||
0227, 0215, 0216, 0013, 0014, 0015, 0016, 0017, /* 0010 */
|
||||
0020, 0021, 0022, 0023, 0235, 0205, 0010, 0207, /* 0020 */
|
||||
@@ -216,7 +223,7 @@ const u_char e2a_POSIX[] = {
|
||||
};
|
||||
|
||||
/* ASCII to EBCDIC -- POSIX and System V compatible. */
|
||||
const u_char a2e_POSIX[] = {
|
||||
u_char a2e_POSIX[] = {
|
||||
0000, 0001, 0002, 0003, 0067, 0055, 0056, 0057, /* 0000 */
|
||||
0026, 0005, 0045, 0013, 0014, 0015, 0016, 0017, /* 0010 */
|
||||
0020, 0021, 0022, 0023, 0074, 0075, 0062, 0046, /* 0020 */
|
||||
@@ -252,7 +259,7 @@ const u_char a2e_POSIX[] = {
|
||||
};
|
||||
|
||||
/* ASCII to IBM EBCDIC -- POSIX and System V compatible. */
|
||||
const u_char a2ibm_POSIX[] = {
|
||||
u_char a2ibm_POSIX[] = {
|
||||
0000, 0001, 0002, 0003, 0067, 0055, 0056, 0057, /* 0000 */
|
||||
0026, 0005, 0045, 0013, 0014, 0015, 0016, 0017, /* 0010 */
|
||||
0020, 0021, 0022, 0023, 0074, 0075, 0062, 0046, /* 0020 */
|
||||
|
||||
+5
-6
@@ -33,7 +33,7 @@
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)dd.1 8.2 (Berkeley) 1/13/94
|
||||
.\" $FreeBSD$
|
||||
.\" $Id: dd.1,v 1.8 1998/11/29 13:54:20 bde Exp $
|
||||
.\"
|
||||
.Dd January 13, 1994
|
||||
.Dt DD 1
|
||||
@@ -282,11 +282,10 @@ appended.
|
||||
.El
|
||||
.El
|
||||
.Pp
|
||||
Where sizes are specified, a decimal, octal, or hexadecimal number of
|
||||
bytes is expected.
|
||||
If the number ends with a ``b'', ``k'', ``m'', ``g'', or ``w'', the
|
||||
number is multiplied by 512, 1024 (1K), 1048576 (1M), 1073741824 (1G)
|
||||
or the number of bytes in an integer, respectively.
|
||||
Where sizes are specified, a decimal number of bytes is expected.
|
||||
If the number ends with a ``b'', ``k'', ``m'' or ``w'', the number
|
||||
is multiplied by 512, 1024 (1K), 1048576 (1M) or the number of bytes
|
||||
in an integer, respectively.
|
||||
Two or more numbers may be separated by an ``x'' to indicate a product.
|
||||
.Pp
|
||||
When finished,
|
||||
|
||||
+64
-77
@@ -46,13 +46,11 @@ static char const copyright[] =
|
||||
static char sccsid[] = "@(#)dd.c 8.5 (Berkeley) 4/2/94";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
"$Id: dd.c,v 1.14 1998/05/06 06:51:39 charnier Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/device.h>
|
||||
#include <sys/disklabel.h>
|
||||
#include <sys/mtio.h>
|
||||
|
||||
#include <ctype.h>
|
||||
@@ -76,12 +74,12 @@ static void setup __P((void));
|
||||
IO in, out; /* input/output state */
|
||||
STAT st; /* statistics */
|
||||
void (*cfunc) __P((void)); /* conversion function */
|
||||
quad_t cpy_cnt; /* # of blocks to copy */
|
||||
off_t pending = 0; /* pending seek if sparse */
|
||||
u_long cpy_cnt; /* # of blocks to copy */
|
||||
u_long pending = 0; /* pending seek if sparse */
|
||||
u_int ddflags; /* conversion options */
|
||||
size_t cbsz; /* conversion block size */
|
||||
quad_t files_cnt = 1; /* # of files to copy */
|
||||
const u_char *ctab; /* conversion table */
|
||||
u_int cbsz; /* conversion block size */
|
||||
u_int files_cnt = 1; /* # of files to copy */
|
||||
u_char *ctab; /* conversion table */
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
@@ -115,7 +113,7 @@ setup()
|
||||
in.fd = STDIN_FILENO;
|
||||
} else {
|
||||
in.fd = open(in.name, O_RDONLY, 0);
|
||||
if (in.fd == -1)
|
||||
if (in.fd < 0)
|
||||
err(1, "%s", in.name);
|
||||
}
|
||||
|
||||
@@ -137,11 +135,11 @@ setup()
|
||||
* Without read we may have a problem if output also does
|
||||
* not support seeks.
|
||||
*/
|
||||
if (out.fd == -1) {
|
||||
if (out.fd < 0) {
|
||||
out.fd = open(out.name, O_WRONLY | OFLAGS, DEFFILEMODE);
|
||||
out.flags |= NOREAD;
|
||||
}
|
||||
if (out.fd == -1)
|
||||
if (out.fd < 0)
|
||||
err(1, "%s", out.name);
|
||||
}
|
||||
|
||||
@@ -151,13 +149,14 @@ setup()
|
||||
* Allocate space for the input and output buffers. If not doing
|
||||
* record oriented I/O, only need a single buffer.
|
||||
*/
|
||||
if (!(ddflags & (C_BLOCK | C_UNBLOCK))) {
|
||||
if (!(ddflags & (C_BLOCK|C_UNBLOCK))) {
|
||||
if ((in.db = malloc(out.dbsz + in.dbsz - 1)) == NULL)
|
||||
err(1, "input buffer");
|
||||
err(1, NULL);
|
||||
out.db = in.db;
|
||||
} else if ((in.db = malloc(MAX(in.dbsz, cbsz) + cbsz)) == NULL ||
|
||||
(out.db = malloc(out.dbsz + cbsz)) == NULL)
|
||||
err(1, "output buffer");
|
||||
} else if ((in.db =
|
||||
malloc((u_int)(MAX(in.dbsz, cbsz) + cbsz))) == NULL ||
|
||||
(out.db = malloc((u_int)(out.dbsz + cbsz))) == NULL)
|
||||
err(1, NULL);
|
||||
in.dbp = in.db;
|
||||
out.dbp = out.db;
|
||||
|
||||
@@ -172,34 +171,50 @@ setup()
|
||||
* kinds of output files, tapes, for example.
|
||||
*/
|
||||
if ((ddflags & (C_OF | C_SEEK | C_NOTRUNC)) == (C_OF | C_SEEK))
|
||||
(void)ftruncate(out.fd, out.offset * out.dbsz);
|
||||
(void)ftruncate(out.fd, (off_t)out.offset * out.dbsz);
|
||||
|
||||
/*
|
||||
* If converting case at the same time as another conversion, build a
|
||||
* table that does both at once. If just converting case, use the
|
||||
* built-in tables.
|
||||
*/
|
||||
if (ddflags & (C_LCASE | C_UCASE)) {
|
||||
if (ddflags & (C_ASCII | C_EBCDIC)) {
|
||||
if (ddflags & (C_LCASE|C_UCASE))
|
||||
if (ddflags & C_ASCII)
|
||||
if (ddflags & C_LCASE) {
|
||||
for (cnt = 0; cnt <= 0377; ++cnt)
|
||||
casetab[cnt] = tolower(ctab[cnt]);
|
||||
if (isupper(ctab[cnt]))
|
||||
ctab[cnt] = tolower(ctab[cnt]);
|
||||
} else {
|
||||
for (cnt = 0; cnt <= 0377; ++cnt)
|
||||
casetab[cnt] = toupper(ctab[cnt]);
|
||||
if (islower(ctab[cnt]))
|
||||
ctab[cnt] = toupper(ctab[cnt]);
|
||||
}
|
||||
} else {
|
||||
else if (ddflags & C_EBCDIC)
|
||||
if (ddflags & C_LCASE) {
|
||||
for (cnt = 0; cnt <= 0377; ++cnt)
|
||||
casetab[cnt] = tolower(cnt);
|
||||
if (isupper(cnt))
|
||||
ctab[cnt] = ctab[tolower(cnt)];
|
||||
} else {
|
||||
for (cnt = 0; cnt <= 0377; ++cnt)
|
||||
casetab[cnt] = toupper(cnt);
|
||||
if (islower(cnt))
|
||||
ctab[cnt] = ctab[toupper(cnt)];
|
||||
}
|
||||
else {
|
||||
ctab = ddflags & C_LCASE ? u2l : l2u;
|
||||
if (ddflags & C_LCASE) {
|
||||
for (cnt = 0; cnt <= 0377; ++cnt)
|
||||
if (isupper(cnt))
|
||||
ctab[cnt] = tolower(cnt);
|
||||
else
|
||||
ctab[cnt] = cnt;
|
||||
} else {
|
||||
for (cnt = 0; cnt <= 0377; ++cnt)
|
||||
if (islower(cnt))
|
||||
ctab[cnt] = toupper(cnt);
|
||||
else
|
||||
ctab[cnt] = cnt;
|
||||
}
|
||||
}
|
||||
ctab = casetab;
|
||||
}
|
||||
|
||||
(void)gettimeofday(&tv, (struct timezone *)NULL);
|
||||
st.start = tv.tv_sec + tv.tv_usec * 1e-6;
|
||||
}
|
||||
@@ -208,59 +223,35 @@ static void
|
||||
getfdtype(io)
|
||||
IO *io;
|
||||
{
|
||||
struct stat sb;
|
||||
struct disklabel dkl;
|
||||
struct mtget mt;
|
||||
int type;
|
||||
struct stat sb;
|
||||
|
||||
if (fstat(io->fd, &sb) == -1)
|
||||
if (fstat(io->fd, &sb))
|
||||
err(1, "%s", io->name);
|
||||
if (S_ISCHR(sb.st_mode) || S_ISBLK(sb.st_mode)) {
|
||||
if (ioctl(io->fd, DIOCGDINFO, &dkl) == 0 ||
|
||||
/* XXX {,k}mem hack: This sucks. */
|
||||
(major(sb.st_rdev) == 2 &&
|
||||
(minor(sb.st_rdev) == 0 || minor(sb.st_rdev) == 1)))
|
||||
io->flags |= ISSEEK;
|
||||
else if (ioctl(io->fd, MTIOCGET, &mt) == 0)
|
||||
io->flags |= ISTAPE;
|
||||
if (S_ISCHR(sb.st_mode) && (io->flags & ISTAPE) == 0)
|
||||
io->flags |= ISCHR;
|
||||
return;
|
||||
}
|
||||
errno = 0;
|
||||
if (lseek(io->fd, (off_t)0, SEEK_CUR) == -1 && errno == ESPIPE)
|
||||
io->flags |= ISPIPE;
|
||||
else
|
||||
io->flags |= ISSEEK;
|
||||
if (S_ISCHR(sb.st_mode))
|
||||
io->flags |= ioctl(io->fd, MTIOCGET, &mt) ? ISCHR : ISTAPE;
|
||||
else if (lseek(io->fd, (off_t)0, SEEK_CUR) == -1 && errno == ESPIPE)
|
||||
io->flags |= ISPIPE; /* XXX fixed in 4.4BSD */
|
||||
}
|
||||
|
||||
static void
|
||||
dd_in()
|
||||
{
|
||||
ssize_t n;
|
||||
int n;
|
||||
|
||||
for (;;) {
|
||||
switch (cpy_cnt) {
|
||||
case -1: /* count=0 was specified */
|
||||
if (cpy_cnt && (st.in_full + st.in_part) >= cpy_cnt)
|
||||
return;
|
||||
case 0:
|
||||
break;
|
||||
default:
|
||||
if (st.in_full + st.in_part >= cpy_cnt)
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Zero the buffer first if sync; if doing block operations,
|
||||
* Zero the buffer first if sync; If doing block operations
|
||||
* use spaces.
|
||||
*/
|
||||
if (ddflags & C_SYNC) {
|
||||
if (ddflags & (C_BLOCK | C_UNBLOCK))
|
||||
if (ddflags & C_SYNC)
|
||||
if (ddflags & (C_BLOCK|C_UNBLOCK))
|
||||
memset(in.dbp, ' ', in.dbsz);
|
||||
else
|
||||
memset(in.dbp, 0, in.dbsz);
|
||||
}
|
||||
|
||||
n = read(in.fd, in.dbp, in.dbsz);
|
||||
if (n == 0) {
|
||||
@@ -269,7 +260,7 @@ dd_in()
|
||||
}
|
||||
|
||||
/* Read error. */
|
||||
if (n == -1) {
|
||||
if (n < 0) {
|
||||
/*
|
||||
* If noerror not specified, die. POSIX requires that
|
||||
* the warning message be followed by an I/O display.
|
||||
@@ -280,12 +271,12 @@ dd_in()
|
||||
summary();
|
||||
|
||||
/*
|
||||
* If it's a seekable file descriptor, seek past the
|
||||
* If it's not a tape drive or a pipe, seek past the
|
||||
* error. If your OS doesn't do the right thing for
|
||||
* raw disks this section should be modified to re-read
|
||||
* in sector size chunks.
|
||||
*/
|
||||
if (in.flags & ISSEEK &&
|
||||
if (!(in.flags & (ISPIPE|ISTAPE)) &&
|
||||
lseek(in.fd, (off_t)in.dbsz, SEEK_CUR))
|
||||
warn("%s", in.name);
|
||||
|
||||
@@ -338,7 +329,7 @@ dd_in()
|
||||
}
|
||||
|
||||
/*
|
||||
* Clean up any remaining I/O and flush output. If necessary, the output file
|
||||
* Cleanup any remaining I/O and flush output. If necesssary, output file
|
||||
* is truncated.
|
||||
*/
|
||||
static void
|
||||
@@ -351,7 +342,7 @@ dd_close()
|
||||
else if (cfunc == unblock)
|
||||
unblock_close();
|
||||
if (ddflags & C_OSYNC && out.dbcnt && out.dbcnt < out.dbsz) {
|
||||
if (ddflags & (C_BLOCK | C_UNBLOCK))
|
||||
if (ddflags & (C_BLOCK|C_UNBLOCK))
|
||||
memset(out.dbp, ' ', out.dbsz - out.dbcnt);
|
||||
else
|
||||
memset(out.dbp, 0, out.dbsz - out.dbcnt);
|
||||
@@ -365,11 +356,9 @@ void
|
||||
dd_out(force)
|
||||
int force;
|
||||
{
|
||||
u_char *outp;
|
||||
size_t cnt, i, n;
|
||||
ssize_t nw;
|
||||
static int warned;
|
||||
int sparse;
|
||||
int cnt, n, nw, i, sparse;
|
||||
u_char *outp;
|
||||
|
||||
/*
|
||||
* Write one or more blocks out. The common case is writing a full
|
||||
@@ -406,8 +395,7 @@ dd_out(force)
|
||||
if (pending != 0) {
|
||||
if (force)
|
||||
pending--;
|
||||
if (lseek(out.fd, pending, SEEK_CUR) ==
|
||||
-1)
|
||||
if (lseek (out.fd, pending, SEEK_CUR) == -1)
|
||||
err(2, "%s: seek error creating sparse file",
|
||||
out.name);
|
||||
if (force)
|
||||
@@ -439,14 +427,13 @@ dd_out(force)
|
||||
++st.out_part;
|
||||
if (nw == cnt)
|
||||
break;
|
||||
if (out.flags & ISTAPE)
|
||||
errx(1, "%s: short write on tape device",
|
||||
out.name);
|
||||
if (out.flags & ISCHR && !warned) {
|
||||
warned = 1;
|
||||
warnx("%s: short write on character device",
|
||||
out.name);
|
||||
}
|
||||
if (out.flags & ISTAPE)
|
||||
errx(1, "%s: short write on tape device", out.name);
|
||||
}
|
||||
if ((out.dbcnt -= n) < out.dbsz)
|
||||
break;
|
||||
@@ -454,6 +441,6 @@ dd_out(force)
|
||||
|
||||
/* Reassemble the output block. */
|
||||
if (out.dbcnt)
|
||||
(void)memmove(out.db, out.dbp - out.dbcnt, out.dbcnt);
|
||||
memmove(out.db, out.dbp - out.dbcnt, out.dbcnt);
|
||||
out.dbp = out.db + out.dbcnt;
|
||||
}
|
||||
+25
-27
@@ -35,44 +35,42 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)dd.h 8.3 (Berkeley) 4/2/94
|
||||
* $FreeBSD$
|
||||
* $Id: dd.h,v 1.7 1997/10/11 20:09:05 joerg Exp $
|
||||
*/
|
||||
|
||||
/* Input/output stream state. */
|
||||
typedef struct {
|
||||
u_char *db; /* buffer address */
|
||||
u_char *dbp; /* current buffer I/O address */
|
||||
/* XXX ssize_t? */
|
||||
size_t dbcnt; /* current buffer byte count */
|
||||
size_t dbrcnt; /* last read byte count */
|
||||
size_t dbsz; /* buffer size */
|
||||
u_char *db; /* buffer address */
|
||||
u_char *dbp; /* current buffer I/O address */
|
||||
u_long dbcnt; /* current buffer byte count */
|
||||
int dbrcnt; /* last read byte count */
|
||||
u_long dbsz; /* buffer size */
|
||||
|
||||
#define ISCHR 0x01 /* character device (warn on short) */
|
||||
#define ISPIPE 0x02 /* pipe-like (not truncatable) */
|
||||
#define ISTAPE 0x04 /* tape */
|
||||
#define ISSEEK 0x08 /* valid to seek on */
|
||||
#define NOREAD 0x10 /* not readable */
|
||||
u_int flags;
|
||||
#define ISPIPE 0x02 /* pipe (not truncatable) */
|
||||
#define ISTAPE 0x04 /* tape (not seekable) */
|
||||
#define NOREAD 0x08 /* not readable */
|
||||
u_int flags;
|
||||
|
||||
char *name; /* name */
|
||||
int fd; /* file descriptor */
|
||||
off_t offset; /* # of blocks to skip */
|
||||
char *name; /* name */
|
||||
int fd; /* file descriptor */
|
||||
u_long offset; /* # of blocks to skip */
|
||||
|
||||
u_quad_t f_stats; /* # of full blocks processed */
|
||||
u_quad_t p_stats; /* # of partial blocks processed */
|
||||
u_quad_t s_stats; /* # of odd swab blocks */
|
||||
u_quad_t t_stats; /* # of truncations */
|
||||
u_long f_stats; /* # of full blocks processed */
|
||||
u_long p_stats; /* # of partial blocks processed */
|
||||
u_long s_stats; /* # of odd swab blocks */
|
||||
u_long t_stats; /* # of truncations */
|
||||
} IO;
|
||||
|
||||
typedef struct {
|
||||
u_quad_t in_full; /* # of full input blocks */
|
||||
u_quad_t in_part; /* # of partial input blocks */
|
||||
u_quad_t out_full; /* # of full output blocks */
|
||||
u_quad_t out_part; /* # of partial output blocks */
|
||||
u_quad_t trunc; /* # of truncated records */
|
||||
u_quad_t swab; /* # of odd-length swab blocks */
|
||||
u_quad_t bytes; /* # of bytes written */
|
||||
double start; /* start time of dd */
|
||||
u_long in_full; /* # of full input blocks */
|
||||
u_long in_part; /* # of partial input blocks */
|
||||
u_long out_full; /* # of full output blocks */
|
||||
u_long out_part; /* # of partial output blocks */
|
||||
u_long trunc; /* # of truncated records */
|
||||
u_long swab; /* # of odd-length swab blocks */
|
||||
u_int64_t bytes; /* # of bytes written */
|
||||
double start; /* start time of dd */
|
||||
} STAT;
|
||||
|
||||
/* Flags (in ddflags). */
|
||||
|
||||
+7
-9
@@ -35,7 +35,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)extern.h 8.3 (Berkeley) 4/2/94
|
||||
* $FreeBSD$
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
@@ -57,12 +57,10 @@ void unblock_close __P((void));
|
||||
extern IO in, out;
|
||||
extern STAT st;
|
||||
extern void (*cfunc)();
|
||||
extern quad_t cpy_cnt;
|
||||
extern size_t cbsz;
|
||||
extern u_long cpy_cnt;
|
||||
extern u_int cbsz;
|
||||
extern u_int ddflags;
|
||||
extern quad_t files_cnt;
|
||||
extern const u_char *ctab;
|
||||
extern const u_char a2e_32V[], a2e_POSIX[];
|
||||
extern const u_char e2a_32V[], e2a_POSIX[];
|
||||
extern const u_char a2ibm_32V[], a2ibm_POSIX[];
|
||||
extern u_char casetab[];
|
||||
extern u_int files_cnt;
|
||||
extern u_char *ctab;
|
||||
extern u_char a2e_32V[], a2e_POSIX[], a2ibm_32V[], a2ibm_POSIX[], e2a_32V[];
|
||||
extern u_char e2a_POSIX[], l2u[], u2l[];
|
||||
+4
-4
@@ -40,7 +40,7 @@
|
||||
static char sccsid[] = "@(#)misc.c 8.3 (Berkeley) 4/2/94";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
"$Id: misc.c,v 1.14 1998/05/13 07:33:50 charnier Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
@@ -66,16 +66,16 @@ summary()
|
||||
secs = 1e-6;
|
||||
/* Use snprintf(3) so that we don't reenter stdio(3). */
|
||||
(void)snprintf(buf, sizeof(buf),
|
||||
"%qu+%qu records in\n%qu+%qu records out\n",
|
||||
"%lu+%lu records in\n%lu+%lu records out\n",
|
||||
st.in_full, st.in_part, st.out_full, st.out_part);
|
||||
(void)write(STDERR_FILENO, buf, strlen(buf));
|
||||
if (st.swab) {
|
||||
(void)snprintf(buf, sizeof(buf), "%qu odd length swab %s\n",
|
||||
(void)snprintf(buf, sizeof(buf), "%lu odd length swab %s\n",
|
||||
st.swab, (st.swab == 1) ? "block" : "blocks");
|
||||
(void)write(STDERR_FILENO, buf, strlen(buf));
|
||||
}
|
||||
if (st.trunc) {
|
||||
(void)snprintf(buf, sizeof(buf), "%qu truncated %s\n",
|
||||
(void)snprintf(buf, sizeof(buf), "%lu truncated %s\n",
|
||||
st.trunc, (st.trunc == 1) ? "block" : "blocks");
|
||||
(void)write(STDERR_FILENO, buf, strlen(buf));
|
||||
}
|
||||
|
||||
+10
-18
@@ -40,14 +40,13 @@
|
||||
static char sccsid[] = "@(#)position.c 8.3 (Berkeley) 4/2/94";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
"$Id: position.c,v 1.7 1998/05/06 06:51:42 charnier Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/mtio.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "dd.h"
|
||||
@@ -62,16 +61,11 @@ static const char rcsid[] =
|
||||
void
|
||||
pos_in()
|
||||
{
|
||||
off_t cnt;
|
||||
int warned;
|
||||
ssize_t nr;
|
||||
size_t bcnt;
|
||||
int bcnt, cnt, nr, warned;
|
||||
|
||||
/* If known to be seekable, try to seek on it. */
|
||||
if (in.flags & ISSEEK) {
|
||||
errno = 0;
|
||||
if (lseek(in.fd, in.offset * in.dbsz, SEEK_CUR) == -1 &&
|
||||
errno != 0)
|
||||
/* If not a character, pipe or tape device, try to seek on it. */
|
||||
if (!(in.flags & (ISCHR|ISPIPE|ISTAPE))) {
|
||||
if (lseek(in.fd, (off_t)in.offset * in.dbsz, SEEK_CUR) == -1)
|
||||
err(1, "%s", in.name);
|
||||
return;
|
||||
}
|
||||
@@ -122,8 +116,7 @@ void
|
||||
pos_out()
|
||||
{
|
||||
struct mtop t_op;
|
||||
off_t cnt;
|
||||
ssize_t n;
|
||||
int cnt, n;
|
||||
|
||||
/*
|
||||
* If not a tape, try seeking on the file. Seeking on a pipe is
|
||||
@@ -131,9 +124,8 @@ pos_out()
|
||||
* have specified the seek operand.
|
||||
*/
|
||||
if (!(out.flags & ISTAPE)) {
|
||||
errno = 0;
|
||||
if (lseek(out.fd, out.offset * out.dbsz, SEEK_CUR) == -1 &&
|
||||
errno != 0)
|
||||
if (lseek(out.fd,
|
||||
(off_t)out.offset * out.dbsz, SEEK_SET) == -1)
|
||||
err(1, "%s", out.name);
|
||||
return;
|
||||
}
|
||||
@@ -143,7 +135,7 @@ pos_out()
|
||||
t_op.mt_op = MTFSR;
|
||||
t_op.mt_count = out.offset;
|
||||
|
||||
if (ioctl(out.fd, MTIOCTOP, &t_op) == -1)
|
||||
if (ioctl(out.fd, MTIOCTOP, &t_op) < 0)
|
||||
err(1, "%s", out.name);
|
||||
return;
|
||||
}
|
||||
@@ -153,7 +145,7 @@ pos_out()
|
||||
if ((n = read(out.fd, out.db, out.dbsz)) > 0)
|
||||
continue;
|
||||
|
||||
if (n == -1)
|
||||
if (n < 0)
|
||||
err(1, "%s", out.name);
|
||||
|
||||
/*
|
||||
|
||||
+1
-3
@@ -1,4 +1,4 @@
|
||||
# $FreeBSD$
|
||||
# $Id: Makefile,v 1.6 1997/08/07 21:30:59 steve Exp $
|
||||
# @(#)Makefile 8.3 (Berkeley) 5/8/95
|
||||
|
||||
PROG= df
|
||||
@@ -8,8 +8,6 @@ BINMODE=2555
|
||||
|
||||
MOUNT= ${.CURDIR}/../../sbin/mount
|
||||
CFLAGS+= -I${MOUNT}
|
||||
LDADD+= ${LIBM}
|
||||
DPADD+= ${LIBM}
|
||||
.PATH: ${MOUNT}
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
+9
-33
@@ -30,7 +30,7 @@
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)df.1 8.3 (Berkeley) 5/8/95
|
||||
.\" $FreeBSD$
|
||||
.\" $Id: df.1,v 1.14 1999/02/12 02:12:06 alex Exp $
|
||||
.\"
|
||||
.Dd May 8, 1995
|
||||
.Dt DF 1
|
||||
@@ -40,11 +40,7 @@
|
||||
.Nd display free disk space
|
||||
.Sh SYNOPSIS
|
||||
.Nm df
|
||||
.Oo
|
||||
.Fl b | h | H | k |
|
||||
.Fl m | P
|
||||
.Oc
|
||||
.Op Fl in
|
||||
.Op Fl ikn
|
||||
.Op Fl t Ar type
|
||||
.Op Ar file | Ar filesystem ...
|
||||
.Sh DESCRIPTION
|
||||
@@ -63,19 +59,6 @@ option below).
|
||||
.Pp
|
||||
The following options are available:
|
||||
.Bl -tag -width Ds
|
||||
.It Fl b
|
||||
Use 512-byte blocks rather than the default. Note that
|
||||
this overrides the
|
||||
.Ev BLOCKSIZE
|
||||
specification from the environment.
|
||||
.It Fl H
|
||||
"Human-readable" output. Use unit suffixes: Byte, Kilobyte, Megabyte,
|
||||
Gigabyte, Terabyte and Petabyte in order to reduce the number of
|
||||
digits to three or less using base 10 for sizes.
|
||||
.It Fl h
|
||||
"Human-readable" output. Use unit suffixes: Byte, Kilobyte, Megabyte,
|
||||
Gigabyte, Terabyte and Petabyte in order to reduce the number of
|
||||
digits to three or less using base 2 for sizes.
|
||||
.It Fl i
|
||||
Include statistics on the number of free inodes.
|
||||
.It Fl k
|
||||
@@ -83,11 +66,6 @@ Use 1024-byte (1-Kbyte) blocks rather than the default. Note that
|
||||
this overrides the
|
||||
.Ev BLOCKSIZE
|
||||
specification from the environment.
|
||||
.It Fl m
|
||||
Use 1048576-byte (1-Mbyte) blocks rather than the default. Note that
|
||||
this overrides the
|
||||
.Ev BLOCKSIZE
|
||||
specification from the environment.
|
||||
.It Fl n
|
||||
Print out the previously obtained statistics from the filesystems.
|
||||
This option should be used if it is possible that one or more
|
||||
@@ -97,11 +75,6 @@ When this option is specified,
|
||||
.Nm
|
||||
will not request new statistics from the filesystems, but will respond
|
||||
with the possibly stale statistics that were previously obtained.
|
||||
.It Fl P
|
||||
Use POSIX compliant output of 512-byte blocks rather than the default.
|
||||
Note that this overrides the
|
||||
.Ev BLOCKSIZE
|
||||
specification from the environment.
|
||||
.It Fl t
|
||||
Only print out statistics for filesystems of the specified types.
|
||||
More than one type may be specified in a comma separated list.
|
||||
@@ -122,9 +95,12 @@ lists all filesystems except those of type
|
||||
and
|
||||
.Tn MFS .
|
||||
The
|
||||
.Xr lsvfs 1
|
||||
.Xr sysctl 8
|
||||
command can be used to find out the types of filesystems
|
||||
that are available on the system.
|
||||
that are available on the system:
|
||||
.Bd -literal -offset indent
|
||||
sysctl vfs
|
||||
.Ed
|
||||
.El
|
||||
.Sh ENVIRONMENT
|
||||
.Bl -tag -width BLOCKSIZE
|
||||
@@ -140,7 +116,6 @@ and
|
||||
.Fl t
|
||||
flags are ignored if a file or filesystem is specified.
|
||||
.Sh SEE ALSO
|
||||
.Xr lsvfs 1 ,
|
||||
.Xr quota 1 ,
|
||||
.Xr fstatfs 2 ,
|
||||
.Xr getfsstat 2 ,
|
||||
@@ -148,7 +123,8 @@ flags are ignored if a file or filesystem is specified.
|
||||
.Xr getmntinfo 3 ,
|
||||
.Xr fstab 5 ,
|
||||
.Xr mount 8 ,
|
||||
.Xr quot 8
|
||||
.Xr quot 8 ,
|
||||
.Xr sysctl 8
|
||||
.Sh HISTORY
|
||||
A
|
||||
.Nm
|
||||
|
||||
+13
-134
@@ -47,7 +47,7 @@ static const char copyright[] =
|
||||
static char sccsid[] = "@(#)df.c 8.9 (Berkeley) 5/8/95";
|
||||
#else
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
"$Id: df.c,v 1.19 1997/10/13 09:36:05 joerg Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -59,55 +59,21 @@ static const char rcsid[] =
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sysexits.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define UNITS_SI 1
|
||||
#define UNITS_2 2
|
||||
|
||||
#define KILO_SZ(n) (n)
|
||||
#define MEGA_SZ(n) ((n) * (n))
|
||||
#define GIGA_SZ(n) ((n) * (n) * (n))
|
||||
#define TERA_SZ(n) ((n) * (n) * (n) * (n))
|
||||
#define PETA_SZ(n) ((n) * (n) * (n) * (n) * (n))
|
||||
|
||||
#define KILO_2_SZ (KILO_SZ(1024ULL))
|
||||
#define MEGA_2_SZ (MEGA_SZ(1024ULL))
|
||||
#define GIGA_2_SZ (GIGA_SZ(1024ULL))
|
||||
#define TERA_2_SZ (TERA_SZ(1024ULL))
|
||||
#define PETA_2_SZ (PETA_SZ(1024ULL))
|
||||
|
||||
#define KILO_SI_SZ (KILO_SZ(1000ULL))
|
||||
#define MEGA_SI_SZ (MEGA_SZ(1000ULL))
|
||||
#define GIGA_SI_SZ (GIGA_SZ(1000ULL))
|
||||
#define TERA_SI_SZ (TERA_SZ(1000ULL))
|
||||
#define PETA_SI_SZ (PETA_SZ(1000ULL))
|
||||
|
||||
unsigned long long vals_si [] = {1, KILO_SI_SZ, MEGA_SI_SZ, GIGA_SI_SZ, TERA_SI_SZ, PETA_SI_SZ};
|
||||
unsigned long long vals_base2[] = {1, KILO_2_SZ, MEGA_2_SZ, GIGA_2_SZ, TERA_2_SZ, PETA_2_SZ};
|
||||
unsigned long long *valp;
|
||||
|
||||
typedef enum { NONE, KILO, MEGA, GIGA, TERA, PETA, UNIT_MAX } unit_t;
|
||||
|
||||
int unitp [] = { NONE, KILO, MEGA, GIGA, TERA, PETA };
|
||||
|
||||
int checkvfsname __P((const char *, char **));
|
||||
char **makevfslist __P((char *));
|
||||
long regetmntinfo __P((struct statfs **, long, char **));
|
||||
int bread __P((off_t, void *, int));
|
||||
char *getmntpt __P((char *));
|
||||
void prthuman __P((struct statfs *, long));
|
||||
void prthumanval __P((double));
|
||||
void prtstat __P((struct statfs *, int));
|
||||
int ufs_df __P((char *, int));
|
||||
unit_t unit_adjust __P((double *));
|
||||
void usage __P((void));
|
||||
|
||||
int hflag, iflag, nflag;
|
||||
int iflag, nflag;
|
||||
struct ufs_args mdev;
|
||||
|
||||
int
|
||||
@@ -122,32 +88,13 @@ main(argc, argv)
|
||||
char *mntpt, *mntpath, **vfslist;
|
||||
|
||||
vfslist = NULL;
|
||||
while ((ch = getopt(argc, argv, "bHhikmnPt:")) != -1)
|
||||
while ((ch = getopt(argc, argv, "iknt:")) != -1)
|
||||
switch (ch) {
|
||||
case 'b':
|
||||
/* FALLTHROUGH */
|
||||
case 'P':
|
||||
putenv("BLOCKSIZE=512");
|
||||
hflag = 0;
|
||||
break;
|
||||
case 'H':
|
||||
hflag = UNITS_SI;
|
||||
valp = vals_si;
|
||||
break;
|
||||
case 'h':
|
||||
hflag = UNITS_2;
|
||||
valp = vals_base2;
|
||||
break;
|
||||
case 'i':
|
||||
iflag = 1;
|
||||
break;
|
||||
case 'k':
|
||||
putenv("BLOCKSIZE=1k");
|
||||
hflag = 0;
|
||||
break;
|
||||
case 'm':
|
||||
putenv("BLOCKSIZE=1m");
|
||||
hflag = 0;
|
||||
break;
|
||||
case 'n':
|
||||
nflag = 1;
|
||||
@@ -183,9 +130,8 @@ main(argc, argv)
|
||||
maxwidth = width;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < mntsize; i++) {
|
||||
for (i = 0; i < mntsize; i++)
|
||||
prtstat(&mntbuf[i], maxwidth);
|
||||
}
|
||||
exit(rv);
|
||||
}
|
||||
|
||||
@@ -297,61 +243,6 @@ regetmntinfo(mntbufp, mntsize, vfslist)
|
||||
return (j);
|
||||
}
|
||||
|
||||
/*
|
||||
* Output in "human-readable" format. Uses 3 digits max and puts
|
||||
* unit suffixes at the end. Makes output compact and easy to read,
|
||||
* especially on huge disks.
|
||||
*
|
||||
*/
|
||||
unit_t
|
||||
unit_adjust(val)
|
||||
double *val;
|
||||
{
|
||||
double abval;
|
||||
unit_t unit;
|
||||
unsigned int unit_sz;
|
||||
|
||||
abval = fabs(*val);
|
||||
|
||||
unit_sz = abval ? ilogb(abval) / 10 : 0;
|
||||
|
||||
if (unit_sz >= UNIT_MAX) {
|
||||
unit = NONE;
|
||||
} else {
|
||||
unit = unitp[unit_sz];
|
||||
*val /= (double)valp[unit_sz];
|
||||
}
|
||||
|
||||
return (unit);
|
||||
}
|
||||
|
||||
void
|
||||
prthuman(sfsp, used)
|
||||
struct statfs *sfsp;
|
||||
long used;
|
||||
{
|
||||
|
||||
prthumanval((double)sfsp->f_blocks * (double)sfsp->f_bsize);
|
||||
prthumanval((double)used * (double)sfsp->f_bsize);
|
||||
prthumanval((double)sfsp->f_bavail * (double)sfsp->f_bsize);
|
||||
}
|
||||
|
||||
void
|
||||
prthumanval(bytes)
|
||||
double bytes;
|
||||
{
|
||||
|
||||
unit_t unit;
|
||||
unit = unit_adjust(&bytes);
|
||||
|
||||
if (bytes == 0)
|
||||
(void)printf(" 0B");
|
||||
else if (bytes > 10)
|
||||
(void)printf(" %5.0f%c", bytes, "BKMGTPE"[unit]);
|
||||
else
|
||||
(void)printf(" %5.1f%c", bytes, "BKMGTPE"[unit]);
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert statfs returned filesystem size into BLOCKSIZE units.
|
||||
* Attempts to avoid overflow for large filesystems.
|
||||
@@ -376,16 +267,9 @@ prtstat(sfsp, maxwidth)
|
||||
if (maxwidth < 11)
|
||||
maxwidth = 11;
|
||||
if (++timesthrough == 1) {
|
||||
if (hflag) {
|
||||
header = " Size";
|
||||
headerlen = strlen(header);
|
||||
(void)printf("%-*.*s %-s Used Avail Capacity",
|
||||
maxwidth, maxwidth, "Filesystem", header);
|
||||
} else {
|
||||
header = getbsize(&headerlen, &blocksize);
|
||||
(void)printf("%-*.*s %-s Used Avail Capacity",
|
||||
maxwidth, maxwidth, "Filesystem", header);
|
||||
}
|
||||
header = getbsize(&headerlen, &blocksize);
|
||||
(void)printf("%-*.*s %s Used Avail Capacity",
|
||||
maxwidth, maxwidth, "Filesystem", header);
|
||||
if (iflag)
|
||||
(void)printf(" iused ifree %%iused");
|
||||
(void)printf(" Mounted on\n");
|
||||
@@ -393,14 +277,10 @@ prtstat(sfsp, maxwidth)
|
||||
(void)printf("%-*.*s", maxwidth, maxwidth, sfsp->f_mntfromname);
|
||||
used = sfsp->f_blocks - sfsp->f_bfree;
|
||||
availblks = sfsp->f_bavail + used;
|
||||
if (hflag) {
|
||||
prthuman(sfsp, used);
|
||||
} else {
|
||||
(void)printf(" %*ld %8ld %8ld", headerlen,
|
||||
fsbtoblk(sfsp->f_blocks, sfsp->f_bsize, blocksize),
|
||||
fsbtoblk(used, sfsp->f_bsize, blocksize),
|
||||
fsbtoblk(sfsp->f_bavail, sfsp->f_bsize, blocksize));
|
||||
}
|
||||
(void)printf(" %*ld %8ld %8ld", headerlen,
|
||||
fsbtoblk(sfsp->f_blocks, sfsp->f_bsize, blocksize),
|
||||
fsbtoblk(used, sfsp->f_bsize, blocksize),
|
||||
fsbtoblk(sfsp->f_bavail, sfsp->f_bsize, blocksize));
|
||||
(void)printf(" %5.0f%%",
|
||||
availblks == 0 ? 100.0 : (double)used / (double)availblks * 100.0);
|
||||
if (iflag) {
|
||||
@@ -496,8 +376,7 @@ bread(off, buf, cnt)
|
||||
void
|
||||
usage()
|
||||
{
|
||||
|
||||
(void)fprintf(stderr,
|
||||
"usage: df [-b | -H | -h | -k | -m | -P] [-ain] [-t type] [file | filesystem ...]\n");
|
||||
exit(EX_USAGE);
|
||||
"usage: df [-ikn] [-t type] [file | filesystem ...]\n");
|
||||
exit(1);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
# $FreeBSD$
|
||||
# $Id$
|
||||
|
||||
PROG= domainname
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" From: @(#)hostname.1 8.1 (Berkeley) 5/31/93
|
||||
.\" $FreeBSD$
|
||||
.\" $Id: domainname.1,v 1.6 1998/05/13 07:37:23 charnier Exp $
|
||||
.\"
|
||||
.Dd September 18, 1994
|
||||
.Dt DOMAINNAME 1
|
||||
|
||||
@@ -42,7 +42,7 @@ static char const copyright[] =
|
||||
static char const sccsid[] = "From: @(#)hostname.c 8.1 (Berkeley) 5/31/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
"$Id$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
# @(#)Makefile 8.1 (Berkeley) 5/31/93
|
||||
# $FreeBSD$
|
||||
# $Id$
|
||||
|
||||
PROG= echo
|
||||
|
||||
|
||||
+2
-12
@@ -33,7 +33,7 @@
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)echo.1 8.1 (Berkeley) 7/22/93
|
||||
.\" $FreeBSD$
|
||||
.\" $Id: echo.1,v 1.6 1998/05/13 07:39:07 charnier Exp $
|
||||
.\"
|
||||
.Dd July 22, 1993
|
||||
.Dt ECHO 1
|
||||
@@ -59,22 +59,12 @@ Do not print the trailing newline character. This may also be
|
||||
achieved by appending `\ec' to the end of the string, as is done
|
||||
by iBCS2 compatible systems.
|
||||
.El
|
||||
.Pp
|
||||
Some shells may provide a builtin
|
||||
.Nm
|
||||
command which is similar or identical to this utility.
|
||||
Consult the
|
||||
.Xr builtin 1
|
||||
manual page.
|
||||
.Sh DIAGNOSTICS
|
||||
The
|
||||
.Nm
|
||||
utility exits 0 on success, and >0 if an error occurs.
|
||||
.Sh SEE ALSO
|
||||
.Xr builtin 1 ,
|
||||
.Xr csh 1 ,
|
||||
.Xr printf 1 ,
|
||||
.Xr sh 1
|
||||
.Xr printf 1
|
||||
.Sh STANDARDS
|
||||
The
|
||||
.Nm
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ static char const copyright[] =
|
||||
static char sccsid[] = "@(#)echo.c 8.1 (Berkeley) 5/31/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
"$Id$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
# $FreeBSD$
|
||||
# $Id: Makefile,v 1.15 1997/02/22 14:03:08 peter Exp $
|
||||
|
||||
PROG= ed
|
||||
SRCS= buf.c cbc.c glbl.c io.c main.c re.c sub.c undo.c
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
$FreeBSD$
|
||||
$Id$
|
||||
|
||||
This version of ed(1) is not strictly POSIX compliant, as described in
|
||||
the POSIX 1003.2 document. The following is a summary of the omissions,
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
$FreeBSD$
|
||||
$Id$
|
||||
|
||||
ed is an 8-bit-clean, POSIX-compliant line editor. It should work with
|
||||
any regular expression package that conforms to the POSIX interface
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@
|
||||
static char * const rcsid = "@(#)buf.c,v 1.4 1994/02/01 00:34:35 alm Exp";
|
||||
#else
|
||||
static char * const rcsid =
|
||||
"$FreeBSD$";
|
||||
"$Id: buf.c,v 1.15 1997/12/31 12:25:33 helbig Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@
|
||||
static char * const rcsid = "@(#)cbc.c,v 1.2 1994/02/01 00:34:36 alm Exp";
|
||||
#else
|
||||
static char * const rcsid =
|
||||
"$FreeBSD$";
|
||||
"$Id: cbc.c,v 1.10 1997/08/07 21:33:40 steve Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
||||
+7
-13
@@ -1,11 +1,10 @@
|
||||
.\" $FreeBSD$
|
||||
.\" $Id: ed.1,v 1.13 1998/05/13 07:41:13 charnier Exp $
|
||||
.Dd May 21, 1993
|
||||
.Dt ED 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
.\" ed, red \- text editor
|
||||
.Nm ed ,
|
||||
.Nm red
|
||||
.Nm ed
|
||||
.Nd text editor
|
||||
.Sh SYNOPSIS
|
||||
.Nm ed
|
||||
@@ -116,8 +115,7 @@ default addresses are supplied.
|
||||
The following options are available:
|
||||
.Bl -tag -width indent
|
||||
.It Fl s
|
||||
Suppress diagnostics.
|
||||
This should be used if
|
||||
Suppress diagnostics. This should be used if
|
||||
.Nm Ns 's
|
||||
standard input is from a script.
|
||||
.It Fl x
|
||||
@@ -176,8 +174,7 @@ This means "before the first line,"
|
||||
and is legal wherever it makes sense.
|
||||
.Pp
|
||||
An address range is two addresses separated either by a comma or
|
||||
semi-colon.
|
||||
The value of the first address in a range cannot exceed the
|
||||
semi-colon. The value of the first address in a range cannot exceed the
|
||||
value of the second. If only one address is given in a range, then
|
||||
the second address is set to the given address. If an
|
||||
.Em n Ns -tuple
|
||||
@@ -455,8 +452,7 @@ The current address is set to last line entered.
|
||||
.It (.,.)d
|
||||
Delete the addressed lines from the buffer.
|
||||
If there is a line after the deleted range, then the current address is set
|
||||
to this line.
|
||||
Otherwise the current address is set to the line
|
||||
to this line. Otherwise the current address is set to the line
|
||||
before the deleted range.
|
||||
.It e Ar file
|
||||
Edit
|
||||
@@ -591,8 +587,7 @@ Print the addressed lines along with
|
||||
their line numbers. The current address is set to the last line
|
||||
printed.
|
||||
.It (.,.)p
|
||||
Print the addressed lines.
|
||||
The current address is set to the last line
|
||||
Print the addressed lines. The current address is set to the last line
|
||||
printed.
|
||||
.It P
|
||||
Toggle the command prompt on and off.
|
||||
@@ -835,8 +830,7 @@ attempts to write the buffer if the terminal hangs up
|
||||
USD:12-13
|
||||
|
||||
.Rs
|
||||
.%A B. W. Kernighan
|
||||
.%A P. J. Plauger
|
||||
.%A B. W. Kernighan and P. J. Plauger
|
||||
.%B Software Tools in Pascal
|
||||
.%O Addison-Wesley
|
||||
.%D 1981
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)ed.h,v 1.5 1994/02/01 00:34:39 alm Exp
|
||||
* $FreeBSD$
|
||||
* $Id: ed.h,v 1.11 1997/12/10 22:18:23 eivind Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h> /* for MAXPATHLEN */
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@
|
||||
static char * const rcsid = "@(#)glob.c,v 1.1 1994/02/01 00:34:40 alm Exp";
|
||||
#else
|
||||
static char * const rcsid =
|
||||
"$FreeBSD$";
|
||||
"$Id: glbl.c,v 1.7 1997/02/22 14:03:15 peter Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@
|
||||
static char * const rcsid = "@(#)io.c,v 1.1 1994/02/01 00:34:41 alm Exp";
|
||||
#else
|
||||
static char * const rcsid =
|
||||
"$FreeBSD$";
|
||||
"$Id: io.c,v 1.8 1997/02/22 14:03:16 peter Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
||||
+4
-6
@@ -37,7 +37,7 @@ static char * const copyright =
|
||||
static char * const rcsid = "@(#)main.c,v 1.1 1994/02/01 00:34:42 alm Exp";
|
||||
#else
|
||||
static char * const rcsid =
|
||||
"$FreeBSD$";
|
||||
"$Id: main.c,v 1.12 1997/10/08 14:47:56 eivind Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -175,9 +175,7 @@ top:
|
||||
if (read_file(*argv, 0) < 0 && !isatty(0))
|
||||
quit(2);
|
||||
else if (**argv != '!')
|
||||
if (strlcpy(old_filename, *argv, sizeof(old_filename))
|
||||
>= sizeof(old_filename))
|
||||
quit(2);
|
||||
strcpy(old_filename, *argv);
|
||||
} else if (argc) {
|
||||
fputs("?\n", stderr);
|
||||
if (**argv == '\0')
|
||||
@@ -1347,8 +1345,8 @@ strip_escapes(s)
|
||||
int i = 0;
|
||||
|
||||
REALLOC(file, filesz, MAXPATHLEN + 1, NULL);
|
||||
while (i < filesz - 1 /* Worry about a possible trailing escape */
|
||||
&& (file[i++] = (*s == '\\') ? *++s : *s))
|
||||
/* assert: no trailing escape */
|
||||
while ((file[i++] = (*s == '\\') ? *++s : *s))
|
||||
s++;
|
||||
return file;
|
||||
}
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@
|
||||
static char * const rcsid = "@(#)re.c,v 1.6 1994/02/01 00:34:43 alm Exp";
|
||||
#else
|
||||
static char * const rcsid =
|
||||
"$FreeBSD$";
|
||||
"$Id: re.c,v 1.13 1997/02/22 14:03:18 peter Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
||||
Loaded 100 of 9607 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user