Subject: dump and restore on the alpha port
To: None <port-alpha@NetBSD.ORG>
From: Tom I Helbekkmo <tih@nhh.no>
List: port-alpha
Date: 11/22/1996 09:15:46
Someone mentioned that dump and restore don't work on the alpha port.
Sure enough, they don't.  The following is a quick hack that at least
allowed me to do a "dump | restore" of my /var file system and have
the resulting copy come out identical to the original.  That's the
extent of my testing so far, but I figured I'd share this right away,
so that others can look at it.  I'd really appreciate it if someone
else could take a look through the sources to dump and restore, to
check whether my changes seem correct and sufficient.

Actually, they are _not_ sufficient: I can't dump from the alpha and
restore on the i386 with this code.  I just can't figure out why.  :-(

-tih

*** include/protocols/dumprestore.h.ORIG	Sat Oct 14 01:37:26 1995
--- include/protocols/dumprestore.h	Fri Nov 22 07:44:35 1996
***************
*** 69,93 ****
  union u_spcl {
  	char dummy[TP_BSIZE];
  	struct	s_spcl {
! 		long	c_type;		    /* record type (see below) */
  		time_t	c_date;		    /* date of this dump */
  		time_t	c_ddate;	    /* date of previous dump */
! 		long	c_volume;	    /* dump volume number */
  		daddr_t	c_tapea;	    /* logical block of this record */
  		ino_t	c_inumber;	    /* number of inode */
! 		long	c_magic;	    /* magic number (see above) */
! 		long	c_checksum;	    /* record checksum */
  		struct	dinode	c_dinode;   /* ownership and mode of inode */
! 		long	c_count;	    /* number of valid c_addr entries */
  		char	c_addr[TP_NINDIR];  /* 1 => data; 0 => hole in inode */
  		char	c_label[LBLSIZE];   /* dump label */
! 		long	c_level;	    /* level of this dump */
  		char	c_filesys[NAMELEN]; /* name of dumpped file system */
  		char	c_dev[NAMELEN];	    /* name of dumpped device */
  		char	c_host[NAMELEN];    /* name of dumpped host */
! 		long	c_flags;	    /* additional information */
! 		long	c_firstrec;	    /* first record on volume */
! 		long	c_spare[32];	    /* reserved for future uses */
  	} s_spcl;
  } u_spcl;
  #define spcl u_spcl.s_spcl
--- 69,93 ----
  union u_spcl {
  	char dummy[TP_BSIZE];
  	struct	s_spcl {
! 		int32_t	c_type;		    /* record type (see below) */
  		time_t	c_date;		    /* date of this dump */
  		time_t	c_ddate;	    /* date of previous dump */
! 		int32_t	c_volume;	    /* dump volume number */
  		daddr_t	c_tapea;	    /* logical block of this record */
  		ino_t	c_inumber;	    /* number of inode */
! 		int32_t	c_magic;	    /* magic number (see above) */
! 		int32_t	c_checksum;	    /* record checksum */
  		struct	dinode	c_dinode;   /* ownership and mode of inode */
! 		int32_t	c_count;	    /* number of valid c_addr entries */
  		char	c_addr[TP_NINDIR];  /* 1 => data; 0 => hole in inode */
  		char	c_label[LBLSIZE];   /* dump label */
! 		int32_t	c_level;	    /* level of this dump */
  		char	c_filesys[NAMELEN]; /* name of dumpped file system */
  		char	c_dev[NAMELEN];	    /* name of dumpped device */
  		char	c_host[NAMELEN];    /* name of dumpped host */
! 		int32_t	c_flags;	    /* additional information */
! 		int32_t	c_firstrec;	    /* first record on volume */
! 		int32_t	c_spare[32];	    /* reserved for future uses */
  	} s_spcl;
  } u_spcl;
  #define spcl u_spcl.s_spcl
*** sbin/dump/traverse.c.ORIG	Sat Oct 14 02:08:54 1995
--- sbin/dump/traverse.c	Fri Nov 22 08:10:00 1996
***************
*** 73,79 ****
  #ifdef	FS_44INODEFMT
  typedef	quad_t fsizeT;
  #else
! typedef	long fsizeT;
  #endif
  
  static	int dirindir __P((ino_t ino, daddr_t blkno, int level, long *size));
--- 73,79 ----
  #ifdef	FS_44INODEFMT
  typedef	quad_t fsizeT;
  #else
! typedef	int32_t fsizeT;
  #endif
  
  static	int dirindir __P((ino_t ino, daddr_t blkno, int level, long *size));
