about summary refs log tree commit diff
path: root/db2/progs
diff options
context:
space:
mode:
Diffstat (limited to 'db2/progs')
-rw-r--r--db2/progs/db_checkpoint/db_checkpoint.c5
-rw-r--r--db2/progs/db_deadlock/db_deadlock.c4
-rw-r--r--db2/progs/db_load/db_load.c55
-rw-r--r--db2/progs/db_printlog/db_printlog.c5
-rw-r--r--db2/progs/db_recover/db_recover.c4
-rw-r--r--db2/progs/db_stat/db_stat.c19
6 files changed, 58 insertions, 34 deletions
diff --git a/db2/progs/db_checkpoint/db_checkpoint.c b/db2/progs/db_checkpoint/db_checkpoint.c
index b2a692bba9..3157a52666 100644
--- a/db2/progs/db_checkpoint/db_checkpoint.c
+++ b/db2/progs/db_checkpoint/db_checkpoint.c
@@ -11,7 +11,7 @@
 static const char copyright[] =
 "@(#) Copyright (c) 1997\n\
 	Sleepycat Software Inc.  All rights reserved.\n";
-static const char sccsid[] = "@(#)db_checkpoint.c	10.12 (Sleepycat) 9/4/97";
+static const char sccsid[] = "@(#)db_checkpoint.c	10.14 (Sleepycat) 1/17/98";
 #endif
 
 #ifndef NO_SYSTEM_INCLUDES
@@ -46,7 +46,6 @@ void	 siginit __P((void));
 void	 usage __P((void));
 
 int	 interrupted;
-time_t	 now;					/* Checkpoint time. */
 const char
 	*progname = "db_checkpoint";		/* Program name. */
 
@@ -203,7 +202,7 @@ logpid(fname, is_open)
 		}
 		(void)time(&now);
 		fprintf(fp,
-		    "%s: %lu %s", progname, (u_long)getpid(), ctime(&now));
+		    "%.24s: %lu %s", progname, (u_long)getpid(), ctime(&now));
 		fclose(fp);
 	} else
 		(void)remove(fname);
diff --git a/db2/progs/db_deadlock/db_deadlock.c b/db2/progs/db_deadlock/db_deadlock.c
index 473e5b9cb2..97fa8ca4f6 100644
--- a/db2/progs/db_deadlock/db_deadlock.c
+++ b/db2/progs/db_deadlock/db_deadlock.c
@@ -11,7 +11,7 @@
 static const char copyright[] =
 "@(#) Copyright (c) 1997\n\
 	Sleepycat Software Inc.  All rights reserved.\n";
-static const char sccsid[] = "@(#)db_deadlock.c	10.16 (Sleepycat) 10/14/97";
+static const char sccsid[] = "@(#)db_deadlock.c	10.17 (Sleepycat) 1/15/98";
 #endif
 
 #ifndef NO_SYSTEM_INCLUDES
@@ -192,7 +192,7 @@ logpid(fname, is_open)
 		}
 		(void)time(&now);
 		fprintf(fp,
-		    "%s: %lu %s", progname, (u_long)getpid(), ctime(&now));
+		    "%.24s: %lu %s", progname, (u_long)getpid(), ctime(&now));
 		fclose(fp);
 	} else
 		(void)remove(fname);
diff --git a/db2/progs/db_load/db_load.c b/db2/progs/db_load/db_load.c
index 6597f10e10..afa5730c25 100644
--- a/db2/progs/db_load/db_load.c
+++ b/db2/progs/db_load/db_load.c
@@ -11,7 +11,7 @@
 static const char copyright[] =
 "@(#) Copyright (c) 1997\n\
 	Sleepycat Software Inc.  All rights reserved.\n";
-static const char sccsid[] = "@(#)db_load.c	10.14 (Sleepycat) 10/19/97";
+static const char sccsid[] = "@(#)db_load.c	10.15 (Sleepycat) 12/29/97";
 #endif
 
 #ifndef NO_SYSTEM_INCLUDES
@@ -51,11 +51,11 @@ main(argc, argv)
 	extern int optind;
 	DB *dbp;
 	DBT key, data;
-	DBTYPE argtype, headertype;
+	DBTYPE argtype, dbtype;
 	DB_ENV *dbenv;
 	DB_INFO dbinfo;
 	db_recno_t recno;
-	int ch, pflag;
+	int ch, no_header, pflag;
 	char **clist, **clp, *home;
 
 	/* Allocate enough room for configuration arguments. */
@@ -63,8 +63,9 @@ main(argc, argv)
 		err(1, NULL);
 
 	home = NULL;
