🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Eugene Brooks Wed, 04 Jan 1989 07:41
(none)
#1437
Author: Eugene Brooks
Date: Wed, 04 Jan 1989 07:41
250 lines
7832 bytes
GNU tar, version 1.01 does not seem to set the magic field to GNUMAGIC when
in "GNU dump" mode, as advertized in the tar.texinfo file.  

The patches below add yet another feature to GNU tar, version 1.01.  If
the 'a' flag is added, when the c flag is used, the patched version of tar
will set the magic field to AMAGIC and include access times in the header.
It will also reset the access dates of the files on the disk to the access
date that existed before the archive was made.

Upon extraction, if the magic field is AMAGIC, the -m option will be disabled
and the file modified and access dates will be set to those recorded on the
archive.  The patched version of tar is useful in conjunction with a stale
file management program named "derez" which was submitted to comp.sources.unix
a long time ago.  Some sites might want to make -a the default behaviour
if they are serious about keeping tar from hiding stale files on their system.

If anyone sees any problems with these modifications, we would like to know!

*** /tmp/,RCSt1a09462	Tue Jan  3 23:25:24 1989
--- create.c	Tue Jan  3 22:45:55 1989
***************
*** 347,353
  		if(f_multivol)
  			save_name = 0;
  
! 		if (f >= 0)
  			(void)close(f);
  
  		break;

--- 347,353 -----
  		if(f_multivol)
  			save_name = 0;
  
! 		if (f >= 0) {
  			(void)close(f);
  			if(f_atime) {
  				time_t times[2];
***************
*** 349,354
  
  		if (f >= 0)
  			(void)close(f);
  
  		break;
  

--- 349,364 -----
  
  		if (f >= 0) {
  			(void)close(f);
+ 			if(f_atime) {
+ 				time_t times[2];
+ 				times[0] = hstat.st_atime;
+ 				times[1] = hstat.st_mtime;
+ 				/* Ignore any error from utime as we might
+ 				not have write permission on the file.
+ 					*/
+ 				utime(p, times) < 0);
+ 			}
+ 		}
  
  		break;
  
***************
*** 640,645
  		findgname(header->header.gname, st->st_gid);
  	}
  #endif
  	return header;
  }
  

--- 650,661 -----
  		findgname(header->header.gname, st->st_gid);
  	}
  #endif
+ 
+ 	if(f_atime && !f_gnudump) {
+ 		to_oct((long) st->st_atime, 1+12, header->header.atime);
+ 		strcpy(header->header.magic, AMAGIC);	/* Mark to restore atime and disable -m flag on extract. */
+ 	}
+ 		
  	return header;
  }
  
*** /tmp/,RCSt1a09468	Tue Jan  3 23:25:26 1989
--- extract.c	Tue Jan  3 22:42:18 1989
***************
*** 298,304
  		 * is really "the time we started extracting files".
  		 * unless f_gnudump is used, in which case .st_atime is used
  		 */
