From 4f0a9dfdbe3586a6a476365ba3cae273c189d0b4 Mon Sep 17 00:00:00 2001 From: d_m Date: Wed, 25 Sep 2024 23:13:04 -0400 Subject: [PATCH] debugging some things --- tar.tal | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/tar.tal b/tar.tal index 089ff47..d516fd1 100644 --- a/tar.tal +++ b/tar.tal @@ -5,12 +5,16 @@ ( see https://en.wikipedia.org/wiki/Tar_(computing)#UStar_format ) ( ) ( TODO: ) +( - check for "ustar" header ) +( - handle filename-prefix ) +( - handle 'L' entries ) ( - support creating archives ) ( - arg validation should depend on mode ) ( - validate checksums ) ( - better error messages on unsupported files, e.g. symlinks ) ( - better usage message ) ( - support using "-" for stdin/stdout? ) +( - option to ignore symlinks? ) ( File1 is used to read/write the tar file ) ( File2 is used to read/write files and directories ) @@ -82,7 +86,8 @@ DUP LIT "0 EQU ?list-file-v ( type^ ) DUP LIT "5 EQU ?list-dir-v ( type^ ) DUP LIT "7 EQU ?list-file-v ( type^ ) - !fail-unsupported ( ) + !list-weird-v + ( !fail-unsupported ) ( ) ( non-verbose file entry listing ) @list-file ( 00^ -> ) @@ -98,6 +103,20 @@ ;header/filename #0064 lprint #0a18 DEO !list-entries +( verbose file entry listing ) +@list-weird-v ( type^ -> ) + ( POP ) + ( LIT "f ) #18 DEO #2018 DEO + ;header/size load-octal11 dump-longer #2018 DEO + ;header/filename #0064 lprint #0a18 DEO + ;header/size load-octal11 round-up-to-512 + + ( dump-header ) + + ;header/size .File2/name DEO2 + ;header/size load-octal11 STH2k write + STH2r remainder-512 skip-lo !list-entries + ( verbose file entry listing ) @list-file-v ( type^ -> ) POP @@ -139,7 +158,7 @@ LDAk LIT "/ NEQ JMP INC2 JMP2r @remainder-512 ( n* -> extra* ) - #01ff AND2 #0200 SWP2 SUB2 ORAk ?{ POP2 #0000 } JMP2r + #01ff AND2 #0200 DUP2 ROT2 SUB2 NEQ2k ?{ POP2 #0000 } NIP2 JMP2r @expand-file ( type^ -> ) POP @@ -192,6 +211,9 @@ ;skip-buf ;write-lo/writer STA2 write-lo write-hi ?write-4g JMP2r +@skip-lo ( lo* -> ) + ;skip-buf ;write-lo/writer STA2 !write-lo + ( skips up to 32768 bytes of; limited by the size of buf ) @skip-buf ( n* -> ) ORAk ?{ POP2 JMP2r } @@ -321,6 +343,8 @@ &loop2 GTH2k ?{ NIP2 LDA #18 DEO #2018 DEO JMP2r } LDAk #18 DEO INC2 !&loop2 +@dump-body1 ( -> ) + @dump-header ( -> ) LIT2 "- 18 DEOk DEOk DEOk DEOk DEO #0a18 DEO ;header/filename #0064 dump-mem @@ -378,6 +402,17 @@ ( '7' contiguous file -- treat as normal file ) ( 'g' global extended header with metadata; POSIX.1-2001 ) ( 'x' extended header with metadata for next file; POSIX.1-2001 ) +( 'A' solaris ACL ) +( 'D' gnu dump dir ) +( 'E' solaris extended attrs ) +( 'I' inode metadata ) +( 'K' this entry's data is the long link location of next file, null-terminated? ) +( 'L' this entry's data is the long filename of next file, null-terminated ) +( 'M' continuation file ) +( 'N' old gnu for long names ) +( 'S' sparse files ) +( 'V' tape/volume header ) +( 'X' extended attrs, sun ) ( /linkname -- for hardlinks, the file containing the linked data ) ( uheader -- ustar header, found in v7 padding bytes ) ( /ustar -- ustar indiciator, should be "ustar " ) @@ -412,5 +447,8 @@ &pad $c ( 0x1f4: padding, 12 bytes ) &end ( 0x200: end of header ) +( buffer for up to 4096 characters of long names/paths ) +|7000 @long-buf $1000 + ( buffer for reading up to 32k bytes of data at a time ) |8000 @buffer $8000