diff -cNr afio.2.4.2/HISTORY afio.2.4.2k2/HISTORY
*** afio.2.4.2/HISTORY	Fri May  8 18:17:33 1998
--- afio.2.4.2k2/HISTORY	Sun May 10 13:12:44 1998
***************
*** 237,239 ****
--- 237,254 ----
  file by karsten.ballueder@stud.uni-karlsruhe.de.  Added script3/
  directory to distribution.
  
+ Version 2.4.2k1: Takatsugu Nokubi (knok@daionet.gr.jp)
+ 
+ Added -N option that creates new ASCII format header. It holds
+ unsigned long i-node number. However it is incompatible with cpio
+ archives format.
+ 
+ Added code that checks hard link strictly. If some files have same
+ i-node number but different file size, they are treated as different
+ files. This code is enabled by defining STRICT_LINK_CHECK macro.
+ 
+ Version 2.4.2k2: Takatsugu Nokubi (knok@daionet.gr.jp)
+ 
+ Strict hard link checing code can't treat correctry link. So I removed
+ the code.
+ 
diff -cNr afio.2.4.2/afio.c afio.2.4.2k2/afio.c
*** afio.2.4.2/afio.c	Fri May  8 18:17:33 1998
--- afio.2.4.2k2/afio.c	Sun May 10 13:10:23 1998
***************
*** 151,156 ****
--- 151,157 ----
       int printbytepos = 0;      /* print position of each file in archive */
       unsigned long bytepos;     /* position of first byte of current file */
       STATIC char *controlscript=NULL;  /* script to pipe control files to */
+      STATIC ushort newfmt = 0;  /* Use new ASCII format */
  
  main (ac, av)
       int ac;