! 		if (!f_modified) {
  			/* fixme if f_gnudump should set ctime too, but how? */
  			if(f_gnudump) acc_upd_times[0]=hstat.st_atime;
  			else acc_upd_times[0] = now;	         /* Accessed now */

--- 298,304 -----
  		 * is really "the time we started extracting files".
  		 * unless f_gnudump is used, in which case .st_atime is used
  		 */
! 		if (!f_modified || f_atime) {
  			/* fixme if f_gnudump should set ctime too, but how? */
  			if(f_gnudump || f_atime) acc_upd_times[0]=hstat.st_atime;
  			else acc_upd_times[0] = now;	         /* Accessed now */
***************
*** 300,306
  		 */
  		if (!f_modified) {
  			/* fixme if f_gnudump should set ctime too, but how? */
! 			if(f_gnudump) acc_upd_times[0]=hstat.st_atime;
  			else acc_upd_times[0] = now;	         /* Accessed now */
  			acc_upd_times[1] = hstat.st_mtime; /* Mod'd */
  			if (utime(skipcrud+head->header.name,

--- 300,306 -----
  		 */
  		if (!f_modified || f_atime) {
  			/* fixme if f_gnudump should set ctime too, but how? */
! 			if(f_gnudump || f_atime) acc_upd_times[0]=hstat.st_atime;
  			else acc_upd_times[0] = now;	         /* Accessed now */
  			acc_upd_times[1] = hstat.st_mtime; /* Mod'd */
  			if (utime(skipcrud+head->header.name,
*** /tmp/,RCSt1a09474	Tue Jan  3 23:25:27 1989
--- list.c	Tue Jan  3 21:42:52 1989
***************
*** 327,332
  		st->st_uid = from_oct(8,  header->header.uid);
  		st->st_gid = from_oct(8,  header->header.gid);
  		st->st_rdev = 0;
  	}
  }
  

--- 327,339 -----
  		st->st_uid = from_oct(8,  header->header.uid);
  		st->st_gid = from_oct(8,  header->header.gid);
  		st->st_rdev = 0;
+ 		if (0==strcmp(header->header.magic, AMAGIC)) {
+ 			st->st_atime = from_oct(1+12, header->header.atime);
+ 			f_atime = 1;
+ 		}
+ 		else {
+ 			f_atime = 0;
+ 		}
  	}
  }
  
*** /tmp/,RCSt1a09480	Tue Jan  3 23:25:29 1989
--- tar.c	Tue Jan  3 22:50:40 1989
***************
*** 182,188
  		ar_file = DEF_AR_FILE;	/* From Makefile */
  
  	/* Parse options */
! 	while ((c = getoldopt(argc, argv, "01234567Ab:BcdDf:GhikK:lmMN:oOprRstT:uvV:wWxX:zZ")
  		) != EOF) {
  		switch (c) {
  		case '0':

--- 182,188 -----
  		ar_file = DEF_AR_FILE;	/* From Makefile */
  
  	/* Parse options */
! 	while ((c = getoldopt(argc, argv, "01234567aAb:BcdDf:GhikK:lmMN:oOprRstT:uvV:wWxX:zZ")
  		) != EOF) {
  		switch (c) {
  		case '0':
***************
*** 214,219
  			}
  			break;
  
  		case 'A':			/* Arguments are tar files,
  						   just cat them onto the end
  						   of the archive.  */

--- 214,226 -----
  			}
  			break;
  
+ 		case 'a':			/* Preserve access times.
+ 							*/
+ 			if(cmd_mode!=CMD_CREATE)
+ 				goto badopt;
+ 			f_atime = 1;
+ 			break;
+ 
  		case 'A':			/* Arguments are tar files,
  						   just cat them onto the end
  						   of the archive.  */
***************
*** 440,445
  
  	fputs("\
  Other options:\n\
  -b N	blocking factor N (block size = Nx512 bytes)\n\
  -B	reblock as we read (for reading 4.2BSD pipes)\n\
  -C dir	change to directory DIR\n\

--- 447,455 -----
  
  	fputs("\
  Other options:\n\
+ -a	Include the time of last access in the archive, and set a magic field\n\
+ 	which will cause the access time to be restored and the -m flag to be\n\
+ 	ignored upon extraction.  The -a flag can only be used with -c.\n\
  -b N	blocking factor N (block size = Nx512 bytes)\n\
  -B	reblock as we read (for reading 4.2BSD pipes)\n\
  -C dir	change to directory DIR\n\
*** /tmp/,RCSt1a09486	Tue Jan  3 23:25:32 1989
--- tar.h	Tue Jan  3 21:09:55 1989
***************
*** 82,87
  /* The magic field is filled with this if uname and gname are valid. */
  #define	TMAGIC		"ustar  "	/* 7 chars and a null */
  
  /* The linkflag defines the type of file */
  #define	LF_OLDNORMAL	'\0'		/* Normal disk file, Unix compat */
  #define	LF_NORMAL	'0'		/* Normal disk file */

--- 82,91 -----
  /* The magic field is filled with this if uname and gname are valid. */
  #define	TMAGIC		"ustar  "	/* 7 chars and a null */
  
+ /* The magic field is filled with this if the image is a "rerez" archive.
+ The atime field is valid and the -m flag is to be disabled on extraction. */
+ #define AMAGIC		"rerez  "	/* 7 chars and a null */
+ 
  /* The linkflag defines the type of file */
  #define	LF_OLDNORMAL	'\0'		/* Normal disk file, Unix compat */
  #define	LF_NORMAL	'0'		/* Normal disk file */
***************
*** 175,180
  TAR_EXTERN char f_exclude;		/* -X */
  TAR_EXTERN char	f_compress;		/* -z */
  					/* -Z */
  
  /*
   * We now default to Unix Standard format rather than 4.2BSD tar format.

--- 179,185 -----
  TAR_EXTERN char f_exclude;		/* -X */
  TAR_EXTERN char	f_compress;		/* -z */
  					/* -Z */
+ TAR_EXTERN char f_atime;		/* -a */
  
  /*
   * We now default to Unix Standard format rather than 4.2BSD tar format.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads