Clean up conflicts.

This commit is contained in:
David E. O'Brien 1998-11-14 03:13:33 +00:00
parent 4c5751da9f
commit e2ee784d30
7 changed files with 146 additions and 87 deletions

View file

@ -38,7 +38,7 @@
*
* %W% (Berkeley) %G%
*
* $Id: amd.c,v 1.1.1.1 1998/08/23 22:07:20 obrien Exp $
* $Id: amd.c,v 1.2 1998/08/23 22:52:08 obrien Exp $
*
*/
@ -57,8 +57,8 @@ struct amu_global_options gopt; /* where global options are stored */
char pid_fsname[16 + MAXHOSTNAMELEN]; /* "kiska.southseas.nz:(pid%d)" */
char *progname; /* "amd" */
char *hostdomain = "unknown.domain";
char hostname[MAXHOSTNAMELEN + 1] = "localhost"; /* Hostname */
char hostd[2 * MAXHOSTNAMELEN + 1]; /* Host+domain */
char hostname[MAXHOSTNAMELEN + 1] = "localhost"; /* Hostname */
char hostd[2 * MAXHOSTNAMELEN + 1]; /* Host+domain */
char *endian = ARCH_ENDIAN; /* Big or Little endian */
char *cpu = HOST_CPU; /* CPU type */
char *PrimNetName; /* name of primary network */

View file

@ -38,7 +38,7 @@
*
* %W% (Berkeley) %G%
*
* $Id: nfs_prot_freebsd3.h,v 1.2 1998/08/27 07:33:23 obrien Exp $
* $Id: nfs_prot_freebsd3.h,v 1.3 1998/09/09 16:11:01 obrien Exp $
*
*/
@ -153,13 +153,14 @@ typedef writeargs nfswriteargs;
/*
*
* FreeBSD 3.0 has NFS V3, but you need to regenrate the rpcsc header files
* as follows:
* FreeBSD 3.0 pre-release has NFS V3, but you need to regenrate the rpcsc
* header files as follows:
* cd /usr/local/rpcsvc
* rpcgen -DWANT_NFS3 mount.x
* rpcgen -DWANT_NFS3 nfs_prot.x
* But that's not expected of everyone, plus there are additional things
* needed so I define everything that's neede for NFS V3 here.
* needed so I define everything that's needed for NFS V3 here.
* The problem is fixed in FreeBSD-3.0-RELEASE hence this code is off.
*/
#ifdef NFSMNT_NFSV3

View file

@ -38,7 +38,7 @@
*
* %W% (Berkeley) %G%
*
* $Id: fixmount.c,v 1.1.1.1 1998/08/23 22:07:20 obrien Exp $
* $Id: fixmount.c,v 1.2 1998/08/23 22:52:08 obrien Exp $
*
*/
@ -354,7 +354,7 @@ main(int argc, char *argv[])
perror("gethostname");
exit(1);
}
thishost[sizeof(thishost) - 1] = '\0';
thishost[sizeof(thishost) - 1] = '\0';
/*
* We need the hostname as it appears to the other side's

View file

@ -38,7 +38,7 @@
*
* %W% (Berkeley) %G%
*
* $Id: hlfsd.c,v 1.1.1.1 1998/08/23 22:07:20 obrien Exp $
* $Id: hlfsd.c,v 1.2 1998/08/23 22:52:08 obrien Exp $
*
* HLFSD was written at Columbia University Computer Science Department, by
* Erez Zadok <ezk@cs.columbia.edu> and Alexander Dupuy <dupuy@cs.columbia.edu>
@ -308,7 +308,7 @@ main(int argc, char *argv[])
}
/* get hostname for logging and open log before we reset umask */
gethostname(hostname, sizeof hostname);
gethostname(hostname, sizeof(hostname));
hostname[sizeof(hostname) - 1] = '\0';
if ((dot = strchr(hostname, '.')) != NULL)
*dot = '\0';

View file

@ -38,7 +38,7 @@
*
* %W% (Berkeley) %G%
*
* $Id: am_defs.h,v 1.1.1.1 1998/08/23 22:07:20 obrien Exp $
* $Id: am_defs.h,v 1.2 1998/08/27 07:33:23 obrien Exp $
*
*/
@ -487,6 +487,18 @@ extern int errno;
/* conflicts with <statfsbuf.h> */
# define _SYS_STATFS_H
# endif /* HAVE_SOCKETBITS_H */
# ifdef HAVE_LINUX_POSIX_TYPES_H
# include <linux/posix_types.h>
# endif /* HAVE_LINUX_POSIX_TYPES_H */
# ifndef _LINUX_BYTEORDER_GENERIC_H
# define _LINUX_BYTEORDER_GENERIC_H
# endif /* _LINUX_BYTEORDER_GENERIC_H */
/* conflicts with <sys/mount.h> in 2.1 kernels */
# ifdef _SYS_MOUNT_H
# ifdef BLOCK_SIZE
# undef BLOCK_SIZE
# endif /* BLOCK_SIZE */
# endif /* _SYS_MOUNT_H */
# include <linux/fs.h>
#endif /* HAVE_LINUX_FS_H */

