MFC
This commit is contained in:
commit
0fbf163e60
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/projects/random_number_generator/; revision=255317
8
Makefile
8
Makefile
@ -498,3 +498,11 @@ universe_epilogue:
|
||||
|
||||
buildLINT:
|
||||
${MAKE} -C ${.CURDIR}/sys/${_TARGET}/conf LINT
|
||||
|
||||
.if defined(.PARSEDIR)
|
||||
.if make(universe)
|
||||
# we do not want a failure of one branch abort all.
|
||||
MAKE_JOB_ERROR_TOKEN= no
|
||||
.export MAKE_JOB_ERROR_TOKEN
|
||||
.endif
|
||||
.endif
|
||||
|
@ -38,6 +38,9 @@
|
||||
# xargs -n1 | sort | uniq -d;
|
||||
# done
|
||||
|
||||
# 20130903: gnupatch is no more
|
||||
OLD_FILES+=usr/bin/gnupatch
|
||||
OLD_FILES+=usr/share/man/man1/gnupatch.1.gz
|
||||
# 20130829: bsdpatch is patch unconditionally
|
||||
OLD_FILES+=usr/bin/bsdpatch
|
||||
OLD_FILES+=usr/share/man/man1/bsdpatch.1.gz
|
||||
|
14
UPDATING
14
UPDATING
@ -31,6 +31,20 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 10.x IS SLOW:
|
||||
disable the most expensive debugging functionality run
|
||||
"ln -s 'abort:false,junk:false' /etc/malloc.conf".)
|
||||
|
||||
20130905:
|
||||
The PROCDESC kernel option is now part of the GENERIC kernel
|
||||
configuration and is required for the rwhod(8) to work.
|
||||
If you are using custom kernel configuration, you should include
|
||||
'options PROCDESC'.
|
||||
|
||||
20130905:
|
||||
The API and ABI related to the Capsicum framework was modified
|
||||
in backward incompatible way. The userland libraries and programs
|
||||
have to be recompiled to work with the new kernel. This includes the
|
||||
following libraries and programs, but the whole buildworld is
|
||||
advised: libc, libprocstat, dhclient, tcpdump, hastd, hastctl,
|
||||
kdump, procstat, rwho, rwhod, uniq.
|
||||
|
||||
20130827:
|
||||
Thomas Dickey (vendor author thereof) reports that dialog(1) since
|
||||
2011/10/18 has a bug in handling --hline. Testers and I noticed the
|
||||
|
@ -324,7 +324,7 @@ skipping: if (evalskip == SKIPCONT && --skipcount <= 0) {
|
||||
}
|
||||
if (evalskip == SKIPBREAK && --skipcount <= 0)
|
||||
evalskip = 0;
|
||||
if (evalskip == SKIPFUNC || evalskip == SKIPFILE)
|
||||
if (evalskip == SKIPRETURN)
|
||||
status = exitstatus;
|
||||
break;
|
||||
}
|
||||
@ -1068,7 +1068,7 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd)
|
||||
funcnest--;
|
||||
popredir();
|
||||
INTON;
|
||||
if (evalskip == SKIPFUNC) {
|
||||
if (evalskip == SKIPRETURN) {
|
||||
evalskip = 0;
|
||||
skipcount = 0;
|
||||
}
|
||||
@ -1305,14 +1305,8 @@ returncmd(int argc, char **argv)
|
||||
{
|
||||
int ret = argc > 1 ? number(argv[1]) : oexitstatus;
|
||||
|
||||
if (funcnest) {
|
||||
evalskip = SKIPFUNC;
|
||||
skipcount = 1;
|
||||
} else {
|
||||
/* skip the rest of the file */
|
||||
evalskip = SKIPFILE;
|
||||
skipcount = 1;
|
||||
}
|
||||
evalskip = SKIPRETURN;
|
||||
skipcount = 1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -67,5 +67,4 @@ extern int skipcount;
|
||||
/* reasons for skipping commands (see comment on breakcmd routine) */
|
||||
#define SKIPBREAK 1
|
||||
#define SKIPCONT 2
|
||||
#define SKIPFUNC 3
|
||||
#define SKIPFILE 4
|
||||
#define SKIPRETURN 3
|
||||
|
@ -83,13 +83,12 @@ static struct job *bgjob = NULL; /* last background process */
|
||||
static struct job *jobmru; /* most recently used job list */
|
||||
static pid_t initialpgrp; /* pgrp of shell on invocation */
|
||||
#endif
|
||||
int in_waitcmd = 0; /* are we in waitcmd()? */
|
||||
volatile sig_atomic_t breakwaitcmd = 0; /* should wait be terminated? */
|
||||
static int ttyfd = -1;
|
||||
|
||||
/* mode flags for dowait */
|
||||
#define DOWAIT_BLOCK 0x1 /* wait until a child exits */
|
||||
#define DOWAIT_SIG 0x2 /* if DOWAIT_BLOCK, abort on signals */
|
||||
#define DOWAIT_SIG 0x2 /* if DOWAIT_BLOCK, abort on SIGINT/SIGQUIT */
|
||||
#define DOWAIT_SIG_ANY 0x4 /* if DOWAIT_SIG, abort on any signal */
|
||||
|
||||
#if JOBS
|
||||
static void restartjob(struct job *);
|
||||
@ -484,7 +483,7 @@ waitcmd(int argc __unused, char **argv __unused)
|
||||
static int
|
||||
waitcmdloop(struct job *job)
|
||||
{
|
||||
int status, retval;
|
||||
int status, retval, sig;
|
||||
struct job *jp;
|
||||
|
||||
/*
|
||||
@ -492,7 +491,6 @@ waitcmdloop(struct job *job)
|
||||
* received.
|
||||
*/
|
||||
|
||||
in_waitcmd++;
|
||||
do {
|
||||
if (job != NULL) {
|
||||
if (job->state == JOBDONE) {
|
||||
@ -508,7 +506,6 @@ waitcmdloop(struct job *job)
|
||||
if (job == bgjob)
|
||||
bgjob = NULL;
|
||||
}
|
||||
in_waitcmd--;
|
||||
return retval;
|
||||
}
|
||||
} else {
|
||||
@ -524,7 +521,6 @@ waitcmdloop(struct job *job)
|
||||
}
|
||||
for (jp = jobtab ; ; jp++) {
|
||||
if (jp >= jobtab + njobs) { /* no running procs */
|
||||
in_waitcmd--;
|
||||
return 0;
|
||||
}
|
||||
if (jp->used && jp->state == 0)
|
||||
@ -532,9 +528,10 @@ waitcmdloop(struct job *job)
|
||||
}
|
||||
}
|
||||
} while (dowait(DOWAIT_BLOCK | DOWAIT_SIG, (struct job *)NULL) != -1);
|
||||
in_waitcmd--;
|
||||
|
||||
return pendingsig + 128;
|
||||
sig = pendingsig_waitcmd;
|
||||
pendingsig_waitcmd = 0;
|
||||
return sig + 128;
|
||||
}
|
||||
|
||||
|
||||
@ -990,7 +987,8 @@ waitforjob(struct job *jp, int *origstatus)
|
||||
INTOFF;
|
||||
TRACE(("waitforjob(%%%td) called\n", jp - jobtab + 1));
|
||||
while (jp->state == 0)
|
||||
if (dowait(DOWAIT_BLOCK | (Tflag ? DOWAIT_SIG : 0), jp) == -1)
|
||||
if (dowait(DOWAIT_BLOCK | (Tflag ? DOWAIT_SIG |
|
||||
DOWAIT_SIG_ANY : 0), jp) == -1)
|
||||
dotrap();
|
||||
#if JOBS
|
||||
if (jp->jobctl) {
|
||||
@ -1081,12 +1079,17 @@ dowait(int mode, struct job *job)
|
||||
pid = wait3(&status, wflags, (struct rusage *)NULL);
|
||||
TRACE(("wait returns %d, status=%d\n", (int)pid, status));
|
||||
if (pid == 0 && (mode & DOWAIT_SIG) != 0) {
|
||||
sigsuspend(&omask);
|
||||
pid = -1;
|
||||
if (((mode & DOWAIT_SIG_ANY) != 0 ?
|
||||
pendingsig : pendingsig_waitcmd) != 0) {
|
||||
errno = EINTR;
|
||||
break;
|
||||
}
|
||||
sigsuspend(&omask);
|
||||
if (int_pending())
|
||||
break;
|
||||
}
|
||||
} while (pid == -1 && errno == EINTR && breakwaitcmd == 0);
|
||||
} while (pid == -1 && errno == EINTR);
|
||||
if (pid == -1 && errno == ECHILD && job != NULL)
|
||||
job->state = JOBDONE;
|
||||
if ((mode & DOWAIT_SIG) != 0) {
|
||||
@ -1095,11 +1098,6 @@ dowait(int mode, struct job *job)
|
||||
sigprocmask(SIG_SETMASK, &omask, NULL);
|
||||
INTON;
|
||||
}
|
||||
if (breakwaitcmd != 0) {
|
||||
breakwaitcmd = 0;
|
||||
if (pid <= 0)
|
||||
return -1;
|
||||
}
|
||||
if (pid <= 0)
|
||||
return pid;
|
||||
INTOFF;
|
||||
|
@ -83,8 +83,6 @@ enum {
|
||||
};
|
||||
|
||||
extern int job_warning; /* user was warned about stopped jobs */
|
||||
extern int in_waitcmd; /* are we in waitcmd()? */
|
||||
extern volatile sig_atomic_t breakwaitcmd; /* break wait to process traps? */
|
||||
|
||||
void setjobctl(int);
|
||||
void showjobs(int, int);
|
||||
|
@ -231,7 +231,7 @@ cmdloop(int top)
|
||||
popstackmark(&smark);
|
||||
setstackmark(&smark);
|
||||
if (evalskip != 0) {
|
||||
if (evalskip == SKIPFILE)
|
||||
if (evalskip == SKIPRETURN)
|
||||
evalskip = 0;
|
||||
break;
|
||||
}
|
||||
|
@ -1145,8 +1145,10 @@ command is
|
||||
.Pp
|
||||
.D1 Ic return Op Ar exitstatus
|
||||
.Pp
|
||||
It terminates the current executional scope, returning from the previous
|
||||
nested function, sourced script, or shell instance, in that order.
|
||||
It terminates the current executional scope, returning from the closest
|
||||
nested function or sourced script;
|
||||
if no function or sourced script is being executed,
|
||||
it exits the shell instance.
|
||||
The
|
||||
.Ic return
|
||||
command is implemented as a special built-in command.
|
||||
|
@ -74,6 +74,7 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
static char sigmode[NSIG]; /* current value of signal */
|
||||
volatile sig_atomic_t pendingsig; /* indicates some signal received */
|
||||
volatile sig_atomic_t pendingsig_waitcmd; /* indicates SIGINT/SIGQUIT received */
|
||||
int in_dotrap; /* do we execute in a trap handler? */
|
||||
static char *volatile trap[NSIG]; /* trap handler commands */
|
||||
static volatile sig_atomic_t gotsig[NSIG];
|
||||
@ -389,23 +390,13 @@ onsig(int signo)
|
||||
}
|
||||
|
||||
/* If we are currently in a wait builtin, prepare to break it */
|
||||
if ((signo == SIGINT || signo == SIGQUIT) && in_waitcmd != 0) {
|
||||
breakwaitcmd = 1;
|
||||
pendingsig = signo;
|
||||
}
|
||||
if (signo == SIGINT || signo == SIGQUIT)
|
||||
pendingsig_waitcmd = signo;
|
||||
|
||||
if (trap[signo] != NULL && trap[signo][0] != '\0' &&
|
||||
(signo != SIGCHLD || !ignore_sigchld)) {
|
||||
gotsig[signo] = 1;
|
||||
pendingsig = signo;
|
||||
|
||||
/*
|
||||
* If a trap is set, not ignored and not the null command, we
|
||||
* need to make sure traps are executed even when a child
|
||||
* blocks signals.
|
||||
*/
|
||||
if (Tflag && !(trap[signo][0] == ':' && trap[signo][1] == '\0'))
|
||||
breakwaitcmd = 1;
|
||||
}
|
||||
|
||||
#ifndef NO_HISTORY
|
||||
@ -428,6 +419,7 @@ dotrap(void)
|
||||
in_dotrap++;
|
||||
for (;;) {
|
||||
pendingsig = 0;
|
||||
pendingsig_waitcmd = 0;
|
||||
for (i = 1; i < NSIG; i++) {
|
||||
if (gotsig[i]) {
|
||||
gotsig[i] = 0;
|
||||
|
@ -34,6 +34,7 @@
|
||||
*/
|
||||
|
||||
extern volatile sig_atomic_t pendingsig;
|
||||
extern volatile sig_atomic_t pendingsig_waitcmd;
|
||||
extern int in_dotrap;
|
||||
extern volatile sig_atomic_t gotwinch;
|
||||
|
||||
|
@ -3990,7 +3990,8 @@ output_insn (void)
|
||||
goto check_prefix;
|
||||
}
|
||||
}
|
||||
else if (i.tm.base_opcode == 0x660f3880 || i.tm.base_opcode == 0x660f3881)
|
||||
else if (i.tm.base_opcode == 0x660f3880 || i.tm.base_opcode == 0x660f3881
|
||||
|| i.tm.base_opcode == 0x660f3882)
|
||||
{
|
||||
/* invept and invvpid are 3 byte instructions with a
|
||||
mandatory prefix. */
|
||||
@ -4040,7 +4041,8 @@ output_insn (void)
|
||||
*p++ = (i.tm.base_opcode >> 16) & 0xff;
|
||||
}
|
||||
else if (i.tm.base_opcode == 0x660f3880 ||
|
||||
i.tm.base_opcode == 0x660f3881)
|
||||
i.tm.base_opcode == 0x660f3881 ||
|
||||
i.tm.base_opcode == 0x660f3882)
|
||||
{
|
||||
p = frag_more (3);
|
||||
*p++ = (i.tm.base_opcode >> 16) & 0xff;
|
||||
|
@ -550,6 +550,7 @@ fetch_data (struct disassemble_info *info, bfd_byte *addr)
|
||||
#define PREGRP104 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 104 } }
|
||||
#define PREGRP105 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 105 } }
|
||||
#define PREGRP106 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 106 } }
|
||||
#define PREGRP107 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 107 } }
|
||||
|
||||
|
||||
#define X86_64_0 NULL, { { NULL, X86_64_SPECIAL }, { NULL, 0 } }
|
||||
@ -2668,6 +2669,14 @@ static const struct dis386 prefix_user_table[][4] = {
|
||||
{ "pclmulqdq", { XM, EXx, Ib } },
|
||||
{ "(bad)", { XX } },
|
||||
},
|
||||
|
||||
/* PREGRP107 */
|
||||
{
|
||||
{ "(bad)", { XX } },
|
||||
{ "(bad)", { XX } },
|
||||
{ "invpcid",{ Gm, Mo } },
|
||||
{ "(bad)", { XX } },
|
||||
},
|
||||
};
|
||||
|
||||
static const struct dis386 x86_64_table[][2] = {
|
||||
@ -2839,7 +2848,7 @@ static const struct dis386 three_byte_table[][256] = {
|
||||
/* 80 */
|
||||
{ PREGRP98 },
|
||||
{ PREGRP99 },
|
||||
{ "(bad)", { XX } },
|
||||
{ PREGRP107 },
|
||||
{ "(bad)", { XX } },
|
||||
{ "(bad)", { XX } },
|
||||
{ "(bad)", { XX } },
|
||||
|
@ -1498,3 +1498,7 @@ xsetbv, 0, 0xf01, 0xd1, CpuXSAVE, No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_qSuf|No_xSu
|
||||
xsave, 1, 0xfae, 0x4, CpuXSAVE, Modrm|No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_xSuf, { BaseIndex|Disp8|Disp16|Disp32|Disp32S }
|
||||
xsaveopt, 1, 0xfae, 0x6, CpuXSAVE, Modrm|No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_xSuf, { BaseIndex|Disp8|Disp16|Disp32|Disp32S }
|
||||
xrstor, 1, 0xfae, 0x5, CpuXSAVE, Modrm|No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_xSuf, { BaseIndex|Disp8|Disp16|Disp32|Disp32S }
|
||||
|
||||
// INVPCID
|
||||
invpcid, 2, 0x660f3882, None, CpuNo64, Modrm|IgnoreSize|No_bSuf|No_wSuf|No_sSuf|No_qSuf|No_xSuf|NoRex64, { BaseIndex|Disp8|Disp16|Disp32|Disp32S, Reg32 }
|
||||
invpcid, 2, 0x660f3882, None, Cpu64, Modrm|IgnoreSize|No_bSuf|No_wSuf|No_sSuf|No_qSuf|No_xSuf|NoRex64, { BaseIndex|Disp8|Disp16|Disp32|Disp32S, Reg64 }
|
||||
|
@ -3641,6 +3641,14 @@ const template i386_optab[] =
|
||||
Modrm|IgnoreSize|No_bSuf|No_wSuf|No_sSuf|No_qSuf|No_xSuf|NoRex64,
|
||||
{ BaseIndex|Disp8|Disp16|Disp32|Disp32S,
|
||||
Reg64 } },
|
||||
{ "invpcid", 2, 0x660f3882, None, CpuNo64,
|
||||
Modrm|IgnoreSize|No_bSuf|No_wSuf|No_sSuf|No_qSuf|No_xSuf|NoRex64,
|
||||
{ BaseIndex|Disp8|Disp16|Disp32|Disp32S,
|
||||
Reg32 } },
|
||||
{ "invpcid", 2, 0x660f3882, None, Cpu64,
|
||||
Modrm|IgnoreSize|No_bSuf|No_wSuf|No_sSuf|No_qSuf|No_xSuf|NoRex64,
|
||||
{ BaseIndex|Disp8|Disp16|Disp32|Disp32S,
|
||||
Reg64 } },
|
||||
{ "vmcall", 0, 0xf01, 0xc1, CpuVMX,
|
||||
No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_qSuf|No_xSuf|ImmExt,
|
||||
{ 0 } },
|
||||
|
@ -1,3 +1,24 @@
|
||||
2013-09-04 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* Makefile (MAKE_VERSION): 20130904
|
||||
Merge with NetBSD make, pick up
|
||||
o Add VAR_INTERNAL context, so that internal setting of
|
||||
MAKEFILE does not override value set by makefiles.
|
||||
|
||||
2013-09-02 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* Makefile (MAKE_VERSION): 20130902
|
||||
Merge with NetBSD make, pick up
|
||||
o CompatRunCommand: only apply shellErrFlag when errCheck is true
|
||||
|
||||
2013-08-28 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* Makefile (MAKE_VERSION): 20130828
|
||||
Merge with NetBSD make, pick up
|
||||
o Fix VAR :sh = syntax from Will Andrews at freebsd.org
|
||||
o Call Job_SetPrefix() from Job_Init() so makefiles have
|
||||
opportunity to set .MAKE.JOB.PREFIX
|
||||
|
||||
2013-07-30 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* Makefile (MAKE_VERSION): 20130730
|
||||
|
@ -114,6 +114,7 @@ unit-tests/order
|
||||
unit-tests/phony-end
|
||||
unit-tests/posix
|
||||
unit-tests/qequals
|
||||
unit-tests/sunshcmd
|
||||
unit-tests/sysv
|
||||
unit-tests/ternary
|
||||
unit-tests/test.exp
|
||||
|
@ -1,7 +1,7 @@
|
||||
# $Id: Makefile,v 1.17 2013/07/30 19:13:53 sjg Exp $
|
||||
# $Id: Makefile,v 1.20 2013/09/04 15:42:03 sjg Exp $
|
||||
|
||||
# Base version on src date
|
||||
MAKE_VERSION= 20130730
|
||||
MAKE_VERSION= 20130904
|
||||
|
||||
PROG= bmake
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: make.1,v 1.220 2013/07/30 19:09:57 sjg Exp $
|
||||
.\" $NetBSD: make.1,v 1.222 2013/08/11 09:53:49 apb Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1990, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@ -29,7 +29,7 @@
|
||||
.\"
|
||||
.\" from: @(#)make.1 8.4 (Berkeley) 3/19/94
|
||||
.\"
|
||||
.Dd July 30, 2013
|
||||
.Dd August 11, 2013
|
||||
.Dt MAKE 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -1971,6 +1971,12 @@ If the source is the special
|
||||
.Ic .DOTLAST
|
||||
target, then the current working
|
||||
directory is searched last.
|
||||
.It Ic .PATH. Ns Va suffix
|
||||
Like
|
||||
.Ic .PATH
|
||||
but applies only to files with a particular suffix.
|
||||
The suffix must have been previously declared with
|
||||
.Ic .SUFFIXES .
|
||||
.It Ic .PHONY
|
||||
Apply the
|
||||
.Ic .PHONY
|
||||
|
@ -1257,6 +1257,10 @@ SSPPEECCIIAALL TTAARRGGEETTSS
|
||||
source is the special ..DDOOTTLLAASSTT target, then the current working
|
||||
directory is searched last.
|
||||
|
||||
..PPAATTHH.._s_u_f_f_i_x
|
||||
Like ..PPAATTHH but applies only to files with a particular suffix.
|
||||
The suffix must have been previously declared with ..SSUUFFFFIIXXEESS.
|
||||
|
||||
..PPHHOONNYY Apply the ..PPHHOONNYY attribute to any specified sources.
|
||||
|
||||
..PPRREECCIIOOUUSS
|
||||
@ -1374,4 +1378,4 @@ BBUUGGSS
|
||||
|
||||
There is no way of escaping a space character in a filename.
|
||||
|
||||
NetBSD 5.1 July 30, 2013 NetBSD 5.1
|
||||
NetBSD 5.1 August 11, 2013 NetBSD 5.1
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: compat.c,v 1.92 2013/07/05 22:14:56 sjg Exp $ */
|
||||
/* $NetBSD: compat.c,v 1.93 2013/09/02 19:26:42 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
|
||||
@ -70,14 +70,14 @@
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: compat.c,v 1.92 2013/07/05 22:14:56 sjg Exp $";
|
||||
static char rcsid[] = "$NetBSD: compat.c,v 1.93 2013/09/02 19:26:42 sjg Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: compat.c,v 1.92 2013/07/05 22:14:56 sjg Exp $");
|
||||
__RCSID("$NetBSD: compat.c,v 1.93 2013/09/02 19:26:42 sjg Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
@ -340,7 +340,7 @@ CompatRunCommand(void *cmdp, void *gnp)
|
||||
/*
|
||||
* The following work for any of the builtin shell specs.
|
||||
*/
|
||||
if (shellErrFlag) {
|
||||
if (errCheck && shellErrFlag) {
|
||||
shargv[shargc++] = shellErrFlag;
|
||||
}
|
||||
if (DEBUG(SHELL))
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: job.c,v 1.175 2013/07/30 19:09:57 sjg Exp $ */
|
||||
/* $NetBSD: job.c,v 1.176 2013/08/04 16:48:15 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
|
||||
@ -70,14 +70,14 @@
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: job.c,v 1.175 2013/07/30 19:09:57 sjg Exp $";
|
||||
static char rcsid[] = "$NetBSD: job.c,v 1.176 2013/08/04 16:48:15 sjg Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: job.c,v 1.175 2013/07/30 19:09:57 sjg Exp $");
|
||||
__RCSID("$NetBSD: job.c,v 1.176 2013/08/04 16:48:15 sjg Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
@ -178,6 +178,14 @@ __RCSID("$NetBSD: job.c,v 1.175 2013/07/30 19:09:57 sjg Exp $");
|
||||
*/
|
||||
#define MAKE_ALWAYS_PASS_JOB_QUEUE ".MAKE.ALWAYS_PASS_JOB_QUEUE"
|
||||
static int Always_pass_job_queue = TRUE;
|
||||
/*
|
||||
* FreeBSD: aborting entire parallel make isn't always
|
||||
* desired. When doing tinderbox for example, failure of
|
||||
* one architecture should not stop all.
|
||||
* We still want to bail on interrupt though.
|
||||
*/
|
||||
#define MAKE_JOB_ERROR_TOKEN "MAKE_JOB_ERROR_TOKEN"
|
||||
static int Job_error_token = TRUE;
|
||||
|
||||
/*
|
||||
* error handling variables
|
||||
@ -2237,6 +2245,9 @@ Job_Init(void)
|
||||
Always_pass_job_queue = getBoolean(MAKE_ALWAYS_PASS_JOB_QUEUE,
|
||||
Always_pass_job_queue);
|
||||
|
||||
Job_error_token = getBoolean(MAKE_JOB_ERROR_TOKEN, Job_error_token);
|
||||
|
||||
|
||||
/*
|
||||
* There is a non-zero chance that we already have children.
|
||||
* eg after 'make -f- <<EOF'
|
||||
@ -2832,13 +2843,19 @@ JobTokenAdd(void)
|
||||
{
|
||||
char tok = JOB_TOKENS[aborting], tok1;
|
||||
|
||||
if (!Job_error_token && aborting == ABORT_ERROR) {
|
||||
if (jobTokensRunning == 0)
|
||||
return;
|
||||
tok = '+'; /* no error token */
|
||||
}
|
||||
|
||||
/* If we are depositing an error token flush everything else */
|
||||
while (tok != '+' && read(tokenWaitJob.inPipe, &tok1, 1) == 1)
|
||||
continue;
|
||||
|
||||
if (DEBUG(JOB))
|
||||
fprintf(debug_file, "(%d) aborting %d, deposit token %c\n",
|
||||
getpid(), aborting, JOB_TOKENS[aborting]);
|
||||
getpid(), aborting, tok);
|
||||
while (write(tokenWaitJob.outPipe, &tok, 1) == -1 && errno == EAGAIN)
|
||||
continue;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: main.c,v 1.222 2013/07/18 15:31:49 sjg Exp $ */
|
||||
/* $NetBSD: main.c,v 1.224 2013/09/04 15:38:26 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
@ -69,7 +69,7 @@
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: main.c,v 1.222 2013/07/18 15:31:49 sjg Exp $";
|
||||
static char rcsid[] = "$NetBSD: main.c,v 1.224 2013/09/04 15:38:26 sjg Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: main.c,v 1.222 2013/07/18 15:31:49 sjg Exp $");
|
||||
__RCSID("$NetBSD: main.c,v 1.224 2013/09/04 15:38:26 sjg Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
@ -1414,7 +1414,7 @@ ReadMakefile(const void *p, const void *q MAKE_ATTR_UNUSED)
|
||||
|
||||
if (!strcmp(fname, "-")) {
|
||||
Parse_File(NULL /*stdin*/, -1);
|
||||
Var_Set("MAKEFILE", "", VAR_GLOBAL, 0);
|
||||
Var_Set("MAKEFILE", "", VAR_INTERNAL, 0);
|
||||
} else {
|
||||
/* if we've chdir'd, rebuild the path name */
|
||||
if (strcmp(curdir, objdir) && *fname != '/') {
|
||||
@ -1463,7 +1463,7 @@ ReadMakefile(const void *p, const void *q MAKE_ATTR_UNUSED)
|
||||
*/
|
||||
found:
|
||||
if (!doing_depend)
|
||||
Var_Set("MAKEFILE", fname, VAR_GLOBAL, 0);
|
||||
Var_Set("MAKEFILE", fname, VAR_INTERNAL, 0);
|
||||
Parse_File(fname, fd);
|
||||
}
|
||||
free(path);
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: make.1,v 1.220 2013/07/30 19:09:57 sjg Exp $
|
||||
.\" $NetBSD: make.1,v 1.222 2013/08/11 09:53:49 apb Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1990, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@ -29,7 +29,7 @@
|
||||
.\"
|
||||
.\" from: @(#)make.1 8.4 (Berkeley) 3/19/94
|
||||
.\"
|
||||
.Dd July 30, 2013
|
||||
.Dd August 11, 2013
|
||||
.Dt MAKE 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -1982,6 +1982,12 @@ If the source is the special
|
||||
.Ic .DOTLAST
|
||||
target, then the current working
|
||||
directory is searched last.
|
||||
.It Ic .PATH. Ns Va suffix
|
||||
Like
|
||||
.Ic .PATH
|
||||
but applies only to files with a particular suffix.
|
||||
The suffix must have been previously declared with
|
||||
.Ic .SUFFIXES .
|
||||
.It Ic .PHONY
|
||||
Apply the
|
||||
.Ic .PHONY
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: make.h,v 1.91 2013/06/18 20:06:09 sjg Exp $ */
|
||||
/* $NetBSD: make.h,v 1.92 2013/09/04 15:38:26 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
@ -404,6 +404,10 @@ extern Boolean varNoExportEnv; /* TRUE if we should not export variables
|
||||
|
||||
extern GNode *DEFAULT; /* .DEFAULT rule */
|
||||
|
||||
extern GNode *VAR_INTERNAL; /* Variables defined internally by make
|
||||
* which should not override those set by
|
||||
* makefiles.
|
||||
*/
|
||||
extern GNode *VAR_GLOBAL; /* Variables defined in a global context, e.g
|
||||
* in the Makefile itself */
|
||||
extern GNode *VAR_CMD; /* Variables defined on the command line */
|
||||
|
@ -1,3 +1,14 @@
|
||||
2013-09-04 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* gendirdeps.mk (_objtops): fix typo also
|
||||
while processing M2D_OBJROOTS to gather qualdir_list
|
||||
qualify $ql with loop iterator to ensure correct results.
|
||||
|
||||
2013-08-01 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): 20130801
|
||||
* libs.mk: update to match progs.mk
|
||||
|
||||
2013-07-26 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): 20130726
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $Id: gendirdeps.mk,v 1.22 2013/05/11 05:16:26 sjg Exp $
|
||||
# $Id: gendirdeps.mk,v 1.23 2013/09/04 17:49:20 sjg Exp $
|
||||
|
||||
# Copyright (c) 2010-2013, Juniper Networks, Inc.
|
||||
# All rights reserved.
|
||||
@ -162,7 +162,7 @@ dir_list != cd ${_OBJDIR} && \
|
||||
.warning Skipping ${_DEPENDFILE:S,${SRCTOP}/,,}
|
||||
# we are not going to update anything
|
||||
.else
|
||||
|
||||
dpadd_dir_list=
|
||||
.if !empty(DPADD)
|
||||
_nonlibs := ${DPADD:T:Nlib*:N*include}
|
||||
.if !empty(_nonlibs)
|
||||
@ -174,6 +174,7 @@ ddep_list += $f.dirdep
|
||||
ddep_list += ${f:H}.dirdep
|
||||
.else
|
||||
dir_list += ${f:H:tA}
|
||||
dpadd_dir_list += ${f:H:tA}
|
||||
.endif
|
||||
.endfor
|
||||
.if !empty(ddep_list)
|
||||
@ -197,7 +198,7 @@ dir_list += ${ddeps}
|
||||
# so we add
|
||||
# ${"${dir_list:M*bsd/sys/${MACHINE_ARCH}/include}":?bsd/include:}
|
||||
# to GENDIRDEPS_DIR_LIST_XTRAS
|
||||
_objtops = ${OBJTOP} ${_OBJTOP} ${_obtop}
|
||||
_objtops = ${OBJTOP} ${_OBJTOP} ${_objtop}
|
||||
_objtops := ${_objtops:O:u}
|
||||
dirdep_list = \
|
||||
${_objtops:@o@${dir_list:M$o*/*:C,$o[^/]*/,,}@} \
|
||||
@ -212,8 +213,11 @@ M2D_OBJROOTS := ${M2D_OBJROOTS:O:u:[-1..1]}
|
||||
skip_ql= ${SRCTOP}* ${_objtops:@o@$o*@}
|
||||
.for o in ${M2D_OBJROOTS:${skip_ql:${M_ListToSkip}}}
|
||||
# we need := so only skip_ql to this point applies
|
||||
ql := ${dir_list:${skip_ql:${M_ListToSkip}}:M$o*/*/*:C,$o([^/]+)/(.*),\2.\1,:S,.${HOST_TARGET},.host,}
|
||||
qualdir_list += ${ql}
|
||||
ql.$o := ${dir_list:${skip_ql:${M_ListToSkip}}:M$o*/*/*:C,$o([^/]+)/(.*),\2.\1,:S,.${HOST_TARGET},.host,}
|
||||
qualdir_list += ${ql.$o}
|
||||
.if ${DEBUG_GENDIRDEPS:Uno:@x@${RELDIR:M$x}@} != ""
|
||||
.info ${RELDIR}: o=$o ${ql.$o qualdir_list:L:@v@$v=${$v}@}
|
||||
.endif
|
||||
skip_ql+= $o*
|
||||
.endfor
|
||||
|
||||
@ -241,6 +245,7 @@ DIRDEPS := ${DIRDEPS:${GENDIRDEPS_FILTER:UNno:ts:}:O:u}
|
||||
.if ${DEBUG_GENDIRDEPS:Uno:@x@${RELDIR:M$x}@} != ""
|
||||
.info ${RELDIR}: M2D_OBJROOTS=${M2D_OBJROOTS}
|
||||
.info ${RELDIR}: dir_list='${dir_list}'
|
||||
.info ${RELDIR}: dpadd_dir_list='${dpadd_dir_list}'
|
||||
.info ${RELDIR}: dirdep_list='${dirdep_list}'
|
||||
.info ${RELDIR}: qualdir_list='${qualdir_list}'
|
||||
.info ${RELDIR}: SKIP_GENDIRDEPS='${SKIP_GENDIRDEPS}'
|
||||
|
@ -55,7 +55,7 @@
|
||||
# Simon J. Gerraty <sjg@crufty.net>
|
||||
|
||||
# RCSid:
|
||||
# $Id: install-mk,v 1.92 2013/07/27 05:37:37 sjg Exp $
|
||||
# $Id: install-mk,v 1.93 2013/08/02 18:28:47 sjg Exp $
|
||||
#
|
||||
# @(#) Copyright (c) 1994 Simon J. Gerraty
|
||||
#
|
||||
@ -70,7 +70,7 @@
|
||||
# sjg@crufty.net
|
||||
#
|
||||
|
||||
MK_VERSION=20130726
|
||||
MK_VERSION=20130801
|
||||
OWNER=
|
||||
GROUP=
|
||||
MODE=444
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $Id: libs.mk,v 1.2 2007/04/30 17:39:27 sjg Exp $
|
||||
# $Id: libs.mk,v 1.3 2013/08/02 18:28:48 sjg Exp $
|
||||
#
|
||||
# @(#) Copyright (c) 2006, Simon J. Gerraty
|
||||
#
|
||||
@ -17,7 +17,15 @@
|
||||
|
||||
.if defined(LIBS)
|
||||
|
||||
# In meta mode, we can capture dependenices for _one_ of the progs.
|
||||
# if makefile doesn't nominate one, we use the first.
|
||||
.ifndef UPDATE_DEPENDFILE_LIB
|
||||
UPDATE_DEPENDFILE_LIB = ${LIBS:[1]}
|
||||
.export UPDATE_DEPENDFILE_LIB
|
||||
.endif
|
||||
|
||||
.ifndef LIB
|
||||
# They may have asked us to build just one
|
||||
.for t in ${LIBS:R:T:S,^lib,,}
|
||||
.if make(lib$t)
|
||||
LIB?= $t
|
||||
@ -28,14 +36,41 @@ lib$t: all
|
||||
|
||||
.if defined(LIB)
|
||||
# just one of many
|
||||
.for v in DPADD SRCS CFLAGS ${LIB_VARS}
|
||||
$v += ${${v}_lib${LIB}}
|
||||
LIB_VARS += \
|
||||
LIBDIR \
|
||||
CFLAGS \
|
||||
COPTS \
|
||||
CPPFLAGS \
|
||||
CXXFLAGS \
|
||||
DPADD \
|
||||
DPLIBS \
|
||||
LDADD \
|
||||
LDFLAGS \
|
||||
MAN \
|
||||
SRCS
|
||||
|
||||
.for v in ${LIB_VARS:O:u}
|
||||
.if defined(${v}.${LIB}) || defined(${v}_${LIB})
|
||||
$v += ${${v}_${LIB}:U${${v}.${LIB}}}
|
||||
.endif
|
||||
.endfor
|
||||
|
||||
# for meta mode, there can be only one!
|
||||
.if ${LIB} == ${UPDATE_DEPENDFILE_LIB:Uno}
|
||||
UPDATE_DEPENDFILE ?= yes
|
||||
.endif
|
||||
UPDATE_DEPENDFILE ?= NO
|
||||
|
||||
# ensure that we don't clobber each other's dependencies
|
||||
DEPENDFILE?= .depend.${LIB}
|
||||
# lib.mk will do the rest
|
||||
.else
|
||||
all: ${LIBS:S,^lib,,:@t@lib$t.a@} .MAKE
|
||||
|
||||
# We cannot capture dependencies for meta mode here
|
||||
UPDATE_DEPENDFILE = NO
|
||||
# nor can we safely run in parallel.
|
||||
.NOTPARALLEL:
|
||||
.endif
|
||||
.endif
|
||||
|
||||
@ -43,12 +78,16 @@ all: ${LIBS:S,^lib,,:@t@lib$t.a@} .MAKE
|
||||
.include <${.PARSEFILE:S,libs,lib,}>
|
||||
|
||||
.ifndef LIB
|
||||
.for t in ${LIBS:R:T:S,^lib,,}
|
||||
lib$t.a: ${SRCS} ${DPADD} ${SRCS_lib$t} ${DPADD_lib$t}
|
||||
(cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} LIB=$t)
|
||||
# tell libs.mk we might want to install things
|
||||
LIBS_TARGETS+= cleandepend cleandir cleanobj depend install
|
||||
|
||||
clean: $t.clean
|
||||
$t.clean:
|
||||
(cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} LIB=$t ${@:E})
|
||||
.for b in ${LIBS:R:T:S,^lib,,}
|
||||
lib$b.a: ${SRCS} ${DPADD} ${SRCS_lib$b} ${DPADD_lib$b}
|
||||
(cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} LIB=$b)
|
||||
|
||||
.for t in ${LIBS_TARGETS:O:u}
|
||||
$b.$t: .PHONY .MAKE
|
||||
(cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} LIB=$b ${@:E})
|
||||
.endfor
|
||||
.endfor
|
||||
.endif
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $Id: progs.mk,v 1.12 2013/04/22 18:10:04 sjg Exp $
|
||||
# $Id: progs.mk,v 1.13 2013/08/02 18:28:48 sjg Exp $
|
||||
#
|
||||
# @(#) Copyright (c) 2006, Simon J. Gerraty
|
||||
#
|
||||
@ -35,9 +35,21 @@ PROG ?= $t
|
||||
|
||||
.if defined(PROG)
|
||||
# just one of many
|
||||
PROG_VARS += BINDIR CFLAGS CPPFLAGS CXXFLAGS DPADD DPLIBS LDADD MAN SRCS
|
||||
PROG_VARS += \
|
||||
BINDIR \
|
||||
CFLAGS \
|
||||
COPTS \
|
||||
CPPFLAGS \
|
||||
CXXFLAGS \
|
||||
DPADD \
|
||||
DPLIBS \
|
||||
LDADD \
|
||||
LDFLAGS \
|
||||
MAN \
|
||||
SRCS
|
||||
|
||||
.for v in ${PROG_VARS:O:u}
|
||||
.if defined(${v}.${PROG})
|
||||
.if defined(${v}.${PROG}) || defined(${v}_${PROG})
|
||||
$v += ${${v}_${PROG}:U${${v}.${PROG}}}
|
||||
.endif
|
||||
.endfor
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: parse.c,v 1.189 2013/06/18 19:31:27 sjg Exp $ */
|
||||
/* $NetBSD: parse.c,v 1.191 2013/08/28 21:56:49 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
@ -69,14 +69,14 @@
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: parse.c,v 1.189 2013/06/18 19:31:27 sjg Exp $";
|
||||
static char rcsid[] = "$NetBSD: parse.c,v 1.191 2013/08/28 21:56:49 sjg Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: parse.c,v 1.189 2013/06/18 19:31:27 sjg Exp $");
|
||||
__RCSID("$NetBSD: parse.c,v 1.191 2013/08/28 21:56:49 sjg Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
@ -1751,6 +1751,12 @@ Parse_IsVar(char *line)
|
||||
ch = *line++;
|
||||
wasSpace = TRUE;
|
||||
}
|
||||
#ifdef SUNSHCMD
|
||||
if (ch == ':' && strncmp(line, "sh", 2) == 0) {
|
||||
line += 2;
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
if (ch == '=')
|
||||
return TRUE;
|
||||
if (*line == '=' && ISEQOPERATOR(ch))
|
||||
|
@ -1,6 +1,6 @@
|
||||
# $Id: Makefile.in,v 1.43 2013/07/16 21:14:30 sjg Exp $
|
||||
# $Id: Makefile.in,v 1.44 2013/08/28 22:09:29 sjg Exp $
|
||||
#
|
||||
# $NetBSD: Makefile,v 1.37 2013/07/16 19:59:28 sjg Exp $
|
||||
# $NetBSD: Makefile,v 1.38 2013/08/28 21:56:50 sjg Exp $
|
||||
#
|
||||
# Unit tests for make(1)
|
||||
# The main targets are:
|
||||
@ -45,6 +45,7 @@ SUBFILES= \
|
||||
phony-end \
|
||||
posix \
|
||||
qequals \
|
||||
sunshcmd \
|
||||
sysv \
|
||||
ternary \
|
||||
unexport \
|
||||
|
10
contrib/bmake/unit-tests/sunshcmd
Normal file
10
contrib/bmake/unit-tests/sunshcmd
Normal file
@ -0,0 +1,10 @@
|
||||
BYECMD = echo bye
|
||||
LATERCMD = echo later
|
||||
TEST1 :sh = echo hello
|
||||
TEST2 :sh = ${BYECMD}
|
||||
TEST3 = ${LATERCMD:sh}
|
||||
|
||||
all:
|
||||
@echo "TEST1=${TEST1}"
|
||||
@echo "TEST2=${TEST2}"
|
||||
@echo "TEST3=${TEST3}"
|
@ -349,6 +349,9 @@ Now we expect an error...
|
||||
*** Error code 1 (continuing)
|
||||
`all' not remade because of errors.
|
||||
V.i386 ?= OK
|
||||
TEST1=hello
|
||||
TEST2=bye
|
||||
TEST3=later
|
||||
FOOBAR =
|
||||
FOOBAR = foobar fubar
|
||||
fun
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: var.c,v 1.183 2013/07/16 20:00:56 sjg Exp $ */
|
||||
/* $NetBSD: var.c,v 1.184 2013/09/04 15:38:26 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
@ -69,14 +69,14 @@
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: var.c,v 1.183 2013/07/16 20:00:56 sjg Exp $";
|
||||
static char rcsid[] = "$NetBSD: var.c,v 1.184 2013/09/04 15:38:26 sjg Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: var.c,v 1.183 2013/07/16 20:00:56 sjg Exp $");
|
||||
__RCSID("$NetBSD: var.c,v 1.184 2013/09/04 15:38:26 sjg Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
@ -187,6 +187,7 @@ static char varNoError[] = "";
|
||||
* The four contexts are searched in the reverse order from which they are
|
||||
* listed.
|
||||
*/
|
||||
GNode *VAR_INTERNAL; /* variables from make itself */
|
||||
GNode *VAR_GLOBAL; /* variables from the makefile */
|
||||
GNode *VAR_CMD; /* variables defined on the command-line */
|
||||
|
||||
@ -419,6 +420,10 @@ VarFind(const char *name, GNode *ctxt, int flags)
|
||||
(ctxt != VAR_GLOBAL))
|
||||
{
|
||||
var = Hash_FindEntry(&VAR_GLOBAL->context, name);
|
||||
if ((var == NULL) && (ctxt != VAR_INTERNAL)) {
|
||||
/* VAR_INTERNAL is subordinate to VAR_GLOBAL */
|
||||
var = Hash_FindEntry(&VAR_INTERNAL->context, name);
|
||||
}
|
||||
}
|
||||
if ((var == NULL) && (flags & FIND_ENV)) {
|
||||
char *env;
|
||||
@ -440,6 +445,9 @@ VarFind(const char *name, GNode *ctxt, int flags)
|
||||
(ctxt != VAR_GLOBAL))
|
||||
{
|
||||
var = Hash_FindEntry(&VAR_GLOBAL->context, name);
|
||||
if ((var == NULL) && (ctxt != VAR_INTERNAL)) {
|
||||
var = Hash_FindEntry(&VAR_INTERNAL->context, name);
|
||||
}
|
||||
if (var == NULL) {
|
||||
return NULL;
|
||||
} else {
|
||||
@ -4182,6 +4190,7 @@ Var_GetHead(char *file)
|
||||
void
|
||||
Var_Init(void)
|
||||
{
|
||||
VAR_INTERNAL = Targ_NewGN("Internal");
|
||||
VAR_GLOBAL = Targ_NewGN("Global");
|
||||
VAR_CMD = Targ_NewGN("Command");
|
||||
|
||||
|
@ -1684,6 +1684,14 @@ ix86_handle_option (size_t code, const char *arg ATTRIBUTE_UNUSED, int value)
|
||||
}
|
||||
return true;
|
||||
|
||||
case OPT_maes:
|
||||
if (!value)
|
||||
{
|
||||
target_flags &= ~MASK_AES;
|
||||
target_flags_explicit |= MASK_AES;
|
||||
}
|
||||
return true;
|
||||
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
@ -2187,6 +2195,10 @@ override_options (void)
|
||||
if (TARGET_SSE3)
|
||||
target_flags |= MASK_SSE2;
|
||||
|
||||
/* Turn on SSE2 builtins for -maes. */
|
||||
if (TARGET_AES)
|
||||
target_flags |= MASK_SSE2;
|
||||
|
||||
/* Turn on SSE builtins for -msse2. */
|
||||
if (TARGET_SSE2)
|
||||
target_flags |= MASK_SSE;
|
||||
|
@ -428,6 +428,8 @@ extern const char *host_detect_local_cpu (int argc, const char **argv);
|
||||
builtin_define ("__SSSE3__"); \
|
||||
if (TARGET_SSE4A) \
|
||||
builtin_define ("__SSE4A__"); \
|
||||
if (TARGET_AES) \
|
||||
builtin_define ("__AES__"); \
|
||||
if (TARGET_SSE_MATH && TARGET_SSE) \
|
||||
builtin_define ("__SSE_MATH__"); \
|
||||
if (TARGET_SSE_MATH && TARGET_SSE2) \
|
||||
|
@ -205,6 +205,10 @@ msse4a
|
||||
Target Report Mask(SSE4A)
|
||||
Support MMX, SSE, SSE2, SSE3 and SSE4A built-in functions and code generation
|
||||
|
||||
maes
|
||||
Target Report Mask(AES)
|
||||
Support AES built-in functions and code generation.
|
||||
|
||||
mpopcnt
|
||||
Target Report Mask(POPCNT)
|
||||
Support code generation of popcount instruction for popcount built-ins
|
||||
|
@ -513,7 +513,7 @@ in the following sections.
|
||||
-mno-fp-ret-in-387 -msoft-float -msvr3-shlib @gol
|
||||
-mno-wide-multiply -mrtd -malign-double @gol
|
||||
-mpreferred-stack-boundary=@var{num} @gol
|
||||
-mmmx -msse -msse2 -msse3 -mssse3 -msse4a -m3dnow -mpopcnt -mabm @gol
|
||||
-mmmx -msse -msse2 -msse3 -mssse3 -msse4a -m3dnow -mpopcnt -mabm -maes @gol
|
||||
-mthreads -mno-align-stringops -minline-all-stringops @gol
|
||||
-mpush-args -maccumulate-outgoing-args -m128bit-long-double @gol
|
||||
-m96bit-long-double -mregparm=@var{num} -msseregparm @gol
|
||||
@ -9367,6 +9367,8 @@ preferred alignment to @option{-mpreferred-stack-boundary=2}.
|
||||
@itemx -mno-popcnt
|
||||
@item -mabm
|
||||
@itemx -mno-abm
|
||||
@item -maes
|
||||
@itemx -mno-aes
|
||||
@opindex mmmx
|
||||
@opindex mno-mmx
|
||||
@opindex msse
|
||||
@ -9374,10 +9376,10 @@ preferred alignment to @option{-mpreferred-stack-boundary=2}.
|
||||
@opindex m3dnow
|
||||
@opindex mno-3dnow
|
||||
These switches enable or disable the use of instructions in the MMX,
|
||||
SSE, SSE2, SSE3, SSSE3, SSE4A, ABM or 3DNow! extended instruction sets.
|
||||
These extensions are also available as built-in functions: see
|
||||
@ref{X86 Built-in Functions}, for details of the functions enabled and
|
||||
disabled by these switches.
|
||||
SSE, SSE2, SSE3, SSSE3, SSE4A, ABM, AES or 3DNow! extended
|
||||
instruction sets. These extensions are also available as built-in
|
||||
functions: see @ref{X86 Built-in Functions}, for details of the functions
|
||||
enabled and disabled by these switches.
|
||||
|
||||
To have SSE/SSE2 instructions generated automatically from floating-point
|
||||
code (as opposed to 387 instructions), see @option{-mfpmath=sse}.
|
||||
|
@ -87,7 +87,7 @@ for (i = 0; i < n_extra_masks; i++) {
|
||||
}
|
||||
|
||||
for (var in masknum) {
|
||||
if (masknum[var] > 31) {
|
||||
if (masknum[var] > 32) {
|
||||
if (var == "")
|
||||
print "#error too many target masks"
|
||||
else
|
||||
|
@ -1,4 +1,5 @@
|
||||
/* $NetBSD: execinfo.h,v 1.2 2012/06/09 21:22:17 christos Exp $ */
|
||||
/* $FreeBSD$ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2012 The NetBSD Foundation, Inc.
|
||||
|
@ -715,8 +715,9 @@ main(int argc, char **argv)
|
||||
int status;
|
||||
FILE *VFile;
|
||||
#ifdef __FreeBSD__
|
||||
cap_rights_t rights;
|
||||
int cansandbox;
|
||||
#endif
|
||||
#endif /* __FreeBSD__ */
|
||||
|
||||
#ifdef WIN32
|
||||
if(wsockinit() != 0) return 1;
|
||||
@ -1206,7 +1207,8 @@ main(int argc, char **argv)
|
||||
if (pd == NULL)
|
||||
error("%s", ebuf);
|
||||
#ifdef __FreeBSD__
|
||||
if (cap_rights_limit(fileno(pcap_file(pd)), CAP_READ) < 0 &&
|
||||
cap_rights_init(&rights, CAP_READ);
|
||||
if (cap_rights_limit(fileno(pcap_file(pd)), &rights) < 0 &&
|
||||
errno != ENOSYS) {
|
||||
error("unable to limit pcap descriptor");
|
||||
}
|
||||
@ -1484,8 +1486,9 @@ main(int argc, char **argv)
|
||||
if (RFileName == NULL && VFileName == NULL) {
|
||||
static const unsigned long cmds[] = { BIOCGSTATS };
|
||||
|
||||
if (cap_rights_limit(pcap_fileno(pd),
|
||||
CAP_IOCTL | CAP_READ) < 0 && errno != ENOSYS) {
|
||||
cap_rights_init(&rights, CAP_IOCTL, CAP_READ);
|
||||
if (cap_rights_limit(pcap_fileno(pd), &rights) < 0 &&
|
||||
errno != ENOSYS) {
|
||||
error("unable to limit pcap descriptor");
|
||||
}
|
||||
if (cap_ioctls_limit(pcap_fileno(pd), cmds,
|
||||
@ -1516,8 +1519,9 @@ main(int argc, char **argv)
|
||||
if (p == NULL)
|
||||
error("%s", pcap_geterr(pd));
|
||||
#ifdef __FreeBSD__
|
||||
if (cap_rights_limit(fileno(pcap_dump_file(p)),
|
||||
CAP_SEEK | CAP_WRITE) < 0 && errno != ENOSYS) {
|
||||
cap_rights_init(&rights, CAP_SEEK, CAP_WRITE);
|
||||
if (cap_rights_limit(fileno(pcap_dump_file(p)), &rights) < 0 &&
|
||||
errno != ENOSYS) {
|
||||
error("unable to limit dump descriptor");
|
||||
}
|
||||
#endif
|
||||
@ -1530,9 +1534,10 @@ main(int argc, char **argv)
|
||||
error("unable to open directory %s",
|
||||
dirname(WFileName));
|
||||
}
|
||||
if (cap_rights_limit(dumpinfo.dirfd, CAP_CREATE |
|
||||
CAP_FCNTL | CAP_FTRUNCATE | CAP_LOOKUP | CAP_SEEK |
|
||||
CAP_WRITE) < 0 && errno != ENOSYS) {
|
||||
cap_rights_init(&rights, CAP_CREATE, CAP_FCNTL,
|
||||
CAP_FTRUNCATE, CAP_LOOKUP, CAP_SEEK, CAP_WRITE);
|
||||
if (cap_rights_limit(dumpinfo.dirfd, &rights) < 0 &&
|
||||
errno != ENOSYS) {
|
||||
error("unable to limit directory rights");
|
||||
}
|
||||
#else /* !__FreeBSD__ */
|
||||
@ -1615,7 +1620,7 @@ main(int argc, char **argv)
|
||||
error("unable to enter the capability mode");
|
||||
if (cap_sandboxed())
|
||||
fprintf(stderr, "capability mode sandbox enabled\n");
|
||||
#endif
|
||||
#endif /* __FreeBSD__ */
|
||||
|
||||
do {
|
||||
status = pcap_loop(pd, cnt, callback, pcap_userdata);
|
||||
@ -1657,8 +1662,9 @@ main(int argc, char **argv)
|
||||
if (pd == NULL)
|
||||
error("%s", ebuf);
|
||||
#ifdef __FreeBSD__
|
||||
cap_rights_init(&rights, CAP_READ);
|
||||
if (cap_rights_limit(fileno(pcap_file(pd)),
|
||||
CAP_READ) < 0 && errno != ENOSYS) {
|
||||
&rights) < 0 && errno != ENOSYS) {
|
||||
error("unable to limit pcap descriptor");
|
||||
}
|
||||
#endif
|
||||
@ -1830,6 +1836,9 @@ static void
|
||||
dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
|
||||
{
|
||||
struct dump_info *dump_info;
|
||||
#ifdef __FreeBSD__
|
||||
cap_rights_t rights;
|
||||
#endif
|
||||
|
||||
++packets_captured;
|
||||
|
||||
@ -1933,8 +1942,9 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
|
||||
if (dump_info->p == NULL)
|
||||
error("%s", pcap_geterr(pd));
|
||||
#ifdef __FreeBSD__
|
||||
cap_rights_init(&rights, CAP_SEEK, CAP_WRITE);
|
||||
if (cap_rights_limit(fileno(pcap_dump_file(dump_info->p)),
|
||||
CAP_SEEK | CAP_WRITE) < 0 && errno != ENOSYS) {
|
||||
&rights) < 0 && errno != ENOSYS) {
|
||||
error("unable to limit dump descriptor");
|
||||
}
|
||||
#endif
|
||||
@ -1993,8 +2003,9 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
|
||||
if (dump_info->p == NULL)
|
||||
error("%s", pcap_geterr(pd));
|
||||
#ifdef __FreeBSD__
|
||||
cap_rights_init(&rights, CAP_SEEK, CAP_WRITE);
|
||||
if (cap_rights_limit(fileno(pcap_dump_file(dump_info->p)),
|
||||
CAP_SEEK | CAP_WRITE) < 0 && errno != ENOSYS) {
|
||||
&rights) < 0 && errno != ENOSYS) {
|
||||
error("unable to limit dump descriptor");
|
||||
}
|
||||
#endif
|
||||
|
@ -162,6 +162,71 @@ daily_scrub_zfs_default_threshold="35" # days between scrubs
|
||||
daily_local="/etc/daily.local" # Local scripts
|
||||
|
||||
|
||||
# Weekly options
|
||||
|
||||
# These options are used by periodic(8) itself to determine what to do
|
||||
# with the output of the sub-programs that are run, and where to send
|
||||
# that output. $weekly_output might be set to /var/log/weekly.log if you
|
||||
# wish to log the weekly output and have the files rotated by newsyslog(8)
|
||||
#
|
||||
weekly_output="root" # user or /file
|
||||
weekly_show_success="YES" # scripts returning 0
|
||||
weekly_show_info="YES" # scripts returning 1
|
||||
weekly_show_badconfig="NO" # scripts returning 2
|
||||
|
||||
# 310.locate
|
||||
weekly_locate_enable="YES" # Update locate weekly
|
||||
|
||||
# 320.whatis
|
||||
weekly_whatis_enable="YES" # Update whatis weekly
|
||||
|
||||
# 330.catman
|
||||
weekly_catman_enable="NO" # Preformat man pages
|
||||
|
||||
# 340.noid
|
||||
weekly_noid_enable="NO" # Find unowned files
|
||||
weekly_noid_dirs="/" # Look here
|
||||
|
||||
# 400.status-pkg
|
||||
weekly_status_pkg_enable="NO" # Find out-of-date pkgs
|
||||
pkg_version=pkg_version # Use this program
|
||||
pkg_version_index=/usr/ports/INDEX-10 # Use this index file
|
||||
|
||||
# 450.status-security
|
||||
weekly_status_security_enable="YES" # Security check
|
||||
# See also "Security options" above for more options
|
||||
weekly_status_security_inline="NO" # Run inline ?
|
||||
weekly_status_security_output="root" # user or /file
|
||||
|
||||
# 999.local
|
||||
weekly_local="/etc/weekly.local" # Local scripts
|
||||
|
||||
|
||||
# Monthly options
|
||||
|
||||
# These options are used by periodic(8) itself to determine what to do
|
||||
# with the output of the sub-programs that are run, and where to send
|
||||
# that output. $monthly_output might be set to /var/log/monthly.log if you
|
||||
# wish to log the monthly output and have the files rotated by newsyslog(8)
|
||||
#
|
||||
monthly_output="root" # user or /file
|
||||
monthly_show_success="YES" # scripts returning 0
|
||||
monthly_show_info="YES" # scripts returning 1
|
||||
monthly_show_badconfig="NO" # scripts returning 2
|
||||
|
||||
# 200.accounting
|
||||
monthly_accounting_enable="YES" # Login accounting
|
||||
|
||||
# 450.status-security
|
||||
monthly_status_security_enable="YES" # Security check
|
||||
# See also "Security options" above for more options
|
||||
monthly_status_security_inline="NO" # Run inline ?
|
||||
monthly_status_security_output="root" # user or /file
|
||||
|
||||
# 999.local
|
||||
monthly_local="/etc/monthly.local" # Local scripts
|
||||
|
||||
|
||||
# Security options
|
||||
|
||||
# These options are used by the security periodic(8) scripts spawned in
|
||||
@ -169,11 +234,14 @@ daily_local="/etc/daily.local" # Local scripts
|
||||
security_status_logdir="/var/log" # Directory for logs
|
||||
security_status_diff_flags="-b -u" # flags for diff output
|
||||
|
||||
# Each of the security_status_*_enable options below can have one of the
|
||||
# Each of the security_status_*_period options below can have one of the
|
||||
# following values:
|
||||
# - NO
|
||||
# - NO: do not run at all
|
||||
# - daily: only run during the daily security status
|
||||
# - weekly: only run during the weekly security status
|
||||
# - monthly: only run during the monthly security status
|
||||
# Note that if periodic security scripts are run from crontab(5) directly,
|
||||
# they will be run unless _enable or _period is set to "NO".
|
||||
|
||||
# 100.chksetuid
|
||||
security_status_chksetuid_enable="YES"
|
||||
@ -239,70 +307,6 @@ security_status_tcpwrap_enable="YES"
|
||||
security_status_tcpwrap_period="daily"
|
||||
|
||||
|
||||
# Weekly options
|
||||
|
||||
# These options are used by periodic(8) itself to determine what to do
|
||||
# with the output of the sub-programs that are run, and where to send
|
||||
# that output. $weekly_output might be set to /var/log/weekly.log if you
|
||||
# wish to log the weekly output and have the files rotated by newsyslog(8)
|
||||
#
|
||||
weekly_output="root" # user or /file
|
||||
weekly_show_success="YES" # scripts returning 0
|
||||
weekly_show_info="YES" # scripts returning 1
|
||||
weekly_show_badconfig="NO" # scripts returning 2
|
||||
|
||||
# 310.locate
|
||||
weekly_locate_enable="YES" # Update locate weekly
|
||||
|
||||
# 320.whatis
|
||||
weekly_whatis_enable="YES" # Update whatis weekly
|
||||
|
||||
# 330.catman
|
||||
weekly_catman_enable="NO" # Preformat man pages
|
||||
|
||||
# 340.noid
|
||||
weekly_noid_enable="NO" # Find unowned files
|
||||
weekly_noid_dirs="/" # Look here
|
||||
|
||||
# 400.status-pkg
|
||||
weekly_status_pkg_enable="NO" # Find out-of-date pkgs
|
||||
pkg_version=pkg_version # Use this program
|
||||
pkg_version_index=/usr/ports/INDEX-10 # Use this index file
|
||||
|
||||
# 450.status-security
|
||||
weekly_status_security_enable="YES" # Security check
|
||||
# See also "Security options" above for more options
|
||||
weekly_status_security_inline="NO" # Run inline ?
|
||||
weekly_status_security_output="root" # user or /file
|
||||
|
||||
# 999.local
|
||||
weekly_local="/etc/weekly.local" # Local scripts
|
||||
|
||||
|
||||
# Monthly options
|
||||
|
||||
# These options are used by periodic(8) itself to determine what to do
|
||||
# with the output of the sub-programs that are run, and where to send
|
||||
# that output. $monthly_output might be set to /var/log/monthly.log if you
|
||||
# wish to log the monthly output and have the files rotated by newsyslog(8)
|
||||
#
|
||||
monthly_output="root" # user or /file
|
||||
monthly_show_success="YES" # scripts returning 0
|
||||
monthly_show_info="YES" # scripts returning 1
|
||||
monthly_show_badconfig="NO" # scripts returning 2
|
||||
|
||||
# 200.accounting
|
||||
monthly_accounting_enable="YES" # Login accounting
|
||||
|
||||
# 450.status-security
|
||||
monthly_status_security_enable="YES" # Security check
|
||||
# See also "Security options" above for more options
|
||||
monthly_status_security_inline="NO" # Run inline ?
|
||||
monthly_status_security_output="root" # user or /file
|
||||
|
||||
# 999.local
|
||||
monthly_local="/etc/monthly.local" # Local scripts
|
||||
|
||||
|
||||
# Define source_periodic_confs, the mechanism used by /etc/periodic/*/*
|
||||
# scripts to source defaults/periodic.conf overrides safely.
|
||||
|
@ -129,7 +129,7 @@ nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
match "vendor" "0x0403";
|
||||
match "product" "(0x6001|0x6004|0x6006|0x6006|0x6010|0x6011|0x6014|0x8372|0x9378|0x9379|0x937a|0x937c|0x9868|0x9e90|0x9f80|0xa6d0|0xabb8|0xb810|0xb811|0xb812|0xbaf8|0xbbe2|0xbca0|0xbca1|0xbca2|0xbca4|0xbcd8|0xbcd9|0xbcda|0xbdc8|0xbfd8|0xbfd9|0xbfda|0xbfdb|0xbfdc|0xc7d0|0xc850|0xc991|0xcaa0|0xcc48|0xcc49|0xcc4a|0xd010|0xd011|0xd012|0xd013|0xd014|0xd015|0xd016|0xd017|0xd070|0xd071|0xd388|0xd389|0xd38a|0xd38b|0xd38c|0xd38d|0xd38e|0xd38f|0xd578|0xd678|0xd738|0xd780|0xdaf8|0xdaf9|0xdafa|0xdafb|0xdafc|0xdafd|0xdafe|0xdaff|0xdc00|0xdc01|0xdd20|0xdf28|0xdf30|0xdf31|0xdf32|0xdf33|0xdf35|0xe000|0xe001|0xe002|0xe004|0xe006|0xe008|0xe009|0xe00a|0xe050|0xe0e8|0xe0e9|0xe0ea|0xe0eb|0xe0ec|0xe0ed|0xe0ee|0xe0ef|0xe0f0|0xe0f1|0xe0f2|0xe0f3|0xe0f4|0xe0f5|0xe0f6|0xe0f7|0xe40b|0xe520|0xe548|0xe6c8|0xe700|0xe729|0xe808|0xe809|0xe80a|0xe80b|0xe80c|0xe80d|0xe80e|0xe80f|0xe888|0xe889|0xe88a|0xe88b|0xe88c|0xe88d|0xe88e|0xe88f|0xea90|0xebe0|0xec88|0xec89|0xed22|0xed71|0xed72|0xed73|0xed74|0xee18|0xeee8|0xeee9|0xeeea|0xeeeb|0xeeec|0xeeed|0xeeee|0xeeef|0xef50|0xef51|0xf068|0xf069|0xf06a|0xf06b|0xf06c|0xf06d|0xf06e|0xf06f|0xf070|0xf0c0|0xf0c8|0xf208|0xf2d0|0xf3c0|0xf3c1|0xf3c2|0xf448|0xf449|0xf44a|0xf44b|0xf44c|0xf460|0xf608|0xf60b|0xf680|0xf850|0xf857|0xf9d0|0xf9d1|0xf9d2|0xf9d3|0xf9d4|0xf9d5|0xfa00|0xfa01|0xfa02|0xfa03|0xfa04|0xfa05|0xfa06|0xfa10|0xfa33|0xfa88|0xfad0|0xfaf0|0xfb58|0xfb59|0xfb5a|0xfb5b|0xfb5c|0xfb5d|0xfb5e|0xfb5f|0xfb80|0xfb99|0xfbfa|0xfc08|0xfc09|0xfc0a|0xfc0b|0xfc0c|0xfc0d|0xfc0e|0xfc0f|0xfc60|0xfc70|0xfc71|0xfc72|0xfc73|0xfc82|0xfd60|0xfe38|0xff00|0xff18|0xff1c|0xff1d|0xff20|0xff38|0xff39|0xff3a|0xff3b|0xff3c|0xff3d|0xff3e|0xff3f|0xffa8)";
|
||||
match "product" "(0x6001|0x6004|0x6006|0x6006|0x6010|0x6011|0x6014|0x6015|0x8372|0x9378|0x9379|0x937a|0x937c|0x9868|0x9e90|0x9f80|0xa6d0|0xabb8|0xb810|0xb811|0xb812|0xbaf8|0xbbe2|0xbca0|0xbca1|0xbca2|0xbca4|0xbcd8|0xbcd9|0xbcda|0xbdc8|0xbfd8|0xbfd9|0xbfda|0xbfdb|0xbfdc|0xc7d0|0xc850|0xc991|0xcaa0|0xcc48|0xcc49|0xcc4a|0xd010|0xd011|0xd012|0xd013|0xd014|0xd015|0xd016|0xd017|0xd070|0xd071|0xd388|0xd389|0xd38a|0xd38b|0xd38c|0xd38d|0xd38e|0xd38f|0xd578|0xd678|0xd738|0xd780|0xdaf8|0xdaf9|0xdafa|0xdafb|0xdafc|0xdafd|0xdafe|0xdaff|0xdc00|0xdc01|0xdd20|0xdf28|0xdf30|0xdf31|0xdf32|0xdf33|0xdf35|0xe000|0xe001|0xe002|0xe004|0xe006|0xe008|0xe009|0xe00a|0xe050|0xe0e8|0xe0e9|0xe0ea|0xe0eb|0xe0ec|0xe0ed|0xe0ee|0xe0ef|0xe0f0|0xe0f1|0xe0f2|0xe0f3|0xe0f4|0xe0f5|0xe0f6|0xe0f7|0xe40b|0xe520|0xe548|0xe6c8|0xe700|0xe729|0xe808|0xe809|0xe80a|0xe80b|0xe80c|0xe80d|0xe80e|0xe80f|0xe888|0xe889|0xe88a|0xe88b|0xe88c|0xe88d|0xe88e|0xe88f|0xea90|0xebe0|0xec88|0xec89|0xed22|0xed71|0xed72|0xed73|0xed74|0xee18|0xeee8|0xeee9|0xeeea|0xeeeb|0xeeec|0xeeed|0xeeee|0xeeef|0xef50|0xef51|0xf068|0xf069|0xf06a|0xf06b|0xf06c|0xf06d|0xf06e|0xf06f|0xf070|0xf0c0|0xf0c8|0xf208|0xf2d0|0xf3c0|0xf3c1|0xf3c2|0xf448|0xf449|0xf44a|0xf44b|0xf44c|0xf460|0xf608|0xf60b|0xf680|0xf850|0xf857|0xf9d0|0xf9d1|0xf9d2|0xf9d3|0xf9d4|0xf9d5|0xfa00|0xfa01|0xfa02|0xfa03|0xfa04|0xfa05|0xfa06|0xfa10|0xfa33|0xfa88|0xfad0|0xfaf0|0xfb58|0xfb59|0xfb5a|0xfb5b|0xfb5c|0xfb5d|0xfb5e|0xfb5f|0xfb80|0xfb99|0xfbfa|0xfc08|0xfc09|0xfc0a|0xfc0b|0xfc0c|0xfc0d|0xfc0e|0xfc0f|0xfc60|0xfc70|0xfc71|0xfc72|0xfc73|0xfc82|0xfd60|0xfe38|0xff00|0xff18|0xff1c|0xff1d|0xff20|0xff38|0xff39|0xff3a|0xff3b|0xff3c|0xff3d|0xff3e|0xff3f|0xffa8)";
|
||||
action "kldload -n uftdi";
|
||||
};
|
||||
|
||||
@ -293,6 +293,14 @@ nomatch 32 {
|
||||
action "kldload -n uipaq";
|
||||
};
|
||||
|
||||
nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
match "vendor" "0x044e";
|
||||
match "product" "(0x3001|0x3002)";
|
||||
action "kldload -n ng_ubt";
|
||||
};
|
||||
|
||||
nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
@ -385,7 +393,7 @@ nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
match "vendor" "0x0489";
|
||||
match "product" "(0xe027|0xe02c|0xe036|0xe03c|0xe03d|0xe04e|0xe056|0xe057)";
|
||||
match "product" "(0xe027|0xe02c|0xe036|0xe03c|0xe03d|0xe042|0xe04e|0xe056|0xe057)";
|
||||
action "kldload -n ng_ubt";
|
||||
};
|
||||
|
||||
@ -517,6 +525,14 @@ nomatch 32 {
|
||||
action "kldload -n uplcom";
|
||||
};
|
||||
|
||||
nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
match "vendor" "0x04bf";
|
||||
match "product" "0x030a";
|
||||
action "kldload -n ng_ubt";
|
||||
};
|
||||
|
||||
nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
@ -529,7 +545,7 @@ nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
match "vendor" "0x04ca";
|
||||
match "product" "(0x3005|0x3006|0x3008)";
|
||||
match "product" "(0x2003|0x3005|0x3006|0x3008)";
|
||||
action "kldload -n ng_ubt";
|
||||
};
|
||||
|
||||
@ -1077,6 +1093,14 @@ nomatch 32 {
|
||||
action "kldload -n if_axe";
|
||||
};
|
||||
|
||||
nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
match "vendor" "0x05ac";
|
||||
match "product" "(0x8213|0x8215|0x8218|0x821a|0x821b|0x821f|0x8281|0x828f)";
|
||||
action "kldload -n ng_ubt";
|
||||
};
|
||||
|
||||
nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
@ -2045,6 +2069,14 @@ nomatch 32 {
|
||||
action "kldload -n ubtbcmfw";
|
||||
};
|
||||
|
||||
nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
match "vendor" "0x0a5c";
|
||||
match "product" "0x21e1";
|
||||
action "kldload -n ng_ubt";
|
||||
};
|
||||
|
||||
nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
@ -2253,6 +2285,14 @@ nomatch 32 {
|
||||
action "kldload -n if_urtwn";
|
||||
};
|
||||
|
||||
nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
match "vendor" "0x0b05";
|
||||
match "product" "0x17b5";
|
||||
action "kldload -n ng_ubt";
|
||||
};
|
||||
|
||||
nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
@ -2445,6 +2485,14 @@ nomatch 32 {
|
||||
action "kldload -n if_rsu";
|
||||
};
|
||||
|
||||
nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
match "vendor" "0x0bdb";
|
||||
match "product" "0x1002";
|
||||
action "kldload -n ng_ubt";
|
||||
};
|
||||
|
||||
nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
@ -2469,6 +2517,14 @@ nomatch 32 {
|
||||
action "kldload -n if_upgt";
|
||||
};
|
||||
|
||||
nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
match "vendor" "0x0c10";
|
||||
match "product" "0x0000";
|
||||
action "kldload -n ng_ubt";
|
||||
};
|
||||
|
||||
nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
@ -2885,6 +2941,14 @@ nomatch 32 {
|
||||
action "kldload -n if_cdce";
|
||||
};
|
||||
|
||||
nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
match "vendor" "0x0e8d";
|
||||
match "product" "0x763f";
|
||||
action "kldload -n ng_ubt";
|
||||
};
|
||||
|
||||
nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
@ -4773,6 +4837,14 @@ nomatch 32 {
|
||||
action "kldload -n u3g";
|
||||
};
|
||||
|
||||
nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
match "vendor" "0x413c";
|
||||
match "product" "0x8197";
|
||||
action "kldload -n ng_ubt";
|
||||
};
|
||||
|
||||
nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
@ -5005,6 +5077,26 @@ nomatch 32 {
|
||||
action "kldload -n uftdi";
|
||||
};
|
||||
|
||||
nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
match "vendor" "0x0489";
|
||||
match "intclass" "0xff";
|
||||
match "intsubclass" "0x01";
|
||||
match "intprotocol" "0x01";
|
||||
action "kldload -n ng_ubt";
|
||||
};
|
||||
|
||||
nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
match "vendor" "0x05ac";
|
||||
match "intclass" "0xff";
|
||||
match "intsubclass" "0x01";
|
||||
match "intprotocol" "0x01";
|
||||
action "kldload -n ng_ubt";
|
||||
};
|
||||
|
||||
nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
@ -5168,5 +5260,5 @@ nomatch 32 {
|
||||
action "kldload -n umass";
|
||||
};
|
||||
|
||||
# 2515 USB entries processed
|
||||
# 2537 USB entries processed
|
||||
|
||||
|
@ -83,6 +83,8 @@
|
||||
v1
|
||||
ext
|
||||
..
|
||||
tr1
|
||||
..
|
||||
..
|
||||
..
|
||||
cam
|
||||
|
@ -23,6 +23,8 @@
|
||||
remote uname=auditdistd gname=wheel mode=0700
|
||||
..
|
||||
..
|
||||
authpf uname=root gname=authpf mode=0770
|
||||
..
|
||||
/set gname=wheel
|
||||
backups
|
||||
..
|
||||
|
@ -143,7 +143,7 @@ static_inet()
|
||||
[Nn][Oo] | '')
|
||||
;;
|
||||
*)
|
||||
static_routes="_default ${static_routes}"
|
||||
static_routes="${static_routes} _default"
|
||||
route__default="default ${defaultrouter}"
|
||||
;;
|
||||
esac
|
||||
@ -205,7 +205,7 @@ static_inet6()
|
||||
[Nn][Oo] | '')
|
||||
;;
|
||||
*)
|
||||
ipv6_static_routes="_default ${ipv6_static_routes}"
|
||||
ipv6_static_routes="${ipv6_static_routes} _default"
|
||||
ipv6_route__default="default ${ipv6_defaultrouter}"
|
||||
;;
|
||||
esac
|
||||
|
@ -12,7 +12,6 @@ SUBDIR= ${_binutils} \
|
||||
${_gperf} \
|
||||
grep \
|
||||
${_groff} \
|
||||
patch \
|
||||
${_rcs} \
|
||||
sdiff \
|
||||
send-pr \
|
||||
|
@ -6,11 +6,12 @@
|
||||
|
||||
INCSDIR=${INCLUDEDIR}/gcc/${GCCVER}
|
||||
|
||||
.PATH: ${GCCDIR}/config/${GCC_CPU}
|
||||
.PATH: ${GCCDIR}/config/${GCC_CPU} ${.CURDIR}/../../../../contrib/llvm/tools/clang/lib/Headers
|
||||
|
||||
.if ${TARGET_ARCH} == "i386" || ${TARGET_ARCH} == "amd64"
|
||||
INCS= ammintrin.h emmintrin.h mmintrin.h mm3dnow.h pmmintrin.h \
|
||||
tmmintrin.h xmmintrin.h mm_malloc.h
|
||||
INCS+= wmmintrin.h __wmmintrin_aes.h __wmmintrin_pclmul.h
|
||||
.elif ${TARGET_ARCH} == "ia64"
|
||||
INCS= ia64intrin.h
|
||||
.elif ${TARGET_ARCH} == "arm"
|
||||
|
54
gnu/usr.bin/cc/include/__wmmintrin_aes.h
Normal file
54
gnu/usr.bin/cc/include/__wmmintrin_aes.h
Normal file
@ -0,0 +1,54 @@
|
||||
/*-
|
||||
* Copyright 2013 John-Mark Gurney
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _WMMINTRIN_AES_H_
|
||||
#define _WMMINTRIN_AES_H_
|
||||
|
||||
#include <emmintrin.h>
|
||||
|
||||
#define MAKE_AES(name) \
|
||||
static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) \
|
||||
_mm_## name ##_si128(__m128i __V, __m128i __R) \
|
||||
{ \
|
||||
__m128i v = __V; \
|
||||
\
|
||||
__asm__ (#name " %2, %0": "=x" (v): "0" (v), "xm" (__R)); \
|
||||
\
|
||||
return v; \
|
||||
}
|
||||
|
||||
MAKE_AES(aesimc)
|
||||
MAKE_AES(aesenc)
|
||||
MAKE_AES(aesenclast)
|
||||
MAKE_AES(aesdec)
|
||||
MAKE_AES(aesdeclast)
|
||||
|
||||
#undef MAKE_AES
|
||||
|
||||
#endif /* _WMMINTRIN_AES_H_ */
|
53
gnu/usr.bin/cc/include/__wmmintrin_pclmul.h
Normal file
53
gnu/usr.bin/cc/include/__wmmintrin_pclmul.h
Normal file
@ -0,0 +1,53 @@
|
||||
/*-
|
||||
* Copyright 2013 John-Mark Gurney
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _WMMINTRIN_PCLMUL_H_
|
||||
#define _WMMINTRIN_PCLMUL_H_
|
||||
|
||||
#include <emmintrin.h>
|
||||
|
||||
/*
|
||||
* c selects which parts of a and b to multiple:
|
||||
* 0x00: a[ 63: 0] * b[ 63: 0]
|
||||
* 0x01: a[127:64] * b[ 63: 0]
|
||||
* 0x10: a[ 63: 0] * b[127:64]
|
||||
* 0x11: a[127:64] * b[127:64]
|
||||
*/
|
||||
#define _mm_clmulepi64_si128(a, b, c) \
|
||||
({ \
|
||||
__m128i _a = (a); \
|
||||
__m128i _b = (b); \
|
||||
\
|
||||
__asm__("pclmulqdq %3, %2, %0": "=x" (_a): "0" (_a), "xm" (_b), \
|
||||
"i" (c)); \
|
||||
\
|
||||
_a; \
|
||||
})
|
||||
|
||||
#endif /* _WMMINTRIN_PCLMUL_H_ */
|
@ -1,21 +0,0 @@
|
||||
/* $FreeBSD$
|
||||
*
|
||||
* $Log: EXTERN.h,v $
|
||||
* Revision 2.0 86/09/17 15:35:37 lwall
|
||||
* Baseline for netwide release.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef EXT
|
||||
#undef EXT
|
||||
#endif
|
||||
#define EXT extern
|
||||
|
||||
#ifdef INIT
|
||||
#undef INIT
|
||||
#endif
|
||||
#define INIT(x)
|
||||
|
||||
#ifdef DOINIT
|
||||
#undef DOINIT
|
||||
#endif
|
@ -1,19 +0,0 @@
|
||||
/* $FreeBSD$
|
||||
*
|
||||
* $Log: INTERN.h,v $
|
||||
* Revision 2.0 86/09/17 15:35:58 lwall
|
||||
* Baseline for netwide release.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef EXT
|
||||
#undef EXT
|
||||
#endif
|
||||
#define EXT
|
||||
|
||||
#ifdef INIT
|
||||
#undef INIT
|
||||
#endif
|
||||
#define INIT(x) = x
|
||||
|
||||
#define DOINIT
|
@ -1,12 +0,0 @@
|
||||
# $FreeBSD$
|
||||
|
||||
PROG= gnupatch
|
||||
CLEANFILES+= gnupatch.1
|
||||
|
||||
gnupatch.1: patch.1
|
||||
cp ${.ALLSRC} ${.TARGET}
|
||||
|
||||
SRCS= backupfile.c inp.c patch.c pch.c util.c version.c
|
||||
CFLAGS+=-DHAVE_CONFIG_H
|
||||
|
||||
.include <bsd.prog.mk>
|
@ -1,390 +0,0 @@
|
||||
/* backupfile.c -- make Emacs style backup file names
|
||||
Copyright (C) 1990, 1991, 1992 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
/* Written by David MacKenzie <djm@gnu.ai.mit.edu>.
|
||||
Some algorithms adapted from GNU Emacs.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/types.h>
|
||||
#include "backupfile.h"
|
||||
#ifdef STDC_HEADERS
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#else
|
||||
char *malloc ();
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined(DIRENT) || defined(_POSIX_VERSION)
|
||||
#include <dirent.h>
|
||||
#define NLENGTH(direct) (strlen((direct)->d_name))
|
||||
#else /* not (DIRENT or _POSIX_VERSION) */
|
||||
#define dirent direct
|
||||
#define NLENGTH(direct) ((direct)->d_namlen)
|
||||
#ifdef SYSNDIR
|
||||
#include <sys/ndir.h>
|
||||
#endif /* SYSNDIR */
|
||||
#ifdef SYSDIR
|
||||
#include <sys/dir.h>
|
||||
#endif /* SYSDIR */
|
||||
#ifdef NDIR
|
||||
#include <ndir.h>
|
||||
#endif /* NDIR */
|
||||
#endif /* DIRENT or _POSIX_VERSION */
|
||||
|
||||
#ifndef isascii
|
||||
#define ISDIGIT(c) (isdigit ((unsigned char) (c)))
|
||||
#else
|
||||
#define ISDIGIT(c) (isascii (c) && isdigit (c))
|
||||
#endif
|
||||
|
||||
#if defined (_POSIX_VERSION)
|
||||
/* POSIX does not require that the d_ino field be present, and some
|
||||
systems do not provide it. */
|
||||
#define REAL_DIR_ENTRY(dp) 1
|
||||
#else
|
||||
#define REAL_DIR_ENTRY(dp) ((dp)->d_ino != 0)
|
||||
#endif
|
||||
|
||||
/* Which type of backup file names are generated. */
|
||||
enum backup_type backup_type = none;
|
||||
|
||||
/* The extension added to file names to produce a simple (as opposed
|
||||
to numbered) backup file name. */
|
||||
char *simple_backup_suffix = "~";
|
||||
|
||||
int argmatch(char *_arg, const char **_optlist);
|
||||
const char *basename(const char *_name);
|
||||
char *dirname(const char *_path);
|
||||
static char *concat(const char *_str1, const char *_str2);
|
||||
char *find_backup_file_name(char *_file);
|
||||
static char *make_version_name (char *_file, int _version);
|
||||
static int max_backup_version(char *_file, char *_dir);
|
||||
static int version_number(char *base, char *backup, int base_length);
|
||||
void invalid_arg(const char *_kind, char *_value, int _problem);
|
||||
|
||||
/* Return NAME with any leading path stripped off. */
|
||||
|
||||
const char *
|
||||
basename(const char *name)
|
||||
{
|
||||
const char *r = name, *p = name;
|
||||
|
||||
while (*p)
|
||||
if (*p++ == '/')
|
||||
r = p;
|
||||
return r;
|
||||
}
|
||||
|
||||
#ifndef NODIR
|
||||
/* Return the name of the new backup file for file FILE,
|
||||
allocated with malloc. Return 0 if out of memory.
|
||||
FILE must not end with a '/' unless it is the root directory.
|
||||
Do not call this function if backup_type == none. */
|
||||
|
||||
char *
|
||||
find_backup_file_name(char *file)
|
||||
{
|
||||
char *dir;
|
||||
char *base_versions;
|
||||
int highest_backup;
|
||||
|
||||
if (backup_type == simple)
|
||||
{
|
||||
char *s = malloc (strlen (file) + strlen (simple_backup_suffix) + 1);
|
||||
strcpy (s, file);
|
||||
addext (s, simple_backup_suffix, '~');
|
||||
return s;
|
||||
}
|
||||
base_versions = concat (basename (file), ".~");
|
||||
if (base_versions == 0)
|
||||
return 0;
|
||||
dir = dirname (file);
|
||||
if (dir == 0)
|
||||
{
|
||||
free (base_versions);
|
||||
return 0;
|
||||
}
|
||||
highest_backup = max_backup_version (base_versions, dir);
|
||||
free (base_versions);
|
||||
free (dir);
|
||||
if (backup_type == numbered_existing && highest_backup == 0)
|
||||
return concat (file, simple_backup_suffix);
|
||||
return make_version_name (file, highest_backup + 1);
|
||||
}
|
||||
|
||||
/* Return the number of the highest-numbered backup file for file
|
||||
FILE in directory DIR. If there are no numbered backups
|
||||
of FILE in DIR, or an error occurs reading DIR, return 0.
|
||||
FILE should already have ".~" appended to it. */
|
||||
|
||||
static int
|
||||
max_backup_version(char *file, char *dir)
|
||||
{
|
||||
DIR *dirp;
|
||||
struct dirent *dp;
|
||||
int highest_version;
|
||||
int this_version;
|
||||
int file_name_length;
|
||||
|
||||
dirp = opendir (dir);
|
||||
if (!dirp)
|
||||
return 0;
|
||||
|
||||
highest_version = 0;
|
||||
file_name_length = strlen (file);
|
||||
|
||||
while ((dp = readdir (dirp)) != 0)
|
||||
{
|
||||
if (!REAL_DIR_ENTRY (dp) || NLENGTH (dp) <= file_name_length)
|
||||
continue;
|
||||
|
||||
this_version = version_number (file, dp->d_name, file_name_length);
|
||||
if (this_version > highest_version)
|
||||
highest_version = this_version;
|
||||
}
|
||||
closedir (dirp);
|
||||
return highest_version;
|
||||
}
|
||||
|
||||
/* Return a string, allocated with malloc, containing
|
||||
"FILE.~VERSION~". Return 0 if out of memory. */
|
||||
|
||||
static char *
|
||||
make_version_name(char *file, int version)
|
||||
{
|
||||
char *backup_name;
|
||||
|
||||
backup_name = malloc (strlen (file) + 16);
|
||||
if (backup_name == 0)
|
||||
return 0;
|
||||
sprintf (backup_name, "%s.~%d~", file, version);
|
||||
return backup_name;
|
||||
}
|
||||
|
||||
/* If BACKUP is a numbered backup of BASE, return its version number;
|
||||
otherwise return 0. BASE_LENGTH is the length of BASE.
|
||||
BASE should already have ".~" appended to it. */
|
||||
|
||||
static int
|
||||
version_number(char *base, char *backup, int base_length)
|
||||
{
|
||||
int version;
|
||||
char *p;
|
||||
|
||||
version = 0;
|
||||
if (!strncmp (base, backup, base_length) && ISDIGIT (backup[base_length]))
|
||||
{
|
||||
for (p = &backup[base_length]; ISDIGIT (*p); ++p)
|
||||
version = version * 10 + *p - '0';
|
||||
if (p[0] != '~' || p[1])
|
||||
version = 0;
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
/* Return the newly-allocated concatenation of STR1 and STR2.
|
||||
If out of memory, return 0. */
|
||||
|
||||
static char *
|
||||
concat(const char *str1, const char *str2)
|
||||
{
|
||||
char *newstr;
|
||||
int str1_length = strlen (str1);
|
||||
|
||||
newstr = malloc (str1_length + strlen (str2) + 1);
|
||||
if (newstr == 0)
|
||||
return 0;
|
||||
strcpy (newstr, str1);
|
||||
strcpy (newstr + str1_length, str2);
|
||||
return newstr;
|
||||
}
|
||||
|
||||
/* Return the leading directories part of PATH,
|
||||
allocated with malloc. If out of memory, return 0.
|
||||
Assumes that trailing slashes have already been
|
||||
removed. */
|
||||
|
||||
char *
|
||||
dirname(const char *path)
|
||||
{
|
||||
char *newpath;
|
||||
const char *slash;
|
||||
int length; /* Length of result, not including NUL. */
|
||||
|
||||
slash = basename (path);
|
||||
if (slash == path)
|
||||
{
|
||||
/* File is in the current directory. */
|
||||
path = ".";
|
||||
length = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Remove any trailing slashes from result. */
|
||||
while (*--slash == '/' && slash > path)
|
||||
;
|
||||
|
||||
length = slash - path + 1;
|
||||
}
|
||||
newpath = malloc (length + 1);
|
||||
if (newpath == 0)
|
||||
return 0;
|
||||
strncpy (newpath, path, length);
|
||||
newpath[length] = 0;
|
||||
return newpath;
|
||||
}
|
||||
|
||||
/* If ARG is an unambiguous match for an element of the
|
||||
null-terminated array OPTLIST, return the index in OPTLIST
|
||||
of the matched element, else -1 if it does not match any element
|
||||
or -2 if it is ambiguous (is a prefix of more than one element). */
|
||||
|
||||
int
|
||||
argmatch(char *arg, const char **optlist)
|
||||
{
|
||||
int i; /* Temporary index in OPTLIST. */
|
||||
int arglen; /* Length of ARG. */
|
||||
int matchind = -1; /* Index of first nonexact match. */
|
||||
int ambiguous = 0; /* If nonzero, multiple nonexact match(es). */
|
||||
|
||||
arglen = strlen (arg);
|
||||
|
||||
/* Test all elements for either exact match or abbreviated matches. */
|
||||
for (i = 0; optlist[i]; i++)
|
||||
{
|
||||
if (!strncmp (optlist[i], arg, arglen))
|
||||
{
|
||||
if (strlen (optlist[i]) == arglen)
|
||||
/* Exact match found. */
|
||||
return i;
|
||||
else if (matchind == -1)
|
||||
/* First nonexact match found. */
|
||||
matchind = i;
|
||||
else
|
||||
/* Second nonexact match found. */
|
||||
ambiguous = 1;
|
||||
}
|
||||
}
|
||||
if (ambiguous)
|
||||
return -2;
|
||||
else
|
||||
return matchind;
|
||||
}
|
||||
|
||||
/* Error reporting for argmatch.
|
||||
KIND is a description of the type of entity that was being matched.
|
||||
VALUE is the invalid value that was given.
|
||||
PROBLEM is the return value from argmatch. */
|
||||
|
||||
void
|
||||
invalid_arg(const char *kind, char *value, int problem)
|
||||
{
|
||||
fprintf (stderr, "patch: ");
|
||||
if (problem == -1)
|
||||
fprintf (stderr, "invalid");
|
||||
else /* Assume -2. */
|
||||
fprintf (stderr, "ambiguous");
|
||||
fprintf (stderr, " %s `%s'\n", kind, value);
|
||||
}
|
||||
|
||||
static const char *backup_args[] =
|
||||
{
|
||||
"never", "simple", "nil", "existing", "t", "numbered", 0
|
||||
};
|
||||
|
||||
static enum backup_type backup_types[] =
|
||||
{
|
||||
simple, simple, numbered_existing, numbered_existing, numbered, numbered
|
||||
};
|
||||
|
||||
/* Return the type of backup indicated by VERSION.
|
||||
Unique abbreviations are accepted. */
|
||||
|
||||
enum backup_type
|
||||
get_version(char *version)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (version == 0 || *version == 0)
|
||||
return numbered_existing;
|
||||
i = argmatch (version, backup_args);
|
||||
if (i >= 0)
|
||||
return backup_types[i];
|
||||
invalid_arg ("version control type", version, i);
|
||||
exit (1);
|
||||
}
|
||||
#endif /* NODIR */
|
||||
|
||||
/* Append to FILENAME the extension EXT, unless the result would be too long,
|
||||
in which case just append the character E. */
|
||||
|
||||
void
|
||||
addext(char *filename, char *ext, int e)
|
||||
{
|
||||
char *s = (char *)(uintptr_t)(const void *)basename (filename);
|
||||
int slen = strlen (s), extlen = strlen (ext);
|
||||
long slen_max = -1;
|
||||
|
||||
#if HAVE_PATHCONF && defined (_PC_NAME_MAX)
|
||||
#ifndef _POSIX_NAME_MAX
|
||||
#define _POSIX_NAME_MAX 14
|
||||
#endif
|
||||
if (slen + extlen <= _POSIX_NAME_MAX)
|
||||
/* The file name is so short there's no need to call pathconf. */
|
||||
slen_max = _POSIX_NAME_MAX;
|
||||
else if (s == filename)
|
||||
slen_max = pathconf (".", _PC_NAME_MAX);
|
||||
else
|
||||
{
|
||||
char c = *s;
|
||||
*s = 0;
|
||||
slen_max = pathconf (filename, _PC_NAME_MAX);
|
||||
*s = c;
|
||||
}
|
||||
#endif
|
||||
if (slen_max == -1) {
|
||||
#ifdef HAVE_LONG_FILE_NAMES
|
||||
slen_max = 255;
|
||||
#else
|
||||
slen_max = 14;
|
||||
#endif
|
||||
}
|
||||
if (slen + extlen <= slen_max)
|
||||
strcpy (s + slen, ext);
|
||||
else
|
||||
{
|
||||
if (slen_max <= slen) {
|
||||
/* Try to preserve difference between .h .c etc. */
|
||||
if (slen == slen_max && s[slen - 2] == '.')
|
||||
s[slen - 2] = s[slen - 1];
|
||||
|
||||
slen = slen_max - 1;
|
||||
}
|
||||
s[slen] = e;
|
||||
s[slen + 1] = 0;
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
/* backupfile.h -- declarations for making Emacs style backup file names
|
||||
Copyright (C) 1990, 1991, 1992 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
/*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/* When to make backup files. */
|
||||
enum backup_type
|
||||
{
|
||||
/* Never make backups. */
|
||||
none,
|
||||
|
||||
/* Make simple backups of every file. */
|
||||
simple,
|
||||
|
||||
/* Make numbered backups of files that already have numbered backups,
|
||||
and simple backups of the others. */
|
||||
numbered_existing,
|
||||
|
||||
/* Make numbered backups of every file. */
|
||||
numbered
|
||||
};
|
||||
|
||||
extern enum backup_type backup_type;
|
||||
extern char *simple_backup_suffix;
|
||||
|
||||
char *find_backup_file_name (char *_file);
|
||||
enum backup_type get_version(char *_version);
|
||||
void addext(char *_filename, char *_ext, int _e);
|
@ -1,195 +0,0 @@
|
||||
/* $FreeBSD$
|
||||
*
|
||||
* $Log: common.h,v $
|
||||
* Revision 2.0.1.2 88/06/22 20:44:53 lwall
|
||||
* patch12: sprintf was declared wrong
|
||||
*
|
||||
* Revision 2.0.1.1 88/06/03 15:01:56 lwall
|
||||
* patch10: support for shorter extensions.
|
||||
*
|
||||
* Revision 2.0 86/09/17 15:36:39 lwall
|
||||
* Baseline for netwide release.
|
||||
*
|
||||
*/
|
||||
|
||||
#define DEBUGGING
|
||||
|
||||
#define VOIDUSED 7
|
||||
#include "config.h"
|
||||
|
||||
/* shut lint up about the following when return value ignored */
|
||||
|
||||
#define Signal (void)signal
|
||||
#define Unlink (void)unlink
|
||||
#define Lseek (void)lseek
|
||||
#define Fseek (void)fseek
|
||||
#define Fstat (void)fstat
|
||||
#define Pclose (void)pclose
|
||||
#define Close (void)close
|
||||
#define Fclose (void)fclose
|
||||
#define Fflush (void)fflush
|
||||
#define Sprintf (void)sprintf
|
||||
#define Snprintf (void)snprintf
|
||||
#define Mktemp (void)mktemp
|
||||
#define Strcpy (void)strcpy
|
||||
#define Strcat (void)strcat
|
||||
#define Strlcpy (void)strlcpy
|
||||
#define Strncpy (void)strncpy
|
||||
#define Strlcat (void)strlcat
|
||||
|
||||
/* NeXT declares malloc and realloc incompatibly from us in some of
|
||||
these files. Temporarily redefine them to prevent errors. */
|
||||
#define malloc system_malloc
|
||||
#define realloc system_realloc
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <ctype.h>
|
||||
#include <signal.h>
|
||||
#undef malloc
|
||||
#undef realloc
|
||||
|
||||
/* constants */
|
||||
|
||||
/* AIX predefines these. */
|
||||
#ifdef TRUE
|
||||
#undef TRUE
|
||||
#endif
|
||||
#ifdef FALSE
|
||||
#undef FALSE
|
||||
#endif
|
||||
#define TRUE (1)
|
||||
#define FALSE (0)
|
||||
|
||||
#define MAXHUNKSIZE 200000 /* is this enough lines? */
|
||||
#define INITHUNKMAX 125 /* initial dynamic allocation size */
|
||||
#define INITLINELEN 4096
|
||||
#define BUFFERSIZE 4096
|
||||
|
||||
#define SCCSPREFIX "s."
|
||||
#define GET "get %s"
|
||||
#define GET_LOCKED "get -e %s"
|
||||
#define SCCSDIFF "get -p %s | diff - %s >/dev/null"
|
||||
|
||||
#define RCSSUFFIX ",v"
|
||||
#define CHECKOUT "co %s"
|
||||
#define CHECKOUT_LOCKED "co -l %s"
|
||||
#define RCSDIFF "rcsdiff %s > /dev/null"
|
||||
|
||||
/* handy definitions */
|
||||
|
||||
#define Null(t) ((t)0)
|
||||
#define Nullch Null(char *)
|
||||
#define Nullfp Null(FILE *)
|
||||
#define Nulline Null(LINENUM)
|
||||
|
||||
#define Ctl(ch) ((ch) & 037)
|
||||
|
||||
#define strNE(s1,s2) (strcmp(s1, s2))
|
||||
#define strEQ(s1,s2) (!strcmp(s1, s2))
|
||||
#define strnNE(s1,s2,l) (strncmp(s1, s2, l))
|
||||
#define strnEQ(s1,s2,l) (!strncmp(s1, s2, l))
|
||||
|
||||
/* typedefs */
|
||||
|
||||
typedef char bool;
|
||||
typedef long LINENUM; /* must be signed */
|
||||
typedef unsigned MEM; /* what to feed malloc */
|
||||
|
||||
/* globals */
|
||||
|
||||
EXT int Argc; /* guess */
|
||||
EXT char **Argv;
|
||||
EXT int optind_last; /* for restarting plan_b */
|
||||
|
||||
EXT struct stat filestat; /* file statistics area */
|
||||
EXT int filemode INIT(0644);
|
||||
|
||||
EXT char *buf; /* general purpose buffer */
|
||||
EXT size_t buf_size; /* size of the general purpose buffer */
|
||||
EXT FILE *ofp INIT(Nullfp); /* output file pointer */
|
||||
EXT FILE *rejfp INIT(Nullfp); /* reject file pointer */
|
||||
|
||||
EXT int myuid; /* cache getuid return value */
|
||||
|
||||
EXT bool using_plan_a INIT(TRUE); /* try to keep everything in memory */
|
||||
EXT bool out_of_mem INIT(FALSE); /* ran out of memory in plan a */
|
||||
|
||||
#define MAXFILEC 2
|
||||
EXT int filec INIT(0); /* how many file arguments? */
|
||||
EXT char *filearg[MAXFILEC];
|
||||
EXT bool ok_to_create_file INIT(FALSE);
|
||||
EXT char *bestguess INIT(Nullch); /* guess at correct filename */
|
||||
|
||||
EXT char *outname INIT(Nullch);
|
||||
EXT char rejname[128];
|
||||
|
||||
EXT char *origprae INIT(Nullch);
|
||||
|
||||
EXT char *TMPOUTNAME;
|
||||
EXT char *TMPINNAME;
|
||||
EXT char *TMPREJNAME;
|
||||
EXT char *TMPPATNAME;
|
||||
EXT bool toutkeep INIT(FALSE);
|
||||
EXT bool trejkeep INIT(FALSE);
|
||||
|
||||
EXT LINENUM last_offset INIT(0);
|
||||
#ifdef DEBUGGING
|
||||
EXT int debug INIT(0);
|
||||
#endif
|
||||
EXT LINENUM maxfuzz INIT(2);
|
||||
EXT bool force INIT(FALSE);
|
||||
EXT bool batch INIT(FALSE);
|
||||
EXT bool verbose INIT(TRUE);
|
||||
EXT bool reverse INIT(FALSE);
|
||||
EXT bool noreverse INIT(FALSE);
|
||||
EXT bool skip_rest_of_patch INIT(FALSE);
|
||||
EXT int strippath INIT(957);
|
||||
EXT bool canonicalize INIT(FALSE);
|
||||
|
||||
#define CONTEXT_DIFF 1
|
||||
#define NORMAL_DIFF 2
|
||||
#define ED_DIFF 3
|
||||
#define NEW_CONTEXT_DIFF 4
|
||||
#define UNI_DIFF 5
|
||||
EXT int diff_type INIT(0);
|
||||
|
||||
EXT bool do_defines INIT(FALSE); /* patch using ifdef, ifndef, etc. */
|
||||
EXT char if_defined[128]; /* #ifdef xyzzy */
|
||||
EXT char not_defined[128]; /* #ifndef xyzzy */
|
||||
EXT char else_defined[] INIT("#else\n");/* #else */
|
||||
EXT char end_defined[128]; /* #endif xyzzy */
|
||||
|
||||
EXT char *revision INIT(Nullch); /* prerequisite revision, if any */
|
||||
|
||||
#include <errno.h>
|
||||
#ifdef STDC_HEADERS
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#else
|
||||
extern int errno;
|
||||
FILE *popen();
|
||||
char *malloc();
|
||||
char *realloc();
|
||||
long atol();
|
||||
char *getenv();
|
||||
char *strcpy();
|
||||
char *strcat();
|
||||
#endif
|
||||
char *mktemp(char *);
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#else
|
||||
long lseek();
|
||||
#endif
|
||||
#if defined(_POSIX_VERSION) || defined(HAVE_FCNTL_H)
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#if !defined(S_ISDIR) && defined(S_IFDIR)
|
||||
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
||||
#endif
|
||||
#if !defined(S_ISREG) && defined(S_IFREG)
|
||||
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
|
||||
#endif
|
@ -1,81 +0,0 @@
|
||||
/* config.h. Generated automatically by configure. */
|
||||
/* Portability variables. -*- C -*- */
|
||||
|
||||
/* Define if the system does not support the `const' keyword. */
|
||||
/* #undef const */
|
||||
|
||||
/* Define if the system supports file names longer than 14 characters. */
|
||||
#define HAVE_LONG_FILE_NAMES
|
||||
|
||||
/* Define if the system has pathconf(). */
|
||||
/* #undef HAVE_PATHCONF */
|
||||
|
||||
/* Define if the system has strerror(). */
|
||||
#define HAVE_STRERROR 1
|
||||
|
||||
/* Define if the system has ANSI C header files and library functions. */
|
||||
#define STDC_HEADERS
|
||||
|
||||
/* Define if the system uses strchr instead of index
|
||||
and strrchr instead of rindex. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
#if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
|
||||
#define index strchr
|
||||
#define rindex strrchr
|
||||
#endif
|
||||
|
||||
/* Define if the system has unistd.h. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Define if the system has fcntl.h. */
|
||||
#define HAVE_FCNTL_H 1
|
||||
|
||||
/* Define as either int or void -- the type that signal handlers return. */
|
||||
#define RETSIGTYPE void
|
||||
|
||||
#ifndef RETSIGTYPE
|
||||
#define RETSIGTYPE void
|
||||
#endif
|
||||
|
||||
/* Which directory library header to use. */
|
||||
#define DIRENT 1 /* dirent.h */
|
||||
/* #undef SYSNDIR */ /* sys/ndir.h */
|
||||
/* #undef SYSDIR */ /* sys/dir.h */
|
||||
/* #undef NDIR */ /* ndir.h */
|
||||
/* #undef NODIR */ /* none -- don't make numbered backup files */
|
||||
|
||||
/* Define if the system lets you pass fewer arguments to a function
|
||||
than the function actually accepts (in the absence of a prototype).
|
||||
Defining it makes I/O calls slightly more efficient.
|
||||
You need not bother defining it unless your C preprocessor chokes on
|
||||
multi-line arguments to macros. */
|
||||
/* #undef CANVARARG */
|
||||
|
||||
/* Define Reg* as either `register' or nothing, depending on whether
|
||||
the C compiler pays attention to this many register declarations.
|
||||
The intent is that you don't have to order your register declarations
|
||||
in the order of importance, so you can freely declare register variables
|
||||
in sub-blocks of code and as function parameters.
|
||||
Do not use Reg<n> more than once per routine.
|
||||
|
||||
These don't really matter a lot, since most modern C compilers ignore
|
||||
register declarations and often do a better job of allocating
|
||||
registers than people do. */
|
||||
|
||||
#define Reg1 register
|
||||
#define Reg2 register
|
||||
#define Reg3 register
|
||||
#define Reg4 register
|
||||
#define Reg5 register
|
||||
#define Reg6 register
|
||||
#define Reg7
|
||||
#define Reg8
|
||||
#define Reg9
|
||||
#define Reg10
|
||||
#define Reg11
|
||||
#define Reg12
|
||||
#define Reg13
|
||||
#define Reg14
|
||||
#define Reg15
|
||||
#define Reg16
|
@ -1,397 +0,0 @@
|
||||
/* $FreeBSD$
|
||||
*
|
||||
* $Log: inp.c,v $
|
||||
* Revision 2.0.1.1 88/06/03 15:06:13 lwall
|
||||
* patch10: made a little smarter about sccs files
|
||||
*
|
||||
* Revision 2.0 86/09/17 15:37:02 lwall
|
||||
* Baseline for netwide release.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "EXTERN.h"
|
||||
#include "common.h"
|
||||
#include "util.h"
|
||||
#include "pch.h"
|
||||
#include "INTERN.h"
|
||||
#include "inp.h"
|
||||
|
||||
/* Input-file-with-indexable-lines abstract type. */
|
||||
|
||||
static long i_size; /* Size of the input file */
|
||||
static char *i_womp; /* Plan a buffer for entire file */
|
||||
static char **i_ptr; /* Pointers to lines in i_womp */
|
||||
|
||||
static int tifd = -1; /* Plan b virtual string array */
|
||||
static char *tibuf[2]; /* Plan b buffers */
|
||||
static LINENUM tiline[2] = {-1, -1}; /* 1st line in each buffer */
|
||||
static LINENUM lines_per_buf; /* How many lines per buffer */
|
||||
static int tireclen; /* Length of records in tmp file */
|
||||
|
||||
/*
|
||||
* New patch--prepare to edit another file.
|
||||
*/
|
||||
void
|
||||
re_input(void)
|
||||
{
|
||||
if (using_plan_a) {
|
||||
i_size = 0;
|
||||
#ifndef lint
|
||||
if (i_ptr != Null(char**))
|
||||
free((char *)i_ptr);
|
||||
#endif
|
||||
if (i_womp != Nullch)
|
||||
free(i_womp);
|
||||
i_womp = Nullch;
|
||||
i_ptr = Null(char **);
|
||||
} else {
|
||||
using_plan_a = TRUE; /* maybe the next one is smaller */
|
||||
Close(tifd);
|
||||
tifd = -1;
|
||||
free(tibuf[0]);
|
||||
free(tibuf[1]);
|
||||
tibuf[0] = tibuf[1] = Nullch;
|
||||
tiline[0] = tiline[1] = -1;
|
||||
tireclen = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Constuct the line index, somehow or other.
|
||||
*/
|
||||
void
|
||||
scan_input(char *filename)
|
||||
{
|
||||
if (!plan_a(filename))
|
||||
plan_b(filename);
|
||||
if (verbose) {
|
||||
say3("Patching file %s using Plan %s...\n", filename,
|
||||
(using_plan_a ? "A" : "B") );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Try keeping everything in memory.
|
||||
*/
|
||||
bool
|
||||
plan_a(char *filename)
|
||||
{
|
||||
int ifd, statfailed;
|
||||
Reg1 char *s;
|
||||
Reg2 LINENUM iline;
|
||||
char lbuf[INITLINELEN];
|
||||
int output_elsewhere = strcmp(filename, outname);
|
||||
extern int check_patch;
|
||||
|
||||
statfailed = stat(filename, &filestat);
|
||||
if (statfailed && ok_to_create_file) {
|
||||
if (verbose)
|
||||
say2("(Creating file %s...)\n",filename);
|
||||
if (check_patch)
|
||||
return TRUE;
|
||||
makedirs(filename, TRUE);
|
||||
close(creat(filename, 0666));
|
||||
statfailed = stat(filename, &filestat);
|
||||
}
|
||||
if (statfailed && check_patch) {
|
||||
fatal2("%s not found and in check_patch mode.", filename);
|
||||
}
|
||||
/*
|
||||
* For nonexistent or read-only files, look for RCS or SCCS
|
||||
* versions.
|
||||
*/
|
||||
if (statfailed ||
|
||||
(! output_elsewhere &&
|
||||
(/* No one can write to it. */
|
||||
(filestat.st_mode & 0222) == 0 ||
|
||||
/* I can't write to it. */
|
||||
((filestat.st_mode & 0022) == 0 && filestat.st_uid != myuid)))) {
|
||||
struct stat cstat;
|
||||
char *cs = Nullch;
|
||||
char *filebase;
|
||||
int pathlen;
|
||||
|
||||
filebase = basename(filename);
|
||||
pathlen = filebase - filename;
|
||||
|
||||
/*
|
||||
* Put any leading path into `s'.
|
||||
* Leave room in lbuf for the diff command.
|
||||
*/
|
||||
s = lbuf + 20;
|
||||
strncpy(s, filename, pathlen);
|
||||
|
||||
#define try(f,a1,a2) (Sprintf(s + pathlen, f, a1, a2), stat(s, &cstat) == 0)
|
||||
if ((try("RCS/%s%s", filebase, RCSSUFFIX) ||
|
||||
try("RCS/%s%s", filebase, "") ||
|
||||
try("%s%s", filebase, RCSSUFFIX)) &&
|
||||
/*
|
||||
* Check that RCS file is not working file.
|
||||
* Some hosts don't report file name length errors.
|
||||
*/
|
||||
(statfailed ||
|
||||
((filestat.st_dev ^ cstat.st_dev) |
|
||||
(filestat.st_ino ^ cstat.st_ino)))) {
|
||||
Sprintf(buf, output_elsewhere?CHECKOUT:CHECKOUT_LOCKED, filename);
|
||||
Sprintf(lbuf, RCSDIFF, filename);
|
||||
cs = "RCS";
|
||||
} else if (try("SCCS/%s%s", SCCSPREFIX, filebase) ||
|
||||
try("%s%s", SCCSPREFIX, filebase)) {
|
||||
Sprintf(buf, output_elsewhere?GET:GET_LOCKED, s);
|
||||
Sprintf(lbuf, SCCSDIFF, s, filename);
|
||||
cs = "SCCS";
|
||||
} else if (statfailed)
|
||||
fatal2("can't find %s\n", filename);
|
||||
/*
|
||||
* else we can't write to it but it's not under a version
|
||||
* control system, so just proceed.
|
||||
*/
|
||||
if (cs) {
|
||||
if (!statfailed) {
|
||||
if ((filestat.st_mode & 0222) != 0)
|
||||
/* The owner can write to it. */
|
||||
fatal3(
|
||||
"file %s seems to be locked by somebody else under %s\n",
|
||||
filename, cs);
|
||||
/*
|
||||
* It might be checked out unlocked. See if
|
||||
* it's safe to check out the default version
|
||||
* locked.
|
||||
*/
|
||||
if (verbose)
|
||||
say3(
|
||||
"Comparing file %s to default %s version...\n",
|
||||
filename, cs);
|
||||
if (system(lbuf))
|
||||
fatal3(
|
||||
"can't check out file %s: differs from default %s version\n",
|
||||
filename, cs);
|
||||
}
|
||||
if (verbose)
|
||||
say3("Checking out file %s from %s...\n", filename, cs);
|
||||
if (system(buf) || stat(filename, &filestat))
|
||||
fatal3("can't check out file %s from %s\n",
|
||||
filename, cs);
|
||||
}
|
||||
}
|
||||
filemode = filestat.st_mode;
|
||||
if (!S_ISREG(filemode))
|
||||
fatal2("%s is not a normal file--can't patch\n", filename);
|
||||
i_size = filestat.st_size;
|
||||
if (out_of_mem) {
|
||||
set_hunkmax(); /* make sure dynamic arrays are allocated */
|
||||
out_of_mem = FALSE;
|
||||
return FALSE; /* force plan b because plan a bombed */
|
||||
}
|
||||
#ifdef lint
|
||||
i_womp = Nullch;
|
||||
#else
|
||||
/*
|
||||
* Lint says this may alloc less than i_size,
|
||||
* but that's okay, I think.
|
||||
*/
|
||||
i_womp = malloc((MEM)(i_size + 2));
|
||||
#endif
|
||||
if (i_womp == Nullch)
|
||||
return FALSE;
|
||||
if ((ifd = open(filename, 0)) < 0)
|
||||
pfatal2("can't open file %s", filename);
|
||||
#ifndef lint
|
||||
if (read(ifd, i_womp, (int)i_size) != i_size) {
|
||||
/*
|
||||
* This probably means i_size > 15 or 16 bits worth. At
|
||||
* this point it doesn't matter if i_womp was undersized.
|
||||
*/
|
||||
Close(ifd);
|
||||
free(i_womp);
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
Close(ifd);
|
||||
if (i_size && i_womp[i_size - 1] != '\n')
|
||||
i_womp[i_size++] = '\n';
|
||||
i_womp[i_size] = '\0';
|
||||
|
||||
/*
|
||||
* Count the lines in the buffer so we know how many pointers we
|
||||
* need.
|
||||
*/
|
||||
iline = 0;
|
||||
for (s = i_womp; *s; s++) {
|
||||
if (*s == '\n')
|
||||
iline++;
|
||||
}
|
||||
#ifdef lint
|
||||
i_ptr = Null(char**);
|
||||
#else
|
||||
i_ptr = (char **)malloc((MEM)((iline + 2) * sizeof(char *)));
|
||||
#endif
|
||||
if (i_ptr == Null(char **)) { /* shucks, it was a near thing */
|
||||
free((char *)i_womp);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Now scan the buffer and build pointer array. */
|
||||
iline = 1;
|
||||
i_ptr[iline] = i_womp;
|
||||
for (s = i_womp; *s; s++) {
|
||||
if (*s == '\n') {
|
||||
/* These are NOT null terminated. */
|
||||
i_ptr[++iline] = s + 1;
|
||||
}
|
||||
}
|
||||
input_lines = iline - 1;
|
||||
|
||||
/* Now check for revision, if any. */
|
||||
if (revision != Nullch) {
|
||||
if (!rev_in_string(i_womp)) {
|
||||
if (force) {
|
||||
if (verbose)
|
||||
say2(
|
||||
"Warning: this file doesn't appear to be the %s version--patching anyway.\n",
|
||||
revision);
|
||||
} else if (batch) {
|
||||
fatal2(
|
||||
"this file doesn't appear to be the %s version--aborting.\n", revision);
|
||||
} else {
|
||||
(void) ask2(
|
||||
"This file doesn't appear to be the %s version--patch anyway? [n] ",
|
||||
revision);
|
||||
if (*buf != 'y')
|
||||
fatal1("aborted\n");
|
||||
}
|
||||
} else if (verbose)
|
||||
say2("Good. This file appears to be the %s version.\n",
|
||||
revision);
|
||||
}
|
||||
|
||||
return TRUE; /* Plan a will work. */
|
||||
}
|
||||
|
||||
/*
|
||||
* Keep (virtually) nothing in memory.
|
||||
*/
|
||||
void
|
||||
plan_b(char *filename)
|
||||
{
|
||||
Reg3 FILE *ifp;
|
||||
Reg1 int i = 0;
|
||||
Reg2 int maxlen = 1;
|
||||
Reg4 bool found_revision = (revision == Nullch);
|
||||
|
||||
using_plan_a = FALSE;
|
||||
if ((ifp = fopen(filename, "r")) == Nullfp)
|
||||
pfatal2("can't open file %s", filename);
|
||||
if ((tifd = creat(TMPINNAME, 0666)) < 0)
|
||||
pfatal2("can't open file %s", TMPINNAME);
|
||||
while (fgets(buf, buf_size, ifp) != Nullch) {
|
||||
if (revision != Nullch && !found_revision && rev_in_string(buf))
|
||||
found_revision = TRUE;
|
||||
if ((i = strlen(buf)) > maxlen)
|
||||
maxlen = i; /* Find longest line. */
|
||||
}
|
||||
if (revision != Nullch) {
|
||||
if (!found_revision) {
|
||||
if (force) {
|
||||
if (verbose)
|
||||
say2(
|
||||
"Warning: this file doesn't appear to be the %s version--patching anyway.\n",
|
||||
revision);
|
||||
} else if (batch) {
|
||||
fatal2(
|
||||
"this file doesn't appear to be the %s version--aborting.\n", revision);
|
||||
} else {
|
||||
(void) ask2(
|
||||
"This file doesn't appear to be the %s version--patch anyway? [n] ",
|
||||
revision);
|
||||
if (*buf != 'y')
|
||||
fatal1("aborted\n");
|
||||
}
|
||||
} else if (verbose)
|
||||
say2("Good. This file appears to be the %s version.\n",
|
||||
revision);
|
||||
}
|
||||
Fseek(ifp, 0L, 0); /* Rewind file. */
|
||||
lines_per_buf = BUFFERSIZE / maxlen;
|
||||
tireclen = maxlen;
|
||||
tibuf[0] = malloc((MEM)(BUFFERSIZE + 1));
|
||||
tibuf[1] = malloc((MEM)(BUFFERSIZE + 1));
|
||||
if (tibuf[1] == Nullch)
|
||||
fatal1("out of memory\n");
|
||||
for (i = 1; ; i++) {
|
||||
if (! (i % lines_per_buf)) /* New block. */
|
||||
if (write(tifd, tibuf[0], BUFFERSIZE) < BUFFERSIZE)
|
||||
pfatal1("can't write temp file");
|
||||
if (fgets(tibuf[0] + maxlen * (i%lines_per_buf),
|
||||
maxlen + 1, ifp) == Nullch) {
|
||||
input_lines = i - 1;
|
||||
if (i % lines_per_buf)
|
||||
if (write(tifd, tibuf[0], BUFFERSIZE) <
|
||||
BUFFERSIZE)
|
||||
pfatal1("can't write temp file");
|
||||
break;
|
||||
}
|
||||
}
|
||||
Fclose(ifp);
|
||||
Close(tifd);
|
||||
if ((tifd = open(TMPINNAME, 0)) < 0) {
|
||||
pfatal2("can't reopen file %s", TMPINNAME);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Fetch a line from the input file, \n terminated, not necessarily \0.
|
||||
*/
|
||||
char *
|
||||
ifetch(line,whichbuf)
|
||||
Reg1 LINENUM line;
|
||||
int whichbuf; /* ignored when file in memory */
|
||||
{
|
||||
if (line < 1 || line > input_lines)
|
||||
return "";
|
||||
if (using_plan_a)
|
||||
return i_ptr[line];
|
||||
else {
|
||||
LINENUM offline = line % lines_per_buf;
|
||||
LINENUM baseline = line - offline;
|
||||
|
||||
if (tiline[0] == baseline)
|
||||
whichbuf = 0;
|
||||
else if (tiline[1] == baseline)
|
||||
whichbuf = 1;
|
||||
else {
|
||||
tiline[whichbuf] = baseline;
|
||||
#ifndef lint /* complains of long accuracy */
|
||||
Lseek(tifd, (long)baseline / lines_per_buf * BUFFERSIZE, 0);
|
||||
#endif
|
||||
if (read(tifd, tibuf[whichbuf], BUFFERSIZE) < 0)
|
||||
pfatal2("error reading tmp file %s", TMPINNAME);
|
||||
}
|
||||
return tibuf[whichbuf] + (tireclen * offline);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* True if the string argument contains the revision number we want.
|
||||
*/
|
||||
bool
|
||||
rev_in_string(char *string)
|
||||
{
|
||||
Reg1 char *s;
|
||||
Reg2 int patlen;
|
||||
|
||||
if (revision == Nullch)
|
||||
return TRUE;
|
||||
patlen = strlen(revision);
|
||||
if (strnEQ(string,revision,patlen) &&
|
||||
isspace((unsigned char)string[patlen]))
|
||||
return TRUE;
|
||||
for (s = string; *s; s++) {
|
||||
if (isspace((unsigned char)*s) &&
|
||||
strnEQ(s + 1, revision, patlen) &&
|
||||
isspace((unsigned char)s[patlen + 1] )) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
/* $FreeBSD$
|
||||
*
|
||||
* $Log: inp.h,v $
|
||||
* Revision 2.0 86/09/17 15:37:25 lwall
|
||||
* Baseline for netwide release.
|
||||
*
|
||||
*/
|
||||
|
||||
EXT LINENUM input_lines INIT(0); /* how long is input file in lines */
|
||||
EXT LINENUM last_frozen_line INIT(0); /* how many input lines have been */
|
||||
/* irretractibly output */
|
||||
void re_input(void);
|
||||
void scan_input(char *_filename);
|
||||
bool plan_a(char *_filename);
|
||||
void plan_b(char *_filename);
|
||||
bool rev_in_string(char *_string);
|
||||
char *ifetch(LINENUM _line, int _whichbuf);
|
||||
|
@ -1,594 +0,0 @@
|
||||
.\" -*- nroff -*-
|
||||
.rn '' }`
|
||||
'\" $Header: patch.man,v 2.0.1.2 88/06/22 20:47:18 lwall Locked $
|
||||
'\" $FreeBSD$
|
||||
'\"
|
||||
'\" $Log: patch.man,v $
|
||||
'\" Revision 2.0.1.2 88/06/22 20:47:18 lwall
|
||||
'\" patch12: now avoids Bell System Logo
|
||||
'\"
|
||||
'\" Revision 2.0.1.1 88/06/03 15:12:51 lwall
|
||||
'\" patch10: -B switch was contributed.
|
||||
'\"
|
||||
'\" Revision 2.0 86/09/17 15:39:09 lwall
|
||||
'\" Baseline for netwide release.
|
||||
'\"
|
||||
'\" Revision 1.4 86/08/01 19:23:22 lwall
|
||||
'\" Documented -v, -p, -F.
|
||||
'\" Added notes to patch senders.
|
||||
'\"
|
||||
'\" Revision 1.3 85/03/26 15:11:06 lwall
|
||||
'\" Frozen.
|
||||
'\"
|
||||
'\" Revision 1.2.1.4 85/03/12 16:14:27 lwall
|
||||
'\" Documented -p.
|
||||
'\"
|
||||
'\" Revision 1.2.1.3 85/03/12 16:09:41 lwall
|
||||
'\" Documented -D.
|
||||
'\"
|
||||
'\" Revision 1.2.1.2 84/12/05 11:06:55 lwall
|
||||
'\" Added -l switch, and noted bistability bug.
|
||||
'\"
|
||||
'\" Revision 1.2.1.1 84/12/04 17:23:39 lwall
|
||||
'\" Branch for sdcrdcf changes.
|
||||
'\"
|
||||
'\" Revision 1.2 84/12/04 17:22:02 lwall
|
||||
'\" Baseline version.
|
||||
'\"
|
||||
.de Sh
|
||||
.br
|
||||
.ne 5
|
||||
.PP
|
||||
\fB\\$1\fR
|
||||
.PP
|
||||
..
|
||||
.de Sp
|
||||
.if t .sp .5v
|
||||
.if n .sp
|
||||
..
|
||||
'\"
|
||||
'\" Set up \*(-- to give an unbreakable dash;
|
||||
'\" string Tr holds user defined translation string.
|
||||
'\" Bell System Logo is used as a dummy character.
|
||||
'\"
|
||||
.if !d Tr .ds Tr
|
||||
.ie n \{\
|
||||
.tr \(*W-\*(Tr
|
||||
.ds -- \(*W-
|
||||
.if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
|
||||
.if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
|
||||
.ds L" ""
|
||||
.ds R" ""
|
||||
.ds L' '
|
||||
.ds R' '
|
||||
'br \}
|
||||
.el \{\
|
||||
.ds -- \(em\|
|
||||
.tr \*(Tr
|
||||
.ds L" ``
|
||||
.ds R" ''
|
||||
.ds L' `
|
||||
.ds R' '
|
||||
'br\}
|
||||
.TH PATCH 1 LOCAL
|
||||
.SH NAME
|
||||
patch - apply a diff file to an original
|
||||
.SH SYNOPSIS
|
||||
.B patch
|
||||
[options] [origfile [patchfile]] [+ [options] [origfile]]...
|
||||
.sp
|
||||
but usually just
|
||||
.sp
|
||||
.B patch
|
||||
<patchfile
|
||||
.SH DESCRIPTION
|
||||
.I Patch
|
||||
will take a patch file containing any of the four forms of difference
|
||||
listing produced by the
|
||||
.I diff
|
||||
program and apply those differences to an original file, producing a patched
|
||||
version.
|
||||
By default, the patched version is put in place of the original, with
|
||||
the original file backed up to the same name with the
|
||||
extension \*(L".orig\*(R" (\*(L"~\*(R" on systems that do not
|
||||
support long file names), or as specified by the
|
||||
\fB\-b\fP (\fB\-\-suffix\fP),
|
||||
\fB\-B\fP (\fB\-\-prefix\fP),
|
||||
or
|
||||
\fB\-V\fP (\fB\-\-version\-control\fP)
|
||||
options.
|
||||
The extension used for making backup files may also be specified in the
|
||||
.B SIMPLE_BACKUP_SUFFIX
|
||||
environment variable, which is overridden by the above options.
|
||||
.PP
|
||||
If the backup file already exists,
|
||||
.B patch
|
||||
creates a new backup file name by changing the first lowercase letter
|
||||
in the last component of the file's name into uppercase. If there are
|
||||
no more lowercase letters in the name, it removes the first character
|
||||
from the name. It repeats this process until it comes up with a
|
||||
backup file that does not already exist.
|
||||
.PP
|
||||
You may also specify where you want the output to go with a
|
||||
\fB\-o\fP (\fB\-\-output\fP)
|
||||
option; if that file already exists, it is backed up first.
|
||||
.PP
|
||||
If
|
||||
.I patchfile
|
||||
is omitted, or is a hyphen, the patch will be read from standard input.
|
||||
If a
|
||||
\fB\-i\fP
|
||||
argument is specified, the filename following it will be used, instead of
|
||||
standard input. You may specify only one
|
||||
\fB\-i\fP
|
||||
directive.
|
||||
.PP
|
||||
Upon startup, patch will attempt to determine the type of the diff listing,
|
||||
unless over-ruled by a
|
||||
\fB\-c\fP (\fB\-\-context\fP),
|
||||
\fB\-e\fP (\fB\-\-ed\fP),
|
||||
\fB\-n\fP (\fB\-\-normal\fP),
|
||||
or
|
||||
\fB\-u\fP (\fB\-\-unified\fP)
|
||||
option.
|
||||
Context diffs (old-style, new-style, and unified) and
|
||||
normal diffs are applied by the
|
||||
.I patch
|
||||
program itself, while
|
||||
.I ed
|
||||
diffs are simply fed to the
|
||||
.I ed
|
||||
editor via a pipe.
|
||||
.PP
|
||||
.I Patch
|
||||
will try to skip any leading garbage, apply the diff,
|
||||
and then skip any trailing garbage.
|
||||
Thus you could feed an article or message containing a
|
||||
diff listing to
|
||||
.IR patch ,
|
||||
and it should work.
|
||||
If the entire diff is indented by a consistent amount,
|
||||
this will be taken into account.
|
||||
.PP
|
||||
With context diffs, and to a lesser extent with normal diffs,
|
||||
.I patch
|
||||
can detect when the line numbers mentioned in the patch are incorrect,
|
||||
and will attempt to find the correct place to apply each hunk of the patch.
|
||||
As a first guess, it takes the line number mentioned for the hunk, plus or
|
||||
minus any offset used in applying the previous hunk.
|
||||
If that is not the correct place,
|
||||
.I patch
|
||||
will scan both forwards and backwards for a set of lines matching the context
|
||||
given in the hunk.
|
||||
First
|
||||
.I patch
|
||||
looks for a place where all lines of the context match.
|
||||
If no such place is found, and it's a context diff, and the maximum fuzz factor
|
||||
is set to 1 or more, then another scan takes place ignoring the first and last
|
||||
line of context.
|
||||
If that fails, and the maximum fuzz factor is set to 2 or more,
|
||||
the first two and last two lines of context are ignored,
|
||||
and another scan is made.
|
||||
(The default maximum fuzz factor is 2.)
|
||||
If
|
||||
.I patch
|
||||
cannot find a place to install that hunk of the patch, it will put the
|
||||
hunk out to a reject file, which normally is the name of the output file
|
||||
plus \*(L".rej\*(R" (\*(L"#\*(R" on systems that do not support
|
||||
long file names).
|
||||
(Note that the rejected hunk will come out in context diff form whether the
|
||||
input patch was a context diff or a normal diff.
|
||||
If the input was a normal diff, many of the contexts will simply be null.)
|
||||
The line numbers on the hunks in the reject file may be different than
|
||||
in the patch file: they reflect the approximate location patch thinks the
|
||||
failed hunks belong in the new file rather than the old one.
|
||||
.PP
|
||||
As each hunk is completed, you will be told whether the hunk succeeded or
|
||||
failed, and which line (in the new file)
|
||||
.I patch
|
||||
thought the hunk should go on.
|
||||
If this is different from the line number specified in the diff you will
|
||||
be told the offset.
|
||||
A single large offset MAY be an indication that a hunk was installed in the
|
||||
wrong place.
|
||||
You will also be told if a fuzz factor was used to make the match, in which
|
||||
case you should also be slightly suspicious.
|
||||
.PP
|
||||
If no original file is specified on the command line,
|
||||
.I patch
|
||||
will try to figure out from the leading garbage what the name of the file
|
||||
to edit is.
|
||||
In the header of a context diff, the file name is found from lines beginning
|
||||
with \*(L"***\*(R" or \*(L"---\*(R", with the shortest name of an existing
|
||||
file winning.
|
||||
Only context diffs have lines like that, but if there is an \*(L"Index:\*(R"
|
||||
line in the leading garbage,
|
||||
.I patch
|
||||
will try to use the file name from that line.
|
||||
The context diff header takes precedence over an Index line.
|
||||
If no file name can be intuited from the leading garbage, you will be asked
|
||||
for the name of the file to patch.
|
||||
.PP
|
||||
If the original file cannot be found or is read-only, but a suitable
|
||||
SCCS or RCS file is handy,
|
||||
.I patch
|
||||
will attempt to get or check out the file.
|
||||
.PP
|
||||
Additionally, if the leading garbage contains a \*(L"Prereq: \*(R" line,
|
||||
.I patch
|
||||
will take the first word from the prerequisites line (normally a version
|
||||
number) and check the input file to see if that word can be found.
|
||||
If not,
|
||||
.I patch
|
||||
will ask for confirmation before proceeding.
|
||||
.PP
|
||||
The upshot of all this is that you should be able to say, while in a news
|
||||
interface, the following:
|
||||
.Sp
|
||||
| patch -d /usr/src/local/blurfl
|
||||
.Sp
|
||||
and patch a file in the blurfl directory directly from the article containing
|
||||
the patch.
|
||||
.PP
|
||||
If the patch file contains more than one patch,
|
||||
.I patch
|
||||
will try to apply each of them as if they came from separate patch files.
|
||||
This means, among other things, that it is assumed that the name of the file
|
||||
to patch must be determined for each diff listing,
|
||||
and that the garbage before each diff listing will
|
||||
be examined for interesting things such as file names and revision level, as
|
||||
mentioned previously.
|
||||
You can give options (and another original file name) for the second and
|
||||
subsequent patches by separating the corresponding argument lists
|
||||
by a \*(L'+\*(R'.
|
||||
(The argument list for a second or subsequent patch may not specify a new
|
||||
patch file, however.)
|
||||
.PP
|
||||
.I Patch
|
||||
recognizes the following options:
|
||||
.TP 5
|
||||
.B "\-b suff, \-\-suffix=suff"
|
||||
causes
|
||||
.B suff
|
||||
to be interpreted as the backup extension, to be
|
||||
used in place of \*(L".orig\*(R" or \*(L"~\*(R".
|
||||
.TP 5
|
||||
.B "\-B pref, \-\-prefix=pref"
|
||||
causes
|
||||
.B pref
|
||||
to be interpreted as a prefix to the backup file
|
||||
name. If this argument is specified, any argument from
|
||||
.B \-b
|
||||
will be ignored.
|
||||
.TP 5
|
||||
.B "\-c, \-\-context"
|
||||
forces
|
||||
.I patch
|
||||
to interpret the patch file as a context diff.
|
||||
.TP 5
|
||||
.B "\-C, \-\-check"
|
||||
see what would happen, but don't do it.
|
||||
.TP 5
|
||||
.B "\-d dir, \-\-directory=dir"
|
||||
causes
|
||||
.I patch
|
||||
to interpret
|
||||
.B dir
|
||||
as a directory, and cd to it before doing
|
||||
anything else.
|
||||
.TP 5
|
||||
.B "\-D sym, \-\-ifdef=sym"
|
||||
causes
|
||||
.I patch
|
||||
to use the "#ifdef...#endif" construct to mark changes.
|
||||
.B sym
|
||||
will be used as the differentiating symbol.
|
||||
.TP 5
|
||||
.B "\-e, \-\-ed"
|
||||
forces
|
||||
.I patch
|
||||
to interpret the patch file as an
|
||||
.I ed
|
||||
script.
|
||||
.TP 5
|
||||
.B "\-E, \-\-remove\-empty\-files"
|
||||
causes
|
||||
.I patch
|
||||
to remove output files that are empty after the patches have been applied.
|
||||
.TP 5
|
||||
.B "\-f, \-\-force"
|
||||
forces
|
||||
.I patch
|
||||
to assume that the user knows exactly what he or she is doing, and to not
|
||||
ask any questions. It assumes the following: skip patches for which a
|
||||
file to patch can't be found; patch files even though they have the
|
||||
wrong version for the ``Prereq:'' line in the patch; and assume that
|
||||
patches are not reversed even if they look like they are.
|
||||
This option does not suppress commentary; use
|
||||
.B \-s
|
||||
for that.
|
||||
.TP 5
|
||||
.B "\-t, \-\-batch"
|
||||
similar to
|
||||
.BR \-f ,
|
||||
in that it suppresses questions, but makes some different assumptions:
|
||||
skip patches for which a file to patch can't be found (the same as \fB\-f\fP);
|
||||
skip patches for which the file has the wrong version for the ``Prereq:'' line
|
||||
in the patch; and assume that patches are reversed if they look like
|
||||
they are.
|
||||
.TP 5
|
||||
.B "\-F number, \-\-fuzz=number"
|
||||
sets the maximum fuzz factor.
|
||||
This option only applies to context diffs, and causes
|
||||
.I patch
|
||||
to ignore up to that many lines in looking for places to install a hunk.
|
||||
Note that a larger fuzz factor increases the odds of a faulty patch.
|
||||
The default fuzz factor is 2, and it may not be set to more than
|
||||
the number of lines of context in the context diff, ordinarily 3.
|
||||
.TP 5
|
||||
.B "\-i patchfile"
|
||||
tells
|
||||
.I patch
|
||||
to apply \fBpatchfile\fP instead of stdin.
|
||||
.TP 5
|
||||
.B "\-I, \-\-index-first"
|
||||
forces
|
||||
.I patch
|
||||
to take ``Index:'' line precedence over context diff header.
|
||||
The same effect have
|
||||
.B PATCH_INDEX_FIRST
|
||||
environment variable if present.
|
||||
.TP 5
|
||||
.B "\-l, \-\-ignore\-whitespace"
|
||||
causes the pattern matching to be done loosely, in case the tabs and
|
||||
spaces have been munged in your input file.
|
||||
Any sequence of whitespace in the pattern line will match any sequence
|
||||
in the input file.
|
||||
Normal characters must still match exactly.
|
||||
Each line of the context must still match a line in the input file.
|
||||
.TP 5
|
||||
.B "\-n, \-\-normal"
|
||||
forces
|
||||
.I patch
|
||||
to interpret the patch file as a normal diff.
|
||||
.TP 5
|
||||
.B "\-N, \-\-forward"
|
||||
causes
|
||||
.I patch
|
||||
to ignore patches that it thinks are reversed or already applied.
|
||||
See also
|
||||
.B \-R .
|
||||
.TP 5
|
||||
.B "\-o file, \-\-output=file"
|
||||
causes
|
||||
.B file
|
||||
to be interpreted as the output file name.
|
||||
.TP 5
|
||||
.B "\-p[number], \-\-strip[=number]"
|
||||
sets the pathname strip count,
|
||||
which controls how pathnames found in the patch file are treated, in case
|
||||
you keep your files in a different directory than the person who sent
|
||||
out the patch.
|
||||
The strip count specifies how many slashes are to be stripped from
|
||||
the front of the pathname.
|
||||
(Any intervening directory names also go away.)
|
||||
For example, supposing the file name in the patch file was
|
||||
.sp
|
||||
/u/howard/src/blurfl/blurfl.c
|
||||
.sp
|
||||
setting
|
||||
.B \-p
|
||||
or
|
||||
.B \-p0
|
||||
gives the entire pathname unmodified,
|
||||
.B \-p1
|
||||
gives
|
||||
.sp
|
||||
u/howard/src/blurfl/blurfl.c
|
||||
.sp
|
||||
without the leading slash,
|
||||
.B \-p4
|
||||
gives
|
||||
.sp
|
||||
blurfl/blurfl.c
|
||||
.sp
|
||||
and not specifying
|
||||
.B \-p
|
||||
at all just gives you "blurfl.c", unless all of the directories in the
|
||||
leading path (u/howard/src/blurfl) exist and that path is relative,
|
||||
in which case you get the entire pathname unmodified.
|
||||
Whatever you end up with is looked for either in the current directory,
|
||||
or the directory specified by the
|
||||
.B \-d
|
||||
option.
|
||||
.TP 5
|
||||
.B "\-r file, \-\-reject\-file=file"
|
||||
causes
|
||||
.B file
|
||||
to be interpreted as the reject file name.
|
||||
.TP 5
|
||||
.B "\-R, \-\-reverse"
|
||||
tells
|
||||
.I patch
|
||||
that this patch was created with the old and new files swapped.
|
||||
(Yes, I'm afraid that does happen occasionally, human nature being what it
|
||||
is.)
|
||||
.I Patch
|
||||
will attempt to swap each hunk around before applying it.
|
||||
Rejects will come out in the swapped format.
|
||||
The
|
||||
.B \-R
|
||||
option will not work with
|
||||
.I ed
|
||||
diff scripts because there is too little
|
||||
information to reconstruct the reverse operation.
|
||||
.Sp
|
||||
If the first hunk of a patch fails,
|
||||
.I patch
|
||||
will reverse the hunk to see if it can be applied that way.
|
||||
If it can, you will be asked if you want to have the
|
||||
.B \-R
|
||||
option set.
|
||||
If it can't, the patch will continue to be applied normally.
|
||||
(Note: this method cannot detect a reversed patch if it is a normal diff
|
||||
and if the first command is an append (i.e. it should have been a delete)
|
||||
since appends always succeed, due to the fact that a null context will match
|
||||
anywhere.
|
||||
Luckily, most patches add or change lines rather than delete them, so most
|
||||
reversed normal diffs will begin with a delete, which will fail, triggering
|
||||
the heuristic.)
|
||||
.TP 5
|
||||
.B "\-s, \-\-silent, \-\-quiet"
|
||||
makes
|
||||
.I patch
|
||||
do its work silently, unless an error occurs.
|
||||
.TP 5
|
||||
.B "\-S, \-\-skip"
|
||||
causes
|
||||
.I patch
|
||||
to ignore this patch from the patch file, but continue on looking
|
||||
for the next patch in the file.
|
||||
Thus
|
||||
.sp
|
||||
patch -S + -S + <patchfile
|
||||
.sp
|
||||
will ignore the first and second of three patches.
|
||||
.TP 5
|
||||
.B "\-u, \-\-unified"
|
||||
forces
|
||||
.I patch
|
||||
to interpret the patch file as a unified context diff (a unidiff).
|
||||
.TP 5
|
||||
.B "\-v, \-\-version"
|
||||
causes
|
||||
.I patch
|
||||
to print out its revision header and patch level.
|
||||
.TP 5
|
||||
.B "\-V method, \-\-version\-control=method"
|
||||
causes
|
||||
.B method
|
||||
to be interpreted as a method for creating
|
||||
backup file names. The type of backups made can also be given in the
|
||||
.B VERSION_CONTROL
|
||||
environment variable, which is overridden by this option.
|
||||
The
|
||||
.B -B
|
||||
option overrides this option, causing the prefix to always be used for
|
||||
making backup file names.
|
||||
The value of the
|
||||
.B VERSION_CONTROL
|
||||
environment variable and the argument to the
|
||||
.B -V
|
||||
option are like the GNU
|
||||
Emacs `version-control' variable; they also recognize synonyms that
|
||||
are more descriptive. The valid values are (unique abbreviations are
|
||||
accepted):
|
||||
.RS
|
||||
.TP
|
||||
`t' or `numbered'
|
||||
Always make numbered backups.
|
||||
.TP
|
||||
`nil' or `existing'
|
||||
Make numbered backups of files that already
|
||||
have them, simple backups of the others.
|
||||
This is the default.
|
||||
.TP
|
||||
`never' or `simple'
|
||||
Always make simple backups.
|
||||
.RE
|
||||
.TP 5
|
||||
.B "\-x number, \-\-debug=number"
|
||||
sets internal debugging flags, and is of interest only to
|
||||
.I patch
|
||||
patchers.
|
||||
.SH AUTHOR
|
||||
Larry Wall <lwall@netlabs.com>
|
||||
.br
|
||||
with many other contributors.
|
||||
.SH ENVIRONMENT
|
||||
.TP
|
||||
.B TMPDIR
|
||||
Directory to put temporary files in; default is /tmp.
|
||||
.TP
|
||||
.B SIMPLE_BACKUP_SUFFIX
|
||||
Extension to use for backup file names instead of \*(L".orig\*(R" or
|
||||
\*(L"~\*(R".
|
||||
.TP
|
||||
.B VERSION_CONTROL
|
||||
Selects when numbered backup files are made.
|
||||
.SH FILES
|
||||
$TMPDIR/patch*
|
||||
.SH SEE ALSO
|
||||
diff(1)
|
||||
.SH NOTES FOR PATCH SENDERS
|
||||
There are several things you should bear in mind if you are going to
|
||||
be sending out patches.
|
||||
First, you can save people a lot of grief by keeping a patchlevel.h file
|
||||
which is patched to increment the patch level as the first diff in the
|
||||
patch file you send out.
|
||||
If you put a Prereq: line in with the patch, it won't let them apply
|
||||
patches out of order without some warning.
|
||||
Second, make sure you've specified the file names right, either in a
|
||||
context diff header, or with an Index: line.
|
||||
If you are patching something in a subdirectory, be sure to tell the patch
|
||||
user to specify a
|
||||
.B \-p
|
||||
option as needed.
|
||||
Third, you can create a file by sending out a diff that compares a
|
||||
null file to the file you want to create.
|
||||
This will only work if the file you want to create doesn't exist already in
|
||||
the target directory.
|
||||
Fourth, take care not to send out reversed patches, since it makes people wonder
|
||||
whether they already applied the patch.
|
||||
Fifth, while you may be able to get away with putting 582 diff listings into
|
||||
one file, it is probably wiser to group related patches into separate files in
|
||||
case something goes haywire.
|
||||
.SH DIAGNOSTICS
|
||||
Too many to list here, but generally indicative that
|
||||
.I patch
|
||||
couldn't parse your patch file.
|
||||
.PP
|
||||
The message \*(L"Hmm...\*(R" indicates that there is unprocessed text in
|
||||
the patch file and that
|
||||
.I patch
|
||||
is attempting to intuit whether there is a patch in that text and, if so,
|
||||
what kind of patch it is.
|
||||
.PP
|
||||
.I Patch
|
||||
will exit with a non-zero status if any reject files were created.
|
||||
When applying a set of patches in a loop it behooves you to check this
|
||||
exit status so you don't apply a later patch to a partially patched file.
|
||||
.SH CAVEATS
|
||||
.I Patch
|
||||
cannot tell if the line numbers are off in an
|
||||
.I ed
|
||||
script, and can only detect
|
||||
bad line numbers in a normal diff when it finds a \*(L"change\*(R" or
|
||||
a \*(L"delete\*(R" command.
|
||||
A context diff using fuzz factor 3 may have the same problem.
|
||||
Until a suitable interactive interface is added, you should probably do
|
||||
a context diff in these cases to see if the changes made sense.
|
||||
Of course, compiling without errors is a pretty good indication that the patch
|
||||
worked, but not always.
|
||||
.PP
|
||||
.I Patch
|
||||
usually produces the correct results, even when it has to do a lot of
|
||||
guessing.
|
||||
However, the results are guaranteed to be correct only when the patch is
|
||||
applied to exactly the same version of the file that the patch was
|
||||
generated from.
|
||||
.SH BUGS
|
||||
Could be smarter about partial matches, excessively \&deviant offsets and
|
||||
swapped code, but that would take an extra pass.
|
||||
.PP
|
||||
If code has been duplicated (for instance with #ifdef OLDCODE ... #else ...
|
||||
#endif),
|
||||
.I patch
|
||||
is incapable of patching both versions, and, if it works at all, will likely
|
||||
patch the wrong one, and tell you that it succeeded to boot.
|
||||
.PP
|
||||
If you apply a patch you've already applied,
|
||||
.I patch
|
||||
will think it is a reversed patch, and offer to un-apply the patch.
|
||||
This could be construed as a feature.
|
||||
.rn }` ''
|
@ -1,971 +0,0 @@
|
||||
char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
|
||||
/* patch - a program to apply diffs to original files
|
||||
*
|
||||
* Copyright 1986, Larry Wall
|
||||
*
|
||||
* This program may be copied as long as you don't try to make any
|
||||
* money off of it, or pretend that you wrote it.
|
||||
*
|
||||
* $Log: patch.c,v $
|
||||
* Revision 2.0.2.0 90/05/01 22:17:50 davison
|
||||
* patch12u: unidiff support added
|
||||
*
|
||||
* Revision 2.0.1.6 88/06/22 20:46:39 lwall
|
||||
* patch12: rindex() wasn't declared
|
||||
*
|
||||
* Revision 2.0.1.5 88/06/03 15:09:37 lwall
|
||||
* patch10: exit code improved.
|
||||
* patch10: better support for non-flexfilenames.
|
||||
*
|
||||
* Revision 2.0.1.4 87/02/16 14:00:04 lwall
|
||||
* Short replacement caused spurious "Out of sync" message.
|
||||
*
|
||||
* Revision 2.0.1.3 87/01/30 22:45:50 lwall
|
||||
* Improved diagnostic on sync error.
|
||||
* Moved do_ed_script() to pch.c.
|
||||
*
|
||||
* Revision 2.0.1.2 86/11/21 09:39:15 lwall
|
||||
* Fuzz factor caused offset of installed lines.
|
||||
*
|
||||
* Revision 2.0.1.1 86/10/29 13:10:22 lwall
|
||||
* Backwards search could terminate prematurely.
|
||||
*
|
||||
* Revision 2.0 86/09/17 15:37:32 lwall
|
||||
* Baseline for netwide release.
|
||||
*
|
||||
* Revision 1.5 86/08/01 20:53:24 lwall
|
||||
* Changed some %d's to %ld's.
|
||||
* Linted.
|
||||
*
|
||||
* Revision 1.4 86/08/01 19:17:29 lwall
|
||||
* Fixes for machines that can't vararg.
|
||||
* Added fuzz factor.
|
||||
* Generalized -p.
|
||||
* General cleanup.
|
||||
*
|
||||
* 85/08/15 van%ucbmonet@berkeley
|
||||
* Changes for 4.3bsd diff -c.
|
||||
*
|
||||
* Revision 1.3 85/03/26 15:07:43 lwall
|
||||
* Frozen.
|
||||
*
|
||||
* Revision 1.2.1.9 85/03/12 17:03:35 lwall
|
||||
* Changed pfp->_file to fileno(pfp).
|
||||
*
|
||||
* Revision 1.2.1.8 85/03/12 16:30:43 lwall
|
||||
* Check i_ptr and i_womp to make sure they aren't null before freeing.
|
||||
* Also allow ed output to be suppressed.
|
||||
*
|
||||
* Revision 1.2.1.7 85/03/12 15:56:13 lwall
|
||||
* Added -p option from jromine@uci-750a.
|
||||
*
|
||||
* Revision 1.2.1.6 85/03/12 12:12:51 lwall
|
||||
* Now checks for normalness of file to patch.
|
||||
*
|
||||
* Revision 1.2.1.5 85/03/12 11:52:12 lwall
|
||||
* Added -D (#ifdef) option from joe@fluke.
|
||||
*
|
||||
* Revision 1.2.1.4 84/12/06 11:14:15 lwall
|
||||
* Made smarter about SCCS subdirectories.
|
||||
*
|
||||
* Revision 1.2.1.3 84/12/05 11:18:43 lwall
|
||||
* Added -l switch to do loose string comparison.
|
||||
*
|
||||
* Revision 1.2.1.2 84/12/04 09:47:13 lwall
|
||||
* Failed hunk count not reset on multiple patch file.
|
||||
*
|
||||
* Revision 1.2.1.1 84/12/04 09:42:37 lwall
|
||||
* Branch for sdcrdcf changes.
|
||||
*
|
||||
* Revision 1.2 84/11/29 13:29:51 lwall
|
||||
* Linted. Identifiers uniqified. Fixed i_ptr malloc() bug. Fixed
|
||||
* multiple calls to mktemp(). Will now work on machines that can only
|
||||
* read 32767 chars. Added -R option for diffs with new and old swapped.
|
||||
* Various cosmetic changes.
|
||||
*
|
||||
* Revision 1.1 84/11/09 17:03:58 lwall
|
||||
* Initial revision
|
||||
*
|
||||
*/
|
||||
|
||||
#include <paths.h>
|
||||
#include "INTERN.h"
|
||||
#include "common.h"
|
||||
#include "EXTERN.h"
|
||||
#include "version.h"
|
||||
#include "util.h"
|
||||
#include "pch.h"
|
||||
#include "inp.h"
|
||||
#include "backupfile.h"
|
||||
#include "getopt.h"
|
||||
|
||||
/* procedures */
|
||||
|
||||
void reinitialize_almost_everything(void);
|
||||
void get_some_switches(void);
|
||||
LINENUM locate_hunk(LINENUM _fuzz);
|
||||
void abort_hunk(void);
|
||||
void apply_hunk(LINENUM _where);
|
||||
void init_output(char *_name);
|
||||
void init_reject(char *_name);
|
||||
void copy_till(LINENUM _lastline);
|
||||
void spew_output(void);
|
||||
void dump_line(LINENUM _line);
|
||||
bool patch_match(LINENUM _base, LINENUM _offset, LINENUM _fuzz);
|
||||
bool similar(char *_a, char *_b, int _len);
|
||||
void my_exit(int _status);
|
||||
|
||||
|
||||
/* TRUE if -E was specified on command line. */
|
||||
static int remove_empty_files = FALSE;
|
||||
|
||||
/* TRUE if -R was specified on command line. */
|
||||
static int reverse_flag_specified = FALSE;
|
||||
|
||||
/* TRUE if -C was specified on command line. */
|
||||
int check_patch = FALSE;
|
||||
|
||||
/* TRUE if -I was specified on command line */
|
||||
/* or PATCH_INDEX_FIRST env. variable is set */
|
||||
int index_first;
|
||||
|
||||
/* TRUE if -S was specified on command line. */
|
||||
int skip_flag_specified = FALSE;
|
||||
|
||||
/* Apply a set of diffs as appropriate. */
|
||||
|
||||
int
|
||||
main(argc,argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
LINENUM where;
|
||||
LINENUM newwhere;
|
||||
LINENUM fuzz;
|
||||
LINENUM mymaxfuzz;
|
||||
int hunk = 0;
|
||||
int failed = 0;
|
||||
int failtotal = 0;
|
||||
bool rev_okayed = 0;
|
||||
int i;
|
||||
|
||||
setbuf(stderr, serrbuf);
|
||||
for (i = 0; i<MAXFILEC; i++)
|
||||
filearg[i] = Nullch;
|
||||
|
||||
buf_size = INITLINELEN;
|
||||
buf = malloc((MEM)(buf_size));
|
||||
if (buf == Nullch)
|
||||
fatal1("out of memory\n");
|
||||
|
||||
myuid = getuid();
|
||||
|
||||
index_first = getenv ("PATCH_INDEX_FIRST") != 0;
|
||||
|
||||
/* Cons up the names of the temporary files. */
|
||||
{
|
||||
/* Directory for temporary files. */
|
||||
char *tmpdir;
|
||||
int tmpname_len;
|
||||
|
||||
tmpdir = getenv ("TMPDIR");
|
||||
if (tmpdir == NULL) {
|
||||
tmpdir = _PATH_TMP;
|
||||
}
|
||||
tmpname_len = strlen (tmpdir) + 20;
|
||||
|
||||
TMPOUTNAME = (char *) malloc (tmpname_len);
|
||||
strcpy (TMPOUTNAME, tmpdir);
|
||||
strcat (TMPOUTNAME, "/patchoXXXXXX");
|
||||
Mktemp(TMPOUTNAME);
|
||||
|
||||
TMPINNAME = (char *) malloc (tmpname_len);
|
||||
strcpy (TMPINNAME, tmpdir);
|
||||
strcat (TMPINNAME, "/patchiXXXXXX");
|
||||
Mktemp(TMPINNAME);
|
||||
|
||||
TMPREJNAME = (char *) malloc (tmpname_len);
|
||||
strcpy (TMPREJNAME, tmpdir);
|
||||
strcat (TMPREJNAME, "/patchrXXXXXX");
|
||||
Mktemp(TMPREJNAME);
|
||||
|
||||
TMPPATNAME = (char *) malloc (tmpname_len);
|
||||
strcpy (TMPPATNAME, tmpdir);
|
||||
strcat (TMPPATNAME, "/patchpXXXXXX");
|
||||
Mktemp(TMPPATNAME);
|
||||
}
|
||||
|
||||
{
|
||||
char *v;
|
||||
|
||||
v = getenv ("SIMPLE_BACKUP_SUFFIX");
|
||||
if (v)
|
||||
simple_backup_suffix = v;
|
||||
else
|
||||
simple_backup_suffix = ".orig";
|
||||
#ifndef NODIR
|
||||
v = getenv ("VERSION_CONTROL");
|
||||
backup_type = get_version (v); /* OK to pass NULL. */
|
||||
#endif
|
||||
}
|
||||
|
||||
/* parse switches */
|
||||
Argc = argc;
|
||||
Argv = argv;
|
||||
get_some_switches();
|
||||
|
||||
/* make sure we clean up /tmp in case of disaster */
|
||||
set_signals(0);
|
||||
|
||||
for (
|
||||
open_patch_file(filearg[1]);
|
||||
there_is_another_patch();
|
||||
reinitialize_almost_everything()
|
||||
) { /* for each patch in patch file */
|
||||
|
||||
if (outname == Nullch)
|
||||
outname = savestr(filearg[0]);
|
||||
|
||||
/* for ed script just up and do it and exit */
|
||||
if (diff_type == ED_DIFF) {
|
||||
do_ed_script();
|
||||
continue;
|
||||
}
|
||||
|
||||
/* initialize the patched file */
|
||||
if (!skip_rest_of_patch)
|
||||
init_output(TMPOUTNAME);
|
||||
|
||||
/* initialize reject file */
|
||||
init_reject(TMPREJNAME);
|
||||
|
||||
/* find out where all the lines are */
|
||||
if (!skip_rest_of_patch)
|
||||
scan_input(filearg[0]);
|
||||
|
||||
/* from here on, open no standard i/o files, because malloc */
|
||||
/* might misfire and we can't catch it easily */
|
||||
|
||||
/* apply each hunk of patch */
|
||||
hunk = 0;
|
||||
failed = 0;
|
||||
rev_okayed = FALSE;
|
||||
out_of_mem = FALSE;
|
||||
while (another_hunk()) {
|
||||
hunk++;
|
||||
fuzz = Nulline;
|
||||
mymaxfuzz = pch_context();
|
||||
if (maxfuzz < mymaxfuzz)
|
||||
mymaxfuzz = maxfuzz;
|
||||
if (!skip_rest_of_patch) {
|
||||
do {
|
||||
where = locate_hunk(fuzz);
|
||||
if (hunk == 1 && where == Nulline && !(force|rev_okayed)) {
|
||||
/* dwim for reversed patch? */
|
||||
if (!pch_swap()) {
|
||||
if (fuzz == Nulline)
|
||||
say1(
|
||||
"Not enough memory to try swapped hunk! Assuming unswapped.\n");
|
||||
continue;
|
||||
}
|
||||
reverse = !reverse;
|
||||
where = locate_hunk(fuzz); /* try again */
|
||||
if (where == Nulline) { /* didn't find it swapped */
|
||||
if (!pch_swap()) /* put it back to normal */
|
||||
fatal1("lost hunk on alloc error!\n");
|
||||
reverse = !reverse;
|
||||
}
|
||||
else if (noreverse) {
|
||||
if (!pch_swap()) /* put it back to normal */
|
||||
fatal1("lost hunk on alloc error!\n");
|
||||
reverse = !reverse;
|
||||
say1(
|
||||
"Ignoring previously applied (or reversed) patch.\n");
|
||||
skip_rest_of_patch = TRUE;
|
||||
}
|
||||
else if (batch) {
|
||||
if (verbose)
|
||||
say3(
|
||||
"%seversed (or previously applied) patch detected! %s -R.",
|
||||
reverse ? "R" : "Unr",
|
||||
reverse ? "Assuming" : "Ignoring");
|
||||
}
|
||||
else {
|
||||
(void) ask3(
|
||||
"%seversed (or previously applied) patch detected! %s -R? [y] ",
|
||||
reverse ? "R" : "Unr",
|
||||
reverse ? "Assume" : "Ignore");
|
||||
if (*buf == 'n') {
|
||||
(void) ask1("Apply anyway? [n] ");
|
||||
if (*buf == 'y')
|
||||
rev_okayed = TRUE;
|
||||
else
|
||||
skip_rest_of_patch = TRUE;
|
||||
where = Nulline;
|
||||
reverse = !reverse;
|
||||
if (!pch_swap()) /* put it back to normal */
|
||||
fatal1("lost hunk on alloc error!\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (!skip_rest_of_patch && where == Nulline &&
|
||||
++fuzz <= mymaxfuzz);
|
||||
|
||||
if (skip_rest_of_patch) { /* just got decided */
|
||||
Fclose(ofp);
|
||||
ofp = Nullfp;
|
||||
}
|
||||
}
|
||||
|
||||
newwhere = pch_newfirst() + last_offset;
|
||||
if (skip_rest_of_patch) {
|
||||
abort_hunk();
|
||||
if (! skip_flag_specified)
|
||||
failed++;
|
||||
if (verbose)
|
||||
say3("Hunk #%d ignored at %ld.\n", hunk, newwhere);
|
||||
}
|
||||
else if (where == Nulline) {
|
||||
abort_hunk();
|
||||
failed++;
|
||||
if (verbose)
|
||||
say3("Hunk #%d failed at %ld.\n", hunk, newwhere);
|
||||
}
|
||||
else {
|
||||
apply_hunk(where);
|
||||
if (verbose) {
|
||||
say3("Hunk #%d succeeded at %ld", hunk, newwhere);
|
||||
if (fuzz)
|
||||
say2(" with fuzz %ld", fuzz);
|
||||
if (last_offset)
|
||||
say3(" (offset %ld line%s)",
|
||||
last_offset, last_offset==1L?"":"s");
|
||||
say1(".\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (out_of_mem && using_plan_a) {
|
||||
optind = optind_last;
|
||||
say1("\n\nRan out of memory using Plan A--trying again...\n\n");
|
||||
if (ofp)
|
||||
Fclose(ofp);
|
||||
ofp = Nullfp;
|
||||
if (rejfp)
|
||||
Fclose(rejfp);
|
||||
rejfp = Nullfp;
|
||||
continue;
|
||||
}
|
||||
|
||||
assert(hunk);
|
||||
|
||||
/* finish spewing out the new file */
|
||||
if (!skip_rest_of_patch)
|
||||
spew_output();
|
||||
|
||||
/* and put the output where desired */
|
||||
ignore_signals();
|
||||
if (!skip_rest_of_patch) {
|
||||
struct stat statbuf;
|
||||
char *realout = outname;
|
||||
|
||||
if (check_patch) {
|
||||
;
|
||||
} else if (move_file(TMPOUTNAME, outname) < 0) {
|
||||
toutkeep = TRUE;
|
||||
realout = TMPOUTNAME;
|
||||
chmod(TMPOUTNAME, filemode);
|
||||
}
|
||||
else
|
||||
chmod(outname, filemode);
|
||||
|
||||
if (remove_empty_files && stat(realout, &statbuf) == 0
|
||||
&& statbuf.st_size == 0) {
|
||||
if (verbose)
|
||||
say2("Removing %s (empty after patching).\n", realout);
|
||||
while (unlink(realout) >= 0) ; /* while is for Eunice. */
|
||||
}
|
||||
}
|
||||
Fclose(rejfp);
|
||||
rejfp = Nullfp;
|
||||
if (failed) {
|
||||
failtotal += failed;
|
||||
if (!*rejname) {
|
||||
Strlcpy(rejname, outname, sizeof(rejname));
|
||||
addext(rejname, ".rej", '#');
|
||||
}
|
||||
if (skip_rest_of_patch) {
|
||||
say4("%d out of %d hunks ignored--saving rejects to %s\n",
|
||||
failed, hunk, rejname);
|
||||
}
|
||||
else {
|
||||
say4("%d out of %d hunks failed--saving rejects to %s\n",
|
||||
failed, hunk, rejname);
|
||||
}
|
||||
if (check_patch) {
|
||||
;
|
||||
} else if (move_file(TMPREJNAME, rejname) < 0)
|
||||
trejkeep = TRUE;
|
||||
}
|
||||
set_signals(1);
|
||||
}
|
||||
my_exit(failtotal);
|
||||
return (failtotal);
|
||||
}
|
||||
|
||||
/* Prepare to find the next patch to do in the patch file. */
|
||||
|
||||
void
|
||||
reinitialize_almost_everything(void)
|
||||
{
|
||||
re_patch();
|
||||
re_input();
|
||||
|
||||
input_lines = 0;
|
||||
last_frozen_line = 0;
|
||||
|
||||
filec = 0;
|
||||
if (filearg[0] != Nullch && !out_of_mem) {
|
||||
free(filearg[0]);
|
||||
filearg[0] = Nullch;
|
||||
}
|
||||
|
||||
if (outname != Nullch) {
|
||||
free(outname);
|
||||
outname = Nullch;
|
||||
}
|
||||
|
||||
last_offset = 0;
|
||||
|
||||
diff_type = 0;
|
||||
|
||||
if (revision != Nullch) {
|
||||
free(revision);
|
||||
revision = Nullch;
|
||||
}
|
||||
|
||||
reverse = reverse_flag_specified;
|
||||
skip_rest_of_patch = FALSE;
|
||||
skip_flag_specified = FALSE;
|
||||
|
||||
get_some_switches();
|
||||
|
||||
if (filec >= 2)
|
||||
fatal1("you may not change to a different patch file\n");
|
||||
}
|
||||
|
||||
static char *shortopts = "-b:B:cCd:D:eEfF:i:IlnNo:p::r:RsStuvV:x:";
|
||||
static struct option longopts[] =
|
||||
{
|
||||
{"suffix", 1, NULL, 'b'},
|
||||
{"prefix", 1, NULL, 'B'},
|
||||
{"check", 0, NULL, 'C'},
|
||||
{"context", 0, NULL, 'c'},
|
||||
{"directory", 1, NULL, 'd'},
|
||||
{"ifdef", 1, NULL, 'D'},
|
||||
{"ed", 0, NULL, 'e'},
|
||||
{"remove-empty-files", 0, NULL, 'E'},
|
||||
{"force", 0, NULL, 'f'},
|
||||
{"fuzz", 1, NULL, 'F'},
|
||||
{"index-first", 0, NULL, 'I'},
|
||||
{"ignore-whitespace", 0, NULL, 'l'},
|
||||
{"normal", 0, NULL, 'n'},
|
||||
{"forward", 0, NULL, 'N'},
|
||||
{"output", 1, NULL, 'o'},
|
||||
{"strip", 2, NULL, 'p'},
|
||||
{"reject-file", 1, NULL, 'r'},
|
||||
{"reverse", 0, NULL, 'R'},
|
||||
{"quiet", 0, NULL, 's'},
|
||||
{"silent", 0, NULL, 's'},
|
||||
{"skip", 0, NULL, 'S'},
|
||||
{"batch", 0, NULL, 't'},
|
||||
{"unified", 0, NULL, 'u'},
|
||||
{"version", 0, NULL, 'v'},
|
||||
{"version-control", 1, NULL, 'V'},
|
||||
{"debug", 1, NULL, 'x'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
/* Process switches and filenames up to next '+' or end of list. */
|
||||
|
||||
void
|
||||
get_some_switches(void)
|
||||
{
|
||||
Reg1 int optc;
|
||||
|
||||
rejname[0] = '\0';
|
||||
optind_last = optind;
|
||||
if (optind == Argc)
|
||||
return;
|
||||
while ((optc = getopt_long (Argc, Argv, shortopts, longopts, (int *) 0))
|
||||
!= -1) {
|
||||
if (optc == 1) {
|
||||
if (strEQ(optarg, "+"))
|
||||
return;
|
||||
if (filec == MAXFILEC)
|
||||
fatal1("too many file arguments\n");
|
||||
filearg[filec++] = savestr(optarg);
|
||||
}
|
||||
else {
|
||||
switch (optc) {
|
||||
case 'b':
|
||||
simple_backup_suffix = savestr(optarg);
|
||||
break;
|
||||
case 'B':
|
||||
origprae = savestr(optarg);
|
||||
break;
|
||||
case 'c':
|
||||
diff_type = CONTEXT_DIFF;
|
||||
break;
|
||||
case 'C':
|
||||
check_patch = TRUE;
|
||||
break;
|
||||
case 'd':
|
||||
if (chdir(optarg) < 0)
|
||||
pfatal2("can't cd to %s", optarg);
|
||||
break;
|
||||
case 'D':
|
||||
do_defines = TRUE;
|
||||
if (!isalpha((unsigned char)*optarg) && '_' != *optarg)
|
||||
fatal1("argument to -D is not an identifier\n");
|
||||
Snprintf(if_defined, sizeof(if_defined), "#ifdef %s\n", optarg);
|
||||
Snprintf(not_defined, sizeof(not_defined), "#ifndef %s\n", optarg);
|
||||
Snprintf(end_defined, sizeof(end_defined), "#endif /* %s */\n", optarg);
|
||||
break;
|
||||
case 'e':
|
||||
diff_type = ED_DIFF;
|
||||
break;
|
||||
case 'E':
|
||||
remove_empty_files = TRUE;
|
||||
break;
|
||||
case 'f':
|
||||
force = TRUE;
|
||||
break;
|
||||
case 'F':
|
||||
maxfuzz = atoi(optarg);
|
||||
break;
|
||||
case 'i':
|
||||
filearg[1] = savestr(optarg);
|
||||
break;
|
||||
case 'I':
|
||||
index_first = TRUE;
|
||||
break;
|
||||
case 'l':
|
||||
canonicalize = TRUE;
|
||||
break;
|
||||
case 'n':
|
||||
diff_type = NORMAL_DIFF;
|
||||
break;
|
||||
case 'N':
|
||||
noreverse = TRUE;
|
||||
break;
|
||||
case 'o':
|
||||
outname = savestr(optarg);
|
||||
break;
|
||||
case 'p':
|
||||
if (optarg)
|
||||
strippath = atoi(optarg);
|
||||
else
|
||||
strippath = 0;
|
||||
break;
|
||||
case 'r':
|
||||
Strlcpy(rejname, optarg, sizeof(rejname));
|
||||
break;
|
||||
case 'R':
|
||||
reverse = TRUE;
|
||||
reverse_flag_specified = TRUE;
|
||||
break;
|
||||
case 's':
|
||||
verbose = FALSE;
|
||||
break;
|
||||
case 'S':
|
||||
skip_rest_of_patch = TRUE;
|
||||
skip_flag_specified = TRUE;
|
||||
break;
|
||||
case 't':
|
||||
batch = TRUE;
|
||||
break;
|
||||
case 'u':
|
||||
diff_type = UNI_DIFF;
|
||||
break;
|
||||
case 'v':
|
||||
version();
|
||||
break;
|
||||
case 'V':
|
||||
#ifndef NODIR
|
||||
backup_type = get_version (optarg);
|
||||
#endif
|
||||
break;
|
||||
#ifdef DEBUGGING
|
||||
case 'x':
|
||||
debug = atoi(optarg);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
fprintf(stderr, "\
|
||||
Usage: %s [options] [origfile [patchfile]] [+ [options] [origfile]]...\n",
|
||||
Argv[0]);
|
||||
fprintf(stderr, "\
|
||||
Options:\n\
|
||||
[-cCeEflnNRsStuv] [-b backup-ext] [-B backup-prefix] [-d directory]\n\
|
||||
[-D symbol] [-F max-fuzz] [-i patchfile] [-o out-file] [-p[strip-count]]\n\
|
||||
[-r rej-name] [-V {numbered,existing,simple}] [--check] [--context]\n\
|
||||
[--prefix=backup-prefix] [--suffix=backup-ext] [--ifdef=symbol]\n\
|
||||
[--directory=directory] [--ed] [--fuzz=max-fuzz] [--force] [--batch]\n\
|
||||
[--ignore-whitespace] [--forward] [--reverse] [--output=out-file]\n");
|
||||
fprintf(stderr, "\
|
||||
[--strip[=strip-count]] [--normal] [--reject-file=rej-name] [--skip]\n\
|
||||
[--remove-empty-files] [--quiet] [--silent] [--unified] [--version]\n\
|
||||
[--version-control={numbered,existing,simple}] [--index-first]\n");
|
||||
my_exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Process any filename args given after "--". */
|
||||
for (; optind < Argc; ++optind) {
|
||||
if (filec == MAXFILEC)
|
||||
fatal1("too many file arguments\n");
|
||||
filearg[filec++] = savestr(Argv[optind]);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Attempt to find the right place to apply this hunk of patch.
|
||||
*/
|
||||
LINENUM
|
||||
locate_hunk(LINENUM fuzz)
|
||||
{
|
||||
Reg1 LINENUM first_guess = pch_first() + last_offset;
|
||||
Reg2 LINENUM offset;
|
||||
LINENUM pat_lines = pch_ptrn_lines();
|
||||
Reg3 LINENUM max_pos_offset = input_lines - first_guess
|
||||
- pat_lines + 1;
|
||||
Reg4 LINENUM max_neg_offset = first_guess - last_frozen_line - 1
|
||||
+ pch_context();
|
||||
|
||||
if (!pat_lines) /* null range matches always */
|
||||
return first_guess;
|
||||
if (max_neg_offset >= first_guess) /* do not try lines < 0 */
|
||||
max_neg_offset = first_guess - 1;
|
||||
if (first_guess <= input_lines && patch_match(first_guess, Nulline, fuzz))
|
||||
return first_guess;
|
||||
for (offset = 1; ; offset++) {
|
||||
Reg5 bool check_after = (offset <= max_pos_offset);
|
||||
Reg6 bool check_before = (offset <= max_neg_offset);
|
||||
|
||||
if (check_after && patch_match(first_guess, offset, fuzz)) {
|
||||
#ifdef DEBUGGING
|
||||
if (debug & 1)
|
||||
say3("Offset changing from %ld to %ld\n", last_offset, offset);
|
||||
#endif
|
||||
last_offset = offset;
|
||||
return first_guess+offset;
|
||||
}
|
||||
else if (check_before && patch_match(first_guess, -offset, fuzz)) {
|
||||
#ifdef DEBUGGING
|
||||
if (debug & 1)
|
||||
say3("Offset changing from %ld to %ld\n", last_offset, -offset);
|
||||
#endif
|
||||
last_offset = -offset;
|
||||
return first_guess-offset;
|
||||
}
|
||||
else if (!check_before && !check_after)
|
||||
return Nulline;
|
||||
}
|
||||
}
|
||||
|
||||
/* We did not find the pattern, dump out the hunk so they can handle it. */
|
||||
|
||||
void
|
||||
abort_hunk(void)
|
||||
{
|
||||
Reg1 LINENUM i;
|
||||
Reg2 LINENUM pat_end = pch_end();
|
||||
/* add in last_offset to guess the same as the previous successful hunk */
|
||||
LINENUM oldfirst = pch_first() + last_offset;
|
||||
LINENUM newfirst = pch_newfirst() + last_offset;
|
||||
LINENUM oldlast = oldfirst + pch_ptrn_lines() - 1;
|
||||
LINENUM newlast = newfirst + pch_repl_lines() - 1;
|
||||
char *stars = (diff_type >= NEW_CONTEXT_DIFF ? " ****" : "");
|
||||
char *minuses = (diff_type >= NEW_CONTEXT_DIFF ? " ----" : " -----");
|
||||
|
||||
fprintf(rejfp, "***************\n");
|
||||
for (i=0; i<=pat_end; i++) {
|
||||
switch (pch_char(i)) {
|
||||
case '*':
|
||||
if (oldlast < oldfirst)
|
||||
fprintf(rejfp, "*** 0%s\n", stars);
|
||||
else if (oldlast == oldfirst)
|
||||
fprintf(rejfp, "*** %ld%s\n", oldfirst, stars);
|
||||
else
|
||||
fprintf(rejfp, "*** %ld,%ld%s\n", oldfirst, oldlast, stars);
|
||||
break;
|
||||
case '=':
|
||||
if (newlast < newfirst)
|
||||
fprintf(rejfp, "--- 0%s\n", minuses);
|
||||
else if (newlast == newfirst)
|
||||
fprintf(rejfp, "--- %ld%s\n", newfirst, minuses);
|
||||
else
|
||||
fprintf(rejfp, "--- %ld,%ld%s\n", newfirst, newlast, minuses);
|
||||
break;
|
||||
case '\n':
|
||||
fprintf(rejfp, "%s", pfetch(i));
|
||||
break;
|
||||
case ' ': case '-': case '+': case '!':
|
||||
fprintf(rejfp, "%c %s", pch_char(i), pfetch(i));
|
||||
break;
|
||||
default:
|
||||
fatal1("fatal internal error in abort_hunk\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* We found where to apply it (we hope), so do it.
|
||||
*/
|
||||
void
|
||||
apply_hunk(LINENUM where)
|
||||
{
|
||||
Reg1 LINENUM old = 1;
|
||||
Reg2 LINENUM lastline = pch_ptrn_lines();
|
||||
Reg3 LINENUM new = lastline+1;
|
||||
#define OUTSIDE 0
|
||||
#define IN_IFNDEF 1
|
||||
#define IN_IFDEF 2
|
||||
#define IN_ELSE 3
|
||||
Reg4 int def_state = OUTSIDE;
|
||||
Reg5 bool R_do_defines = do_defines;
|
||||
Reg6 LINENUM pat_end = pch_end();
|
||||
|
||||
where--;
|
||||
while (pch_char(new) == '=' || pch_char(new) == '\n')
|
||||
new++;
|
||||
|
||||
while (old <= lastline) {
|
||||
if (pch_char(old) == '-') {
|
||||
copy_till(where + old - 1);
|
||||
if (R_do_defines) {
|
||||
if (def_state == OUTSIDE) {
|
||||
fputs(not_defined, ofp);
|
||||
def_state = IN_IFNDEF;
|
||||
}
|
||||
else if (def_state == IN_IFDEF) {
|
||||
fputs(else_defined, ofp);
|
||||
def_state = IN_ELSE;
|
||||
}
|
||||
fputs(pfetch(old), ofp);
|
||||
}
|
||||
last_frozen_line++;
|
||||
old++;
|
||||
}
|
||||
else if (new > pat_end) {
|
||||
break;
|
||||
}
|
||||
else if (pch_char(new) == '+') {
|
||||
copy_till(where + old - 1);
|
||||
if (R_do_defines) {
|
||||
if (def_state == IN_IFNDEF) {
|
||||
fputs(else_defined, ofp);
|
||||
def_state = IN_ELSE;
|
||||
}
|
||||
else if (def_state == OUTSIDE) {
|
||||
fputs(if_defined, ofp);
|
||||
def_state = IN_IFDEF;
|
||||
}
|
||||
}
|
||||
fputs(pfetch(new), ofp);
|
||||
new++;
|
||||
}
|
||||
else if (pch_char(new) != pch_char(old)) {
|
||||
say3("Out-of-sync patch, lines %ld,%ld--mangled text or line numbers, maybe?\n",
|
||||
pch_hunk_beg() + old,
|
||||
pch_hunk_beg() + new);
|
||||
#ifdef DEBUGGING
|
||||
say3("oldchar = '%c', newchar = '%c'\n",
|
||||
pch_char(old), pch_char(new));
|
||||
#endif
|
||||
my_exit(1);
|
||||
}
|
||||
else if (pch_char(new) == '!') {
|
||||
copy_till(where + old - 1);
|
||||
if (R_do_defines) {
|
||||
fputs(not_defined, ofp);
|
||||
def_state = IN_IFNDEF;
|
||||
}
|
||||
while (pch_char(old) == '!') {
|
||||
if (R_do_defines) {
|
||||
fputs(pfetch(old), ofp);
|
||||
}
|
||||
last_frozen_line++;
|
||||
old++;
|
||||
}
|
||||
if (R_do_defines) {
|
||||
fputs(else_defined, ofp);
|
||||
def_state = IN_ELSE;
|
||||
}
|
||||
while (pch_char(new) == '!') {
|
||||
fputs(pfetch(new), ofp);
|
||||
new++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
assert(pch_char(new) == ' ');
|
||||
old++;
|
||||
new++;
|
||||
if (R_do_defines && def_state != OUTSIDE) {
|
||||
fputs(end_defined, ofp);
|
||||
def_state = OUTSIDE;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (new <= pat_end && pch_char(new) == '+') {
|
||||
copy_till(where + old - 1);
|
||||
if (R_do_defines) {
|
||||
if (def_state == OUTSIDE) {
|
||||
fputs(if_defined, ofp);
|
||||
def_state = IN_IFDEF;
|
||||
}
|
||||
else if (def_state == IN_IFNDEF) {
|
||||
fputs(else_defined, ofp);
|
||||
def_state = IN_ELSE;
|
||||
}
|
||||
}
|
||||
while (new <= pat_end && pch_char(new) == '+') {
|
||||
fputs(pfetch(new), ofp);
|
||||
new++;
|
||||
}
|
||||
}
|
||||
if (R_do_defines && def_state != OUTSIDE) {
|
||||
fputs(end_defined, ofp);
|
||||
}
|
||||
}
|
||||
|
||||
/* Open the new file. */
|
||||
|
||||
void
|
||||
init_output(char *name)
|
||||
{
|
||||
ofp = fopen(name, "w");
|
||||
if (ofp == Nullfp)
|
||||
pfatal2("can't create %s", name);
|
||||
}
|
||||
|
||||
/* Open a file to put hunks we can't locate. */
|
||||
|
||||
void
|
||||
init_reject(char *name)
|
||||
{
|
||||
rejfp = fopen(name, "w");
|
||||
if (rejfp == Nullfp)
|
||||
pfatal2("can't create %s", name);
|
||||
}
|
||||
|
||||
/* Copy input file to output, up to wherever hunk is to be applied. */
|
||||
|
||||
void
|
||||
copy_till(LINENUM lastline)
|
||||
{
|
||||
Reg2 LINENUM R_last_frozen_line = last_frozen_line;
|
||||
|
||||
if (R_last_frozen_line > lastline)
|
||||
fatal1("misordered hunks! output would be garbled\n");
|
||||
while (R_last_frozen_line < lastline) {
|
||||
dump_line(++R_last_frozen_line);
|
||||
}
|
||||
last_frozen_line = R_last_frozen_line;
|
||||
}
|
||||
|
||||
/* Finish copying the input file to the output file. */
|
||||
|
||||
void
|
||||
spew_output(void)
|
||||
{
|
||||
#ifdef DEBUGGING
|
||||
if (debug & 256)
|
||||
say3("il=%ld lfl=%ld\n",input_lines,last_frozen_line);
|
||||
#endif
|
||||
if (input_lines)
|
||||
copy_till(input_lines); /* dump remainder of file */
|
||||
Fclose(ofp);
|
||||
ofp = Nullfp;
|
||||
}
|
||||
|
||||
/* Copy one line from input to output. */
|
||||
|
||||
void
|
||||
dump_line(LINENUM line)
|
||||
{
|
||||
Reg1 char *s;
|
||||
Reg2 char R_newline = '\n';
|
||||
|
||||
/* Note: string is not null terminated. */
|
||||
for (s=ifetch(line, 0); putc(*s, ofp) != R_newline; s++) ;
|
||||
}
|
||||
|
||||
/* Does the patch pattern match at line base+offset? */
|
||||
|
||||
bool
|
||||
patch_match(LINENUM base, LINENUM offset, LINENUM fuzz)
|
||||
{
|
||||
Reg1 LINENUM pline = 1 + fuzz;
|
||||
Reg2 LINENUM iline;
|
||||
Reg3 LINENUM pat_lines = pch_ptrn_lines() - fuzz;
|
||||
|
||||
for (iline=base+offset+fuzz; pline <= pat_lines; pline++,iline++) {
|
||||
if (canonicalize) {
|
||||
if (!similar(ifetch(iline, (offset >= 0)),
|
||||
pfetch(pline),
|
||||
pch_line_len(pline) ))
|
||||
return FALSE;
|
||||
}
|
||||
else if (strnNE(ifetch(iline, (offset >= 0)),
|
||||
pfetch(pline),
|
||||
pch_line_len(pline) ))
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Do two lines match with canonicalized white space? */
|
||||
|
||||
bool
|
||||
similar(char *a, char *b, int len)
|
||||
{
|
||||
while (len) {
|
||||
if (isspace((unsigned char)*b)) { /* whitespace (or \n) to match? */
|
||||
if (!isspace((unsigned char)*a)) /* no corresponding whitespace? */
|
||||
return FALSE;
|
||||
while (len && isspace((unsigned char)*b) && *b != '\n')
|
||||
b++,len--; /* skip pattern whitespace */
|
||||
while (isspace((unsigned char)*a) && *a != '\n')
|
||||
a++; /* skip target whitespace */
|
||||
if (*a == '\n' || *b == '\n')
|
||||
return (*a == *b); /* should end in sync */
|
||||
}
|
||||
else if (*a++ != *b++) /* match non-whitespace chars */
|
||||
return FALSE;
|
||||
else
|
||||
len--; /* probably not necessary */
|
||||
}
|
||||
return TRUE; /* actually, this is not reached */
|
||||
/* since there is always a \n */
|
||||
}
|
||||
|
||||
/* Exit with cleanup. */
|
||||
|
||||
void
|
||||
my_exit(int status)
|
||||
{
|
||||
Unlink(TMPINNAME);
|
||||
if (!toutkeep) {
|
||||
Unlink(TMPOUTNAME);
|
||||
}
|
||||
if (!trejkeep) {
|
||||
Unlink(TMPREJNAME);
|
||||
}
|
||||
Unlink(TMPPATNAME);
|
||||
exit(status);
|
||||
}
|
@ -1 +0,0 @@
|
||||
#define PATCH_VERSION "2.1"
|
File diff suppressed because it is too large
Load Diff
@ -1,36 +0,0 @@
|
||||
/* $FreeBSD$
|
||||
*
|
||||
* $Log: pch.h,v $
|
||||
* Revision 2.0.1.1 87/01/30 22:47:16 lwall
|
||||
* Added do_ed_script().
|
||||
*
|
||||
* Revision 2.0 86/09/17 15:39:57 lwall
|
||||
* Baseline for netwide release.
|
||||
*
|
||||
*/
|
||||
|
||||
EXT FILE *pfp INIT(Nullfp); /* patch file pointer */
|
||||
|
||||
void re_patch(void);
|
||||
void open_patch_file(char *_filename);
|
||||
void set_hunkmax(void);
|
||||
void grow_hunkmax(void);
|
||||
bool there_is_another_patch(void);
|
||||
int intuit_diff_type(void);
|
||||
void next_intuit_at(long _file_pos, long _file_line);
|
||||
void skip_to(long _file_pos, long _file_line);
|
||||
bool another_hunk(void);
|
||||
bool pch_swap(void);
|
||||
char *pfetch(LINENUM _line);
|
||||
short pch_line_len(LINENUM _line);
|
||||
LINENUM pch_first(void);
|
||||
LINENUM pch_ptrn_lines(void);
|
||||
LINENUM pch_newfirst(void);
|
||||
LINENUM pch_repl_lines(void);
|
||||
LINENUM pch_end(void);
|
||||
LINENUM pch_context(void);
|
||||
LINENUM pch_hunk_beg(void);
|
||||
char pch_char(LINENUM _line);
|
||||
char *pfetch(LINENUM _line);
|
||||
size_t pgets(bool _do_indent);
|
||||
void do_ed_script(void);
|
@ -1,458 +0,0 @@
|
||||
/* $FreeBSD$ */
|
||||
|
||||
#include <paths.h>
|
||||
|
||||
#include "EXTERN.h"
|
||||
#include "common.h"
|
||||
#include "INTERN.h"
|
||||
#include "util.h"
|
||||
#include "backupfile.h"
|
||||
|
||||
void my_exit(int _status); /* in patch.c */
|
||||
|
||||
#ifndef HAVE_STRERROR
|
||||
static char *
|
||||
private_strerror (errnum)
|
||||
int errnum;
|
||||
{
|
||||
extern char *sys_errlist[];
|
||||
extern int sys_nerr;
|
||||
|
||||
if (errnum > 0 && errnum <= sys_nerr)
|
||||
return sys_errlist[errnum];
|
||||
return "Unknown system error";
|
||||
}
|
||||
#define strerror private_strerror
|
||||
#endif /* !HAVE_STRERROR */
|
||||
|
||||
/*
|
||||
* Rename a file, copying it if necessary.
|
||||
*/
|
||||
int
|
||||
move_file(char *from, char *to)
|
||||
{
|
||||
char bakname[512];
|
||||
Reg1 char *s;
|
||||
Reg2 int i;
|
||||
Reg3 int fromfd;
|
||||
|
||||
/* to stdout? */
|
||||
|
||||
if (strEQ(to, "-")) {
|
||||
#ifdef DEBUGGING
|
||||
if (debug & 4)
|
||||
say2("Moving %s to stdout.\n", from);
|
||||
#endif
|
||||
fromfd = open(from, 0);
|
||||
if (fromfd < 0)
|
||||
pfatal2("internal error, can't reopen %s", from);
|
||||
while ((i = read(fromfd, buf, buf_size)) > 0)
|
||||
if (write(1, buf, i) != 1)
|
||||
pfatal1("write failed");
|
||||
Close(fromfd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (origprae) {
|
||||
Strcpy(bakname, origprae);
|
||||
Strcat(bakname, to);
|
||||
} else {
|
||||
#ifndef NODIR
|
||||
char *backupname = find_backup_file_name(to);
|
||||
if (backupname == (char *) 0)
|
||||
fatal1("out of memory\n");
|
||||
Strcpy(bakname, backupname);
|
||||
free(backupname);
|
||||
#else /* NODIR */
|
||||
Strcpy(bakname, to);
|
||||
Strcat(bakname, simple_backup_suffix);
|
||||
#endif /* NODIR */
|
||||
}
|
||||
|
||||
if (stat(to, &filestat) == 0) { /* output file exists */
|
||||
dev_t to_device = filestat.st_dev;
|
||||
ino_t to_inode = filestat.st_ino;
|
||||
char *simplename = bakname;
|
||||
|
||||
for (s = bakname; *s; s++) {
|
||||
if (*s == '/')
|
||||
simplename = s + 1;
|
||||
}
|
||||
/*
|
||||
* Find a backup name that is not the same file.
|
||||
* Change the first lowercase char into uppercase;
|
||||
* if that isn't sufficient, chop off the first char
|
||||
* and try again.
|
||||
*/
|
||||
while (stat(bakname, &filestat) == 0 &&
|
||||
to_device == filestat.st_dev &&
|
||||
to_inode == filestat.st_ino) {
|
||||
/* Skip initial non-lowercase chars. */
|
||||
for (s=simplename; *s && !islower((unsigned char)*s);
|
||||
s++)
|
||||
;
|
||||
if (*s)
|
||||
*s = toupper((unsigned char)*s);
|
||||
else
|
||||
Strcpy(simplename, simplename + 1);
|
||||
}
|
||||
while (unlink(bakname) >= 0)
|
||||
; /* while() is for benefit of Eunice */
|
||||
#ifdef DEBUGGING
|
||||
if (debug & 4)
|
||||
say3("Moving %s to %s.\n", to, bakname);
|
||||
#endif
|
||||
if (rename(to, bakname) < 0) {
|
||||
say4("Can't backup %s, output is in %s: %s\n", to, from,
|
||||
strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
while (unlink(to) >= 0)
|
||||
;
|
||||
}
|
||||
#ifdef DEBUGGING
|
||||
if (debug & 4)
|
||||
say3("Moving %s to %s.\n", from, to);
|
||||
#endif
|
||||
if (rename(from, to) < 0) { /* different file system? */
|
||||
Reg4 int tofd;
|
||||
|
||||
tofd = creat(to, 0666);
|
||||
if (tofd < 0) {
|
||||
say4("Can't create %s, output is in %s: %s\n",
|
||||
to, from, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
fromfd = open(from, 0);
|
||||
if (fromfd < 0)
|
||||
pfatal2("internal error, can't reopen %s", from);
|
||||
while ((i = read(fromfd, buf, buf_size)) > 0)
|
||||
if (write(tofd, buf, i) != i)
|
||||
pfatal1("write failed");
|
||||
Close(fromfd);
|
||||
Close(tofd);
|
||||
}
|
||||
Unlink(from);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Copy a file.
|
||||
*/
|
||||
void
|
||||
copy_file(char *from, char *to)
|
||||
{
|
||||
Reg3 int tofd;
|
||||
Reg2 int fromfd;
|
||||
Reg1 int i;
|
||||
|
||||
tofd = creat(to, 0666);
|
||||
if (tofd < 0)
|
||||
pfatal2("can't create %s", to);
|
||||
fromfd = open(from, 0);
|
||||
if (fromfd < 0)
|
||||
pfatal2("internal error, can't reopen %s", from);
|
||||
while ((i = read(fromfd, buf, buf_size)) > 0)
|
||||
if (write(tofd, buf, i) != i)
|
||||
pfatal2("write to %s failed", to);
|
||||
Close(fromfd);
|
||||
Close(tofd);
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate a unique area for a string.
|
||||
*/
|
||||
char *
|
||||
savestr(char *s)
|
||||
{
|
||||
Reg3 char *rv;
|
||||
Reg2 char *t;
|
||||
|
||||
if (!s)
|
||||
s = "Oops";
|
||||
t = s;
|
||||
while (*t++)
|
||||
;
|
||||
rv = malloc((MEM) (t - s));
|
||||
if (rv == Nullch) {
|
||||
if (using_plan_a)
|
||||
out_of_mem = TRUE;
|
||||
else
|
||||
fatal1("out of memory\n");
|
||||
} else {
|
||||
t = rv;
|
||||
while ((*t++ = *s++));
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
#if defined(lint) && defined(CANVARARG)
|
||||
|
||||
/*VARARGS ARGSUSED*/
|
||||
say(pat) char *pat; { ; }
|
||||
/*VARARGS ARGSUSED*/
|
||||
fatal(pat) char *pat; { ; }
|
||||
/*VARARGS ARGSUSED*/
|
||||
pfatal(pat) char *pat; { ; }
|
||||
/*VARARGS ARGSUSED*/
|
||||
ask(pat) char *pat; { ; }
|
||||
|
||||
#else
|
||||
|
||||
/*
|
||||
* Vanilla terminal output (buffered).
|
||||
*/
|
||||
void
|
||||
say(pat,arg1,arg2,arg3)
|
||||
char *pat;
|
||||
long arg1,arg2,arg3;
|
||||
{
|
||||
fprintf(stderr, pat, arg1, arg2, arg3);
|
||||
Fflush(stderr);
|
||||
}
|
||||
|
||||
/*
|
||||
* Terminal output, pun intended.
|
||||
*/
|
||||
void /* very void */
|
||||
fatal(pat,arg1,arg2,arg3)
|
||||
char *pat;
|
||||
long arg1,arg2,arg3;
|
||||
{
|
||||
fprintf(stderr, "patch: **** ");
|
||||
fprintf(stderr, pat, arg1, arg2, arg3);
|
||||
my_exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Say something from patch, something from the system, then silence...
|
||||
*/
|
||||
void /* very void */
|
||||
pfatal(pat,arg1,arg2,arg3)
|
||||
char *pat;
|
||||
long arg1,arg2,arg3;
|
||||
{
|
||||
int errnum = errno;
|
||||
|
||||
fprintf(stderr, "patch: **** ");
|
||||
fprintf(stderr, pat, arg1, arg2, arg3);
|
||||
fprintf(stderr, ": %s\n", strerror(errnum));
|
||||
my_exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get a response from the user, somehow or other.
|
||||
*/
|
||||
int
|
||||
ask(pat,arg1,arg2,arg3)
|
||||
char *pat;
|
||||
long arg1,arg2,arg3;
|
||||
{
|
||||
int ttyfd;
|
||||
int r;
|
||||
bool tty2 = isatty(2);
|
||||
|
||||
Sprintf(buf, pat, arg1, arg2, arg3);
|
||||
Fflush(stderr);
|
||||
write(2, buf, strlen(buf));
|
||||
if (tty2) { /* might be redirected to a file */
|
||||
r = read(2, buf, buf_size);
|
||||
} else if (isatty(1)) { /* this may be new file output */
|
||||
Fflush(stdout);
|
||||
write(1, buf, strlen(buf));
|
||||
r = read(1, buf, buf_size);
|
||||
} else if ((ttyfd = open(_PATH_TTY, 2)) >= 0 && isatty(ttyfd)) {
|
||||
/* might be deleted or unwriteable */
|
||||
write(ttyfd, buf, strlen(buf));
|
||||
r = read(ttyfd, buf, buf_size);
|
||||
Close(ttyfd);
|
||||
} else if (isatty(0)) { /* this is probably patch input */
|
||||
Fflush(stdin);
|
||||
write(0, buf, strlen(buf));
|
||||
r = read(0, buf, buf_size);
|
||||
} else { /* no terminal at all--default it */
|
||||
buf[0] = '\n';
|
||||
buf[1] = 0;
|
||||
say1(buf);
|
||||
return 0; /* signal possible error */
|
||||
}
|
||||
if (r <= 0)
|
||||
buf[0] = 0;
|
||||
else
|
||||
buf[r] = '\0';
|
||||
if (!tty2)
|
||||
say1(buf);
|
||||
|
||||
if (r <= 0)
|
||||
return 0; /* if there was an error, return it */
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
#endif /* lint */
|
||||
|
||||
/*
|
||||
* How to handle certain events when not in a critical region.
|
||||
*/
|
||||
void
|
||||
set_signals(int reset)
|
||||
{
|
||||
#ifndef lint
|
||||
static RETSIGTYPE (*hupval)(),(*intval)();
|
||||
|
||||
if (!reset) {
|
||||
hupval = signal(SIGHUP, SIG_IGN);
|
||||
if (hupval != SIG_IGN)
|
||||
hupval = (RETSIGTYPE(*)())my_exit;
|
||||
intval = signal(SIGINT, SIG_IGN);
|
||||
if (intval != SIG_IGN)
|
||||
intval = (RETSIGTYPE(*)())my_exit;
|
||||
}
|
||||
Signal(SIGHUP, hupval);
|
||||
Signal(SIGINT, intval);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* How to handle certain events when in a critical region.
|
||||
*/
|
||||
void
|
||||
ignore_signals(void)
|
||||
{
|
||||
#ifndef lint
|
||||
Signal(SIGHUP, SIG_IGN);
|
||||
Signal(SIGINT, SIG_IGN);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Make sure we'll have the directories to create a file.
|
||||
* If `striplast' is TRUE, ignore the last element of `filename'.
|
||||
*/
|
||||
void
|
||||
makedirs(filename,striplast)
|
||||
Reg1 char *filename;
|
||||
bool striplast;
|
||||
{
|
||||
char tmpbuf[256];
|
||||
Reg2 char *s = tmpbuf;
|
||||
char *dirv[20]; /* Point to the NULs between elements. */
|
||||
Reg3 int i;
|
||||
Reg4 int dirvp = 0; /* Number of finished entries in dirv. */
|
||||
|
||||
/*
|
||||
* Copy `filename' into `tmpbuf' with a NUL instead of a slash
|
||||
* between the directories.
|
||||
*/
|
||||
while (*filename) {
|
||||
if (*filename == '/') {
|
||||
filename++;
|
||||
dirv[dirvp++] = s;
|
||||
*s++ = '\0';
|
||||
} else {
|
||||
*s++ = *filename++;
|
||||
}
|
||||
}
|
||||
*s = '\0';
|
||||
dirv[dirvp] = s;
|
||||
if (striplast)
|
||||
dirvp--;
|
||||
if (dirvp < 0)
|
||||
return;
|
||||
|
||||
strcpy(buf, "mkdir");
|
||||
s = buf;
|
||||
for (i = 0; i <= dirvp; i++) {
|
||||
struct stat sbuf;
|
||||
|
||||
if (stat(tmpbuf, &sbuf) && errno == ENOENT) {
|
||||
while (*s)
|
||||
s++;
|
||||
*s++ = ' ';
|
||||
strcpy(s, tmpbuf);
|
||||
}
|
||||
*dirv[i] = '/';
|
||||
}
|
||||
if (s != buf)
|
||||
system(buf);
|
||||
}
|
||||
|
||||
/*
|
||||
* Make filenames more reasonable.
|
||||
*/
|
||||
char *
|
||||
fetchname(char *at, int strip_leading, int assume_exists)
|
||||
{
|
||||
char *fullname;
|
||||
char *name;
|
||||
Reg1 char *t;
|
||||
char tmpbuf[200];
|
||||
int sleading = strip_leading;
|
||||
|
||||
if (!at)
|
||||
return Nullch;
|
||||
while (isspace((unsigned char)*at))
|
||||
at++;
|
||||
#ifdef DEBUGGING
|
||||
if (debug & 128)
|
||||
say4("fetchname %s %d %d\n",at,strip_leading,assume_exists);
|
||||
#endif
|
||||
if (strnEQ(at, _PATH_DEVNULL, sizeof _PATH_DEVNULL - 1))
|
||||
/* So files can be created by diffing against /dev/null. */
|
||||
return Nullch;
|
||||
name = fullname = t = savestr(at);
|
||||
|
||||
/* Strip off up to `sleading' leading slashes and null terminate. */
|
||||
for (; *t && !isspace((unsigned char)*t); t++)
|
||||
if (*t == '/')
|
||||
if (--sleading >= 0)
|
||||
name = t + 1;
|
||||
*t = '\0';
|
||||
|
||||
/*
|
||||
* If no -p option was given (957 is the default value!),
|
||||
* we were given a relative pathname,
|
||||
* and the leading directories that we just stripped off all exist,
|
||||
* put them back on.
|
||||
*/
|
||||
if (strip_leading == 957 && name != fullname && *fullname != '/') {
|
||||
name[-1] = '\0';
|
||||
if (stat(fullname, &filestat) == 0 &&
|
||||
S_ISDIR(filestat.st_mode)) {
|
||||
name[-1] = '/';
|
||||
name = fullname;
|
||||
}
|
||||
}
|
||||
|
||||
name = savestr(name);
|
||||
free(fullname);
|
||||
|
||||
if (stat(name, &filestat) && !assume_exists) {
|
||||
char *filebase = basename(name);
|
||||
int pathlen = filebase - name;
|
||||
|
||||
/* Put any leading path into `tmpbuf'. */
|
||||
strncpy(tmpbuf, name, pathlen);
|
||||
|
||||
#define try(f, a1, a2) \
|
||||
(Sprintf(tmpbuf + pathlen, f, a1, a2), stat(tmpbuf, &filestat) == 0)
|
||||
if (try("RCS/%s%s", filebase, RCSSUFFIX) ||
|
||||
try("RCS/%s%s", filebase, "") ||
|
||||
try( "%s%s", filebase, RCSSUFFIX) ||
|
||||
try("SCCS/%s%s", SCCSPREFIX, filebase) ||
|
||||
try( "%s%s", SCCSPREFIX, filebase))
|
||||
return name;
|
||||
free(name);
|
||||
name = Nullch;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
char *
|
||||
xmalloc(unsigned int size)
|
||||
{
|
||||
register char *p = (char *) malloc (size);
|
||||
if (!p)
|
||||
fatal("out of memory");
|
||||
return p;
|
||||
}
|
@ -1,88 +0,0 @@
|
||||
/* $FreeBSD$
|
||||
*
|
||||
* $Log: util.h,v $
|
||||
* Revision 2.0 86/09/17 15:40:06 lwall
|
||||
* Baseline for netwide release.
|
||||
*
|
||||
*/
|
||||
|
||||
/* and for those machine that can't handle a variable argument list */
|
||||
|
||||
#ifdef CANVARARG
|
||||
|
||||
#define say1 say
|
||||
#define say2 say
|
||||
#define say3 say
|
||||
#define say4 say
|
||||
#define ask1 ask
|
||||
#define ask2 ask
|
||||
#define ask3 ask
|
||||
#define ask4 ask
|
||||
#define fatal1 fatal
|
||||
#define fatal2 fatal
|
||||
#define fatal3 fatal
|
||||
#define fatal4 fatal
|
||||
#define pfatal1 pfatal
|
||||
#define pfatal2 pfatal
|
||||
#define pfatal3 pfatal
|
||||
#define pfatal4 pfatal
|
||||
|
||||
#else /* hope they allow multi-line macro actual arguments */
|
||||
|
||||
#ifdef lint
|
||||
|
||||
#define say1(a) say(a, 0, 0, 0)
|
||||
#define say2(a,b) say(a, (b)==(b), 0, 0)
|
||||
#define say3(a,b,c) say(a, (b)==(b), (c)==(c), 0)
|
||||
#define say4(a,b,c,d) say(a, (b)==(b), (c)==(c), (d)==(d))
|
||||
#define ask1(a) ask(a, 0, 0, 0)
|
||||
#define ask2(a,b) ask(a, (b)==(b), 0, 0)
|
||||
#define ask3(a,b,c) ask(a, (b)==(b), (c)==(c), 0)
|
||||
#define ask4(a,b,c,d) ask(a, (b)==(b), (c)==(c), (d)==(d))
|
||||
#define fatal1(a) fatal(a, 0, 0, 0)
|
||||
#define fatal2(a,b) fatal(a, (b)==(b), 0, 0)
|
||||
#define fatal3(a,b,c) fatal(a, (b)==(b), (c)==(c), 0)
|
||||
#define fatal4(a,b,c,d) fatal(a, (b)==(b), (c)==(c), (d)==(d))
|
||||
#define pfatal1(a) pfatal(a, 0, 0, 0)
|
||||
#define pfatal2(a,b) pfatal(a, (b)==(b), 0, 0)
|
||||
#define pfatal3(a,b,c) pfatal(a, (b)==(b), (c)==(c), 0)
|
||||
#define pfatal4(a,b,c,d) pfatal(a, (b)==(b), (c)==(c), (d)==(d))
|
||||
|
||||
#else /* lint */
|
||||
/* if this doesn't work, try defining CANVARARG above */
|
||||
#define say1(a) say(a, Nullch, Nullch, Nullch)
|
||||
#define say2(a,b) say(a, b, Nullch, Nullch)
|
||||
#define say3(a,b,c) say(a, b, c, Nullch)
|
||||
#define say4 say
|
||||
#define ask1(a) ask(a, Nullch, Nullch, Nullch)
|
||||
#define ask2(a,b) ask(a, b, Nullch, Nullch)
|
||||
#define ask3(a,b,c) ask(a, b, c, Nullch)
|
||||
#define ask4 ask
|
||||
#define fatal1(a) fatal(a, Nullch, Nullch, Nullch)
|
||||
#define fatal2(a,b) fatal(a, b, Nullch, Nullch)
|
||||
#define fatal3(a,b,c) fatal(a, b, c, Nullch)
|
||||
#define fatal4 fatal
|
||||
#define pfatal1(a) pfatal(a, Nullch, Nullch, Nullch)
|
||||
#define pfatal2(a,b) pfatal(a, b, Nullch, Nullch)
|
||||
#define pfatal3(a,b,c) pfatal(a, b, c, Nullch)
|
||||
#define pfatal4 pfatal
|
||||
|
||||
#endif /* lint */
|
||||
|
||||
/* if neither of the above work, join all multi-line macro calls. */
|
||||
#endif
|
||||
|
||||
EXT char serrbuf[BUFSIZ]; /* buffer for stderr */
|
||||
|
||||
char *fetchname(char *_at, int _strip_leading, int _assume_exists);
|
||||
int move_file(char *_from, char *_to);
|
||||
void copy_file(char *_from, char *_to);
|
||||
void say(/*const char *pat, long _arg1, long _arg2, long _arg3*/);
|
||||
void fatal();
|
||||
void pfatal();
|
||||
int ask(/*const char *pat, long _arg1, long _arg2, long _arg3*/);
|
||||
char *savestr(char *_s);
|
||||
void set_signals(int _reset);
|
||||
void ignore_signals(void);
|
||||
void makedirs(/*char *_filename, bool _striplast*/);
|
||||
char *basename();
|
@ -1,25 +0,0 @@
|
||||
/* $FreeBSD$
|
||||
*
|
||||
* $Log: version.c,v $
|
||||
* Revision 2.0 86/09/17 15:40:11 lwall
|
||||
* Baseline for netwide release.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "EXTERN.h"
|
||||
#include "common.h"
|
||||
#include "util.h"
|
||||
#include "INTERN.h"
|
||||
#include "patchlevel.h"
|
||||
#include "version.h"
|
||||
|
||||
void my_exit(int _status); /* in patch.c */
|
||||
|
||||
/* Print out the version number and die. */
|
||||
|
||||
void
|
||||
version(void)
|
||||
{
|
||||
fprintf(stderr, "Patch version %s\n", PATCH_VERSION);
|
||||
my_exit(0);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
/* $FreeBSD$
|
||||
*
|
||||
* $Log: version.h,v $
|
||||
* Revision 2.0 86/09/17 15:40:14 lwall
|
||||
* Baseline for netwide release.
|
||||
*
|
||||
*/
|
||||
|
||||
void version(void);
|
@ -35,7 +35,6 @@
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
@ -48,6 +47,13 @@
|
||||
#define libiconv iconv
|
||||
#define libiconv_t iconv_t
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
typedef bool __iconv_bool;
|
||||
#elif __STDC_VERSION__ >= 199901L
|
||||
typedef _Bool __iconv_bool;
|
||||
#else
|
||||
typedef int __iconv_bool;
|
||||
#endif
|
||||
|
||||
struct __tag_iconv_t;
|
||||
typedef struct __tag_iconv_t *iconv_t;
|
||||
@ -61,7 +67,7 @@ int iconv_close(iconv_t);
|
||||
/*
|
||||
* non-portable interfaces for iconv
|
||||
*/
|
||||
int __iconv_get_list(char ***, size_t *, bool);
|
||||
int __iconv_get_list(char ***, size_t *, __iconv_bool);
|
||||
void __iconv_free_list(char **, size_t);
|
||||
size_t __iconv(iconv_t, const char **, size_t *, char **,
|
||||
size_t *, __uint32_t, size_t *);
|
||||
|
@ -72,6 +72,7 @@ SUBDIR= ${SUBDIR_ORDERED} \
|
||||
libdwarf \
|
||||
libedit \
|
||||
${_libefi} \
|
||||
libexecinfo \
|
||||
libexpat \
|
||||
libfetch \
|
||||
libgeom \
|
||||
|
@ -165,6 +165,7 @@ RT_HEADERS= cxxabi.h\
|
||||
|
||||
.for hdr in ${STD_HEADERS}
|
||||
STD+= ${HDRDIR}/${hdr}
|
||||
INCSLINKS+= ${CXXINCLUDEDIR}/${hdr} ${CXXINCLUDEDIR}/tr1/${hdr}
|
||||
.endfor
|
||||
.for hdr in ${RT_HEADERS}
|
||||
STD+= ${LIBCXXRTDIR}/${hdr}
|
||||
|
@ -100,6 +100,7 @@ NOASM=
|
||||
CFLAGS+= -DYP
|
||||
.include "${.CURDIR}/yp/Makefile.inc"
|
||||
.endif
|
||||
.include "${.CURDIR}/capability/Makefile.inc"
|
||||
.if ${MK_HESIOD} != "no"
|
||||
CFLAGS+= -DHESIOD
|
||||
.endif
|
||||
|
19
lib/libc/capability/Makefile.inc
Normal file
19
lib/libc/capability/Makefile.inc
Normal file
@ -0,0 +1,19 @@
|
||||
# $FreeBSD$
|
||||
|
||||
# capability sources
|
||||
.PATH: ${.CURDIR}/../../sys/kern
|
||||
|
||||
SRCS+= subr_capability.c
|
||||
|
||||
SYM_MAPS+= ${.CURDIR}/capability/Symbol.map
|
||||
|
||||
#MAN+= cap_rights_init.3
|
||||
|
||||
#MLINKS+=cap_rights_init.3 cap_rights_set.3
|
||||
#MLINKS+=cap_rights_init.3 cap_rights_clear.3
|
||||
#MLINKS+=cap_rights_init.3 cap_rights_is_set.3
|
||||
#MLINKS+=cap_rights_init.3 cap_rights_is_valid.3
|
||||
#MLINKS+=cap_rights_init.3 cap_rights_merge.3
|
||||
#MLINKS+=cap_rights_init.3 cap_rights_remove.3
|
||||
#MLINKS+=cap_rights_init.3 cap_rights_contains.3
|
||||
|
14
lib/libc/capability/Symbol.map
Normal file
14
lib/libc/capability/Symbol.map
Normal file
@ -0,0 +1,14 @@
|
||||
/*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
FBSD_1.3 {
|
||||
__cap_rights_clear;
|
||||
cap_rights_contains;
|
||||
__cap_rights_init;
|
||||
__cap_rights_is_set;
|
||||
cap_rights_is_valid;
|
||||
cap_rights_merge;
|
||||
cap_rights_remove;
|
||||
__cap_rights_set;
|
||||
};
|
@ -132,6 +132,7 @@ is possible on a descriptor (see
|
||||
.It 30 Ta Dv SIGUSR1 Ta "terminate process" Ta "User defined signal 1"
|
||||
.It 31 Ta Dv SIGUSR2 Ta "terminate process" Ta "User defined signal 2"
|
||||
.It 32 Ta Dv SIGTHR Ta "terminate process" Ta "thread interrupt"
|
||||
.It 33 Ta Dv SIGLIBRT Ta "terminate process" Ta "real-time library interrupt"
|
||||
.El
|
||||
.Pp
|
||||
The
|
||||
|
@ -31,6 +31,7 @@
|
||||
#define _CITRUS_ICONV_LOCAL_H_
|
||||
|
||||
#include <iconv.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define _CITRUS_ICONV_GETOPS_FUNC_BASE(_n_) \
|
||||
int _n_(struct _citrus_iconv_ops *)
|
||||
|
@ -42,8 +42,6 @@ __sym_compat(__semctl, freebsd7___semctl, FBSD_1.0);
|
||||
__sym_compat(msgctl, freebsd7_msgctl, FBSD_1.0);
|
||||
__sym_compat(shmctl, freebsd7_shmctl, FBSD_1.0);
|
||||
|
||||
__sym_compat(cap_getrights, cap_rights_get, FBSD_1.2);
|
||||
|
||||
#undef __sym_compat
|
||||
|
||||
#endif /* __LIBC_COMPAT_H__ */
|
||||
|
@ -51,7 +51,7 @@ __FBSDID("$FreeBSD$");
|
||||
int
|
||||
__sflags(const char *mode, int *optr)
|
||||
{
|
||||
int ret, m, o;
|
||||
int ret, m, o, known;
|
||||
|
||||
switch (*mode++) {
|
||||
|
||||
@ -78,34 +78,35 @@ __sflags(const char *mode, int *optr)
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* 'b' (binary) is ignored */
|
||||
if (*mode == 'b')
|
||||
mode++;
|
||||
|
||||
/* [rwa][b]\+ means read and write */
|
||||
if (*mode == '+') {
|
||||
mode++;
|
||||
ret = __SRW;
|
||||
m = O_RDWR;
|
||||
}
|
||||
|
||||
/* 'b' (binary) can appear here, too -- and is ignored again */
|
||||
if (*mode == 'b')
|
||||
mode++;
|
||||
|
||||
/* 'x' means exclusive (fail if the file exists) */
|
||||
if (*mode == 'x') {
|
||||
mode++;
|
||||
if (m == O_RDONLY) {
|
||||
errno = EINVAL;
|
||||
return (0);
|
||||
do {
|
||||
known = 1;
|
||||
switch (*mode++) {
|
||||
case 'b':
|
||||
/* 'b' (binary) is ignored */
|
||||
break;
|
||||
case '+':
|
||||
/* [rwa][b]\+ means read and write */
|
||||
ret = __SRW;
|
||||
m = O_RDWR;
|
||||
break;
|
||||
case 'x':
|
||||
/* 'x' means exclusive (fail if the file exists) */
|
||||
o |= O_EXCL;
|
||||
break;
|
||||
case 'e':
|
||||
/* set close-on-exec */
|
||||
o |= O_CLOEXEC;
|
||||
break;
|
||||
default:
|
||||
known = 0;
|
||||
break;
|
||||
}
|
||||
o |= O_EXCL;
|
||||
}
|
||||
} while (known);
|
||||
|
||||
/* set close-on-exec */
|
||||
if (*mode == 'e')
|
||||
o |= O_CLOEXEC;
|
||||
if ((o & O_EXCL) != 0 && m == O_RDONLY) {
|
||||
errno = EINVAL;
|
||||
return (0);
|
||||
}
|
||||
|
||||
*optr = m | o;
|
||||
return (ret);
|
||||
|
@ -59,6 +59,8 @@ __system(const char *command)
|
||||
|
||||
(void)sigemptyset(&newsigblock);
|
||||
(void)sigaddset(&newsigblock, SIGCHLD);
|
||||
(void)sigaddset(&newsigblock, SIGINT);
|
||||
(void)sigaddset(&newsigblock, SIGQUIT);
|
||||
(void)_sigprocmask(SIG_BLOCK, &newsigblock, &oldsigblock);
|
||||
switch(pid = vfork()) {
|
||||
case -1: /* error */
|
||||
|
@ -363,7 +363,6 @@ FBSD_1.1 {
|
||||
FBSD_1.2 {
|
||||
cap_enter;
|
||||
cap_getmode;
|
||||
cap_new;
|
||||
getloginclass;
|
||||
pdfork;
|
||||
pdgetpid;
|
||||
@ -385,7 +384,7 @@ FBSD_1.3 {
|
||||
cap_fcntls_limit;
|
||||
cap_ioctls_get;
|
||||
cap_ioctls_limit;
|
||||
cap_rights_get;
|
||||
__cap_rights_get;
|
||||
cap_rights_limit;
|
||||
cap_sandboxed;
|
||||
chflagsat;
|
||||
|
@ -28,7 +28,7 @@
|
||||
.\" From: @(#)sigaction.2 8.2 (Berkeley) 4/3/94
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd June 8, 2013
|
||||
.Dd September 6, 2013
|
||||
.Dt SIGACTION 2
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -55,7 +55,7 @@ struct sigaction {
|
||||
.Sh DESCRIPTION
|
||||
The system defines a set of signals that may be delivered to a process.
|
||||
Signal delivery resembles the occurrence of a hardware interrupt:
|
||||
the signal is normally blocked from further occurrence, the current process
|
||||
the signal is normally blocked from further occurrence, the current thread
|
||||
context is saved, and a new one is built.
|
||||
A process may specify a
|
||||
.Em handler
|
||||
@ -64,13 +64,14 @@ to which a signal is delivered, or specify that a signal is to be
|
||||
A process may also specify that a default action is to be taken
|
||||
by the system when a signal occurs.
|
||||
A signal may also be
|
||||
.Em blocked ,
|
||||
in which case its delivery is postponed until it is
|
||||
.Em blocked
|
||||
for a thread,
|
||||
in which case it will not be delivered to that thread until it is
|
||||
.Em unblocked .
|
||||
The action to be taken on delivery is determined at the time
|
||||
of delivery.
|
||||
Normally, signal handlers execute on the current stack
|
||||
of the process.
|
||||
of the thread.
|
||||
This may be changed, on a per-handler basis,
|
||||
so that signals are taken on a special
|
||||
.Em "signal stack" .
|
||||
@ -82,20 +83,30 @@ but other signals may yet occur.
|
||||
A global
|
||||
.Em "signal mask"
|
||||
defines the set of signals currently blocked from delivery
|
||||
to a process.
|
||||
The signal mask for a process is initialized
|
||||
to a thread.
|
||||
The signal mask for a thread is initialized
|
||||
from that of its parent (normally empty).
|
||||
It may be changed with a
|
||||
.Xr sigprocmask 2
|
||||
call, or when a signal is delivered to the process.
|
||||
or
|
||||
.Xr pthread_sigmask 3
|
||||
call, or when a signal is delivered to the thread.
|
||||
.Pp
|
||||
When a signal
|
||||
condition arises for a process, the signal is added to a set of
|
||||
signals pending for the process.
|
||||
If the signal is not currently
|
||||
condition arises for a process or thread, the signal is added to a set of
|
||||
signals pending for the process or thread.
|
||||
Whether the signal is directed at the process in general or at a specific
|
||||
thread depends on how it is generated.
|
||||
For signals directed at a specific thread,
|
||||
if the signal is not currently
|
||||
.Em blocked
|
||||
by the process then it is delivered to the process.
|
||||
Signals may be delivered any time a process enters the operating system
|
||||
by the thread then it is delivered to the thread.
|
||||
For signals directed at the process,
|
||||
if the signal is not currently
|
||||
.Em blocked
|
||||
by all threads then it is delivered to one thread that does not have it blocked
|
||||
(the selection of which is unspecified).
|
||||
Signals may be delivered any time a thread enters the operating system
|
||||
(e.g., during a system call, page fault or trap, or clock interrupt).
|
||||
If multiple signals are ready to be delivered at the same time,
|
||||
any signals that could be caused by traps are delivered first.
|
||||
@ -106,17 +117,17 @@ The set of pending signals is returned by the
|
||||
.Xr sigpending 2
|
||||
system call.
|
||||
When a caught signal
|
||||
is delivered, the current state of the process is saved,
|
||||
is delivered, the current state of the thread is saved,
|
||||
a new signal mask is calculated (as described below),
|
||||
and the signal handler is invoked.
|
||||
The call to the handler
|
||||
is arranged so that if the signal handling routine returns
|
||||
normally the process will resume execution in the context
|
||||
normally the thread will resume execution in the context
|
||||
from before the signal's delivery.
|
||||
If the process wishes to resume in a different context, then it
|
||||
If the thread wishes to resume in a different context, then it
|
||||
must arrange to restore the previous context itself.
|
||||
.Pp
|
||||
When a signal is delivered to a process a new signal mask is
|
||||
When a signal is delivered to a thread a new signal mask is
|
||||
installed for the duration of the process' signal handler
|
||||
(or until a
|
||||
.Xr sigprocmask 2
|
||||
@ -218,7 +229,7 @@ to
|
||||
If this bit is set, the system will deliver the signal to the process
|
||||
on a
|
||||
.Em "signal stack" ,
|
||||
specified with
|
||||
specified by each thread with
|
||||
.Xr sigaltstack 2 .
|
||||
.It Dv SA_NODEFER
|
||||
If this bit is set, further occurrences of the delivered signal are
|
||||
@ -272,6 +283,11 @@ However, calls that have already committed are not restarted,
|
||||
but instead return a partial success (for example, a short read count).
|
||||
.Pp
|
||||
After a
|
||||
.Xr pthread_create 3
|
||||
the signal mask is inherited by the new thread and
|
||||
the set of pending signals and the signal stack for the new thread are empty.
|
||||
.Pp
|
||||
After a
|
||||
.Xr fork 2
|
||||
or
|
||||
.Xr vfork 2
|
||||
|
@ -31,7 +31,7 @@
|
||||
.\" @(#)sigpending.2 8.3 (Berkeley) 1/12/94
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd January 12, 1994
|
||||
.Dd September 6, 2013
|
||||
.Dt SIGPENDING 2
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -47,7 +47,7 @@
|
||||
The
|
||||
.Fn sigpending
|
||||
system call returns a mask of the signals pending for delivery
|
||||
to the calling process in the location indicated by
|
||||
to the calling thread or the calling process in the location indicated by
|
||||
.Fa set .
|
||||
Signals may be pending because they are currently masked,
|
||||
or transiently before delivery (although the latter case is not
|
||||
|
@ -28,7 +28,7 @@
|
||||
.\" @(#)sigreturn.2 8.1 (Berkeley) 6/4/93
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd June 4, 1993
|
||||
.Dd September 6, 2013
|
||||
.Dt SIGRETURN 2
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -46,7 +46,7 @@ The
|
||||
system call
|
||||
allows users to atomically unmask, switch stacks,
|
||||
and return from a signal context.
|
||||
The processes signal mask and stack status are
|
||||
The thread's signal mask and stack status are
|
||||
restored from the context structure pointed to by
|
||||
.Fa scp .
|
||||
The system call does not return;
|
||||
@ -65,7 +65,7 @@ is set to indicate the error.
|
||||
The
|
||||
.Fn sigreturn
|
||||
system call
|
||||
will fail and the process context will remain unchanged
|
||||
will fail and the thread context will remain unchanged
|
||||
if one of the following occurs.
|
||||
.Bl -tag -width Er
|
||||
.It Bq Er EFAULT
|
||||
|
@ -27,7 +27,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd September 27, 2012
|
||||
.Dd September 6, 2013
|
||||
.Dt SIGWAIT 2
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -50,7 +50,7 @@ waits until one or more of the selected signals has been generated.
|
||||
Then
|
||||
.Fn sigwait
|
||||
atomically clears one of the selected signals from the set of pending signals
|
||||
for the process and sets the location pointed to by
|
||||
(for the process or for the current thread) and sets the location pointed to by
|
||||
.Fa sig
|
||||
to the signal number that was cleared.
|
||||
.Pp
|
||||
|
@ -3,12 +3,16 @@
|
||||
LIBEXECINFO= ${.CURDIR}/../../contrib/libexecinfo
|
||||
|
||||
LIB= execinfo
|
||||
SHLIB_MAJOR= 1
|
||||
|
||||
.PATH: ${LIBEXECINFO}
|
||||
|
||||
INCS= execinfo.h symtab.h unwind.h
|
||||
INCS= execinfo.h
|
||||
SRCS= backtrace.c symtab.c unwind.c
|
||||
|
||||
DPADD= ${LIBELF}
|
||||
LDADD= -lelf
|
||||
|
||||
MAN= backtrace.3
|
||||
|
||||
MLINKS+= backtrace.3 backtrace_symbols.3
|
||||
|
@ -5,6 +5,9 @@
|
||||
SHLIB_MAJOR= 4
|
||||
WARNS?= 6
|
||||
CFLAGS+= -I${.CURDIR}/../../libc/iconv
|
||||
|
||||
CFLAGS+= -Dbool=_Bool
|
||||
|
||||
.if !defined(COMPAT_32BIT)
|
||||
SHLIBDIR= /usr/lib/i18n
|
||||
.else
|
||||
|
@ -378,7 +378,7 @@ procstat_freefiles(struct procstat *procstat, struct filestat_list *head)
|
||||
|
||||
static struct filestat *
|
||||
filestat_new_entry(void *typedep, int type, int fd, int fflags, int uflags,
|
||||
int refcount, off_t offset, char *path, cap_rights_t cap_rights)
|
||||
int refcount, off_t offset, char *path, cap_rights_t *cap_rightsp)
|
||||
{
|
||||
struct filestat *entry;
|
||||
|
||||
@ -395,7 +395,7 @@ filestat_new_entry(void *typedep, int type, int fd, int fflags, int uflags,
|
||||
entry->fs_ref_count = refcount;
|
||||
entry->fs_offset = offset;
|
||||
entry->fs_path = path;
|
||||
entry->fs_cap_rights = cap_rights;
|
||||
entry->fs_cap_rights = *cap_rightsp;
|
||||
return (entry);
|
||||
}
|
||||
|
||||
@ -851,7 +851,7 @@ procstat_getfiles_sysctl(struct procstat *procstat, struct kinfo_proc *kp,
|
||||
* Create filestat entry.
|
||||
*/
|
||||
entry = filestat_new_entry(kif, type, fd, fflags, uflags,
|
||||
refcount, offset, path, cap_rights);
|
||||
refcount, offset, path, &cap_rights);
|
||||
if (entry != NULL)
|
||||
STAILQ_INSERT_TAIL(head, entry, next);
|
||||
}
|
||||
|
@ -36,6 +36,7 @@
|
||||
#ifndef ZFS
|
||||
#include <sys/elf.h>
|
||||
#endif
|
||||
#include <sys/caprights.h>
|
||||
|
||||
/*
|
||||
* Vnode types.
|
||||
|
@ -697,7 +697,7 @@ ugen20_detach_kernel_driver(struct libusb20_device *pdev,
|
||||
if (ioctl(pdev->file_ctrl, IOUSB(USB_IFACE_DRIVER_DETACH), &temp)) {
|
||||
return (LIBUSB20_ERROR_OTHER);
|
||||
}
|
||||
return (0); /* kernel driver is active */
|
||||
return (0); /* kernel driver is detached */
|
||||
}
|
||||
|
||||
static int
|
||||
@ -724,7 +724,7 @@ ugen20_do_request_sync(struct libusb20_device *pdev,
|
||||
/* get actual length */
|
||||
*pactlen = req.ucr_actlen;
|
||||
}
|
||||
return (0); /* kernel driver is active */
|
||||
return (0); /* request was successful */
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -53,6 +53,7 @@ COMMON_SRCS= b_exp.c b_log.c b_tgamma.c \
|
||||
e_pow.c e_powf.c e_rem_pio2.c \
|
||||
e_rem_pio2f.c e_remainder.c e_remainderf.c e_scalb.c e_scalbf.c \
|
||||
e_sinh.c e_sinhf.c e_sqrt.c e_sqrtf.c fenv.c \
|
||||
imprecise.c \
|
||||
k_cos.c k_cosf.c k_exp.c k_expf.c k_rem_pio2.c k_sin.c k_sinf.c \
|
||||
k_tan.c k_tanf.c \
|
||||
s_asinh.c s_asinhf.c s_atan.c s_atanf.c s_carg.c s_cargf.c s_cargl.c \
|
||||
|
@ -270,4 +270,13 @@ FBSD_1.3 {
|
||||
log1pl;
|
||||
log2l;
|
||||
logl;
|
||||
# Implemented as weak aliases for imprecise versions
|
||||
coshl;
|
||||
erfcl;
|
||||
erfl;
|
||||
lgammal;
|
||||
powl;
|
||||
sinhl;
|
||||
tanhl;
|
||||
tgammal;
|
||||
};
|
||||
|
69
lib/msun/src/imprecise.c
Normal file
69
lib/msun/src/imprecise.c
Normal file
@ -0,0 +1,69 @@
|
||||
/*-
|
||||
* Copyright (c) 2013 David Chisnall
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
|
||||
/*
|
||||
* If long double is not the same size as double, then these will lose
|
||||
* precision and we should emit a warning whenever something links against
|
||||
* them.
|
||||
*/
|
||||
#if (LDBL_MANT_DIG > 53)
|
||||
#define WARN_IMPRECISE(x) \
|
||||
__warn_references(x, # x " has lower than advertised precision");
|
||||
#else
|
||||
#define WARN_IMPRECISE(x)
|
||||
#endif
|
||||
/*
|
||||
* Declare the functions as weak variants so that other libraries providing
|
||||
* real versions can override them.
|
||||
*/
|
||||
#define DECLARE_WEAK(x)\
|
||||
__weak_reference(imprecise_## x, x);\
|
||||
WARN_IMPRECISE(x)
|
||||
|
||||
long double
|
||||
imprecise_powl(long double x, long double y)
|
||||
{
|
||||
|
||||
return pow(x, y);
|
||||
}
|
||||
DECLARE_WEAK(powl);
|
||||
|
||||
#define DECLARE_IMPRECISE(f) \
|
||||
long double imprecise_ ## f ## l(long double v) { return f(v); }\
|
||||
DECLARE_WEAK(f ## l)
|
||||
|
||||
DECLARE_IMPRECISE(cosh);
|
||||
DECLARE_IMPRECISE(erfc);
|
||||
DECLARE_IMPRECISE(erf);
|
||||
DECLARE_IMPRECISE(lgamma);
|
||||
DECLARE_IMPRECISE(sinh);
|
||||
DECLARE_IMPRECISE(tanh);
|
||||
DECLARE_IMPRECISE(tgamma);
|
@ -693,17 +693,22 @@ populate_mfs_tree() {
|
||||
# rm $a # do not remove!
|
||||
) || fail $? crunch
|
||||
|
||||
if [ -f ${dst}/stand/sshd ] ; then
|
||||
log "Setting up host key for sshd:"
|
||||
if [ -f ${BUILDDIR}/floppy.tree/etc/ssh_host_key.gz ] ; then
|
||||
log "Using existing host key"
|
||||
log "Setting up host key for sshd:"
|
||||
for K in rsa1 rsa dsa ; do
|
||||
if [ $K = rsa1 ] ; then
|
||||
i=ssh_host_key
|
||||
else
|
||||
log "Generating new host key"
|
||||
ssh-keygen -t rsa1 -f ${BUILDDIR}/floppy.tree/etc/ssh_host_key \
|
||||
-N "" -C "root@picobsd"
|
||||
gzip -9 ${BUILDDIR}/floppy.tree/etc/ssh_host_key* || true
|
||||
i=ssh_host_${K}_key
|
||||
fi
|
||||
fi
|
||||
if [ -f ${BUILDDIR}/floppy.tree/etc/$i.gz ] ; then
|
||||
log "Using existing host key $i"
|
||||
else
|
||||
log "Generating new host key $i"
|
||||
ssh-keygen -t $K -f ${BUILDDIR}/floppy.tree/etc/$i \
|
||||
-N "" -C "root@picobsd"
|
||||
gzip -9 ${BUILDDIR}/floppy.tree/etc/${i}* || true
|
||||
fi
|
||||
done
|
||||
|
||||
log "Copy generic and site-specific MFS tree..."
|
||||
for MFS_TREE in ${PICO_TREE}/mfs_tree ${MY_TREE}/mfs_tree ; do
|
||||
@ -880,9 +885,11 @@ fill_floppy_image() {
|
||||
|
||||
mkdir -p ${dst}/boot/kernel
|
||||
# XXX loader.conf does not work unless we also load the .4th files
|
||||
echo "hint.acpi.0.disabled=\"1\"" > ${dst}/boot/loader.conf
|
||||
echo "console=\"comconsole\"" >> ${dst}/boot/loader.conf
|
||||
cp -p /boot/loader ${dst}/boot/loader || fail $? no_space "copying bootloader"
|
||||
# echo "hint.acpi.0.disabled=\"1\"" > ${dst}/boot/loader.conf
|
||||
# echo "console=\"comconsole\"" >> ${dst}/boot/loader.conf
|
||||
local blf="loader* *.4th" # loader.rc loader.4th support.4th"
|
||||
(cd /boot; cp -p loader ${dst}/boot) || fail $? no_space "copying bootloader"
|
||||
cp ${MY_TREE}/floppy.tree/boot/loader.conf ${dst}/boot || true
|
||||
gzip -c kernel > ${dst}/boot/kernel/kernel.gz || fail $? no_space "copying kernel"
|
||||
|
||||
# now transfer the floppy tree. If it is already in mfs, dont bother.
|
||||
@ -972,6 +979,8 @@ set_build_parameters() {
|
||||
#-- export MACHINE_ARCH=`uname -m` MACHINE=`uname -m`
|
||||
# export CWARNFLAGS="-Wextra -Wno-sign-compare -Wno-missing-field-initializers"
|
||||
eval "export BINMAKE=\"`cd ${SRC}; make -f Makefile -V BINMAKE`\""
|
||||
[ "$BINMAKE" = "" ] && \
|
||||
eval "export BINMAKE=\"`cd ${SRC}; make -f Makefile -V SUB_MAKE`\""
|
||||
fi
|
||||
|
||||
if [ "${o_init_src}" != "" ] ; then
|
||||
|
@ -207,6 +207,19 @@
|
||||
.Op Fl w
|
||||
.Op Fl y
|
||||
.Nm
|
||||
.Ic sanitize
|
||||
.Op device id
|
||||
.Op generic args
|
||||
.Aq Fl a Ar overwrite | block | crypto | exitfailure
|
||||
.Op Fl c Ar passes
|
||||
.Op Fl I
|
||||
.Op Fl P Ar pattern
|
||||
.Op Fl q
|
||||
.Op Fl U
|
||||
.Op Fl r
|
||||
.Op Fl w
|
||||
.Op Fl y
|
||||
.Nm
|
||||
.Ic idle
|
||||
.Op device id
|
||||
.Op generic args
|
||||
@ -1088,6 +1101,116 @@ The user
|
||||
will not be asked about the timeout if a timeout is specified on the
|
||||
command line.
|
||||
.El
|
||||
.It Ic sanitize
|
||||
Issue the
|
||||
.Tn SCSI
|
||||
SANITIZE command to the named device.
|
||||
.Pp
|
||||
.Em WARNING! WARNING! WARNING!
|
||||
.Pp
|
||||
ALL data in the cache and on the disk will be destroyed or made inaccessible.
|
||||
Recovery of the data is not possible.
|
||||
Use extreme caution when issuing this command.
|
||||
.Pp
|
||||
The
|
||||
.Sq sanitize
|
||||
subcommand takes several arguments that modify its default behavior.
|
||||
The
|
||||
.Fl q
|
||||
and
|
||||
.Fl y
|
||||
arguments can be useful for scripts.
|
||||
.Bl -tag -width 6n
|
||||
.It Fl a Ar operation
|
||||
Specify the sanitize operation to perform.
|
||||
.Bl -tag -width 16n
|
||||
.It overwrite
|
||||
Perform an overwrite operation by writing a user supplied
|
||||
data pattern to the device one or more times.
|
||||
The pattern is given by the
|
||||
.Fl P
|
||||
argument.
|
||||
The number of times is given by the
|
||||
.Fl c
|
||||
argument.
|
||||
.It block
|
||||
Perform a block erase operation.
|
||||
All the device's blocks are set to a vendor defined
|
||||
value, typically zero.
|
||||
.It crypto
|
||||
Perform a cryptographic erase operation.
|
||||
The encryption keys are changed to prevent the decryption
|
||||
of the data.
|
||||
.It exitfailure
|
||||
Exits a previously failed sanitize operation.
|
||||
A failed sanitize operation can only be exited if it was
|
||||
run in the unrestricted completion mode, as provided by the
|
||||
.Fl U
|
||||
argument.
|
||||
.El
|
||||
.It Fl c Ar passes
|
||||
The number of passes when performing an
|
||||
.Sq overwrite
|
||||
operation.
|
||||
Valid values are between 1 and 31. The default is 1.
|
||||
.It Fl I
|
||||
When performing an
|
||||
.Sq overwrite
|
||||
operation, the pattern is inverted between consecutive passes.
|
||||
.It Fl P Ar pattern
|
||||
Path to the file containing the pattern to use when
|
||||
performing an
|
||||
.Sq overwrite
|
||||
operation.
|
||||
The pattern is repeated as needed to fill each block.
|
||||
.It Fl q
|
||||
Be quiet, do not print any status messages.
|
||||
This option will not disable
|
||||
the questions, however.
|
||||
To disable questions, use the
|
||||
.Fl y
|
||||
argument, below.
|
||||
.It Fl U
|
||||
Perform the sanitize in the unrestricted completion mode.
|
||||
If the operation fails, it can later be exited with the
|
||||
.Sq exitfailure
|
||||
operation.
|
||||
.It Fl r
|
||||
Run in
|
||||
.Dq report only
|
||||
mode.
|
||||
This will report status on a sanitize that is already running on the drive.
|
||||
.It Fl w
|
||||
Issue a non-immediate sanitize command.
|
||||
By default,
|
||||
.Nm
|
||||
issues the SANITIZE command with the immediate bit set.
|
||||
This tells the
|
||||
device to immediately return the sanitize command, before
|
||||
the sanitize has actually completed.
|
||||
Then,
|
||||
.Nm
|
||||
gathers
|
||||
.Tn SCSI
|
||||
sense information from the device every second to determine how far along
|
||||
in the sanitize process it is.
|
||||
If the
|
||||
.Fl w
|
||||
argument is specified,
|
||||
.Nm
|
||||
will issue a non-immediate sanitize command, and will be unable to print any
|
||||
information to let the user know what percentage of the disk has been
|
||||
sanitized.
|
||||
.It Fl y
|
||||
Do not ask any questions.
|
||||
By default,
|
||||
.Nm
|
||||
will ask the user if he/she really wants to sanitize the disk in question,
|
||||
and also if the default sanitize command timeout is acceptable.
|
||||
The user
|
||||
will not be asked about the timeout if a timeout is specified on the
|
||||
command line.
|
||||
.El
|
||||
.It Ic idle
|
||||
Put ATA device into IDLE state. Optional parameter
|
||||
.Pq Fl t
|
||||
@ -1300,6 +1423,8 @@ PLEXTOR
|
||||
.It
|
||||
QUANTUM
|
||||
.It
|
||||
SAMSUNG
|
||||
.It
|
||||
SEAGATE
|
||||
.El
|
||||
.Pp
|
||||
|
@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/stdint.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/endian.h>
|
||||
#include <sys/sbuf.h>
|
||||
|
||||
@ -93,7 +94,8 @@ typedef enum {
|
||||
CAM_CMD_SMP_MANINFO = 0x0000001b,
|
||||
CAM_CMD_DOWNLOAD_FW = 0x0000001c,
|
||||
CAM_CMD_SECURITY = 0x0000001d,
|
||||
CAM_CMD_HPA = 0x0000001e
|
||||
CAM_CMD_HPA = 0x0000001e,
|
||||
CAM_CMD_SANITIZE = 0x0000001f,
|
||||
} cam_cmdmask;
|
||||
|
||||
typedef enum {
|
||||
@ -209,6 +211,7 @@ static struct camcontrol_opts option_table[] = {
|
||||
{"rate", CAM_CMD_RATE, CAM_ARG_NONE, negotiate_opts},
|
||||
{"debug", CAM_CMD_DEBUG, CAM_ARG_NONE, "IPTSXcp"},
|
||||
{"format", CAM_CMD_FORMAT, CAM_ARG_NONE, "qrwy"},
|
||||
{"sanitize", CAM_CMD_SANITIZE, CAM_ARG_NONE, "a:c:IP:qrUwy"},
|
||||
{"idle", CAM_CMD_IDLE, CAM_ARG_NONE, "t:"},
|
||||
{"standby", CAM_CMD_STANDBY, CAM_ARG_NONE, "t:"},
|
||||
{"sleep", CAM_CMD_SLEEP, CAM_ARG_NONE, ""},
|
||||
@ -301,6 +304,8 @@ static int ratecontrol(struct cam_device *device, int retry_count,
|
||||
int timeout, int argc, char **argv, char *combinedopt);
|
||||
static int scsiformat(struct cam_device *device, int argc, char **argv,
|
||||
char *combinedopt, int retry_count, int timeout);
|
||||
static int scsisanitize(struct cam_device *device, int argc, char **argv,
|
||||
char *combinedopt, int retry_count, int timeout);
|
||||
static int scsireportluns(struct cam_device *device, int argc, char **argv,
|
||||
char *combinedopt, int retry_count, int timeout);
|
||||
static int scsireadcapacity(struct cam_device *device, int argc, char **argv,
|
||||
@ -5536,6 +5541,402 @@ scsiformat(struct cam_device *device, int argc, char **argv,
|
||||
return(error);
|
||||
}
|
||||
|
||||
static int
|
||||
scsisanitize(struct cam_device *device, int argc, char **argv,
|
||||
char *combinedopt, int retry_count, int timeout)
|
||||
{
|
||||
union ccb *ccb;
|
||||
u_int8_t action = 0;
|
||||
int c;
|
||||
int ycount = 0, quiet = 0;
|
||||
int error = 0, retval = 0;
|
||||
int use_timeout = 10800 * 1000;
|
||||
int immediate = 1;
|
||||
int invert = 0;
|
||||
int passes = 0;
|
||||
int ause = 0;
|
||||
int fd = -1;
|
||||
const char *pattern = NULL;
|
||||
u_int8_t *data_ptr = NULL;
|
||||
u_int32_t dxfer_len = 0;
|
||||
u_int8_t byte2 = 0;
|
||||
int num_warnings = 0;
|
||||
int reportonly = 0;
|
||||
|
||||
ccb = cam_getccb(device);
|
||||
|
||||
if (ccb == NULL) {
|
||||
warnx("scsisanitize: error allocating ccb");
|
||||
return(1);
|
||||
}
|
||||
|
||||
bzero(&(&ccb->ccb_h)[1],
|
||||
sizeof(struct ccb_scsiio) - sizeof(struct ccb_hdr));
|
||||
|
||||
while ((c = getopt(argc, argv, combinedopt)) != -1) {
|
||||
switch(c) {
|
||||
case 'a':
|
||||
if (strcasecmp(optarg, "overwrite") == 0)
|
||||
action = SSZ_SERVICE_ACTION_OVERWRITE;
|
||||
else if (strcasecmp(optarg, "block") == 0)
|
||||
action = SSZ_SERVICE_ACTION_BLOCK_ERASE;
|
||||
else if (strcasecmp(optarg, "crypto") == 0)
|
||||
action = SSZ_SERVICE_ACTION_CRYPTO_ERASE;
|
||||
else if (strcasecmp(optarg, "exitfailure") == 0)
|
||||
action = SSZ_SERVICE_ACTION_EXIT_MODE_FAILURE;
|
||||
else {
|
||||
warnx("invalid service operation \"%s\"",
|
||||
optarg);
|
||||
error = 1;
|
||||
goto scsisanitize_bailout;
|
||||
}
|
||||
break;
|
||||
case 'c':
|
||||
passes = strtol(optarg, NULL, 0);
|
||||
if (passes < 1 || passes > 31) {
|
||||
warnx("invalid passes value %d", passes);
|
||||
error = 1;
|
||||
goto scsisanitize_bailout;
|
||||
}
|
||||
break;
|
||||
case 'I':
|
||||
invert = 1;
|
||||
break;
|
||||
case 'P':
|
||||
pattern = optarg;
|
||||
break;
|
||||
case 'q':
|
||||
quiet++;
|
||||
break;
|
||||
case 'U':
|
||||
ause = 1;
|
||||
break;
|
||||
case 'r':
|
||||
reportonly = 1;
|
||||
break;
|
||||
case 'w':
|
||||
immediate = 0;
|
||||
break;
|
||||
case 'y':
|
||||
ycount++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (reportonly)
|
||||
goto doreport;
|
||||
|
||||
if (action == 0) {
|
||||
warnx("an action is required");
|
||||
error = 1;
|
||||
goto scsisanitize_bailout;
|
||||
} else if (action == SSZ_SERVICE_ACTION_OVERWRITE) {
|
||||
struct scsi_sanitize_parameter_list *pl;
|
||||
struct stat sb;
|
||||
ssize_t sz, amt;
|
||||
|
||||
if (pattern == NULL) {
|
||||
warnx("overwrite action requires -P argument");
|
||||
error = 1;
|
||||
goto scsisanitize_bailout;
|
||||
}
|
||||
fd = open(pattern, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
warn("cannot open pattern file %s", pattern);
|
||||
error = 1;
|
||||
goto scsisanitize_bailout;
|
||||
}
|
||||
if (fstat(fd, &sb) < 0) {
|
||||
warn("cannot stat pattern file %s", pattern);
|
||||
error = 1;
|
||||
goto scsisanitize_bailout;
|
||||
}
|
||||
sz = sb.st_size;
|
||||
if (sz > SSZPL_MAX_PATTERN_LENGTH) {
|
||||
warnx("pattern file size exceeds maximum value %d",
|
||||
SSZPL_MAX_PATTERN_LENGTH);
|
||||
error = 1;
|
||||
goto scsisanitize_bailout;
|
||||
}
|
||||
dxfer_len = sizeof(*pl) + sz;
|
||||
data_ptr = calloc(1, dxfer_len);
|
||||
if (data_ptr == NULL) {
|
||||
warnx("cannot allocate parameter list buffer");
|
||||
error = 1;
|
||||
goto scsisanitize_bailout;
|
||||
}
|
||||
|
||||
amt = read(fd, data_ptr + sizeof(*pl), sz);
|
||||
if (amt < 0) {
|
||||
warn("cannot read pattern file");
|
||||
error = 1;
|
||||
goto scsisanitize_bailout;
|
||||
} else if (amt != sz) {
|
||||
warnx("short pattern file read");
|
||||
error = 1;
|
||||
goto scsisanitize_bailout;
|
||||
}
|
||||
|
||||
pl = (struct scsi_sanitize_parameter_list *)data_ptr;
|
||||
if (passes == 0)
|
||||
pl->byte1 = 1;
|
||||
else
|
||||
pl->byte1 = passes;
|
||||
if (invert != 0)
|
||||
pl->byte1 |= SSZPL_INVERT;
|
||||
scsi_ulto2b(sz, pl->length);
|
||||
} else {
|
||||
const char *arg;
|
||||
|
||||
if (passes != 0)
|
||||
arg = "-c";
|
||||
else if (invert != 0)
|
||||
arg = "-I";
|
||||
else if (pattern != NULL)
|
||||
arg = "-P";
|
||||
else
|
||||
arg = NULL;
|
||||
if (arg != NULL) {
|
||||
warnx("%s argument only valid with overwrite "
|
||||
"operation", arg);
|
||||
error = 1;
|
||||
goto scsisanitize_bailout;
|
||||
}
|
||||
}
|
||||
|
||||
if (quiet == 0) {
|
||||
fprintf(stdout, "You are about to REMOVE ALL DATA from the "
|
||||
"following device:\n");
|
||||
|
||||
error = scsidoinquiry(device, argc, argv, combinedopt,
|
||||
retry_count, timeout);
|
||||
|
||||
if (error != 0) {
|
||||
warnx("scsisanitize: error sending inquiry");
|
||||
goto scsisanitize_bailout;
|
||||
}
|
||||
}
|
||||
|
||||
if (ycount == 0) {
|
||||
if (!get_confirmation()) {
|
||||
error = 1;
|
||||
goto scsisanitize_bailout;
|
||||
}
|
||||
}
|
||||
|
||||
if (timeout != 0)
|
||||
use_timeout = timeout;
|
||||
|
||||
if (quiet == 0) {
|
||||
fprintf(stdout, "Current sanitize timeout is %d seconds\n",
|
||||
use_timeout / 1000);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the user hasn't disabled questions and didn't specify a
|
||||
* timeout on the command line, ask them if they want the current
|
||||
* timeout.
|
||||
*/
|
||||
if ((ycount == 0)
|
||||
&& (timeout == 0)) {
|
||||
char str[1024];
|
||||
int new_timeout = 0;
|
||||
|
||||
fprintf(stdout, "Enter new timeout in seconds or press\n"
|
||||
"return to keep the current timeout [%d] ",
|
||||
use_timeout / 1000);
|
||||
|
||||
if (fgets(str, sizeof(str), stdin) != NULL) {
|
||||
if (str[0] != '\0')
|
||||
new_timeout = atoi(str);
|
||||
}
|
||||
|
||||
if (new_timeout != 0) {
|
||||
use_timeout = new_timeout * 1000;
|
||||
fprintf(stdout, "Using new timeout value %d\n",
|
||||
use_timeout / 1000);
|
||||
}
|
||||
}
|
||||
|
||||
byte2 = action;
|
||||
if (ause != 0)
|
||||
byte2 |= SSZ_UNRESTRICTED_EXIT;
|
||||
if (immediate != 0)
|
||||
byte2 |= SSZ_IMMED;
|
||||
|
||||
scsi_sanitize(&ccb->csio,
|
||||
/* retries */ retry_count,
|
||||
/* cbfcnp */ NULL,
|
||||
/* tag_action */ MSG_SIMPLE_Q_TAG,
|
||||
/* byte2 */ byte2,
|
||||
/* control */ 0,
|
||||
/* data_ptr */ data_ptr,
|
||||
/* dxfer_len */ dxfer_len,
|
||||
/* sense_len */ SSD_FULL_SIZE,
|
||||
/* timeout */ use_timeout);
|
||||
|
||||
/* Disable freezing the device queue */
|
||||
ccb->ccb_h.flags |= CAM_DEV_QFRZDIS;
|
||||
|
||||
if (arglist & CAM_ARG_ERR_RECOVER)
|
||||
ccb->ccb_h.flags |= CAM_PASS_ERR_RECOVER;
|
||||
|
||||
if (((retval = cam_send_ccb(device, ccb)) < 0)
|
||||
|| ((immediate == 0)
|
||||
&& ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP))) {
|
||||
const char errstr[] = "error sending sanitize command";
|
||||
|
||||
if (retval < 0)
|
||||
warn(errstr);
|
||||
else
|
||||
warnx(errstr);
|
||||
|
||||
if (arglist & CAM_ARG_VERBOSE) {
|
||||
cam_error_print(device, ccb, CAM_ESF_ALL,
|
||||
CAM_EPF_ALL, stderr);
|
||||
}
|
||||
error = 1;
|
||||
goto scsisanitize_bailout;
|
||||
}
|
||||
|
||||
/*
|
||||
* If we ran in non-immediate mode, we already checked for errors
|
||||
* above and printed out any necessary information. If we're in
|
||||
* immediate mode, we need to loop through and get status
|
||||
* information periodically.
|
||||
*/
|
||||
if (immediate == 0) {
|
||||
if (quiet == 0) {
|
||||
fprintf(stdout, "Sanitize Complete\n");
|
||||
}
|
||||
goto scsisanitize_bailout;
|
||||
}
|
||||
|
||||
doreport:
|
||||
do {
|
||||
cam_status status;
|
||||
|
||||
bzero(&(&ccb->ccb_h)[1],
|
||||
sizeof(struct ccb_scsiio) - sizeof(struct ccb_hdr));
|
||||
|
||||
/*
|
||||
* There's really no need to do error recovery or
|
||||
* retries here, since we're just going to sit in a
|
||||
* loop and wait for the device to finish sanitizing.
|
||||
*/
|
||||
scsi_test_unit_ready(&ccb->csio,
|
||||
/* retries */ 0,
|
||||
/* cbfcnp */ NULL,
|
||||
/* tag_action */ MSG_SIMPLE_Q_TAG,
|
||||
/* sense_len */ SSD_FULL_SIZE,
|
||||
/* timeout */ 5000);
|
||||
|
||||
/* Disable freezing the device queue */
|
||||
ccb->ccb_h.flags |= CAM_DEV_QFRZDIS;
|
||||
|
||||
retval = cam_send_ccb(device, ccb);
|
||||
|
||||
/*
|
||||
* If we get an error from the ioctl, bail out. SCSI
|
||||
* errors are expected.
|
||||
*/
|
||||
if (retval < 0) {
|
||||
warn("error sending CAMIOCOMMAND ioctl");
|
||||
if (arglist & CAM_ARG_VERBOSE) {
|
||||
cam_error_print(device, ccb, CAM_ESF_ALL,
|
||||
CAM_EPF_ALL, stderr);
|
||||
}
|
||||
error = 1;
|
||||
goto scsisanitize_bailout;
|
||||
}
|
||||
|
||||
status = ccb->ccb_h.status & CAM_STATUS_MASK;
|
||||
|
||||
if ((status != CAM_REQ_CMP)
|
||||
&& (status == CAM_SCSI_STATUS_ERROR)
|
||||
&& ((ccb->ccb_h.status & CAM_AUTOSNS_VALID) != 0)) {
|
||||
struct scsi_sense_data *sense;
|
||||
int error_code, sense_key, asc, ascq;
|
||||
|
||||
sense = &ccb->csio.sense_data;
|
||||
scsi_extract_sense_len(sense, ccb->csio.sense_len -
|
||||
ccb->csio.sense_resid, &error_code, &sense_key,
|
||||
&asc, &ascq, /*show_errors*/ 1);
|
||||
|
||||
/*
|
||||
* According to the SCSI-3 spec, a drive that is in the
|
||||
* middle of a sanitize should return NOT READY with an
|
||||
* ASC of "logical unit not ready, sanitize in
|
||||
* progress". The sense key specific bytes will then
|
||||
* be a progress indicator.
|
||||
*/
|
||||
if ((sense_key == SSD_KEY_NOT_READY)
|
||||
&& (asc == 0x04) && (ascq == 0x1b)) {
|
||||
uint8_t sks[3];
|
||||
|
||||
if ((scsi_get_sks(sense, ccb->csio.sense_len -
|
||||
ccb->csio.sense_resid, sks) == 0)
|
||||
&& (quiet == 0)) {
|
||||
int val;
|
||||
u_int64_t percentage;
|
||||
|
||||
val = scsi_2btoul(&sks[1]);
|
||||
percentage = 10000 * val;
|
||||
|
||||
fprintf(stdout,
|
||||
"\rSanitizing: %ju.%02u %% "
|
||||
"(%d/%d) done",
|
||||
(uintmax_t)(percentage /
|
||||
(0x10000 * 100)),
|
||||
(unsigned)((percentage /
|
||||
0x10000) % 100),
|
||||
val, 0x10000);
|
||||
fflush(stdout);
|
||||
} else if ((quiet == 0)
|
||||
&& (++num_warnings <= 1)) {
|
||||
warnx("Unexpected SCSI Sense Key "
|
||||
"Specific value returned "
|
||||
"during sanitize:");
|
||||
scsi_sense_print(device, &ccb->csio,
|
||||
stderr);
|
||||
warnx("Unable to print status "
|
||||
"information, but sanitze will "
|
||||
"proceed.");
|
||||
warnx("will exit when sanitize is "
|
||||
"complete");
|
||||
}
|
||||
sleep(1);
|
||||
} else {
|
||||
warnx("Unexpected SCSI error during sanitize");
|
||||
cam_error_print(device, ccb, CAM_ESF_ALL,
|
||||
CAM_EPF_ALL, stderr);
|
||||
error = 1;
|
||||
goto scsisanitize_bailout;
|
||||
}
|
||||
|
||||
} else if (status != CAM_REQ_CMP) {
|
||||
warnx("Unexpected CAM status %#x", status);
|
||||
if (arglist & CAM_ARG_VERBOSE)
|
||||
cam_error_print(device, ccb, CAM_ESF_ALL,
|
||||
CAM_EPF_ALL, stderr);
|
||||
error = 1;
|
||||
goto scsisanitize_bailout;
|
||||
}
|
||||
} while((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP);
|
||||
|
||||
if (quiet == 0)
|
||||
fprintf(stdout, "\nSanitize Complete\n");
|
||||
|
||||
scsisanitize_bailout:
|
||||
if (fd >= 0)
|
||||
close(fd);
|
||||
if (data_ptr != NULL)
|
||||
free(data_ptr);
|
||||
cam_freeccb(ccb);
|
||||
|
||||
return(error);
|
||||
}
|
||||
|
||||
static int
|
||||
scsireportluns(struct cam_device *device, int argc, char **argv,
|
||||
char *combinedopt, int retry_count, int timeout)
|
||||
@ -7361,6 +7762,10 @@ usage(int printlong)
|
||||
" [-q][-R syncrate][-v][-T <enable|disable>]\n"
|
||||
" [-U][-W bus_width]\n"
|
||||
" camcontrol format [dev_id][generic args][-q][-r][-w][-y]\n"
|
||||
" camcontrol sanitize [dev_id][generic args]\n"
|
||||
" [-a overwrite|block|crypto|exitfailure]\n"
|
||||
" [-c passes][-I][-P pattern][-q][-U][-r][-w]\n"
|
||||
" [-y]\n"
|
||||
" camcontrol idle [dev_id][generic args][-t time]\n"
|
||||
" camcontrol standby [dev_id][generic args][-t time]\n"
|
||||
" camcontrol sleep [dev_id][generic args]\n"
|
||||
@ -7403,6 +7808,7 @@ usage(int printlong)
|
||||
"tags report or set the number of transaction slots for a device\n"
|
||||
"negotiate report or set device negotiation parameters\n"
|
||||
"format send the SCSI FORMAT UNIT command to the named device\n"
|
||||
"sanitize send the SCSI SANITIZE command to the named device\n"
|
||||
"idle send the ATA IDLE command to the named device\n"
|
||||
"standby send the ATA STANDBY command to the named device\n"
|
||||
"sleep send the ATA SLEEP command to the named device\n"
|
||||
@ -7498,6 +7904,16 @@ usage(int printlong)
|
||||
"-r run in report only mode\n"
|
||||
"-w don't send immediate format command\n"
|
||||
"-y don't ask any questions\n"
|
||||
"sanitize arguments:\n"
|
||||
"-a operation operation mode: overwrite, block, crypto or exitfailure\n"
|
||||
"-c passes overwrite passes to perform (1 to 31)\n"
|
||||
"-I invert overwrite pattern after each pass\n"
|
||||
"-P pattern path to overwrite pattern file\n"
|
||||
"-q be quiet, don't print status messages\n"
|
||||
"-r run in report only mode\n"
|
||||
"-U run operation in unrestricted completion exit mode\n"
|
||||
"-w don't send immediate sanitize command\n"
|
||||
"-y don't ask any questions\n"
|
||||
"idle/standby arguments:\n"
|
||||
"-t <arg> number of seconds before respective state.\n"
|
||||
"fwdownload arguments:\n"
|
||||
@ -7860,6 +8276,10 @@ main(int argc, char **argv)
|
||||
arglist & CAM_ARG_VERBOSE, retry_count, timeout,
|
||||
get_disk_type(cam_dev));
|
||||
break;
|
||||
case CAM_CMD_SANITIZE:
|
||||
error = scsisanitize(cam_dev, argc, argv,
|
||||
combinedopt, retry_count, timeout);
|
||||
break;
|
||||
#endif /* MINIMALISTIC */
|
||||
case CAM_CMD_USAGE:
|
||||
usage(1);
|
||||
|
@ -77,6 +77,7 @@ typedef enum {
|
||||
VENDOR_PLEXTOR,
|
||||
VENDOR_QUALSTAR,
|
||||
VENDOR_QUANTUM,
|
||||
VENDOR_SAMSUNG,
|
||||
VENDOR_SEAGATE,
|
||||
VENDOR_UNKNOWN
|
||||
} fw_vendor_t;
|
||||
@ -98,6 +99,7 @@ static const struct fw_vendor vendors_list[] = {
|
||||
{VENDOR_PLEXTOR, "PLEXTOR", 0x2000, 0x04, 0x05, 0, 1},
|
||||
{VENDOR_QUALSTAR, "QUALSTAR", 0x2030, 0x05, 0x05, 0, 0},
|
||||
{VENDOR_QUANTUM, "QUANTUM", 0x2000, 0x04, 0x05, 0, 1},
|
||||
{VENDOR_SAMSUNG, "SAMSUNG", 0x8000, 0x07, 0x07, 0, 1},
|
||||
{VENDOR_SEAGATE, "SEAGATE", 0x8000, 0x07, 0x07, 0, 1},
|
||||
/* the next 2 are SATA disks going through SAS HBA */
|
||||
{VENDOR_SEAGATE, "ATA ST", 0x8000, 0x07, 0x07, 0, 1},
|
||||
|
@ -43,6 +43,8 @@
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/capability.h>
|
||||
|
||||
#include "dhcpd.h"
|
||||
#include "privsep.h"
|
||||
#include <sys/capability.h>
|
||||
@ -132,6 +134,7 @@ int dhcp_bpf_wfilter_len = sizeof(dhcp_bpf_wfilter) / sizeof(struct bpf_insn);
|
||||
void
|
||||
if_register_send(struct interface_info *info)
|
||||
{
|
||||
cap_rights_t rights;
|
||||
struct bpf_version v;
|
||||
struct bpf_program p;
|
||||
int sock, on = 1;
|
||||
@ -160,7 +163,8 @@ if_register_send(struct interface_info *info)
|
||||
if (ioctl(info->wfdesc, BIOCLOCK, NULL) < 0)
|
||||
error("Cannot lock bpf");
|
||||
|
||||
if (cap_rights_limit(info->wfdesc, CAP_WRITE) < 0 && errno != ENOSYS)
|
||||
cap_rights_init(&rights, CAP_WRITE);
|
||||
if (cap_rights_limit(info->wfdesc, &rights) < 0 && errno != ENOSYS)
|
||||
error("Can't limit bpf descriptor: %m");
|
||||
|
||||
/*
|
||||
@ -213,6 +217,7 @@ void
|
||||
if_register_receive(struct interface_info *info)
|
||||
{
|
||||
static const unsigned long cmds[2] = { SIOCGIFFLAGS, SIOCGIFMEDIA };
|
||||
cap_rights_t rights;
|
||||
struct bpf_version v;
|
||||
struct bpf_program p;
|
||||
int flag = 1, sz;
|
||||
@ -264,10 +269,9 @@ if_register_receive(struct interface_info *info)
|
||||
if (ioctl(info->rfdesc, BIOCLOCK, NULL) < 0)
|
||||
error("Cannot lock bpf");
|
||||
|
||||
if (cap_rights_limit(info->rfdesc,
|
||||
CAP_IOCTL | CAP_POLL_EVENT | CAP_READ) < 0 && errno != ENOSYS) {
|
||||
cap_rights_init(&rights, CAP_IOCTL, CAP_POLL_EVENT, CAP_READ);
|
||||
if (cap_rights_limit(info->rfdesc, &rights) < 0 && errno != ENOSYS)
|
||||
error("Can't limit bpf descriptor: %m");
|
||||
}
|
||||
if (cap_ioctls_limit(info->rfdesc, cmds, 2) < 0 && errno != ENOSYS)
|
||||
error("Can't limit ioctls for bpf descriptor: %m");
|
||||
}
|
||||
|
@ -56,6 +56,8 @@
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/capability.h>
|
||||
|
||||
#include "dhcpd.h"
|
||||
#include "privsep.h"
|
||||
|
||||
@ -346,6 +348,7 @@ main(int argc, char *argv[])
|
||||
int immediate_daemon = 0;
|
||||
struct passwd *pw;
|
||||
pid_t otherpid;
|
||||
cap_rights_t rights;
|
||||
|
||||
/* Initially, log errors to stderr as well as to syslogd. */
|
||||
openlog(__progname, LOG_PID | LOG_NDELAY, DHCPD_LOG_FACILITY);
|
||||
@ -477,10 +480,9 @@ main(int argc, char *argv[])
|
||||
|
||||
close(pipe_fd[0]);
|
||||
privfd = pipe_fd[1];
|
||||
if (cap_rights_limit(privfd, CAP_READ | CAP_WRITE) < 0 &&
|
||||
errno != ENOSYS) {
|
||||
cap_rights_init(&rights, CAP_READ, CAP_WRITE);
|
||||
if (cap_rights_limit(privfd, &rights) < 0 && errno != ENOSYS)
|
||||
error("can't limit private descriptor: %m");
|
||||
}
|
||||
|
||||
if ((fd = open(path_dhclient_db, O_RDONLY|O_EXLOCK|O_CREAT, 0)) == -1)
|
||||
error("can't open and lock %s: %m", path_dhclient_db);
|
||||
@ -492,10 +494,9 @@ main(int argc, char *argv[])
|
||||
add_protocol("AF_ROUTE", routefd, routehandler, ifi);
|
||||
if (shutdown(routefd, SHUT_WR) < 0)
|
||||
error("can't shutdown route socket: %m");
|
||||
if (cap_rights_limit(routefd, CAP_POLL_EVENT | CAP_READ) < 0 &&
|
||||
errno != ENOSYS) {
|
||||
cap_rights_init(&rights, CAP_POLL_EVENT, CAP_READ);
|
||||
if (cap_rights_limit(routefd, &rights) < 0 && errno != ENOSYS)
|
||||
error("can't limit route socket: %m");
|
||||
}
|
||||
|
||||
if (chroot(_PATH_VAREMPTY) == -1)
|
||||
error("chroot");
|
||||
@ -1840,13 +1841,15 @@ void
|
||||
rewrite_client_leases(void)
|
||||
{
|
||||
struct client_lease *lp;
|
||||
cap_rights_t rights;
|
||||
|
||||
if (!leaseFile) {
|
||||
leaseFile = fopen(path_dhclient_db, "w");
|
||||
if (!leaseFile)
|
||||
error("can't create %s: %m", path_dhclient_db);
|
||||
if (cap_rights_limit(fileno(leaseFile), CAP_FSTAT | CAP_FSYNC |
|
||||
CAP_FTRUNCATE | CAP_SEEK | CAP_WRITE) < 0 &&
|
||||
cap_rights_init(&rights, CAP_FSTAT, CAP_FSYNC, CAP_FTRUNCATE,
|
||||
CAP_SEEK, CAP_WRITE);
|
||||
if (cap_rights_limit(fileno(leaseFile), &rights) < 0 &&
|
||||
errno != ENOSYS) {
|
||||
error("can't limit lease descriptor: %m");
|
||||
}
|
||||
@ -2354,6 +2357,7 @@ void
|
||||
go_daemon(void)
|
||||
{
|
||||
static int state = 0;
|
||||
cap_rights_t rights;
|
||||
|
||||
if (no_daemon || state)
|
||||
return;
|
||||
@ -2366,9 +2370,11 @@ go_daemon(void)
|
||||
if (daemon(1, 0) == -1)
|
||||
error("daemon");
|
||||
|
||||
cap_rights_init(&rights);
|
||||
|
||||
if (pidfile != NULL) {
|
||||
pidfile_write(pidfile);
|
||||
if (cap_rights_limit(pidfile_fileno(pidfile), CAP_NONE) < 0 &&
|
||||
if (cap_rights_limit(pidfile_fileno(pidfile), &rights) < 0 &&
|
||||
errno != ENOSYS) {
|
||||
error("can't limit pidfile descriptor: %m");
|
||||
}
|
||||
@ -2383,11 +2389,12 @@ go_daemon(void)
|
||||
nullfd = -1;
|
||||
}
|
||||
|
||||
if (cap_rights_limit(STDIN_FILENO, CAP_NONE) < 0 && errno != ENOSYS)
|
||||
if (cap_rights_limit(STDIN_FILENO, &rights) < 0 && errno != ENOSYS)
|
||||
error("can't limit stdin: %m");
|
||||
if (cap_rights_limit(STDOUT_FILENO, CAP_WRITE) < 0 && errno != ENOSYS)
|
||||
cap_rights_init(&rights, CAP_WRITE);
|
||||
if (cap_rights_limit(STDOUT_FILENO, &rights) < 0 && errno != ENOSYS)
|
||||
error("can't limit stdout: %m");
|
||||
if (cap_rights_limit(STDERR_FILENO, CAP_WRITE) < 0 && errno != ENOSYS)
|
||||
if (cap_rights_limit(STDERR_FILENO, &rights) < 0 && errno != ENOSYS)
|
||||
error("can't limit stderr: %m");
|
||||
}
|
||||
|
||||
|
@ -231,6 +231,7 @@ drop_privs(const struct hast_resource *res)
|
||||
pjdlog_common(LOG_DEBUG, 1, errno,
|
||||
"Unable to sandbox using capsicum");
|
||||
} else if (res != NULL) {
|
||||
cap_rights_t rights;
|
||||
static const unsigned long geomcmds[] = {
|
||||
DIOCGDELETE,
|
||||
DIOCGFLUSH
|
||||
@ -239,8 +240,9 @@ drop_privs(const struct hast_resource *res)
|
||||
PJDLOG_ASSERT(res->hr_role == HAST_ROLE_PRIMARY ||
|
||||
res->hr_role == HAST_ROLE_SECONDARY);
|
||||
|
||||
if (cap_rights_limit(res->hr_localfd,
|
||||
CAP_FLOCK | CAP_IOCTL | CAP_PREAD | CAP_PWRITE) == -1) {
|
||||
cap_rights_init(&rights, CAP_FLOCK, CAP_IOCTL, CAP_PREAD,
|
||||
CAP_PWRITE);
|
||||
if (cap_rights_limit(res->hr_localfd, &rights) == -1) {
|
||||
pjdlog_errno(LOG_ERR,
|
||||
"Unable to limit capability rights on local descriptor");
|
||||
}
|
||||
@ -258,7 +260,8 @@ drop_privs(const struct hast_resource *res)
|
||||
G_GATE_CMD_DESTROY
|
||||
};
|
||||
|
||||
if (cap_rights_limit(res->hr_ggatefd, CAP_IOCTL) == -1) {
|
||||
cap_rights_init(&rights, CAP_IOCTL);
|
||||
if (cap_rights_limit(res->hr_ggatefd, &rights) == -1) {
|
||||
pjdlog_errno(LOG_ERR,
|
||||
"Unable to limit capability rights to CAP_IOCTL on ggate descriptor");
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user