Skip to contentSkip to conversation

xfsdump: remove unnecessary #ifdefs

PATCH In review Bill Kendall 3 participants 3 messages Aug 30, 2011 – Sep 19, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfsdump: remove unnecessary #ifdefs

There are a number of #defines in xfsdump that are always enabled and no longer need to be conditional code. This patch removes the following macros and enables the related code unconditionally:

- SIZEEST is required for multi-stream dumps for determining split points.

- RMT, BASED and SESSCPLT are tied to command line options (dump/restore -m, dump -B and restore -Q, respectively).

- INVCONVFIX, PIPEINVFIX, and EOMFIX are all related to fixes that went in a long time ago.

- WHITEPARSE allows for filenames with spaces and special chars to be properly parsed during an interactive restore session.

- DOSOCKS allows Unix domain sockets to be backed up and restored. Other special files (block/char devs, FIFOs) are always backed up, so do the same for sockets.

Additionally the definition of F_FSSETDM has been removed from restore/Makefile since it is never referenced.

---
 common/drive_minrmt.c   |   12 ------
 common/drive_scsitape.c |   12 ------
 common/drive_simple.c   |    2 -
 common/main.c           |    4 --
 dump/Makefile           |    2 +-
 dump/content.c          |   46 ------------------------
 dump/inomap.c           |    2 -
 dump/inomap.h           |    2 -
 inventory/inv_stobj.c   |   11 ------
 invutil/Makefile        |    4 +--
 restore/Makefile        |    4 +--
 restore/content.c       |   89 ++++++++--------------------------------------
 restore/dirattr.c       |    2 -
 restore/namreg.c        |    2 -
 restore/tree.c          |   33 -----------------
 15 files changed, 19 insertions(+), 208 deletions(-)
common/drive_minrmt.c +0 -12
index e76345e..836b663 100644
@@ -57,7 +57,6 @@
 
 /* remote tape protocol debug
  */
-#ifdef RMT
 #ifdef RMTDBG
 #define	open(p,f)		dbgrmtopen(p,f)
 #define	close(fd)		dbgrmtclose(fd)
@@ -71,7 +70,6 @@
 #define	read rmtread
 #define	write rmtwrite
 #endif /* RMTDBG */
-#endif /* RMT */
 
 /* if the media file header structure changes, this number must be
  * bumped, and STAPE_VERSION_1 must be defined and recognized.
@@ -242,21 +240,17 @@ typedef struct drive_context drive_context_t;
 
 extern void usage( void );
 #ifdef DUMP
-#ifdef SIZEEST
 extern u_int64_t hdr_mfilesz;
-#endif /* SIZEEST */
 #endif /* DUMP */
 
 /* remote tape protocol declarations (should be a system header file)
  */
-#ifdef RMT
 extern int rmtopen( char *, int, ... );
 extern int rmtclose( int );
 extern int rmtfstat( int, struct stat * );
 extern int rmtioctl( int, int, ... );
 extern int rmtread( int, void*, uint);
 extern int rmtwrite( int, const void *, uint);
-#endif /* RMT */
 
 
 /* forward declarations of locally defined static functions ******************/
@@ -345,7 +339,6 @@ static bool_t isxfsdumperasetape( drive_t *drivep );
 
 /* RMT trace stubs
  */
-#ifdef RMT
 #ifdef RMTDBG
 static int dbgrmtopen( char *, int );
 static int dbgrmtclose( int );
@@ -353,7 +346,6 @@ static int dbgrmtioctl( int, int, void * );
 static int dbgrmtread( int, void *, uint);
 static int dbgrmtwrite( int, void *, uint);
 #endif /* RMTDBG */
-#endif /* RMT */
 
 #define ERASE_MAGIC "$^*@++! This tape was quick erased by SGI xfsdump $^*@++!"
 