View file

@ -38,7 +38,7 @@
*
* %W% (Berkeley) %G%
*
* $Id: mk-amd-map.c,v 1.3 1998/08/27 02:56:47 obrien Exp $
* $Id: mk-amd-map.c,v 1.4 1998/08/27 07:25:25 obrien Exp $
*/
/*
@ -56,6 +56,11 @@ int orig_umask, foreground, debug_flags;
pid_t mypid;
serv_state amd_state;
/* (libdb version 2) uses .db extensions but an old dbm API */
/* check for libgdbm to distinguish it from linux systems */
#if defined(DBM_SUFFIX) && !defined(HAVE_LIBGDBM)
# define HAVE_DB_SUFFIX
#endif /* not defined(DBM_SUFFIX) && !defined(HAVE_LIBGDBM) */
#ifdef HAVE_MAP_NDBM
@ -118,7 +123,7 @@ read_file(FILE *fp, char *map, voidp db)
int line_no = 0;
int errs = 0;
while (read_line(key_val, sizeof(key_val), fp)) {
while (read_line(key_val, 2048, fp)) {
char *kp;
char *cp;
char *hash;
@ -212,14 +217,18 @@ remove_file(char *f)
int
main(int argc, char *argv[])
{
FILE *mapf;
int mapfd = -1;
char *map;
int rc = 0;
DBM *mapd = NULL;
FILE *mapf; /* the input file to read from */
int error;
char *mapsrc;
DBM *db = NULL;
static char maptmp[] = "dbmXXXXXX";
#ifdef HAVE_DB_SUFFIX
char maptdb[16];
char *mapdb = (char *) NULL;
char *map_name_db = (char *) NULL;
#else /* not HAVE_DB_SUFFIX */
char maptpag[16], maptdir[16];
char *map_name_pag = (char *) NULL, *map_name_dir = (char *) NULL;
#endif /* not HAVE_DB_SUFFIX */
int len;
char *sl;
int printit = 0;
@ -242,97 +251,134 @@ main(int argc, char *argv[])
fputs("Usage: mk-amd-map [-p] file-map\n", stderr);
exit(1);
}
map = argv[optind];
mapsrc = argv[optind];
/* test if can get to the map directory */
sl = strrchr(map, '/');
sl = strrchr(mapsrc, '/');
if (sl) {
*sl = '\0';
if (chdir(map) < 0) {
if (chdir(mapsrc) < 0) {
fputs("Can't chdir to ", stderr);
perror(map);
perror(mapsrc);
exit(1);
}
map = sl + 1;
mapsrc = sl + 1;
}
/* open source file */
mapf = fopen(mapsrc, "r");
if (!mapf) {
fprintf(stderr, "cannot open source file ");
perror(mapsrc);
exit(1);
}
#ifndef DEBUG
signal(SIGINT, SIG_IGN);
#endif /* DEBUG */
if (!printit) {
len = strlen(map);
mapdb = (char *) malloc(len + 4);
if (!mapdb) {
len = strlen(mapsrc);
#ifdef HAVE_DB_SUFFIX
map_name_db = (char *) malloc(len + 4);
error = (map_name_db == NULL);
#else /* not HAVE_DB_SUFFIX */
map_name_pag = (char *) malloc(len + 5);
map_name_dir = (char *) malloc(len + 5);
error = (map_name_pag == NULL || map_name_dir == NULL);
#endif /* not HAVE_DB_SUFFIX */
if (error) {
perror("mk-amd-map: malloc");
exit(1);
}
#ifdef HAVE_MKSTEMP
mapfd = mkstemp(maptmp);
#else /* not HAVE_MKSTEMP */
map = mktemp(maptmp);
if (!maptmp) {
fprintf(stderr, "cannot create temporary file\n");
exit(1);
}
mapfd = open(map, O_RDONLY);
#endif /* not HAVE_MKSTEMP */
/* open DBM files */
mktemp(maptmp);
/* remove existing temps (if any) */
#ifdef HAVE_DB_SUFFIX
sprintf(maptdb, "%s.db", maptmp);
if (remove_file(maptdb) < 0) {
fprintf(stderr, "Can't remove existing temporary files;");
fprintf(stderr, "Can't remove existing temporary file; ");
perror(maptdb);
exit(1);
}
}
/* open and check if map file was opened OK */
mapf = fdopen(mapfd, "r");
if (mapf && !printit)
mapd = dbm_open(maptmp, O_RDWR|O_CREAT, 0444);
else
mapd = 0;
#ifndef DEBUG
/* ignore ^C if debuggung is on (but why?) */
signal(SIGINT, SIG_IGN);
#endif /* not DEBUG */
if (mapd || printit) {
int error = read_file(mapf, map, mapd);
(void) close(mapfd);
(void) fclose(mapf);
dbm_close(mapd);
if (printit) {
if (error) {
fprintf(stderr, "Error creating ndbm map for %s\n", map);
rc = 1;
}
} else {
if (error) {
fprintf(stderr, "Error reading source file %s\n", map);
rc = 1;
} else {
sprintf(mapdb, "%s.db", map);
if (unlink(mapdb) == 0)
fprintf(stderr, "WARNING: existing map \"%s.db\" destroyed\n", map);
if (rename(maptdb, mapdb) < 0) {
fprintf(stderr, "Couldn't rename %s to ", maptdb);
perror(mapdb);
/* Throw away the temporary map */
unlink(maptdb);
rc = 1;
}
}
#else /* not HAVE_DB_SUFFIX */
sprintf(maptpag, "%s.pag", maptmp);
sprintf(maptdir, "%s.dir", maptmp);
if (remove_file(maptpag) < 0 || remove_file(maptdir) < 0) {
fprintf(stderr, "Can't remove existing temporary files; %s and ", maptpag);
perror(maptdir);
exit(1);
}
#endif /* not HAVE_DB_SUFFIX */
} else {
fprintf(stderr, "Can't open \"%s.db\" for ", map);
perror("writing");
rc = 1;
db = dbm_open(maptmp, O_RDWR|O_CREAT, 0444);
if (!db) {
fprintf(stderr, "cannot initialize temporary database: %s", maptmp);
exit(1);
}
}
exit(rc);
/* print db to stdout or to temp database */
error = read_file(mapf, mapsrc, db);
fclose(mapf);
if (error) {
if (printit)
fprintf(stderr, "Error reading source file %s\n", mapsrc);
else
fprintf(stderr, "Error creating database map for %s\n", mapsrc);
exit(1);
}
if (printit)
exit(0); /* nothing more to do */
/* if gets here, we wrote to a database */
dbm_close(db);
/* all went well */
#ifdef HAVE_DB_SUFFIX
sprintf(map_name_db, "%s.db", mapsrc);
if (rename(maptdb, map_name_db) < 0) {
fprintf(stderr, "Couldn't rename %s to ", maptdb);
perror(map_name_db);
/* Throw away the temporary map */
unlink(maptdb);
exit(1);
}
#else /* not HAVE_DB_SUFFIX */
sprintf(map_name_pag, "%s.pag", mapsrc);
sprintf(map_name_dir, "%s.dir", mapsrc);
if (rename(maptpag, map_name_pag) < 0) {
fprintf(stderr, "Couldn't rename %s to ", maptpag);
perror(map_name_pag);
/* Throw away the temporary map */
unlink(maptpag);
unlink(maptdir);
exit(1);
}
if (rename(maptdir, map_name_dir) < 0) {
fprintf(stderr, "Couldn't rename %s to ", maptdir);
perror(map_name_dir);
/* remove the (presumably bad) .pag file */
unlink(map_name_pag);
/* throw away remaining part of original map */
unlink(map_name_dir);
/* throw away the temporary map */
unlink(maptdir);
fprintf(stderr, "WARNING: existing map \"%s.{dir,pag}\" destroyed\n",
mapsrc);
exit(1);
}
#endif /* not HAVE_DB_SUFFIX */
exit(0);
}
#else /* not HAVE_MAP_NDBM */
int
main()
{
fputs("mk-amd-map: This system does not support hashed database files\n", stderr);

View file

@ -38,7 +38,7 @@
*
* %W% (Berkeley) %G%
*
* $Id: wire-test.c,v 1.1.1.1 1998/08/23 22:07:21 obrien Exp $
* $Id: wire-test.c,v 1.2 1998/08/23 22:52:09 obrien Exp $
*
*/
@ -69,7 +69,7 @@ main(int argc, char **argv)
mypid = getpid();
orig_umask = umask(0);
if (gethostname(hostname, sizeof hostname) < 0) {
if (gethostname(hostname, sizeof(hostname)) < 0) {
perror(argv[0]);
exit(1);
}