#ifndef lint
static const char rcsid[] =
- "$Id: main.c,v 1.72 2002/06/05 13:29:15 stelian Exp $";
+ "$Id: main.c,v 1.82 2003/03/07 09:15:50 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 <string.h>
#include <unistd.h>
#include <errno.h>
+#include <mntent.h>
#include <sys/param.h>
#include <sys/time.h>
int blockswritten = 0; /* number of blocks written on current tape */
int tapeno = 0; /* current tape number */
int density = 0; /* density in bytes/0.1" " <- this is for hilit19 */
-int ntrec = NTREC; /* # tape blocks in each tape record */
+int ntrec = NTREC; /* # blocks in each tape record */
int cartridge = 0; /* Assume non-cartridge tape */
#ifdef USE_QFA
int tapepos = 0; /* assume no QFA tapeposition needed by user */
char *__progname;
#endif
-int maxbsize = 64*1024; /* XXX MAXBSIZE from sys/param.h */
+int maxbsize = 1024*1024; /* XXX MAXBSIZE from sys/param.h */
static long numarg __P((const char *, long, long));
static void obsolete __P((int *, char **[]));
static void usage __P((void));
dump_ino_t ino;
int dirty;
struct dinode *dp;
- struct fstab *dt;
+ struct mntent *dt;
char *map;
int ch;
int i, anydirskipped;
#endif /* USE_QFA */
while ((ch = getopt(argc, argv,
- "0123456789A:aB:b:cd:e:E:f:F:h:I:"
+ "0123456789A:aB:b:cd:D:e:E:f:F:h:I:"
#ifdef HAVE_BZLIB
"j::"
#endif
case 'b': /* blocks per tape write */
ntrec = numarg("number of blocks per write",
- 1L, 1000L);
+ 1L, 1048576L);
if (ntrec > maxbsize/1024) {
msg("Please choose a blocksize <= %dkB\n",
maxbsize/1024);
density = numarg("density", 10L, 327670L) / 10;
if (density >= 625 && !bflag)
ntrec = HIGHDENSITYTREC;
+ break;
+
+ case 'D': /* path of dumpdates file */
+ dumpdates = optarg;
break;
/* 04-Feb-00 ILC */
case 'I':
breademax =
- numarg ("number of errors to ignore", 1L, 0L);
+ numarg ("number of errors to ignore", 0L, 0L);
break;
#ifdef KERBEROS
msg("The ENTIRE dump is aborted.\n");
exit(X_STARTUP);
}
- disk = rawname(dt->fs_spec);
- (void)strncpy(spcl.c_dev, dt->fs_spec, NAMELEN);
- (void)strncpy(spcl.c_filesys, dt->fs_file, NAMELEN);
+ disk = rawname(dt->mnt_fsname);
+ (void)strncpy(spcl.c_dev, dt->mnt_fsname, NAMELEN);
+ (void)strncpy(spcl.c_filesys, dt->mnt_dir, NAMELEN);
} else {
#ifdef __linux__
#ifdef HAVE_REALPATH
* a filesystem specified in fstab. Search for it.
*/
if ((dt = fstabsearch(pathname)) != NULL) {
- disk = rawname(dt->fs_spec);
- (void)strncpy(spcl.c_dev, dt->fs_spec, NAMELEN);
- (void)strncpy(spcl.c_filesys, dt->fs_file, NAMELEN);
+ disk = rawname(dt->mnt_fsname);
+ (void)strncpy(spcl.c_dev, dt->mnt_fsname, NAMELEN);
+ (void)strncpy(spcl.c_filesys, dt->mnt_dir, NAMELEN);
} else {
/*
* The argument was not found in the fstab
dt = fstabsearchdir(pathname, directory);
if (dt != NULL) {
char name[MAXPATHLEN];
- (void)strncpy(spcl.c_dev, dt->fs_spec, NAMELEN);
+ (void)strncpy(spcl.c_dev, dt->mnt_fsname, NAMELEN);
(void)snprintf(name, sizeof(name), "%s (dir %s)",
- dt->fs_file, directory);
+ dt->mnt_dir, directory);
(void)strncpy(spcl.c_filesys, name, NAMELEN);
- disk = rawname(dt->fs_spec);
+ disk = rawname(dt->mnt_fsname);
} else {
(void)strncpy(spcl.c_dev, disk, NAMELEN);
(void)strncpy(spcl.c_filesys, "an unlisted file system",
if (TP_BSIZE != (1 << tp_bshift))
quit("TP_BSIZE (%d) is not a power of 2", TP_BSIZE);
maxino = fs->super->s_inodes_count + 1;
-#if 0
spcl.c_flags |= DR_NEWINODEFMT;
-#endif
#else /* __linux __*/
if ((diskfd = open(disk, O_RDONLY)) < 0) {
msg("Cannot open %s\n", disk);
if (!sizest) {
msg("Label: %s\n", spcl.c_label);
+
+ msg("Writing %d Kilobyte records\n", ntrec);
if (compressed)
msg("Compressing output at compression level %d (%s)\n",
if (directory[0] == 0)
anydirskipped = mapfiles(maxino, &tapesize);
else {
- if (STAT(pathname, &statbuf) == -1) {
+ if (LSTAT(pathname, &statbuf) == -1) {
msg("File cannot be accessed (%s).\n", pathname);
msg("The ENTIRE dump is aborted.\n");
exit(X_STARTUP);
int anydirskipped2;
char *p = *argv;
/* check if file is available */
- if (STAT(p, &statbuf) == -1) {
+ if (LSTAT(p, &statbuf) == -1) {
msg("File cannot be accessed (%s).\n", p);
msg("The ENTIRE dump is aborted.\n");
exit(X_STARTUP);
/* check if file is a directory */
if (!(statbuf.st_mode & S_IFDIR))
anydirskipped2 = maponefile(maxino, &tapesize,
- p+strlen(dt->fs_file));
+ p+strlen(dt->mnt_dir));
else
/* read directory inodes.
* NOTE: nested directories are not recognized
* so inodes may be umped twice!
*/
anydirskipped2 = mapfilesfromdir(maxino, &tapesize,
- p+strlen(dt->fs_file));
+ p+strlen(dt->mnt_dir));
if (!anydirskipped)
anydirskipped = anydirskipped2;
argv++;
if (pipeout || unlimited) {
tapesize += 1 + ntrec; /* 1 map header + trailer blocks */
- msg("estimated %ld tape blocks.\n", tapesize);
+ msg("estimated %ld blocks.\n", tapesize);
} else {
double fetapes;
tapesize += (etapes - 1) *
(howmany(mapsize * sizeof(char), TP_BSIZE) + 1);
tapesize += etapes + ntrec; /* headers + trailer blks */
- msg("estimated %ld tape blocks on %3.2f tape(s).\n",
+ msg("estimated %ld blocks on %3.2f tape(s).\n",
tapesize, fetapes);
}
/* print QFA-file header */
snprintf(gTps, sizeof(gTps), "%s\n%s\n%ld\n\n", QFA_MAGIC, QFA_VERSION, (unsigned long)spcl.c_date);
gTps[sizeof(gTps) - 1] = '\0';
- if (write(gTapeposfd, gTps, strlen(gTps)) != strlen(gTps))
+ if (write(gTapeposfd, gTps, strlen(gTps)) != (ssize_t)strlen(gTps))
quit("can't write tapeposfile\n");
sprintf(gTps, "ino\ttapeno\ttapepos\n");
- if (write(gTapeposfd, gTps, strlen(gTps)) != strlen(gTps))
+ if (write(gTapeposfd, gTps, strlen(gTps)) != (ssize_t)strlen(gTps))
quit("can't write tapeposfile\n");
}
#endif /* USE_QFA */
tnow = trewind();
if (pipeout || fifoout)
- msg("%ld tape blocks (%.2fMB)\n", spcl.c_tapea,
+ msg("%ld blocks (%.2fMB)\n", spcl.c_tapea,
((double)spcl.c_tapea * TP_BSIZE / 1048576));
else
- msg("%ld tape blocks (%.2fMB) on %d volume(s)\n",
+ msg("%ld blocks (%.2fMB) on %d volume(s)\n",
spcl.c_tapea,
((double)spcl.c_tapea * TP_BSIZE / 1048576),
spcl.c_volume);
#endif
"mMnqSuv"
"] [-A file] [-B records] [-b blocksize]\n"
- "\t%s [-d density] [-e inode#,inode#,...] [-E file] [-f file]\n"
- "\t%s [-h level] [-I nr errors] "
+ "\t%s [-d density] [-D file] [-e inode#,inode#,...] [-E file]\n"
+ "\t%s [-f file] [-h level] [-I nr errors] "
#ifdef HAVE_BZLIB
"[-j zlevel] "
#endif
case 'B':
case 'b':
case 'd':
+ case 'D':
case 'e':
case 'E':
case 'f':
exit(X_STARTUP);
}
if (reason)
- msg("Added inode %u to exclude list (%s)\n",
+ msg("Excluding inode %u (%s) from dump\n",
ino, reason);
else
- msg("Added inode %u to exclude list\n", ino);
+ msg("Excluding inode %u from dump\n", ino);
iexclude_list[iexclude_num++] = ino;
}
}
unsigned long inod;
inod = strtoul(ino, &r, 10);
- if (*r != '\0' || inod <= ROOTINO) {
+ if (( *r != '\0' && !isspace(*r) ) || inod <= ROOTINO) {
msg("Invalid inode argument %s\n", ino);
msg("The ENTIRE dump is aborted.\n");
exit(X_STARTUP);