-	argtype = DB_UNKNOWN;
-	while ((ch = getopt(argc, argv, "c:f:h:t:")) != EOF)
+	no_header = 0;
+	argtype = dbtype = DB_UNKNOWN;
+	while ((ch = getopt(argc, argv, "c:f:h:Tt:")) != EOF)
 		switch (ch) {
 		case 'c':
 			*clp++ = optarg;
@@ -76,6 +77,9 @@ main(argc, argv)
 		case 'h':
 			home = optarg;
 			break;
+		case 'T':
+			no_header = pflag = 1;
+			break;
 		case 't':
 			if (strcmp(optarg, "btree") == 0) {
 				argtype = DB_BTREE;
@@ -85,6 +89,10 @@ main(argc, argv)
 				argtype = DB_HASH;
 				break;
 			}
+			if (strcmp(optarg, "recno") == 0) {
+				argtype = DB_RECNO;
+				break;
+			}
 			usage();
 			/* NOTREACHED */
 		case '?':
@@ -101,21 +109,31 @@ main(argc, argv)
 	dbenv = db_init(home);
 	memset(&dbinfo, 0, sizeof(DB_INFO));
 
-	/* Read the header. */
-	rheader(&headertype, &pflag, &dbinfo);
+	/*
+	 * Read the header.  If there isn't any header, we're expecting flat
+	 * text, set the pflag appropriately.
+	 */
+	if (no_header)
+		dbtype = argtype;
+	else {
+		rheader(&dbtype, &pflag, &dbinfo);
+		if (argtype != DB_UNKNOWN) {
+			/* Conversion to/from recno is prohibited. */
+			if ((dbtype == DB_RECNO && argtype != DB_RECNO) ||
+			    (argtype == DB_RECNO && dbtype != DB_RECNO))
+				errx(1,
+			    "databases of type recno may not be converted");
+			dbtype = argtype;
+		}
+	}
+	if (dbtype == DB_UNKNOWN)
+		errx(1, "no database type specified");
 
 	/* Apply command-line configuration changes. */
 	configure(&dbinfo, clist);
 
-	/* Conversion to/from recno is prohibited. */
-	if (argtype != DB_UNKNOWN) {
-		if (headertype == DB_RECNO)
-			errx(1, "databases of type recno may not be converted");
-		headertype = argtype;
-	}
-
 	/* Open the DB file. */
-	if ((errno = db_open(argv[0], headertype, DB_CREATE | DB_TRUNCATE,
+	if ((errno = db_open(argv[0], dbtype, DB_CREATE | DB_TRUNCATE,
 	    S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH,
 	    dbenv, &dbinfo, &dbp)) != 0)
 		err(1, "%s", argv[0]);
@@ -133,7 +151,7 @@ main(argc, argv)
 	}
 
 	/* Get each key/data pair and add them to the database. */
-	if (headertype == DB_RECNO) {
+	if (dbtype == DB_RECNO) {
 		key.data = &recno;
 		key.size = sizeof(recno);
 		for (recno = 1;; ++recno) {
@@ -273,8 +291,11 @@ rheader(dbtypep, pflagp, dbinfop)
 	*pflagp = 0;
 
 	for (lineno = 1;; ++lineno) {
+		/* If we don't see the expected information, it's an error. */
 		if (fscanf(stdin, "%[^=]=%s\n", name, value) != 2)
 			errx(1, "line %lu: unexpected format", lineno);
+
+		/* Check for the end of the header lines. */
 		if (strcmp(name, "HEADER") == 0)
 			break;
 
@@ -455,6 +476,6 @@ void
 usage()
 {
 	(void)fprintf(stderr,
-"usage: db_load [-c name=value] [-f file] [-h home] [-t btree | hash] db_file\n");
+"usage: db_load [-T]\n\t[-c name=value] [-f file] [-h home] [-t btree | hash] db_file\n");
 	exit(1);
 }
diff --git a/db2/progs/db_printlog/db_printlog.c b/db2/progs/db_printlog/db_printlog.c
index 6bbd118b1b..24554bcd14 100644
--- a/db2/progs/db_printlog/db_printlog.c
+++ b/db2/progs/db_printlog/db_printlog.c
@@ -11,7 +11,7 @@
 static const char copyright[] =
 "@(#) Copyright (c) 1997\n\
 	Sleepycat Software Inc.  All rights reserved.\n";
-static const char sccsid[] = "@(#)db_printlog.c	10.10 (Sleepycat) 8/27/97";
+static const char sccsid[] = "@(#)db_printlog.c	10.11 (Sleepycat) 1/8/98";
 #endif
 
 #ifndef NO_SYSTEM_INCLUDES
@@ -150,7 +150,8 @@ void
 onint(signo)
 	int signo;
 {
-	signo = 1;			/* XXX: Shut the compiler up. */
+	COMPQUIET(signo, 0);
+
 	interrupted = 1;
 }
 
diff --git a/db2/progs/db_recover/db_recover.c b/db2/progs/db_recover/db_recover.c
index 5a39d320f8..f902fed8c0 100644
--- a/db2/progs/db_recover/db_recover.c
+++ b/db2/progs/db_recover/db_recover.c
@@ -11,7 +11,7 @@
 static const char copyright[] =
 "@(#) Copyright (c) 1997\n\
 	Sleepycat Software Inc.  All rights reserved.\n";
-static const char sccsid[] = "@(#)db_recover.c	10.16 (Sleepycat) 10/28/97";
+static const char sccsid[] = "@(#)db_recover.c	10.17 (Sleepycat) 1/15/98";
 #endif
 
 #ifndef NO_SYSTEM_INCLUDES
@@ -73,7 +73,7 @@ main(argc, argv)
 
 	dbenv = db_init(home, flags, verbose);
 	if (verbose) {
-		__db_err(dbenv, "Recovery complete at %s", ctime(&now));
+		__db_err(dbenv, "Recovery complete at %.24s", ctime(&now));
 		__db_err(dbenv, "%s %lu %s [%lu][%lu]",
 		    "Maximum transaction id",
 		    (u_long)dbenv->tx_info->region->last_txnid,
diff --git a/db2/progs/db_stat/db_stat.c b/db2/progs/db_stat/db_stat.c
index b1f1615fa9..5295f011a6 100644
--- a/db2/progs/db_stat/db_stat.c
+++ b/db2/progs/db_stat/db_stat.c
@@ -11,7 +11,7 @@
 static const char copyright[] =
 "@(#) Copyright (c) 1997\n\
 	Sleepycat Software Inc.  All rights reserved.\n";
-static const char sccsid[] = "@(#)db_stat.c	8.26 (Sleepycat) 11/2/97";
+static const char sccsid[] = "@(#)db_stat.c	8.30 (Sleepycat) 1/8/98";
 #endif
 
 #ifndef NO_SYSTEM_INCLUDES
@@ -31,9 +31,6 @@ static const char sccsid[] = "@(#)db_stat.c	8.26 (Sleepycat) 11/2/97";
 
 #undef stat
 
-#define	MB	1048576
-#define	DIVIDER	"=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-="
-
 typedef enum { T_NOTSET, T_DB, T_LOG, T_MPOOL, T_TXN } test_t;
 
 void	btree_stats __P((DB *));
@@ -232,6 +229,8 @@ void
 hash_stats(dbp)
 	DB *dbp;
 {
+	COMPQUIET(dbp, NULL);
+
 	return;
 }
 
@@ -251,8 +250,9 @@ log_stats(dbenv)
 	printf("%#lx\tLog magic number.\n", (u_long)sp->st_magic);
 	printf("%lu\tLog version number.\n", (u_long)sp->st_version);
 	printf("%#o\tLog file mode.\n", sp->st_mode);
-	if (sp->st_lg_max % MB == 0)
-		printf("%luMb\tLog file size.\n", (u_long)sp->st_lg_max / MB);
+	if (sp->st_lg_max % MEGABYTE == 0)
+		printf("%luMb\tLog file size.\n",
+		    (u_long)sp->st_lg_max / MEGABYTE);
 	else if (sp->st_lg_max % 1024 == 0)
 		printf("%luKb\tLog file size.\n", (u_long)sp->st_lg_max / 1024);
 	else
@@ -263,6 +263,8 @@ log_stats(dbenv)
 	    (u_long)sp->st_wc_mbytes, (u_long)sp->st_wc_bytes);
 	printf("%lu\tTotal log file writes.\n", (u_long)sp->st_wcount);
 	printf("%lu\tTotal log file flushes.\n", (u_long)sp->st_scount);
+	printf("%lu\tCurrent log file number.\n", (u_long)sp->st_cur_file);
+	printf("%lu\tCurrent log file offset.\n", (u_long)sp->st_cur_offset);
 	printf("%lu\tThe number of region locks granted without waiting.\n",
 	    (u_long)sp->st_region_nowait);
 	printf("%lu\tThe number of region locks granted after waiting.\n",
@@ -325,7 +327,7 @@ mpool_stats(dbenv)
 	    (u_long)gsp->st_region_wait);
 
 	for (; fsp != NULL && *fsp != NULL; ++fsp) {
-		printf("%s\n", DIVIDER);
+		printf("%s\n", DB_LINE);
 		printf("%s\n", (*fsp)->file_name);
 		printf("%lu\tPage size.\n", (u_long)(*fsp)->st_pagesize);
 		printf("%lu\tRequested pages found in the cache",
@@ -513,7 +515,8 @@ void
 onint(signo)
 	int signo;
 {
-	signo = 1;			/* XXX: Shut the compiler up. */
+	COMPQUIET(signo, 0);
+
 	interrupted = 1;
 }