@@ -2760,7 +2752,6 @@ set_recommended_sizes( drive_t *drivep )
 	if (contextp->dc_filesz > 0) {
 		fsize = contextp->dc_filesz;
 #ifdef DUMP
-#ifdef SIZEEST
 		if ( hdr_mfilesz > fsize ) {
 			mlog( MLOG_WARNING, _(
 			      "recommended media file size of %llu Mb less than "
@@ -2769,7 +2760,6 @@ set_recommended_sizes( drive_t *drivep )
 			      hdr_mfilesz / ( 1024 * 1024 ),
 			      drivep->d_pathname );
 		}
-#endif /* SIZEEST */
 #endif /* DUMP */
 	}
 
@@ -2964,7 +2954,6 @@ tape_rec_checksum_check( drive_context_t *contextp, char *bufp )
 
 /* to trace rmt operations
  */
-#ifdef RMT
 #ifdef RMTDBG
 static int
 dbgrmtopen( char *path, int flags )
@@ -3039,7 +3028,6 @@ dbgrmtwrite( int fd, void *p, uint sz )
 	return rval;
 }
 #endif /* RMTDBG */
-#endif /* RMT */
 
 /* display_access_failed_message()
  *	Print tape device open/access failed message.
common/drive_scsitape.c +0 -12
index e436eb1..8c1bd49 100644
@@ -53,7 +53,6 @@
 
 /* remote tape protocol debug
  */
-#ifdef RMT
 #ifdef RMTDBG
 #define	open(p,f)		dbgrmtopen(p,f)
 #define	close(fd)		dbgrmtclose(fd)
@@ -67,7 +66,6 @@
 #define	read rmtread
 #define	write rmtwrite
 #endif /* RMTDBG */
-#endif /* RMT */
 
 /* if the media file header structure changes, this number must be
  * bumped, and STAPE_VERSION_1 must be defined and recognized.
@@ -284,21 +282,17 @@ typedef long mtstat_t;
 
 extern void usage( void );
 #ifdef DUMP
-#ifdef SIZEEST
 extern u_int64_t hdr_mfilesz;
-#endif /* SIZEEST */
 #endif /* DUMP */
 
 /* remote tape protocol declarations (should be a system header file)
  */
-#ifdef RMT
 extern int rmtopen( char *, int, ... );
 extern int rmtclose( int );
 extern int rmtfstat( int, struct stat * );
 extern int rmtioctl( int, int, ... );
 extern int rmtread( int, void*, uint);
 extern int rmtwrite( int, const void *, uint);
-#endif /* RMT */
 
 
 /* forward declarations of locally defined static functions ******************/
@@ -390,7 +384,6 @@ static void map_ts_status( struct mtget *, struct mtget_sgi );
 
 /* RMT trace stubs
  */
-#ifdef RMT
 #ifdef RMTDBG
 static int dbgrmtopen( char *, int );
 static int dbgrmtclose( int );
@@ -398,7 +391,6 @@ static int dbgrmtioctl( int, int, void *);
 static int dbgrmtread( int, void*, uint);
 static int dbgrmtwrite( int, void *, uint);
 #endif /* RMTDBG */
-#endif /* RMT */
 
 /* definition of locally defined global variables ****************************/
 
@@ -3292,7 +3284,6 @@ set_recommended_sizes( drive_t *drivep )
 	if (contextp->dc_filesz > 0) {
 		fsize = contextp->dc_filesz;
 #ifdef DUMP
-#ifdef SIZEEST
 		if ( hdr_mfilesz > fsize ) {
 			mlog( MLOG_WARNING, _(
 			      "recommended media file size of %llu Mb less than"
@@ -3301,7 +3292,6 @@ set_recommended_sizes( drive_t *drivep )
 			      hdr_mfilesz / ( 1024 * 1024 ),
 			      drivep->d_pathname );
 		}
-#endif /* SIZEEST */
 #endif /* DUMP */
         }
 
@@ -3657,7 +3647,6 @@ tape_rec_checksum_check( drive_context_t *contextp, char *bufp )
 
 /* to trace rmt operations
  */
-#ifdef RMT
 #ifdef RMTDBG
 static int
 dbgrmtopen( char *path, int flags )
@@ -3732,7 +3721,6 @@ dbgrmtwrite( int fd, void *p, uint sz )
 	return rval;
 }
 #endif /* RMTDBG */