***************
*** 507,520 ****
  writeheader(ino)
  	ino_t ino;
  {
! 	register long sum, cnt, *lp;
  
  	spcl.c_inumber = ino;
  	spcl.c_magic = NFS_MAGIC;
  	spcl.c_checksum = 0;
! 	lp = (long *)&spcl;
  	sum = 0;
! 	cnt = sizeof(union u_spcl) / (4 * sizeof(long));
  	while (--cnt >= 0) {
  		sum += *lp++;
  		sum += *lp++;
--- 507,520 ----
  writeheader(ino)
  	ino_t ino;
  {
! 	register int32_t sum, cnt, *lp;
  
  	spcl.c_inumber = ino;
  	spcl.c_magic = NFS_MAGIC;
  	spcl.c_checksum = 0;
! 	lp = (int32_t *)&spcl;
  	sum = 0;
! 	cnt = sizeof(union u_spcl) / (4 * sizeof(int32_t));
  	while (--cnt >= 0) {
  		sum += *lp++;
  		sum += *lp++;
*** sbin/restore/dirs.c.ORIG	Thu Oct 24 13:14:01 1996
--- sbin/restore/dirs.c	Fri Nov 22 07:43:42 1996
***************
*** 76,83 ****
  struct inotab {
  	struct	inotab *t_next;
  	ino_t	t_ino;
! 	long	t_seekpt;
! 	long	t_size;
  };
  static struct inotab *inotab[HASHSIZE];
  
--- 76,83 ----
  struct inotab {
  	struct	inotab *t_next;
  	ino_t	t_ino;
! 	int32_t	t_seekpt;
! 	int32_t	t_size;
  };
  static struct inotab *inotab[HASHSIZE];
  
***************
*** 100,107 ****
  #define DIRBLKSIZ 1024
  struct rstdirdesc {
  	int	dd_fd;
! 	long	dd_loc;
! 	long	dd_size;
  	char	dd_buf[DIRBLKSIZ];
  };
  
--- 100,107 ----
  #define DIRBLKSIZ 1024
  struct rstdirdesc {
  	int	dd_fd;
! 	int32_t	dd_loc;
! 	int32_t	dd_size;
  	char	dd_buf[DIRBLKSIZ];
  };
  
*** sbin/restore/symtab.c.ORIG	Sat Oct 14 02:13:34 1995
--- sbin/restore/symtab.c	Fri Nov 22 07:42:14 1996
***************
*** 439,451 ****
   * Useful quantities placed at the end of a dumped symbol table.
   */
  struct symtableheader {
! 	long	volno;
! 	long	stringsize;
! 	long	entrytblsize;
  	time_t	dumptime;
  	time_t	dumpdate;
  	ino_t	maxino;
! 	long	ntrec;
  };
  
  /*
--- 439,451 ----
   * Useful quantities placed at the end of a dumped symbol table.
   */
  struct symtableheader {
! 	int32_t	volno;
! 	int32_t	stringsize;
! 	int32_t	entrytblsize;
  	time_t	dumptime;
  	time_t	dumpdate;
  	ino_t	maxino;
! 	int32_t	ntrec;
  };
  
  /*
*** sbin/restore/tape.c.ORIG	Sat Mar 16 13:18:43 1996
--- sbin/restore/tape.c	Fri Nov 22 07:40:53 1996
***************
*** 1002,1034 ****
  	long i;
  	union {
  		quad_t	qval;
! 		long	val[2];
  	} qcvt;
  	union u_ospcl {
  		char dummy[TP_BSIZE];
  		struct	s_ospcl {
! 			long	c_type;
! 			long	c_date;
! 			long	c_ddate;
! 			long	c_volume;
! 			long	c_tapea;
! 			u_short	c_inumber;
! 			long	c_magic;
! 			long	c_checksum;
  			struct odinode {
  				unsigned short odi_mode;
! 				u_short	odi_nlink;
! 				u_short	odi_uid;
! 				u_short	odi_gid;
! 				long	odi_size;
! 				long	odi_rdev;
! 				char	odi_addr[36];
! 				long	odi_atime;
! 				long	odi_mtime;
! 				long	odi_ctime;
  			} c_dinode;
! 			long	c_count;
! 			char	c_addr[256];
  		} s_ospcl;
  	} u_ospcl;
  
--- 1002,1034 ----
  	long i;
  	union {
  		quad_t	qval;
! 		int32_t	val[2];
  	} qcvt;
  	union u_ospcl {
  		char dummy[TP_BSIZE];
  		struct	s_ospcl {
! 			int32_t   c_type;
! 			int32_t   c_date;
! 			int32_t   c_ddate;
! 			int32_t   c_volume;
! 			int32_t   c_tapea;
! 			u_int16_t c_inumber;
! 			int32_t   c_magic;
! 			int32_t   c_checksum;
  			struct odinode {
  				unsigned short odi_mode;
! 				u_int16_t odi_nlink;
! 				u_int16_t odi_uid;
! 				u_int16_t odi_gid;
! 				int32_t   odi_size;
! 				int32_t   odi_rdev;
! 				char      odi_addr[36];
! 				int32_t   odi_atime;
! 				int32_t   odi_mtime;
! 				int32_t   odi_ctime;
  			} c_dinode;
! 			int32_t c_count;
! 			char    c_addr[256];
  		} s_ospcl;
  	} u_ospcl;