#ifndef lint
static const char rcsid[] =
- "$Id: main.c,v 1.85 2003/03/31 09:42:58 stelian Exp $";
+ "$Id: main.c,v 1.89 2004/01/04 10:48:35 stelian Exp $";
#endif /* not lint */
#include <config.h>
#include <ctype.h>
#include <compaterr.h>
#include <fcntl.h>
+#include <fstab.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <ext2fs/ext2fs.h>
#include <sys/stat.h>
#include <bsdcompat.h>
+#include <linux/fs.h> /* for definition of BLKFLSBUF */
#elif defined sunos
#include <sys/vnode.h>
#define SBOFF (SBLOCK * DEV_BSIZE)
#endif
+int abortifconnerr = 1; /* set to 1 if lib dumprmt.o should exit on connection errors
+ otherwise just print a message using msg */
/*
* Dump maps used to describe what is to be dumped.
*/
long long bytes_written = 0; /* total bytes written */
long uncomprblks = 0;/* uncompressed blocks written */
+long smtc_errno;
+
#ifdef __linux__
char *__progname;
#endif
static void do_exclude_ino_str __P((char *));
static void incompat_flags __P((int, char, char));
-static dump_ino_t iexclude_list[IEXCLUDE_MAXNUM];/* the inode exclude list */
-static int iexclude_num = 0; /* number of elements in the list */
+static char* iexclude_bitmap = NULL; /* the inode exclude bitmap */
+static unsigned int iexclude_bitmap_bytes = 0; /* size of bitmap in bytes */
int
main(int argc, char *argv[])
tsize = cartridge ? 1700L*120L : 2300L*120L;
}
- if (strchr(tapeprefix, ':')) {
- host = tapeprefix;
- tapeprefix = strchr(host, ':');
- *tapeprefix++ = '\0';
+ {
+ int i;
+ char *n;
+
+ if ((n = strchr(tapeprefix, ':'))) {
+ for (i = 0; i < (n - tapeprefix); i++) {
+ if (tapeprefix[i] == '/')
+ break;
+ }
+ if (tapeprefix[i] != '/') {
+ host = tapeprefix;
+ tapeprefix = strchr(host, ':');
+ *tapeprefix++ = '\0';
#ifdef RDUMP
- if (index(tapeprefix, '\n')) {
- msg("invalid characters in tape\n");
- msg("The ENTIRE dump is aborted.\n");
- exit(X_STARTUP);
- }
- if (rmthost(host) == 0)
- exit(X_STARTUP);
+ if (index(tapeprefix, '\n')) {
+ msg("invalid characters in tape\n");
+ msg("The ENTIRE dump is aborted.\n");
+ exit(X_STARTUP);
+ }
+ if (rmthost(host) == 0)
+ exit(X_STARTUP);
#else
- msg("remote dump not enabled\n");
- msg("The ENTIRE dump is aborted.\n");
- exit(X_STARTUP);
+ msg("remote dump not enabled\n");
+ msg("The ENTIRE dump is aborted.\n");
+ exit(X_STARTUP);
#endif
+ }
+ }
}
+
(void)setuid(getuid()); /* rmthost() is the only reason to be setuid */
if (Apath && (Afile = open(Apath, O_WRONLY|O_CREAT|O_TRUNC,
S_IRUSR | S_IWUSR | S_IRGRP |
exit(X_STARTUP);
}
#ifdef BLKFLSBUF
- (void)ioctl(diskfd, BLKFLSBUF);
+ (void)ioctl(diskfd, BLKFLSBUF, 0);
#endif
retval = dump_fs_open(disk, &fs);
if (retval) {
}
/*
- * This tests whether an inode is in the exclude list
+ * This tests whether an inode is in the exclude bitmap
*/
int
exclude_ino(dump_ino_t ino)
{
- /* 04-Feb-00 ILC */
- if (iexclude_num) { /* if there are inodes in the exclude list */
- int idx; /* then check this inode against it */
- for (idx = 0; idx < iexclude_num; idx++)
- if (ino == iexclude_list[idx])
- return 1;
+ /* if the inode exclude bitmap exists and covers given inode */
+ if (iexclude_bitmap && iexclude_bitmap_bytes > ino / 8) {
+ /* then check this inode against it */
+ int idx = iexclude_bitmap[ino / 8];
+ if (idx & (1 << (ino % 8)))
+ return 1;
}
return 0;
}
/*
- * This tests adds an inode to the exclusion list if it isn't already there
+ * This adds an inode to the exclusion bitmap if it isn't already there
*/
void
do_exclude_ino(dump_ino_t ino, const char *reason)
{
- if (!exclude_ino(ino)) {
- if (iexclude_num == IEXCLUDE_MAXNUM) {
- msg("Too many exclude options\n");
- msg("The ENTIRE dump is aborted.\n");
- exit(X_STARTUP);
- }
+ if (exclude_ino(ino))
+ return;
+
+ if (vflag) {
if (reason)
- msg("Excluding inode %u (%s) from dump\n",
- ino, reason);
+ msg("Excluding inode %u (%s) from dump\n", ino, reason);
else
msg("Excluding inode %u from dump\n", ino);
- iexclude_list[iexclude_num++] = ino;
}
+
+ /* check for enough mem; initialize */
+ if ((ino/8 + 1) > iexclude_bitmap_bytes) {
+ if (iexclude_bitmap_bytes == 0) {
+ unsigned int j;
+ iexclude_bitmap_bytes = 2 * (ino/8 + 1);
+ iexclude_bitmap = (char*) malloc(iexclude_bitmap_bytes);
+ if (iexclude_bitmap == NULL) {
+ msg("allocating memory failed\n");
+ exit(X_STARTUP);
+ }
+ for (j = 0; j < iexclude_bitmap_bytes; j++)
+ iexclude_bitmap[j] = 0;
+ }
+ else {
+ unsigned int oldsize = iexclude_bitmap_bytes;
+ iexclude_bitmap_bytes *=
+ (ino / 8 + 1) / iexclude_bitmap_bytes + 1;
+ iexclude_bitmap = (char*) realloc(iexclude_bitmap,
+ iexclude_bitmap_bytes);
+ if (iexclude_bitmap == NULL) {
+ msg("allocating memory failed\n");
+ exit(X_STARTUP);
+ }
+ for( ; oldsize < iexclude_bitmap_bytes; oldsize++)
+ iexclude_bitmap[oldsize] = 0;
+ }
+ }
+
+ iexclude_bitmap[ino / 8] |= 1 << (ino % 8);
}
static void