-#endif /* RMT */
 
 /* display_access_failed_message()
  *	Print tape device open/access failed message.
common/drive_simple.c +0 -2
index 1938619..cb88aa8 100644
@@ -35,7 +35,6 @@
 #include "media.h"
 #include "arch_xlate.h"
 
-#ifdef RMT
 /* this rmt junk is here because the rmt protocol supports writing ordinary
  * (non-device) files in the remote /dev directory! yuck!
  */
@@ -52,7 +51,6 @@ extern int rmtioctl( int, int, ... );
 extern int rmtopen( char *, int, ... );
 extern int rmtread( int, void*, uint);
 extern int rmtwrite( int, const void *, uint);
-#endif
 
 
 /* drive_simple.c - drive strategy for standard in or a file
common/main.c +0 -4
index 980d2d4..55cdd93 100644
@@ -970,9 +970,7 @@ usage( void )
 	ULO(_("<verbosity {silent, verbose, trace}>"),	GETOPT_VERBOSITY );
 	ULO(_("<maximum file size>"),			GETOPT_MAXDUMPFILESIZE );
 	ULO(_("(don't dump extended file attributes)"),	GETOPT_NOEXTATTR );
-#ifdef BASED
 	ULO(_("<base dump session id>"),		GETOPT_BASED );
-#endif /* BASED */
 #ifdef REVEAL
 	ULO(_("(generate tape record checksums)"),	GETOPT_RECCHKSUM );
 #endif /* REVEAL */
@@ -1043,9 +1041,7 @@ usage( void )
 #ifdef REVEAL
 	ULO(_("(pin down I/O buffers)"),		GETOPT_RINGPIN );
 #endif /* REVEAL */
-#ifdef SESSCPLT
 	ULO(_("(force interrupted session completion)"),GETOPT_SESSCPLT );
-#endif /* SESSCPLT */
 	ULO(_("(resume)"),				GETOPT_RESUME );
 	ULO(_("<session id>"),				GETOPT_SESSIONID );
 	ULO(_("(don't timeout dialogs)"),		GETOPT_NOTIMEOUTS );
dump/Makefile +1 -1
index 8c6172e..ce964a0 100644
@@ -92,7 +92,7 @@ LDIRT = $(LINKS)
 LLDLIBS = $(LIBUUID) $(LIBHANDLE) $(LIBATTR) $(LIBRMT)
 LTDEPENDENCIES = $(LIBRMT)
 
-LCFLAGS = -DDUMP -DRMT -DBASED -DDOSOCKS -DINVCONVFIX -DSIZEEST -DPIPEINVFIX
+LCFLAGS = -DDUMP
 
 default: depend $(LTCOMMAND)
 
dump/content.c +0 -46

146 lines not on this page · raw message

dump/inomap.c +0 -2
index fcb5792..3055391 100644
@@ -1089,13 +1089,11 @@ inomap_init( intgen_t igrpcnt )
 	return 0;
 }
 
-#ifdef SIZEEST
 u_int64_t
 inomap_getsz( void )
 {
 	return (inomap.lastseg.hnkoff + 1) * HNKSZ;
 }
-#endif /* SIZEEST */
 
 static inline bool_t
 inomap_validaddr( seg_addr_t *addrp )
dump/inomap.h +0 -2
index 4c3cfa9..ce6bd9d 100644
@@ -64,9 +64,7 @@ extern bool_t inomap_build( jdm_fshandle_t *fshandlep,
 			    size64_t statcnt,
 			    size64_t *statdonep );
 