***************
*** 175,181 ****
    /* ignore SIGPIPE to deal with gzip -d exiting prematurely */
    VOID signal (SIGPIPE, SIG_IGN);
    while (c = options (ac, av, 
!          "aioprtIOVCb:c:de:fghjklmns:uvxXy:Y:zFKZL:R:qAE:G:M:w:W:T:SBD:P:Q:U")
          )
      {
        switch (c)
--- 176,182 ----
    /* ignore SIGPIPE to deal with gzip -d exiting prematurely */
    VOID signal (SIGPIPE, SIG_IGN);
    while (c = options (ac, av, 
!          "aioprtIOVCb:c:de:fghjklmns:uvxXy:Y:zFKZL:R:qAE:G:M:w:W:T:SBD:P:Q:UN")
          )
      {
        switch (c)
***************
*** 382,387 ****
--- 383,391 ----
    	case 'U':	/* compress All files */
    	  forceZflag=1;
     	  break;
+ 	case 'N':       /* Use new ASCII format */
+ 	  newfmt = 1;
+ 	  break;
  
  	default:
  	  usage ();
***************
*** 853,858 ****
--- 857,911 ----
  }
  
  /*
+  * inascii2()
+  *
+  * Read an ASCII header (new format). Returns zero if successful;
+  * -1 otherwise. Assumes that the entire magic number
+  * has been read.
+  */
+ 
+ STATIC int
+ inascii2 (magic, name, asb)
+      reg char *magic;
+      reg char *name;
+      reg Stat *asb;
+ {
+   auto uint namelen;
+   auto char header[H_STRLEN2 + 1];
+   PStat pasb;
+ 
+   if (strncmp (magic, M_ASCII2, M_STRLEN) != 0)
+     return (-1);
+   if (inread (header, H_STRLEN2) < 0)
+     return (warnarch ("Corrupt ASCII header", (off_t) H_STRLEN2));
+   header[H_STRLEN2] = '\0';
+   /* this should be much more portable than the one above */
+   if (sscanf (header, PH_SCAN2, &pasb.st_dev,
+ 	      &pasb.st_ino, &pasb.st_mode, &pasb.st_uid,
+ 	      &pasb.st_gid, &pasb.st_nlink, &pasb.st_rdev,
+ 	      &pasb.st_mtime, &namelen, &pasb.st_size) != H_COUNT)
+     return (warnarch ("Bad ASCII header", (off_t) H_STRLEN));
+   /* now, we let the compiler cast the info to the right types (field sizes) */
+   asb->sb_dev = pasb.st_dev;
+   asb->sb_ino = pasb.st_ino;
+   asb->sb_mode = pasb.st_mode;
+   asb->sb_uid = pasb.st_uid;
+   asb->sb_gid = pasb.st_gid;
+   asb->sb_nlink = pasb.st_nlink;
+   asb->sb_rdev = pasb.st_rdev;
+   asb->sb_mtime = pasb.st_mtime;
+   asb->sb_size = pasb.st_size;
+ 
+   if (namelen == 0 || namelen >= PATHSIZE)
+     return (warnarch ("Bad ASCII pathname length", (off_t) H_STRLEN));
+   if (inread (name, namelen) < 0)
+     return (warnarch ("Corrupt ASCII pathname", (off_t) namelen));
+   if (name[namelen - 1] != '\0')
+     return (warnarch ("Bad ASCII pathname", (off_t) namelen));
+   return (0);
+ }
+ 
+ /*
   * inavail()
   *
   * Index availible input data within the buffer. Stores a pointer
***************
*** 1293,1298 ****
--- 1346,1352 ----
        VOID inread (magic, M_STRLEN);
        skipped = 0;
        while ((align = inascii (magic, name, asb)) < 0
+ 	     && (align = inascii2 (magic, name, asb)) < 0
  	     && (align = inbinary (magic, name, asb)) < 0
  	     && (align = inswab (magic, name, asb)) < 0)
  	{
***************
*** 2618,2624 ****
  		VOID linkto (name, &sb);
  	}
  	
! 	outhead (name, &sb);
  	if (fd)
  	    if (fd==ZIPFD) 
  	    {
--- 2672,2678 ----
  		VOID linkto (name, &sb);
  	}
  	
! 	newfmt == 1 ? outhead2 (name, &sb) : outhead (name, &sb);
  	if (fd)
  	    if (fd==ZIPFD) 
  	    {
***************
*** 2924,2929 ****
--- 2978,3015 ----
  }
  
  /*
+  * outhead2()
+  *
+  * Write an archive header.
+  */
+ STATIC void
+ outhead2 (name, asb)
+      reg char *name;
+      reg Stat *asb;
+ {
+   reg uint namelen;
+   auto char header[M_STRLEN + H_STRLEN2 + 1];
+ 
+   if ((name[0] == '/') && !abspaths)
+     if (name[1])
+       ++name;
+     else
+       name = ".";
+   namelen = (uint) strlen (name) + 1;
+   VOID strcpy (header, M_ASCII2);
+   VOID sprintf (header + M_STRLEN, H_PRINT2, ush (asb->sb_dev),
+ 		(asb->sb_ino), ush (asb->sb_mode), ush (asb->sb_uid),
+ 		ush (asb->sb_gid), ush (asb->sb_nlink), ush (asb->sb_rdev),
+ 		mflag ? timenow : asb->sb_mtime, namelen, asb->sb_size);
+   outwrite (header, M_STRLEN + H_STRLEN2);
+   outwrite (name, namelen);
+ #ifdef	S_IFLNK
+   if ((asb->sb_mode & S_IFMT) == S_IFLNK)
+     outwrite (asb->sb_link, (uint) asb->sb_size);
+ #endif /* S_IFLNK */
+ }
+ 
+ /*
   * outpad()
   *
   * Pad the archive.
***************
*** 3524,3530 ****
   Floppy:  -F : device is a floppy drive, -s required    -K : verify floppies\n\
   Install: -n : protect newer files  -k : skip corrupt data at beginning\n\
   Select:  -y [pattern] : only process files matching pattern\n\
!           -Y [pattern] : do not process files matching pattern\n",
  		myname, myname, myname, myname);
    VOID fprintf (stderr,"Version %s dated %s\n", VERSION, DATE);
    exit (1);
--- 3610,3617 ----
   Floppy:  -F : device is a floppy drive, -s required    -K : verify floppies\n\
   Install: -n : protect newer files  -k : skip corrupt data at beginning\n\
   Select:  -y [pattern] : only process files matching pattern\n\
!           -Y [pattern] : do not process files matching pattern\n\
!  Format:  -N : Create new ASCII format archive\n",
  		myname, myname, myname, myname);
    VOID fprintf (stderr,"Version %s dated %s\n", VERSION, DATE);
    exit (1);
diff -cNr afio.2.4.2/afio.h afio.2.4.2k2/afio.h
*** afio.2.4.2/afio.h	Fri May  8 18:17:33 1998
--- afio.2.4.2k2/afio.h	Fri May  8 18:17:33 1998
***************
*** 100,110 ****
--- 100,112 ----
  #define	FSBUF	(8*1024)	/* Filesystem buffer size */
  #define	H_COUNT	10		/* Number of items in ASCII header */
  #define	H_PRINT	"%06o%06o%06o%06o%06o%06o%06o%011lo%06o%011lo"
+ #define	H_PRINT2	"%06o%011lo%06o%06o%06o%06o%06o%011lo%06o%011lo"
  
  /* H_SCAN is obsolete, replaced by PH_SCAN to be more portable. */
  #define	H_SCAN	"%6ho%6ho%6ho%6ho%6ho%6ho%6ho%11lo%6o%11lo"
  
  #define PH_SCAN  "%6lo%6lo%6lo%6lo%6lo%6lo%6lo%11lo%6o%11lo"
+ #define PH_SCAN2  "%6lo%11lo%6lo%6lo%6lo%6lo%6lo%11lo%6o%11lo"
  
  typedef struct {
  long unsigned int st_dev;
***************
*** 120,125 ****
--- 122,129 ----
  
  #define	H_STRLEN 70		/* ASCII header string length */
  #define	M_ASCII "070707"	/* ASCII magic number */
+ #define	H_STRLEN2 75		/* ASCII header string length */
+ #define	M_ASCII2 "770707"	/* ASCII magic number */
  #define	M_BINARY 070707		/* Binary magic number */
  #define	M_STRLEN 6		/* ASCII magic number length */
  #define	NULLDEV	-1		/* Null device code */
***************
*** 328,333 ****
--- 332,338 ----
  int inentry ();
  int infill ();
  int inhead ();
+ int inhead2 ();
  int inread ();
  int inskip ();
  int inswab ();
***************
*** 374,379 ****
--- 379,385 ----
  void outeof ();
  void outflush ();
  void outhead ();
+ void outhead2 ();
  void outpad ();
  void outwait ();
  void outwrite ();
diff -cNr afio.2.4.2/patchlevel.h afio.2.4.2k2/patchlevel.h
*** afio.2.4.2/patchlevel.h	Fri May  8 18:17:33 1998
--- afio.2.4.2k2/patchlevel.h	Sun May 10 13:13:22 1998
***************
*** 1,5 ****
! #define VERSION	"2.4.2"
! #define DATE	"21 Jan 1996"
  
  /*
   * Version 1.68		        1985		Mark Brukhartz
--- 1,5 ----
! #define VERSION	"2.4.2k2"
! #define DATE	"10 May 1998"
  
  /*
   * Version 1.68		        1985		Mark Brukhartz
***************
*** 13,16 ****
--- 13,18 ----
   * Version 2.4                  26 Nov 94       Anders Baekgaard, Koen Holtman
   * Version 2.4.1                08 Feb 95       Koen Holtman
   * Version 2.4.2                21 Jan 96       Koen Holtman
+  * Version 2.4.2k1              08 May 98       Takatsugu Nokubi
+  * Version 2.4.2k2              10 May 98       Takatsugu Nokubi
   */
