-$Id: CHANGES,v 1.105 2001/03/18 15:35:43 stelian Exp $
+$Id: CHANGES,v 1.106 2001/03/19 13:22:48 stelian Exp $
Changes between versions 0.4b21 and 0.4b22 (released ????????????????)
======================================================================
the patch and to Bdale Garbee <bdale@gag.com> for forwarding
it upstream.
+5. Many cleanups (CPP defines, const char warnings, check of
+ ext2fs COMPAT flags) by Andreas Dilger <adilger@turbolinux.com>.
+
Changes between versions 0.4b20 and 0.4b21 (released January 13, 2001)
======================================================================
* Stelian Pop <pop@noos.fr>, 1999-2000
* Stelian Pop <pop@noos.fr> - Alcôve <www.alcove.fr>, 2000
*
- * $Id: fstab.h,v 1.10 2000/12/21 11:14:53 stelian Exp $
+ * $Id: fstab.h,v 1.11 2001/03/19 13:22:48 stelian Exp $
*/
/*
#define FSTAB_XX "ignore" /* ignore totally */
struct fstab {
- char *fs_spec; /* block special device name */
+ const char *fs_spec; /* block special device name */
char *fs_file; /* file system path prefix */
char *fs_vfstype; /* File system type, ufs, nfs */
char *fs_mntops; /* Mount options ala -o */
#define PROC_PARTITIONS "/proc/partitions"
#define DEVLABELDIR "/dev"
-#define EXT2_SUPER_MAGIC 0xEF53
+#define EXT2_SUPER_OFFSET 1024
+#define EXT2_SUPER_SIZE sizeof(struct ext2_super_block)
+#define EXT2_SUPER_MAGIC 0xEF53
+
struct ext2_super_block {
unsigned char s_dummy1[56];
unsigned char s_magic[2];
if (fd < 0)
return 1;
- if (lseek(fd, 1024, SEEK_SET) != 1024
- || read(fd, (char *) &e2sb, sizeof(e2sb)) != sizeof(e2sb)
- || (ext2magic(e2sb) != EXT2_SUPER_MAGIC)) {
+ if (lseek(fd, EXT2_SUPER_OFFSET, SEEK_SET) != EXT2_SUPER_OFFSET ||
+ read(fd, (char *) &e2sb, EXT2_SUPER_SIZE) != EXT2_SUPER_SIZE ||
+ ext2magic(e2sb) != EXT2_SUPER_MAGIC) {
close(fd);
return 1;
}
#ifndef lint
static const char rcsid[] =
- "$Id: fstab.c,v 1.10 2000/12/21 11:14:53 stelian Exp $";
+ "$Id: fstab.c,v 1.11 2001/03/19 13:22:48 stelian Exp $";
#endif /* not lint */
#include <config.h>
int typexx;
#define MAXLINELENGTH 1024
char subline[MAXLINELENGTH];
- char *device_name;
for (;;) {
+ const char *device_name;
if (!(mnt = getmntent(_fs_fp)))
return 0;
* Stelian Pop <pop@noos.fr>, 1999-2000
* Stelian Pop <pop@noos.fr> - Alcôve <www.alcove.fr>, 2000
*
- * $Id: dump.h,v 1.20 2001/02/21 16:13:05 stelian Exp $
+ * $Id: dump.h,v 1.21 2001/03/19 13:22:48 stelian Exp $
*/
/*-
/*
* All calculations done in 0.1" units!
*/
-char *disk; /* name of the disk file */
+const char *disk; /* name of the disk file */
char tape[MAXPATHLEN]; /* name of the tape file */
char *tapeprefix; /* prefix of the tape file */
char *dumpdates; /* name of the file containing dump date information*/
void dumpabort __P((int signo));
void getfstab __P((void));
-char *rawname __P((char *cp));
+const char *rawname __P((const char *cp));
struct dinode *getino __P((ino_t inum));
/* rdump routines */
#ifndef lint
static const char rcsid[] =
- "$Id: itime.c,v 1.15 2001/02/22 10:57:40 stelian Exp $";
+ "$Id: itime.c,v 1.16 2001/03/19 13:22:48 stelian Exp $";
#endif /* not lint */
#include <config.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#ifdef __STDC__
+#include <stdlib.h>
+#include <string.h>
+#endif
+
#include <sys/param.h>
#include <sys/time.h>
#ifdef __linux__
#include <linux/ext2_fs.h>
+#include <ext2fs/ext2fs.h>
#include <time.h>
#include <bsdcompat.h>
#include <sys/file.h>
#include <unistd.h>
-#else
-#ifdef sunos
+#elif defined sunos
#include <sys/vnode.h>
#include <ufs/fsdir.h>
#else
#include <ufs/ufs/dinode.h>
#endif
-#endif
#include <protocols/dumprestore.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdio.h>
-#ifdef __STDC__
-#include <stdlib.h>
-#include <string.h>
-#endif
-
-#ifdef __linux__
-#include <ext2fs/ext2fs.h>
-#endif
-
#include "dump.h"
struct dumpdates **ddatev;
{
register struct dumpdates *ddp;
register int i;
- char *fname;
- fname = disk;
#ifdef FDEBUG
msg("Looking for name %s in dumpdates = %s for level = %c\n",
- fname, dumpdates, level);
+ disk, dumpdates, level);
#endif
spcl.c_ddate = 0;
lastlevel = '0';
* and older date
*/
ITITERATE(i, ddp) {
- if (strncmp(fname, ddp->dd_name, sizeof (ddp->dd_name)) != 0)
+ if (strncmp(disk, ddp->dd_name, sizeof (ddp->dd_name)) != 0)
continue;
if (ddp->dd_level >= level)
continue;
register struct dumpdates *dtwalk;
register int i;
int fd;
- char *fname;
if(uflag == 0)
return;
quit("cannot rewrite %s: %s\n", dumpdates, strerror(errno));
fd = fileno(df);
(void) flock(fd, LOCK_EX);
- fname = disk;
free((char *)ddatev);
ddatev = 0;
nddates = 0;
quit("fseek: %s\n", strerror(errno));
spcl.c_ddate = 0;
ITITERATE(i, dtwalk) {
- if (strncmp(fname, dtwalk->dd_name,
+ if (strncmp(disk, dtwalk->dd_name,
sizeof (dtwalk->dd_name)) != 0)
continue;
if (dtwalk->dd_level != level)
(struct dumpdates *)calloc(1, sizeof (struct dumpdates));
nddates += 1;
found:
- (void) strncpy(dtwalk->dd_name, fname, sizeof (dtwalk->dd_name));
+ (void) strncpy(dtwalk->dd_name, disk, sizeof (dtwalk->dd_name));
dtwalk->dd_level = level;
dtwalk->dd_ddate = spcl.c_date;
#ifndef lint
static const char rcsid[] =
- "$Id: main.c,v 1.34 2001/02/22 10:57:40 stelian Exp $";
+ "$Id: main.c,v 1.35 2001/03/19 13:22: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 <sys/param.h>
#include <sys/time.h>
#ifdef __linux__
#include <linux/ext2_fs.h>
+#include <ext2fs/ext2fs.h>
#include <time.h>
#include <sys/stat.h>
#include <bsdcompat.h>
-#else
-#ifdef sunos
+#elif defined sunos
#include <sys/vnode.h>
#include <ufs/inode.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ffs/fs.h>
#endif
-#endif
#include <protocols/dumprestore.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>
-
-#ifdef __linux__
-#include <ext2fs/ext2fs.h>
-#endif
-
#include "dump.h"
#include "pathnames.h"
#include "bylabel.h"
usage();
obsolete(&argc, &argv);
+
+ while ((ch = getopt(argc, argv,
+ "0123456789aB:b:cd:e:f:F:h:L:"
#ifdef KERBEROS
+ "k"
+#endif
+ "Mns:ST:uWw"
#ifdef HAVE_ZLIB
-#define optstring "0123456789aB:b:cd:e:f:F:h:kL:Mns:ST:uWwz"
-#else
-#define optstring "0123456789aB:b:cd:e:f:F:h:kL:Mns:ST:uWw"
-#endif /* HAVE_ZLIB */
-#else
-#ifdef HAVE_ZLIB
-#define optstring "0123456789aB:b:cd:e:f:F:h:L:Mns:ST:uWwz"
-#else
-#define optstring "0123456789aB:b:cd:e:f:F:h:L:Mns:ST:uWw"
-#endif /* HAVE_ZLIB */
-#endif /* KERBEROS */
- while ((ch = getopt(argc, argv, optstring)) != -1)
+ "z"
+#endif
+ )) != -1)
#undef optstring
switch (ch) {
/* dump level */
}
diskparam = *argv++;
if (strlen(diskparam) >= MAXPATHLEN) {
- (void)fprintf(stderr, "Disk or filesystem name too long: %s\n", diskparam);
+ (void)fprintf(stderr, "Disk or filesystem name too long: %s\n",
+ diskparam);
exit(X_STARTUP);
}
argc--;
set_operators(); /* /etc/group snarfed */
getfstab(); /* /etc/fstab snarfed */
+ /*
+ * disk may end in / and this can confuse
+ * fstabsearch.
+ */
+ i = strlen(diskparam) - 1;
+ if (i > 1 && diskparam[i] == '/')
+ diskparam[i] = '\0';
+
disk = get_device_name(diskparam);
if (!disk) { /* null means the disk is some form
of LABEL= or UID= but it was not
msg("Cannot find a disk having %s\n", diskparam);
exit(X_STARTUP);
}
- /*
- * disk may end in / and this can confuse
- * fstabsearch.
- */
- if (strlen(disk) > 1 && disk[strlen(disk) - 1] == '/')
- disk[strlen(disk) - 1] = '\0';
/*
* disk can be either the full special file name,
* the suffix of the special file name,
}
}
-char *
-rawname(char *cp)
+const char *
+rawname(const char *cp)
{
#ifdef __linux__
return cp;
if (dp == NULL)
return (NULL);
- *dp = '\0';
- (void)strncpy(rawbuf, cp, MAXPATHLEN - 1);
- rawbuf[MAXPATHLEN-1] = '\0';
- *dp = '/';
+ (void)strncpy(rawbuf, cp, min(dp-cp, MAXPATHLEN - 1));
+ rawbuf[min(dp-cp, MAXPATHLEN-1)] = '\0';
(void)strncat(rawbuf, "/r", MAXPATHLEN - 1 - strlen(rawbuf));
(void)strncat(rawbuf, dp + 1, MAXPATHLEN - 1 - strlen(rawbuf));
return (rawbuf);
#ifndef lint
static const char rcsid[] =
- "$Id: optr.c,v 1.20 2001/02/22 10:57:40 stelian Exp $";
+ "$Id: optr.c,v 1.21 2001/03/19 13:22:48 stelian Exp $";
#endif /* not lint */
#include <config.h>
{
register struct pfstab *pf;
register struct fstab *fs;
- char *rn;
+ const char *rn;
for (pf = table; pf != NULL; pf = pf->pf_next) {
fs = pf->pf_fstab;
#ifndef lint
static const char rcsid[] =
- "$Id: tape.c,v 1.33 2001/03/18 15:35:44 stelian Exp $";
+ "$Id: tape.c,v 1.34 2001/03/19 13:22:48 stelian Exp $";
#endif /* not lint */
#include <config.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <setjmp.h>
+#include <signal.h>
+#include <stdio.h>
+#include <compaterr.h>
+#ifdef __STDC__
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#else
+int write(), read();
+#endif
+
#ifdef __linux__
#include <sys/types.h>
#include <time.h>
#include <sys/wait.h>
#ifdef __linux__
#include <linux/ext2_fs.h>
+#include <ext2fs/ext2fs.h>
#include <bsdcompat.h>
-#else /* __linux__ */
-#ifdef sunos
+#elif defined sunos
#include <sys/vnode.h>
#include <ufs/fs.h>
#else
#include <ufs/ufs/dinode.h>
#include <ufs/ffs/fs.h>
-#endif
#endif /* __linux__ */
#include <protocols/dumprestore.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <setjmp.h>
-#include <signal.h>
-#include <stdio.h>
-#include <compaterr.h>
-#ifdef __STDC__
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#else
-int write(), read();
-#endif
-
-#ifdef __linux__
-#include <ext2fs/ext2fs.h>
-#endif
-
#ifdef HAVE_ZLIB
#include <zlib.h>
#endif /* HAVE_ZLIB */
#ifndef lint
static const char rcsid[] =
- "$Id: traverse.c,v 1.25 2000/12/21 11:14:54 stelian Exp $";
+ "$Id: traverse.c,v 1.26 2001/03/19 13:22:49 stelian Exp $";
#endif /* not lint */
#include <config.h>
+#include <ctype.h>
+#include <stdio.h>
+#ifdef __STDC__
+#include <string.h>
+#include <unistd.h>
+#endif
+
#include <sys/param.h>
#include <sys/stat.h>
#ifdef __linux__
#include <linux/ext2_fs.h>
+#include <ext2fs/ext2fs.h>
#include <bsdcompat.h>
#include <compaterr.h>
#include <stdlib.h>
-#define swab32(x) ext2fs_swab32(x)
-#else /* __linux__ */
-#define swab32(x) x
-#ifdef sunos
+#elif defined sunos
#include <sys/vnode.h>
#include <ufs/fs.h>
#include <ufs/ufs/dir.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ffs/fs.h>
-#endif
#endif /* __linux__ */
#include <protocols/dumprestore.h>
-#include <ctype.h>
-#include <stdio.h>
-#ifdef __STDC__
-#include <string.h>
-#include <unistd.h>
-#endif
-
-#ifdef __linux__
-#include <ext2fs/ext2fs.h>
-#endif
-
#include "dump.h"
#define HASDUMPEDFILE 0x1
#endif
static void mapfileino __P((ino_t ino, struct dinode const *dp, long *tapesize, int *dirskipped));
static int exclude_ino __P((ino_t ino));
+extern ino_t iexclude_list[IEXCLUDE_MAXNUM]; /* the inode exclude list */
+extern int iexclude_num; /* number of elements in list */
+
+/* Temporary fix waiting for Andreas fixes... */
+#define ext2_ino_t ino_t
+#undef EXT3_FEATURE_INCOMPAT_RECOVER
-/* #define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004 */
-#ifdef EXT3_FEATURE_INCOMPAT_RECOVER
+#ifndef EXT3_FEATURE_COMPAT_HAS_JOURNAL
+#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004
+#endif
+#ifndef EXT2_FEATURE_INCOMPAT_FILETYPE
+#define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002
+#endif
+#ifndef EXT3_FEATURE_INCOMPAT_RECOVER
+#define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004
#define FORCE_OPEN EXT2_FLAG_FORCE
+#define ext2_journal_ino(sb) (*((__u32 *)sb + 0x38))
#else
#define FORCE_OPEN 0
+#define ext2_journal_ino(sb) (sb->s_journal_inum)
+#endif
+#ifndef EXT3_FEATURE_INCOMPAT_JOURNAL_DEV
+#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008
+#endif
+
+#ifndef EXT2_LIB_FEATURE_INCOMPAT_SUPP
+#define EXT2_LIB_FEATURE_INCOMPAT_SUPP (EXT3_FEATURE_INCOMPAT_RECOVER | \
+ EXT2_FEATURE_INCOMPAT_FILETYPE)
#endif
int dump_fs_open(const char *disk, ext2_filsys *fs)
{
int retval;
- struct ext2fs_sb *s;
retval = ext2fs_open(disk, FORCE_OPEN, 0, 0, unix_io_manager, fs);
-#if defined(EXT2_LIB_FEATURE_COMPAT_SUPP) && defined(EXT2_LIB_FEATURE_INCOMPAT_SUPP) && defined(EXT2_LIB_FEATURE_RO_COMPAT_SUPP) && defined(EXT2_ET_UNSUPP_FEATURE) && defined(EXT2_ET_RO_UNSUPP_FEATURE)
if (!retval) {
- s = (struct ext2fs_sb *) (*fs)->super;
- if ((s->s_feature_compat & ~EXT2_LIB_FEATURE_COMPAT_SUPP) ||
-#ifdef EXT3_FEATURE_INCOMPAT_RECOVER
- (s->s_feature_incompat & ~(EXT3_FEATURE_INCOMPAT_RECOVER | EXT2_LIB_FEATURE_INCOMPAT_SUPP))) {
-#else
- (s->s_feature_incompat & ~EXT2_LIB_FEATURE_INCOMPAT_SUPP)) {
-#endif
+ struct ext2_super_block *es = (*fs)->super;
+ ext2_ino_t journal_ino = ext2_journal_ino(es);
+ if (es->s_feature_incompat & EXT3_FEATURE_INCOMPAT_JOURNAL_DEV){
+ fprintf(stderr, "This an journal, not a filesystem!\n");
retval = EXT2_ET_UNSUPP_FEATURE;
+ ext2fs_close(*fs);
}
- else if (s->s_feature_ro_compat & ~EXT2_LIB_FEATURE_RO_COMPAT_SUPP) {
- retval = EXT2_ET_RO_UNSUPP_FEATURE;
+ else if ((retval = es->s_feature_incompat &
+ ~(EXT2_LIB_FEATURE_INCOMPAT_SUPP |
+ EXT3_FEATURE_INCOMPAT_RECOVER))) {
+ fprintf(stderr,
+ "Unsupported feature(s) 0x%x in filesystem\n",
+ retval);
+ retval = EXT2_ET_UNSUPP_FEATURE;
+ ext2fs_close(*fs);
+ }
+ else if (es->s_feature_compat &
+ EXT3_FEATURE_COMPAT_HAS_JOURNAL && journal_ino &&
+ !exclude_ino(journal_ino)) {
+ iexclude_list[iexclude_num++] = journal_ino;
+ msg("Added ext3 journal inode %d to exclude list\n",
+ journal_ino);
}
}
-#endif /* defined && defined && defined... */
return retval;
}
return (blkest + 1);
}
-extern ino_t iexclude_list[IEXCLUDE_MAXNUM]; /* the inode exclude list */
-extern int iexclude_num; /* number of elements in the list */
-
/*
* This tests whether an inode is in the exclude list
*/
*/
#if defined(EXT2_FLAG_SWAP_BYTES)
if ((fs->flags & EXT2_FLAG_SWAP_BYTES) ||
- (fs->flags & EXT2_FLAG_SWAP_BYTES_READ)) {
+ (fs->flags & EXT2_FLAG_SWAP_BYTES_READ))
#endif
+ {
max = sblock->fs_bsize >> 2;
swapme = (blk_t *) idblk;
for (i = 0; i < max; i++, swapme++)
- *swapme = swab32(*swapme);
-#if defined(EXT2_FLAG_SWAP_BYTES)
+ *swapme = ext2fs_swab32(*swapme);
}
-#endif
-#endif
+#endif /* __linux__ */
else
memset(idblk, 0, (int)sblock->fs_bsize);
if (ind_level <= 0) {
/*
* Write a header record to the dump tape.
*/
+#if defined __linux__ && !defined(int32_t)
+#define int32_t __s32
+#endif
void
writeheader(ino_t ino)
{
-#ifdef __linux__
- register __s32 sum, cnt, *lp;
-#else
register int32_t sum, cnt, *lp;
-#endif
spcl.c_inumber = ino;
spcl.c_magic = NFS_MAGIC;
spcl.c_checksum = 0;
-#ifdef __linux__
- lp = (__s32 *)&spcl;
-#else
lp = (int32_t *)&spcl;
-#endif
sum = 0;
-#ifdef __linux__
- cnt = sizeof(union u_spcl) / (4 * sizeof(__s32));
-#else
cnt = sizeof(union u_spcl) / (4 * sizeof(int32_t));
-#endif
while (--cnt >= 0) {
sum += *lp++;
sum += *lp++;
#ifndef lint
static const char rcsid[] =
- "$Id: tape.c,v 1.26 2001/03/18 15:35:44 stelian Exp $";
+ "$Id: tape.c,v 1.27 2001/03/19 13:22:49 stelian Exp $";
#endif /* not lint */
#include <config.h>
+#include <errno.h>
+#include <compaterr.h>
+#include <setjmp.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
#include <sys/param.h>
#include <sys/file.h>
#include <sys/mtio.h>
#include <sys/time.h>
#include <time.h>
#include <linux/ext2_fs.h>
+#include <ext2fs/ext2fs.h>
#include <bsdcompat.h>
#else /* __linux__ */
#include <ufs/ufs/dinode.h>
#endif /* __linux__ */
#include <protocols/dumprestore.h>
-#include <errno.h>
-#include <compaterr.h>
-#include <setjmp.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
#ifdef HAVE_ZLIB
#include <zlib.h>
#endif /* HAVE_ZLIB */
-#ifdef __linux__
-#include <ext2fs/ext2fs.h>
-#endif
-
#include "restore.h"
#include "extern.h"
#include "pathnames.h"
#ifndef lint
static const char rcsid[] =
- "$Id: utilities.c,v 1.11 2000/12/21 11:14:54 stelian Exp $";
+ "$Id: utilities.c,v 1.12 2001/03/19 13:22:49 stelian Exp $";
#endif /* not lint */
#include <config.h>
+#include <errno.h>
+#include <compaterr.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
#include <sys/param.h>
#include <sys/stat.h>
#ifdef __linux__
#include <sys/time.h>
#include <linux/ext2_fs.h>
+#include <ext2fs/ext2fs.h>
#include <bsdcompat.h>
#else /* __linux__ */
#include <ufs/ufs/dinode.h>
#include <ufs/ufs/dir.h>
#endif /* __linux__ */
-#include <errno.h>
-#include <compaterr.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-
-#ifdef __linux__
-#include <ext2fs/ext2fs.h>
-#endif
-
#include "restore.h"
#include "extern.h"