-#ifdef SIZEEST
 extern u_int64_t inomap_getsz( void );
-#endif /* SIZEEST */
 
 /* inomap_skip - tell inomap about inodes to skip in the dump
  */
inventory/inv_stobj.c +0 -11
index d1d6f08..becac17 100644
@@ -1287,23 +1287,16 @@ stobj_convert_sessinfo(inv_session_t **buf, invt_sessinfo_t *sinfo)
 {
 	inv_session_t  *ises;
 	int i, j, nmf;
-#ifdef INVCONVFIX
 	int nstreams;
 	invt_mediafile_t *mf;
-#endif /* INVCONVFIX */
 
 	ises = calloc( 1, sizeof( inv_session_t ) );
 
 	stobj_convert_session(ises, sinfo->ses, sinfo->seshdr);
 	ises->s_streams = calloc( ises->s_nstreams, sizeof( inv_stream_t ) );
-#ifdef INVCONVFIX
 	mf = sinfo->mfiles;
 	nstreams = (int) ises->s_nstreams;
 	for ( i = 0 ; i < nstreams ; i++ ) {
-#else /* INVCONVFIX */
-	i = (int) ises->s_nstreams;
-	while ( i-- ) {
-#endif /* INVCONVFIX */
 		stobj_convert_strm(&ises->s_streams[i], &sinfo->strms[i]);
 		nmf = (int) ises->s_streams[i].st_nmediafiles;
 		ises->s_streams[i].st_mediafiles = calloc( (u_int) nmf,
@@ -1311,11 +1304,7 @@ stobj_convert_sessinfo(inv_session_t **buf, invt_sessinfo_t *sinfo)
 
 		for ( j = 0; j < nmf; j++ ) {
 			stobj_convert_mfile( &ises->s_streams[i].st_mediafiles[j],
-#ifdef INVCONVFIX
 					     mf++ );
-#else /* INVCONVFIX */
-					     sinfo->mfiles);
-#endif /* INVCONVFIX */
 		}
 	}
 	
invutil/Makefile +1 -3
index cfd6cb0..7136ee9 100644
@@ -49,9 +49,7 @@ LINKS  = $(COMMINCL) $(COMMON) $(INVINCL) $(INVCOMMON)
 LDIRT = $(LINKS)
 LLDLIBS = $(LIBUUID) $(LIBCURSES)
 
-#LCFLAGS = -DDUMP -DRMT -DEXTATTR -DBASED -DDOSOCKS -DINVCONVFIX -DSIZEEST -DPIPEINVFIX
-LCFLAGS = -DDUMP -DBASED -DDOSOCKS -DINVCONVFIX -DSIZEEST -DPIPEINVFIX
-#LCFLAGS = -DINV_DEBUG -DDUMP -DBASED -DDOSOCKS -DINVCONVFIX -DSIZEEST -DPIPEINVFIX
+LCFLAGS = -DDUMP
 
 ifeq ($(ENABLE_CURSES), yes)
 CFILES += $(CURSESCOMMON)
restore/Makefile +1 -3
index 588a8f0..003ea16 100644
@@ -102,9 +102,7 @@ LDIRT = $(LINKS)
 LLDLIBS = $(LIBUUID) $(LIBHANDLE) $(LIBATTR) $(LIBRMT)
 LTDEPENDENCIES = $(LIBRMT)
 
-LCFLAGS = -DRESTORE -DRMT -DBASED -DDOSOCKS -DINVCONVFIX -DPIPEINVFIX \
-	-DEOMFIX -DSESSCPLT -DWHITEPARSE \
-	-DF_FSSETDM
+LCFLAGS = -DRESTORE
 
 default: depend $(LTCOMMAND)
 
restore/content.c +16 -73

252 lines not on this page · raw message

restore/dirattr.c +0 -2
index ec160af..68d1b49 100644
@@ -197,11 +197,9 @@ static dirattr_pers_t *dpp = 0;
 bool_t
 dirattr_init( char *hkdir, bool_t resume, u_int64_t dircnt )
 {
-#ifdef SESSCPLT
 	if ( dtp ) {
 		return BOOL_TRUE;
 	}
-#endif /* SESSCPLT */
 
 	/* sanity checks
 	 */
restore/namreg.c +0 -2
index 619a7d7..80d558a 100644
@@ -114,11 +114,9 @@ static namreg_pers_t *npp = 0;
 bool_t
 namreg_init( char *hkdir, bool_t resume, u_int64_t inocnt )
 {
-#ifdef SESSCPLT
 	if ( ntp ) {
 		return BOOL_TRUE;
 	}
-#endif /* SESSCPLT */
 
 	/* sanity checks
 	 */
restore/tree.c +0 -33
index 25652e9..7bddddf 100644
@@ -511,11 +511,9 @@ tree_sync( char *hkdir,
 	bool_t ok;
 	intgen_t rval;
 
-#ifdef SESSCPLT
 	if ( persp ) {
 		return BOOL_TRUE;
 	}
-#endif /* SESSCPLT */
 
 	/* sanity checks
 	 */
@@ -3028,8 +3026,6 @@ tsi_cmd_quit( void *ctxp,
 {
 }
 
-#ifdef WHITEPARSE
-
 static int parse( int slotcnt, char **slotbuf, char *string );
 
 static void
@@ -3047,31 +3043,6 @@ tsi_cmd_parse( char *buf )
 	tranp->t_inter.i_argc = ( size_t )min( max( 0, wordcnt ), INTER_ARGMAX );
 }
 
-#else /* WHITEPARSE */
-
-static void
-tsi_cmd_parse( char *buf )
-{
-	size_t argc;
-	char *t;
-	char *b;
-
-	if ( ! buf ) {
-		tranp->t_inter.i_argc = 0;
-		return;
-	}
-
-	argc = 0;
-	b = buf;
-	while ( argc < INTER_ARGMAX && ( t = strtok( b, " \t" )) != 0 ) {
-		tranp->t_inter.i_argv[ argc++ ] = t;
-		b = 0;
-	}
-	tranp->t_inter.i_argc = argc;
-}
-
-#endif /* WHITEPARSE */
-
 struct tsi_cmd_tbl {
 	char *tct_pattern;
 	char *tct_help;
@@ -4579,8 +4550,6 @@ tree_chk2_recurse( nh_t cldh, nh_t parh )
 
 #endif /* TREE_CHK */
 
-#ifdef WHITEPARSE
-
 static char *whites = " \t\r\n\v\f";
 
 static int is_white( char c );
@@ -4894,8 +4863,6 @@ octal_to_size( char c )
 	return 0;
 }
 
-#endif /* WHITEPARSE */
-
 static int
 mkdir_r(char *path)
 {
Signature · 6 lines
1.7.0.4

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Reviewed-by on v1 1/1
#2 lore raw
In reply to Bill Kendall
Quoted 16 lines · Bill Kendall

There are a number of #defines in xfsdump that are always enabled and no longer need to be conditional code. This patch removes the following macros and enables the related code unconditionally:

- SIZEEST is required for multi-stream dumps for determining split points.

- RMT, BASED and SESSCPLT are tied to command line options (dump/restore -m, dump -B and restore -Q, respectively).

- INVCONVFIX, PIPEINVFIX, and EOMFIX are all related to fixes that went in a long time ago.

- WHITEPARSE allows for filenames with spaces and special chars to be properly parsed during an interactive restore session.

Quoted 6 lines

- DOSOCKS allows Unix domain sockets to be backed up and restored. Other special files (block/char devs, FIFOs) are always backed up, so do the same for sockets.

Additionally the definition of F_FSSETDM has been removed from restore/Makefile since it is never referenced.

Looks good. Sorry it took so long to get to this.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs