1994-05-26 05:23:31 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1980, 1993
|
|
|
|
* The Regents of the University of California. 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.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef lint
|
1997-09-15 06:37:10 +00:00
|
|
|
static const char copyright[] =
|
1994-05-26 05:23:31 +00:00
|
|
|
"@(#) Copyright (c) 1980, 1993\n\
|
|
|
|
The Regents of the University of California. All rights reserved.\n";
|
|
|
|
#endif /* not lint */
|
|
|
|
|
|
|
|
#ifndef lint
|
1997-09-15 06:37:10 +00:00
|
|
|
#if 0
|
1994-05-26 05:23:31 +00:00
|
|
|
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93";
|
1997-09-15 06:37:10 +00:00
|
|
|
#endif
|
|
|
|
static const char rcsid[] =
|
1999-04-10 14:03:38 +00:00
|
|
|
"$Id: main.c,v 1.27 1999/04/07 09:27:56 grog Exp $";
|
1994-05-26 05:23:31 +00:00
|
|
|
#endif /* not lint */
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/file.h>
|
1996-01-12 08:57:10 +00:00
|
|
|
#include <sys/mman.h>
|
1994-05-26 05:23:31 +00:00
|
|
|
#include <ctype.h>
|
1996-01-12 08:57:10 +00:00
|
|
|
#include <err.h>
|
1997-09-15 06:37:10 +00:00
|
|
|
#include <stdio.h>
|
1996-01-12 08:57:10 +00:00
|
|
|
#include <sysexits.h>
|
1997-09-15 06:37:10 +00:00
|
|
|
#include <unistd.h>
|
1996-06-02 17:22:01 +00:00
|
|
|
#include "y.tab.h"
|
1994-05-26 05:23:31 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
1995-02-22 15:37:32 +00:00
|
|
|
#ifndef TRUE
|
|
|
|
#define TRUE (1)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef FALSE
|
|
|
|
#define FALSE (0)
|
|
|
|
#endif
|
|
|
|
|
1998-02-18 04:15:04 +00:00
|
|
|
char *PREFIX;
|
|
|
|
static int no_config_clobber = TRUE;
|
1995-12-11 10:52:34 +00:00
|
|
|
int old_config_present;
|
1994-05-26 05:23:31 +00:00
|
|
|
|
1997-09-15 06:37:10 +00:00
|
|
|
static void usage __P((void));
|
|
|
|
void configfile __P((void));
|
|
|
|
|
1994-05-26 05:23:31 +00:00
|
|
|
/*
|
|
|
|
* Config builds a set of files for building a UNIX
|
|
|
|
* system given a description of the desired system.
|
|
|
|
*/
|
1997-09-15 06:37:10 +00:00
|
|
|
int
|
1994-05-26 05:23:31 +00:00
|
|
|
main(argc, argv)
|
|
|
|
int argc;
|
|
|
|
char **argv;
|
|
|
|
{
|
|
|
|
|
|
|
|
struct stat buf;
|
|
|
|
int ch;
|
|
|
|
char *p;
|
|
|
|
|
1999-04-07 09:28:03 +00:00
|
|
|
debugging = 1; /* on by default */
|
|
|
|
while ((ch = getopt(argc, argv, "gprns")) != -1)
|
1994-05-26 05:23:31 +00:00
|
|
|
switch (ch) {
|
|
|
|
case 'g':
|
1999-04-07 09:28:03 +00:00
|
|
|
fprintf(stderr,
|
|
|
|
"Debugging is enabled by default, there is "
|
|
|
|
"no need to specify the -g option\n" );
|
1994-05-26 05:23:31 +00:00
|
|
|
break;
|
|
|
|
case 'p':
|
|
|
|
profiling++;
|
|
|
|
break;
|
1998-02-19 00:45:33 +00:00
|
|
|
case 'n':
|
|
|
|
/* no_config_clobber is now true by default, no-op */
|
1998-03-16 11:19:10 +00:00
|
|
|
fprintf(stderr,
|
|
|
|
"*** Using obsolete config option '-n' ***\n");
|
1998-02-19 00:45:33 +00:00
|
|
|
break;
|
1998-02-18 04:15:04 +00:00
|
|
|
case 'r':
|
|
|
|
no_config_clobber = FALSE;
|
1995-02-22 15:37:32 +00:00
|
|
|
break;
|
1999-04-07 09:28:03 +00:00
|
|
|
case 's':
|
|
|
|
debugging = 0;
|
|
|
|
break;
|
1994-05-26 05:23:31 +00:00
|
|
|
case '?':
|
|
|
|
default:
|
1997-09-15 06:37:10 +00:00
|
|
|
usage();
|
1994-05-26 05:23:31 +00:00
|
|
|
}
|
|
|
|
argc -= optind;
|
|
|
|
argv += optind;
|
|
|
|
|
1997-09-15 06:37:10 +00:00
|
|
|
if (argc != 1)
|
|
|
|
usage();
|
1994-05-26 05:23:31 +00:00
|
|
|
|
1999-04-07 09:28:03 +00:00
|
|
|
if (debugging)
|
|
|
|
printf("Building kernel with full debugging symbols. Do\n"
|
|
|
|
"\"config -s %s\" "
|
|
|
|
"for historic partial symbolic support.\n"
|
|
|
|
"To install the debugging kernel, do "
|
|
|
|
"make install.debug\n",
|
|
|
|
argv [0] );
|
|
|
|
|
1997-09-15 06:37:10 +00:00
|
|
|
if (freopen(PREFIX = *argv, "r", stdin) == NULL)
|
|
|
|
err(2, "%s", PREFIX);
|
1995-02-22 15:37:32 +00:00
|
|
|
|
1994-09-03 21:23:36 +00:00
|
|
|
p = path((char *)NULL);
|
|
|
|
if (stat(p, &buf)) {
|
1997-09-15 06:37:10 +00:00
|
|
|
if (mkdir(p, 0777))
|
|
|
|
err(2, "%s", p);
|
1994-05-26 05:23:31 +00:00
|
|
|
}
|
|
|
|
else if ((buf.st_mode & S_IFMT) != S_IFDIR) {
|
1997-09-15 06:37:10 +00:00
|
|
|
errx(2, "%s isn't a directory", p);
|
1994-05-26 05:23:31 +00:00
|
|
|
}
|
1995-02-22 15:37:32 +00:00
|
|
|
else if (!no_config_clobber) {
|
1994-09-03 21:23:36 +00:00
|
|
|
char tmp[strlen(p) + 8];
|
|
|
|
|
|
|
|
fprintf(stderr, "Removing old directory %s: ", p);
|
|
|
|
fflush(stderr);
|
|
|
|
sprintf(tmp, "rm -rf %s", p);
|
|
|
|
if (system(tmp)) {
|
|
|
|
fprintf(stderr, "Failed!\n");
|
1997-09-15 06:37:10 +00:00
|
|
|
err(2, "%s", tmp);
|
1994-09-03 21:23:36 +00:00
|
|
|
}
|
|
|
|
fprintf(stderr, "Done.\n");
|
1997-09-15 06:37:10 +00:00
|
|
|
if (mkdir(p, 0777))
|
|
|
|
err(2, "%s", p);
|
1994-09-03 21:23:36 +00:00
|
|
|
}
|
1995-12-11 10:52:34 +00:00
|
|
|
else
|
1998-02-18 04:15:04 +00:00
|
|
|
old_config_present = 1;
|
1995-12-11 10:52:34 +00:00
|
|
|
|
1994-05-26 13:24:02 +00:00
|
|
|
loadaddress = -1;
|
1994-05-26 05:23:31 +00:00
|
|
|
dtab = NULL;
|
|
|
|
confp = &conf_list;
|
|
|
|
compp = &comp_list;
|
|
|
|
if (yyparse())
|
|
|
|
exit(3);
|
|
|
|
switch (machine) {
|
|
|
|
|
|
|
|
case MACHINE_VAX:
|
|
|
|
vax_ioconf(); /* Print ioconf.c */
|
|
|
|
ubglue(); /* Create ubglue.s */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MACHINE_TAHOE:
|
|
|
|
tahoe_ioconf();
|
|
|
|
vbglue();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MACHINE_HP300:
|
|
|
|
case MACHINE_LUNA68K:
|
|
|
|
hp300_ioconf();
|
|
|
|
hpglue();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MACHINE_I386:
|
1998-05-02 01:57:39 +00:00
|
|
|
case MACHINE_PC98:
|
1994-05-26 05:23:31 +00:00
|
|
|
i386_ioconf(); /* Print ioconf.c */
|
|
|
|
vector(); /* Create vector.s */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MACHINE_MIPS:
|
|
|
|
case MACHINE_PMAX:
|
|
|
|
pmax_ioconf();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MACHINE_NEWS3400:
|
|
|
|
news_ioconf();
|
|
|
|
break;
|
|
|
|
|
1998-06-09 14:02:08 +00:00
|
|
|
case MACHINE_ALPHA:
|
|
|
|
alpha_ioconf();
|
|
|
|
break;
|
|
|
|
|
1994-05-26 05:23:31 +00:00
|
|
|
default:
|
|
|
|
printf("Specify machine type, e.g. ``machine vax''\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* make symbolic links in compilation directory
|
|
|
|
* for "sys" (to make genassym.c work along with #include <sys/xxx>)
|
|
|
|
* and similarly for "machine".
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
char xxx[80];
|
|
|
|
|
1998-02-18 04:15:04 +00:00
|
|
|
(void) snprintf(xxx, sizeof(xxx), "../../%s/include", machinename);
|
1994-05-26 05:23:31 +00:00
|
|
|
(void) symlink(xxx, path("machine"));
|
|
|
|
}
|
1995-12-11 10:52:34 +00:00
|
|
|
options(); /* make options .h files */
|
1994-05-26 05:23:31 +00:00
|
|
|
makefile(); /* build Makefile */
|
|
|
|
headers(); /* make a lot of .h files */
|
|
|
|
swapconf(); /* swap config files */
|
1996-06-08 23:27:16 +00:00
|
|
|
configfile(); /* put config file into kernel*/
|
1995-05-03 20:16:57 +00:00
|
|
|
printf("Kernel build directory is %s\n", p);
|
1994-05-26 05:23:31 +00:00
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
1997-09-15 06:37:10 +00:00
|
|
|
static void
|
|
|
|
usage()
|
|
|
|
{
|
1999-04-10 14:03:38 +00:00
|
|
|
fprintf(stderr, "usage: config [-gprs] sysname\n");
|
1997-09-15 06:37:10 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
1994-05-26 05:23:31 +00:00
|
|
|
/*
|
|
|
|
* get_word
|
|
|
|
* returns EOF on end of file
|
|
|
|
* NULL on end of line
|
|
|
|
* pointer to the word otherwise
|
|
|
|
*/
|
|
|
|
char *
|
|
|
|
get_word(fp)
|
|
|
|
register FILE *fp;
|
|
|
|
{
|
|
|
|
static char line[80];
|
|
|
|
register int ch;
|
|
|
|
register char *cp;
|
1994-11-17 20:30:01 +00:00
|
|
|
int escaped_nl = 0;
|
1994-05-26 05:23:31 +00:00
|
|
|
|
1994-11-17 20:30:01 +00:00
|
|
|
begin:
|
1994-05-26 05:23:31 +00:00
|
|
|
while ((ch = getc(fp)) != EOF)
|
|
|
|
if (ch != ' ' && ch != '\t')
|
|
|
|
break;
|
|
|
|
if (ch == EOF)
|
|
|
|
return ((char *)EOF);
|
1994-11-17 20:30:01 +00:00
|
|
|
if (ch == '\\'){
|
|
|
|
escaped_nl = 1;
|
|
|
|
goto begin;
|
|
|
|
}
|
1994-05-26 05:23:31 +00:00
|
|
|
if (ch == '\n')
|
1994-11-17 20:30:01 +00:00
|
|
|
if (escaped_nl){
|
|
|
|
escaped_nl = 0;
|
|
|
|
goto begin;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return (NULL);
|
1994-05-26 05:23:31 +00:00
|
|
|
cp = line;
|
|
|
|
*cp++ = ch;
|
|
|
|
while ((ch = getc(fp)) != EOF) {
|
|
|
|
if (isspace(ch))
|
|
|
|
break;
|
|
|
|
*cp++ = ch;
|
|
|
|
}
|
|
|
|
*cp = 0;
|
|
|
|
if (ch == EOF)
|
|
|
|
return ((char *)EOF);
|
|
|
|
(void) ungetc(ch, fp);
|
|
|
|
return (line);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* get_quoted_word
|
|
|
|
* like get_word but will accept something in double or single quotes
|
|
|
|
* (to allow embedded spaces).
|
|
|
|
*/
|
|
|
|
char *
|
|
|
|
get_quoted_word(fp)
|
|
|
|
register FILE *fp;
|
|
|
|
{
|
|
|
|
static char line[256];
|
|
|
|
register int ch;
|
|
|
|
register char *cp;
|
1994-11-17 20:30:01 +00:00
|
|
|
int escaped_nl = 0;
|
1994-05-26 05:23:31 +00:00
|
|
|
|
1994-11-17 20:30:01 +00:00
|
|
|
begin:
|
1994-05-26 05:23:31 +00:00
|
|
|
while ((ch = getc(fp)) != EOF)
|
|
|
|
if (ch != ' ' && ch != '\t')
|
|
|
|
break;
|
|
|
|
if (ch == EOF)
|
|
|
|
return ((char *)EOF);
|
1994-11-17 20:30:01 +00:00
|
|
|
if (ch == '\\'){
|
|
|
|
escaped_nl = 1;
|
|
|
|
goto begin;
|
|
|
|
}
|
1994-05-26 05:23:31 +00:00
|
|
|
if (ch == '\n')
|
1994-11-17 20:30:01 +00:00
|
|
|
if (escaped_nl){
|
|
|
|
escaped_nl = 0;
|
|
|
|
goto begin;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return (NULL);
|
1994-05-26 05:23:31 +00:00
|
|
|
cp = line;
|
|
|
|
if (ch == '"' || ch == '\'') {
|
|
|
|
register int quote = ch;
|
|
|
|
|
|
|
|
while ((ch = getc(fp)) != EOF) {
|
|
|
|
if (ch == quote)
|
|
|
|
break;
|
|
|
|
if (ch == '\n') {
|
|
|
|
*cp = 0;
|
|
|
|
printf("config: missing quote reading `%s'\n",
|
|
|
|
line);
|
|
|
|
exit(2);
|
|
|
|
}
|
|
|
|
*cp++ = ch;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
*cp++ = ch;
|
|
|
|
while ((ch = getc(fp)) != EOF) {
|
|
|
|
if (isspace(ch))
|
|
|
|
break;
|
|
|
|
*cp++ = ch;
|
|
|
|
}
|
|
|
|
if (ch != EOF)
|
|
|
|
(void) ungetc(ch, fp);
|
|
|
|
}
|
|
|
|
*cp = 0;
|
|
|
|
if (ch == EOF)
|
|
|
|
return ((char *)EOF);
|
|
|
|
return (line);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* prepend the path to a filename
|
|
|
|
*/
|
|
|
|
char *
|
|
|
|
path(file)
|
|
|
|
char *file;
|
|
|
|
{
|
|
|
|
register char *cp;
|
|
|
|
|
|
|
|
#define CDIR "../../compile/"
|
|
|
|
cp = malloc((unsigned int)(sizeof(CDIR) + strlen(PREFIX) +
|
|
|
|
(file ? strlen(file) : 0) + 2));
|
|
|
|
(void) strcpy(cp, CDIR);
|
|
|
|
(void) strcat(cp, PREFIX);
|
|
|
|
if (file) {
|
|
|
|
(void) strcat(cp, "/");
|
|
|
|
(void) strcat(cp, file);
|
|
|
|
}
|
|
|
|
return (cp);
|
|
|
|
}
|
1996-01-12 08:57:10 +00:00
|
|
|
|
1997-09-15 06:37:10 +00:00
|
|
|
void
|
1996-06-08 23:27:16 +00:00
|
|
|
configfile()
|
|
|
|
{
|
|
|
|
FILE *fi, *fo;
|
|
|
|
char *p;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
fi = fopen(PREFIX,"r");
|
1997-09-15 06:37:10 +00:00
|
|
|
if(!fi)
|
|
|
|
err(2, "%s", PREFIX);
|
1996-12-26 23:40:32 +00:00
|
|
|
fo = fopen(p=path("config.c.new"),"w");
|
1997-09-15 06:37:10 +00:00
|
|
|
if(!fo)
|
|
|
|
err(2, "%s", p);
|
1996-12-26 23:40:32 +00:00
|
|
|
fprintf(fo,"#include \"opt_config.h\"\n");
|
1996-06-08 23:27:16 +00:00
|
|
|
fprintf(fo,"#ifdef INCLUDE_CONFIG_FILE \n");
|
1998-12-10 02:35:55 +00:00
|
|
|
fprintf(fo,"static const char config[] = \"\\\n");
|
1998-04-23 16:37:06 +00:00
|
|
|
fprintf(fo,"START CONFIG FILE %s\\n\\\n___",PREFIX);
|
1996-06-08 23:27:16 +00:00
|
|
|
while (EOF != (i=getc(fi))) {
|
|
|
|
if(i == '\n') {
|
1998-04-23 16:37:06 +00:00
|
|
|
fprintf(fo,"\\n\\\n___");
|
1996-06-08 23:27:16 +00:00
|
|
|
} else if(i == '\"') {
|
|
|
|
fprintf(fo,"\\\"");
|
|
|
|
} else if(i == '\\') {
|
|
|
|
fprintf(fo,"\\\\");
|
|
|
|
} else {
|
|
|
|
putc(i,fo);
|
|
|
|
}
|
|
|
|
}
|
1998-04-23 16:37:06 +00:00
|
|
|
fprintf(fo,"\\n\\\nEND CONFIG FILE %s\\n\\\n",PREFIX);
|
1996-06-08 23:27:16 +00:00
|
|
|
fprintf(fo,"\";\n");
|
1996-12-26 23:40:32 +00:00
|
|
|
fprintf(fo,"\n#endif /* INCLUDE_CONFIG_FILE */\n");
|
1996-06-08 23:27:16 +00:00
|
|
|
fclose(fi);
|
|
|
|
fclose(fo);
|
1996-12-26 23:40:32 +00:00
|
|
|
moveifchanged(path("config.c.new"), path("config.c"));
|
1996-06-08 23:27:16 +00:00
|
|
|
}
|
|
|
|
|
1996-01-12 08:57:10 +00:00
|
|
|
/*
|
|
|
|
* moveifchanged --
|
|
|
|
* compare two files; rename if changed.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
moveifchanged(const char *from_name, const char *to_name)
|
|
|
|
{
|
|
|
|
char *p, *q;
|
|
|
|
int changed;
|
|
|
|
size_t tsize;
|
|
|
|
struct stat from_sb, to_sb;
|
|
|
|
int from_fd, to_fd;
|
|
|
|
|
|
|
|
changed = 0;
|
|
|
|
|
|
|
|
if ((from_fd = open(from_name, O_RDONLY)) < 0)
|
|
|
|
err(EX_OSERR, "moveifchanged open(%s)", from_name);
|
|
|
|
|
|
|
|
if ((to_fd = open(to_name, O_RDONLY)) < 0)
|
|
|
|
changed++;
|
|
|
|
|
|
|
|
if (!changed && fstat(from_fd, &from_sb) < 0)
|
|
|
|
err(EX_OSERR, "moveifchanged fstat(%s)", from_name);
|
|
|
|
|
|
|
|
if (!changed && fstat(to_fd, &to_sb) < 0)
|
|
|
|
err(EX_OSERR, "moveifchanged fstat(%s)", to_name);
|
|
|
|
|
|
|
|
if (!changed && from_sb.st_size != to_sb.st_size)
|
|
|
|
changed++;
|
|
|
|
|
|
|
|
tsize = (size_t)from_sb.st_size;
|
|
|
|
|
|
|
|
if (!changed) {
|
1997-01-16 21:58:40 +00:00
|
|
|
p = mmap(NULL, tsize, PROT_READ, MAP_SHARED, from_fd, (off_t)0);
|
1998-06-09 14:02:08 +00:00
|
|
|
#ifndef MAP_FAILED
|
|
|
|
#define MAP_FAILED ((caddr_t) -1)
|
|
|
|
#endif
|
1997-01-16 21:58:40 +00:00
|
|
|
if (p == MAP_FAILED)
|
1996-01-12 08:57:10 +00:00
|
|
|
err(EX_OSERR, "mmap %s", from_name);
|
1997-01-16 21:58:40 +00:00
|
|
|
q = mmap(NULL, tsize, PROT_READ, MAP_SHARED, to_fd, (off_t)0);
|
|
|
|
if (q == MAP_FAILED)
|
1996-01-12 08:57:10 +00:00
|
|
|
err(EX_OSERR, "mmap %s", to_name);
|
|
|
|
|
|
|
|
changed = memcmp(p, q, tsize);
|
|
|
|
munmap(p, tsize);
|
|
|
|
munmap(q, tsize);
|
|
|
|
}
|
|
|
|
if (changed) {
|
|
|
|
if (rename(from_name, to_name) < 0)
|
|
|
|
err(EX_OSERR, "rename(%s, %s)", from_name, to_name);
|
|
|
|
} else {
|
|
|
|
if (unlink(from_name) < 0)
|
1997-11-18 03:41:51 +00:00
|
|
|
err(EX_OSERR, "unlink(%s)", from_name);
|
1996-01-12 08:57:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DIAG
|
|
|
|
if (changed)
|
|
|
|
printf("CHANGED! rename (%s, %s)\n", from_name, to_name);
|
|
|
|
else
|
|
|
|
printf("SAME! unlink (%s)\n", from_name);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|