X-Git-Url: https://git.wh0rd.org/?p=dump.git;a=blobdiff_plain;f=dump%2Fmain.c;h=173ec03a38026b54edb60f51a0594169080f2492;hp=ac6a7a14417f0af477a58220a642b6f7af30592f;hb=fceb4f25728fd34fabfad406c32c5d8c142aae90;hpb=e51470bfc05d83f82c37d24504220c7163bbd4c1 diff --git a/dump/main.c b/dump/main.c index ac6a7a1..173ec03 100644 --- a/dump/main.c +++ b/dump/main.c @@ -41,7 +41,7 @@ #ifndef lint static const char rcsid[] = - "$Id: main.c,v 1.67 2002/01/25 14:59:53 stelian Exp $"; + "$Id: main.c,v 1.72 2002/06/05 13:29:15 stelian Exp $"; #endif /* not lint */ #include @@ -61,7 +61,6 @@ static const char rcsid[] = #include #include #ifdef __linux__ -#include #ifdef HAVE_EXT2FS_EXT2_FS_H #include #else @@ -97,6 +96,8 @@ int mapsize; /* size of the state maps */ char *usedinomap; /* map of allocated inodes */ char *dumpdirmap; /* map of directories to be dumped */ char *dumpinomap; /* map of files to be dumped */ +char *metainomap; /* which of the inodes in dumpinomap will get + only their metadata dumped */ const char *disk; /* name of the disk file */ char tape[MAXPATHLEN];/* name of the tape file */ @@ -107,8 +108,10 @@ char level; /* dump level of this dump */ int bzipflag; /* compression is done using bzlib */ int Afile = 0; /* archive file descriptor */ int uflag; /* update flag */ +int mflag; /* dump metadata only if possible */ int Mflag; /* multi-volume flag */ int qflag; /* quit on errors flag */ +int vflag; /* verbose flag */ int breademax = 32; /* maximum number of bread errors before we quit */ char *eot_script; /* end of volume script fiag */ int diskfd; /* disk file descriptor */ @@ -192,12 +195,12 @@ static int iexclude_num = 0; /* number of elements in the list */ int main(int argc, char *argv[]) { - register dump_ino_t ino; - register int dirty; - register struct dinode *dp; - register struct fstab *dt; - register char *map; - register int ch; + dump_ino_t ino; + int dirty; + struct dinode *dp; + struct fstab *dt; + char *map; + int ch; int i, anydirskipped; int aflag = 0, bflag = 0, Tflag = 0, honorlevel = 1; dump_ino_t maxino; @@ -210,7 +213,7 @@ main(int argc, char *argv[]) #endif time_t tnow; char *diskparam; - char *Apath; + char *Apath = NULL; spcl.c_label[0] = '\0'; spcl.c_date = time(NULL); @@ -249,11 +252,11 @@ main(int argc, char *argv[]) #ifdef KERBEROS "k" #endif - "Mnq" + "mMnq" #ifdef USE_QFA "Q:" #endif - "s:ST:uWw" + "s:ST:uvWw" #ifdef HAVE_ZLIB "z::" #endif @@ -378,6 +381,10 @@ main(int argc, char *argv[]) } break; + case 'm': /* metadata only flag */ + mflag = 1; + break; + case 'M': /* multi-volume flag */ Mflag = 1; break; @@ -421,6 +428,10 @@ main(int argc, char *argv[]) uflag = 1; break; + case 'v': /* verbose */ + vflag = 1; + break; + case 'W': /* what to do */ case 'w': lastdump(ch); @@ -531,7 +542,8 @@ main(int argc, char *argv[]) */ i = strlen(diskparam) - 1; if (i > 1 && diskparam[i] == '/') - diskparam[i] = '\0'; + if (!(i == 6 && !strcmp(diskparam, "LABEL=/"))) + diskparam[i] = '\0'; disk = get_device_name(diskparam); if (!disk) { /* null means the disk is some form @@ -730,7 +742,9 @@ main(int argc, char *argv[]) usedinomap = (char *)calloc((unsigned) mapsize, sizeof(char)); dumpdirmap = (char *)calloc((unsigned) mapsize, sizeof(char)); dumpinomap = (char *)calloc((unsigned) mapsize, sizeof(char)); - if (usedinomap == NULL || dumpdirmap == NULL || dumpinomap == NULL) + metainomap = (char *)calloc((unsigned) mapsize, sizeof(char)); + if (usedinomap == NULL || dumpdirmap == NULL || + dumpinomap == NULL || metainomap == NULL) quit("out of memory allocating inode maps\n"); tapesize = 2 * (howmany(mapsize * sizeof(char), TP_BSIZE) + 1); @@ -907,6 +921,8 @@ main(int argc, char *argv[]) */ if (dp->di_nlink == 0 || dp->di_dtime != 0) continue; + if (vflag) + msg("dumping directory inode %lu\n", ino); (void)dumpdirino(dp, ino); #else (void)dumpino(dp, ino); @@ -933,7 +949,13 @@ main(int argc, char *argv[]) * inodes since this is done in dumpino(). */ #endif - (void)dumpino(dp, ino); + if (vflag) { + if (mflag && TSTINO(ino, metainomap)) + msg("dumping regular inode %lu (meta only)\n", ino); + else + msg("dumping regular inode %lu\n", ino); + } + (void)dumpino(dp, ino, mflag && TSTINO(ino, metainomap)); } tend_writing = time(NULL); @@ -1016,7 +1038,7 @@ usage(void) #ifdef KERBEROS "k" #endif - "MnqSu" + "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] "