#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.80 2003/01/10 10:52:48 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;
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);
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",
/* 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);
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);