home *** CD-ROM | disk | FTP | other *** search
open in:
MacOS 8.1
|
Win98
|
DOS
browse contents |
view JSON data
|
view as text
This file was processed as: Tape Archive
(archive/tar).
Confidence | Program | Detection | Match Type | Support
|
---|
100%
| dexvert
| Tape Archive (archive/tar)
| magic
| Supported |
100%
| file
| tar archive
| default
| |
99%
| file
| tar archive (old), directory tar/, mode 040755, uid 000423, gid 000000, size 00000000000, seconds 05224107147, comment: 0
| default
| |
98%
| file
| data
| default
| |
65%
| TrID
| Sybase iAnywhere database files
| default (weak)
| |
34%
| TrID
| TAR - Tape ARchive (directory)
| default
| |
100%
| dearkID
| deark: tar
| default
| |
100%
| lsar
| Tar
| default (weak)
| |
100%
| gt2
| TAR Archiv gefunden (Auflistung ist deaktiviert)
| default
| |
100%
| disktype
| Pre-POSIX tar archive
| default
|
|
hex view+--------+-------------------------+-------------------------+--------+--------+
|00000000| 74 61 72 2f 00 00 00 00 | 00 00 00 00 00 00 00 00 |tar/....|........|
|00000010| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000040| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000050| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000060| 00 00 00 00 30 34 30 37 | 35 35 00 00 30 30 30 34 |....0407|55..0004|
|00000070| 32 33 00 00 30 30 30 30 | 30 30 00 00 30 30 30 30 |23..0000|00..0000|
|00000080| 30 30 30 30 30 30 30 00 | 30 35 32 32 34 31 30 37 |0000000.|05224107|
|00000090| 31 34 37 00 30 31 30 32 | 37 32 00 20 35 00 00 00 |147.0102|72. 5...|
|000000a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000000b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000000c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000000d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000000e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000000f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000100| 00 20 20 20 20 20 30 00 | 00 6c 75 69 67 69 00 00 |. 0.|.luigi..|
|00000110| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000120| 00 00 00 00 00 00 00 00 | 00 73 79 73 74 65 6d 00 |........|.system.|
|00000130| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000140| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000150| 00 00 00 00 00 00 00 00 | 00 00 20 31 00 20 30 00 |........|.. 1. 0.|
|00000160| 20 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 | .......|........|
|00000170| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000180| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000190| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000001a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000001b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000001c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000001d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000001e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000001f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000200| 74 61 72 2f 63 72 65 61 | 74 65 2e 63 00 00 00 00 |tar/crea|te.c....|
|00000210| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000220| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000230| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000240| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000250| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000260| 00 00 00 00 31 30 30 36 | 34 34 00 00 30 30 30 34 |....1006|44..0004|
|00000270| 32 33 00 00 30 30 30 30 | 30 30 00 00 30 30 30 30 |23..0000|00..0000|
|00000280| 30 30 33 30 35 30 30 00 | 30 35 32 30 31 35 34 33 |0030500.|05201543|
|00000290| 30 37 36 00 30 31 30 32 | 30 36 00 20 30 00 00 00 |076.0102|06. 0...|
|000002a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000002b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000002c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000002d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000002e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000002f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000300| 00 33 37 37 37 37 37 37 | 37 37 37 37 00 00 00 00 |.3777777|7777....|
|00000310| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000320| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000330| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000340| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000350| 00 00 00 00 00 00 00 00 | 00 00 20 31 00 20 30 00 |........|.. 1. 0.|
|00000360| 20 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 | .......|........|
|00000370| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000380| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000390| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000003a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000003b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000003c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000003d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000003e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000003f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000400| 2f 2a 0d 0a 20 2a 20 43 | 72 65 61 74 65 20 61 20 |/*.. * C|reate a |
|00000410| 74 61 72 20 61 72 63 68 | 69 76 65 2e 0d 0a 20 2a |tar arch|ive... *|
|00000420| 0d 0a 20 2a 20 57 72 69 | 74 74 65 6e 20 32 35 20 |.. * Wri|tten 25 |
|00000430| 41 75 67 20 31 39 38 35 | 20 62 79 20 4a 6f 68 6e |Aug 1985| by John|
|00000440| 20 47 69 6c 6d 6f 72 65 | 2c 20 69 68 6e 70 34 21 | Gilmore|, ihnp4!|
|00000450| 68 6f 70 74 6f 61 64 21 | 67 6e 75 2e 0d 0a 20 2a |hoptoad!|gnu... *|
|00000460| 0d 0a 20 2a 20 40 28 23 | 29 63 72 65 61 74 65 2e |.. * @(#|)create.|
|00000470| 63 20 31 2e 31 39 20 39 | 2f 39 2f 38 36 20 50 75 |c 1.19 9|/9/86 Pu|
|00000480| 62 6c 69 63 20 44 6f 6d | 61 69 6e 20 2d 20 67 6e |blic Dom|ain - gn|
|00000490| 75 0d 0a 20 2a 2f 0d 0a | 23 69 6e 63 6c 75 64 65 |u.. */..|#include|
|000004a0| 20 3c 73 79 73 2f 74 79 | 70 65 73 2e 68 3e 0d 0a | <sys/ty|pes.h>..|
|000004b0| 23 69 6e 63 6c 75 64 65 | 20 3c 73 79 73 2f 73 74 |#include| <sys/st|
|000004c0| 61 74 2e 68 3e 0d 0a 23 | 69 6e 63 6c 75 64 65 20 |at.h>..#|include |
|000004d0| 3c 66 63 6e 74 6c 2e 68 | 3e 0d 0a 23 69 6e 63 6c |<fcntl.h|>..#incl|
|000004e0| 75 64 65 20 3c 73 74 64 | 69 6f 2e 68 3e 0d 0a 0d |ude <std|io.h>...|
|000004f0| 0a 23 69 66 20 64 65 66 | 69 6e 65 64 28 42 53 44 |.#if def|ined(BSD|
|00000500| 34 32 29 2f 2a 20 7c 7c | 20 64 65 66 69 6e 65 64 |42)/* ||| defined|
|00000510| 28 4d 53 44 4f 53 29 20 | 20 2a 2f 0d 0a 23 69 66 |(MSDOS) | */..#if|
|00000520| 64 65 66 09 4f 53 0d 0a | 23 69 6e 63 6c 75 64 65 |def.OS..|#include|
|00000530| 20 3c 6e 64 69 72 2e 68 | 3e 0d 0a 23 65 6c 73 65 | <ndir.h|>..#else|
|00000540| 0d 0a 2f 2a 20 23 69 6e | 63 6c 75 64 65 20 3c 73 |../* #in|clude <s|
|00000550| 79 73 2f 64 69 72 2e 68 | 3e 20 2a 2f 0d 0a 23 69 |ys/dir.h|> */..#i|
|00000560| 6e 63 6c 75 64 65 20 3c | 64 69 72 65 63 74 2e 68 |nclude <|direct.h|
|00000570| 3e 0d 0a 23 65 6e 64 69 | 66 0d 0a 23 65 6c 73 65 |>..#endi|f..#else|
|00000580| 0d 0a 2f 2a 0d 0a 20 2a | 20 46 49 58 4d 45 3a 20 |../*.. *| FIXME: |
|00000590| 4f 6e 20 6f 74 68 65 72 | 20 73 79 73 74 65 6d 73 |On other| systems|
|000005a0| 20 74 68 65 72 65 20 69 | 73 20 6e 6f 20 73 74 61 | there i|s no sta|
|000005b0| 6e 64 61 72 64 20 70 6c | 61 63 65 20 66 6f 72 20 |ndard pl|ace for |
|000005c0| 74 68 65 20 68 65 61 64 | 65 72 20 66 69 6c 65 0d |the head|er file.|
|000005d0| 0a 20 2a 20 66 6f 72 20 | 74 68 65 20 70 6f 72 74 |. * for |the port|
|000005e0| 61 62 6c 65 20 64 69 72 | 65 63 74 6f 72 79 20 61 |able dir|ectory a|
|000005f0| 63 63 65 73 73 20 72 6f | 75 74 69 6e 65 73 2e 20 |ccess ro|utines. |
|00000600| 20 43 68 61 6e 67 65 20 | 74 68 65 20 23 69 6e 63 | Change |the #inc|
|00000610| 6c 75 64 65 20 6c 69 6e | 65 0d 0a 20 2a 20 62 65 |lude lin|e.. * be|
|00000620| 6c 6f 77 20 74 6f 20 62 | 72 69 6e 67 20 69 74 20 |low to b|ring it |
|00000630| 69 6e 20 66 72 6f 6d 20 | 77 68 65 72 65 76 65 72 |in from |wherever|
|00000640| 20 69 74 20 69 73 2e 0d | 0a 20 2a 2f 0d 0a 23 69 | it is..|. */..#i|
|00000650| 6e 63 6c 75 64 65 20 22 | 6d 73 64 5f 64 69 72 2e |nclude "|msd_dir.|
|00000660| 68 22 0d 0a 2f 2a 20 23 | 69 6e 63 6c 75 64 65 20 |h"../* #|include |
|00000670| 22 6e 64 69 72 2e 68 22 | 20 2a 2f 0d 0a 23 65 6e |"ndir.h"| */..#en|
|00000680| 64 69 66 0d 0a 0d 0a 23 | 69 66 64 65 66 20 55 53 |dif....#|ifdef US|
|00000690| 47 0d 0a 23 69 6e 63 6c | 75 64 65 20 3c 73 79 73 |G..#incl|ude <sys|
|000006a0| 2f 73 79 73 6d 61 63 72 | 6f 73 2e 68 3e 09 2f 2a |/sysmacr|os.h>./*|
|000006b0| 20 6d 61 6a 6f 72 28 29 | 20 61 6e 64 20 6d 69 6e | major()| and min|
|000006c0| 6f 72 28 29 20 64 65 66 | 69 6e 65 64 20 68 65 72 |or() def|ined her|
|000006d0| 65 20 2a 2f 0d 0a 23 65 | 6e 64 69 66 0d 0a 0d 0a |e */..#e|ndif....|
|000006e0| 2f 2a 0d 0a 20 2a 20 56 | 37 20 64 6f 65 73 6e 27 |/*.. * V|7 doesn'|
|000006f0| 74 20 68 61 76 65 20 61 | 20 23 64 65 66 69 6e 65 |t have a| #define|
|00000700| 20 66 6f 72 20 74 68 69 | 73 2e 0d 0a 20 2a 2f 0d | for thi|s... */.|
|00000710| 0a 23 69 66 6e 64 65 66 | 20 4f 5f 52 44 4f 4e 4c |.#ifndef| O_RDONL|
|00000720| 59 0d 0a 23 64 65 66 69 | 6e 65 09 4f 5f 52 44 4f |Y..#defi|ne.O_RDO|
|00000730| 4e 4c 59 09 30 0d 0a 23 | 65 6e 64 69 66 0d 0a 0d |NLY.0..#|endif...|
|00000740| 0a 23 69 6e 63 6c 75 64 | 65 20 3c 74 61 72 2e 68 |.#includ|e <tar.h|
|00000750| 3e 0d 0a 0d 0a 2f 2a 0d | 0a 20 2a 20 49 66 20 74 |>..../*.|. * If t|
|00000760| 68 65 72 65 20 61 72 65 | 20 6e 6f 20 73 79 6d 62 |here are| no symb|
|00000770| 6f 6c 69 63 20 6c 69 6e | 6b 73 2c 20 74 68 65 72 |olic lin|ks, ther|
|00000780| 65 20 69 73 20 6e 6f 20 | 6c 73 74 61 74 28 29 2e |e is no |lstat().|
|00000790| 20 20 55 73 65 20 73 74 | 61 74 28 29 2e 0d 0a 20 | Use st|at()... |
|000007a0| 2a 2f 0d 0a 23 69 66 6e | 64 65 66 20 53 5f 49 46 |*/..#ifn|def S_IF|
|000007b0| 4c 4e 4b 0d 0a 23 64 65 | 66 69 6e 65 20 6c 73 74 |LNK..#de|fine lst|
|000007c0| 61 74 20 73 74 61 74 0d | 0a 23 65 6e 64 69 66 0d |at stat.|.#endif.|
|000007d0| 0a 0d 0a 65 78 74 65 72 | 6e 20 63 68 61 72 09 2a |...exter|n char.*|
|000007e0| 6d 61 6c 6c 6f 63 28 29 | 3b 0d 0a 65 78 74 65 72 |malloc()|;..exter|
|000007f0| 6e 20 63 68 61 72 09 2a | 73 74 72 63 70 79 28 29 |n char.*|strcpy()|
|00000800| 3b 0d 0a 65 78 74 65 72 | 6e 20 63 68 61 72 09 2a |;..exter|n char.*|
|00000810| 73 74 72 6e 63 70 79 28 | 29 3b 0d 0a 65 78 74 65 |strncpy(|);..exte|
|00000820| 72 6e 20 69 6e 74 09 65 | 72 72 6e 6f 3b 0d 0a 0d |rn int.e|rrno;...|
|00000830| 0a 75 6e 69 6f 6e 20 72 | 65 63 6f 72 64 20 2a 73 |.union r|ecord *s|
|00000840| 74 61 72 74 5f 68 65 61 | 64 65 72 28 29 3b 0d 0a |tart_hea|der();..|
|00000850| 76 6f 69 64 20 66 69 6e | 69 73 68 5f 68 65 61 64 |void fin|ish_head|
|00000860| 65 72 28 29 3b 0d 0a 63 | 68 61 72 20 2a 6e 61 6d |er();..c|har *nam|
|00000870| 65 5f 6e 65 78 74 28 29 | 3b 0d 0a 76 6f 69 64 20 |e_next()|;..void |
|00000880| 74 6f 5f 6f 63 74 28 29 | 3b 0d 0a 0d 0a 0d 0a 76 |to_oct()|;......v|
|00000890| 6f 69 64 0d 0a 63 72 65 | 61 74 65 5f 61 72 63 68 |oid..cre|ate_arch|
|000008a0| 69 76 65 28 29 0d 0a 7b | 0d 0a 09 72 65 67 69 73 |ive()..{|...regis|
|000008b0| 74 65 72 20 63 68 61 72 | 09 2a 70 3b 0d 0a 0d 0a |ter char|.*p;....|
|000008c0| 09 6f 70 65 6e 5f 61 72 | 63 68 69 76 65 28 30 29 |.open_ar|chive(0)|
|000008d0| 3b 09 09 2f 2a 20 4f 70 | 65 6e 20 66 6f 72 20 77 |;../* Op|en for w|
|000008e0| 72 69 74 69 6e 67 20 2a | 2f 0d 0a 0d 0a 09 77 68 |riting *|/.....wh|
|000008f0| 69 6c 65 20 28 70 20 3d | 20 6e 61 6d 65 5f 6e 65 |ile (p =| name_ne|
|00000900| 78 74 28 29 29 20 7b 0d | 0a 09 09 64 75 6d 70 5f |xt()) {.|...dump_|
|00000910| 66 69 6c 65 28 70 29 3b | 0d 0a 09 7d 0d 0a 0d 0a |file(p);|...}....|
|00000920| 09 77 72 69 74 65 5f 65 | 6f 74 28 29 3b 0d 0a 09 |.write_e|ot();...|
|00000930| 63 6c 6f 73 65 5f 61 72 | 63 68 69 76 65 28 29 3b |close_ar|chive();|
|00000940| 0d 0a 09 6e 61 6d 65 5f | 63 6c 6f 73 65 28 29 3b |...name_|close();|
|00000950| 0d 0a 7d 09 09 0d 0a 0d | 0a 2f 2a 0d 0a 20 2a 20 |..}.....|./*.. * |
|00000960| 44 75 6d 70 20 61 20 73 | 69 6e 67 6c 65 20 66 69 |Dump a s|ingle fi|
|00000970| 6c 65 2e 20 20 49 66 20 | 69 74 27 73 20 61 20 64 |le. If |it's a d|
|00000980| 69 72 65 63 74 6f 72 79 | 2c 20 72 65 63 75 72 73 |irectory|, recurs|
|00000990| 65 2e 0d 0a 20 2a 20 52 | 65 73 75 6c 74 20 69 73 |e... * R|esult is|
|000009a0| 20 31 20 66 6f 72 20 73 | 75 63 63 65 73 73 2c 20 | 1 for s|uccess, |
|000009b0| 30 20 66 6f 72 20 66 61 | 69 6c 75 72 65 2e 0d 0a |0 for fa|ilure...|
|000009c0| 20 2a 2f 0d 0a 69 6e 74 | 0d 0a 64 75 6d 70 5f 66 | */..int|..dump_f|
|000009d0| 69 6c 65 28 70 29 0d 0a | 09 63 68 61 72 09 2a 70 |ile(p)..|.char.*p|
|000009e0| 3b 09 09 09 2f 2a 20 46 | 69 6c 65 20 6e 61 6d 65 |;.../* F|ile name|
|000009f0| 20 74 6f 20 64 75 6d 70 | 20 2a 2f 0d 0a 7b 0d 0a | to dump| */..{..|
|00000a00| 09 73 74 72 75 63 74 20 | 73 74 61 74 09 73 74 61 |.struct |stat.sta|
|00000a10| 74 62 75 66 5b 31 5d 3b | 0d 0a 09 75 6e 69 6f 6e |tbuf[1];|...union|
|00000a20| 20 72 65 63 6f 72 64 09 | 2a 68 65 61 64 65 72 3b | record.|*header;|
|00000a30| 0d 0a 09 63 68 61 72 20 | 74 79 70 65 3b 0d 0a 0d |...char |type;...|
|00000a40| 0a 23 69 66 64 65 66 09 | 58 42 55 46 0d 0a 09 69 |.#ifdef.|XBUF...i|
|00000a50| 66 28 66 5f 78 62 75 66 | 20 26 26 20 21 73 74 72 |f(f_xbuf| && !str|
|00000a60| 63 6d 70 28 70 2c 20 61 | 72 5f 66 69 6c 65 29 29 |cmp(p, a|r_file))|
|00000a70| 0d 0a 09 09 72 65 74 75 | 72 6e 28 30 29 3b 0d 0a |....retu|rn(0);..|
|00000a80| 23 65 6e 64 69 66 0d 0a | 09 2f 2a 0d 0a 09 20 2a |#endif..|./*... *|
|00000a90| 20 55 73 65 20 73 74 61 | 74 20 69 66 20 66 6f 6c | Use sta|t if fol|
|00000aa0| 6c 6f 77 69 6e 67 20 28 | 72 61 74 68 65 72 20 74 |lowing (|rather t|
|00000ab0| 68 61 6e 20 64 75 6d 70 | 69 6e 67 29 20 34 2e 32 |han dump|ing) 4.2|
|00000ac0| 42 53 44 27 73 0d 0a 09 | 20 2a 20 73 79 6d 62 6f |BSD's...| * symbo|
|00000ad0| 6c 69 63 20 6c 69 6e 6b | 73 2e 20 20 4f 74 68 65 |lic link|s. Othe|
|00000ae0| 72 77 69 73 65 2c 20 75 | 73 65 20 6c 73 74 61 74 |rwise, u|se lstat|
|00000af0| 20 28 77 68 69 63 68 2c | 20 6f 6e 20 6e 6f 6e 2d | (which,| on non-|
|00000b00| 34 2e 32 0d 0a 09 20 2a | 20 73 79 73 74 65 6d 73 |4.2... *| systems|
|00000b10| 2c 20 69 73 20 23 64 65 | 66 69 6e 65 27 64 20 74 |, is #de|fine'd t|
|00000b20| 6f 20 73 74 61 74 20 61 | 6e 79 77 61 79 2e 0d 0a |o stat a|nyway...|
|00000b30| 09 20 2a 2f 0d 0a 09 69 | 66 20 28 30 20 21 3d 20 |. */...i|f (0 != |
|00000b40| 66 5f 66 6f 6c 6c 6f 77 | 5f 6c 69 6e 6b 73 3f 20 |f_follow|_links? |
|00000b50| 73 74 61 74 28 70 2c 20 | 73 74 61 74 62 75 66 29 |stat(p, |statbuf)|
|00000b60| 3a 20 6c 73 74 61 74 28 | 70 2c 20 73 74 61 74 62 |: lstat(|p, statb|
|00000b70| 75 66 29 29 0d 0a 09 7b | 0d 0a 62 61 64 70 65 72 |uf))...{|..badper|
|00000b80| 72 6f 72 3a 0d 0a 09 09 | 70 65 72 72 6f 72 28 70 |ror:....|perror(p|
|00000b90| 29 3b 0d 0a 62 61 64 66 | 69 6c 65 3a 0d 0a 09 09 |);..badf|ile:....|
|00000ba0| 65 72 72 6f 72 73 2b 2b | 3b 0d 0a 09 09 72 65 74 |errors++|;....ret|
|00000bb0| 75 72 6e 20 30 3b 0d 0a | 09 7d 0d 0a 0d 0a 09 73 |urn 0;..|.}.....s|
|00000bc0| 77 69 74 63 68 20 28 73 | 74 61 74 62 75 66 2d 3e |witch (s|tatbuf->|
|00000bd0| 73 74 5f 6d 6f 64 65 20 | 26 20 53 5f 49 46 4d 54 |st_mode |& S_IFMT|
|00000be0| 29 20 7b 0d 0a 0d 0a 09 | 63 61 73 65 20 53 5f 49 |) {.....|case S_I|
|00000bf0| 46 52 45 47 3a 09 09 09 | 2f 2a 20 52 65 67 75 6c |FREG:...|/* Regul|
|00000c00| 61 72 20 66 69 6c 65 20 | 2a 2f 0d 0a 09 7b 0d 0a |ar file |*/...{..|
|00000c10| 09 09 69 6e 74 09 66 3b | 09 09 2f 2a 20 46 69 6c |..int.f;|../* Fil|
|00000c20| 65 20 64 65 73 63 72 69 | 70 74 6f 72 20 2a 2f 0d |e descri|ptor */.|
|00000c30| 0a 09 09 69 6e 74 09 62 | 75 66 73 69 7a 65 2c 20 |...int.b|ufsize, |
|00000c40| 63 6f 75 6e 74 3b 0d 0a | 09 09 72 65 67 69 73 74 |count;..|..regist|
|00000c50| 65 72 20 6c 6f 6e 67 09 | 73 69 7a 65 6c 65 66 74 |er long.|sizeleft|
|00000c60| 3b 0d 0a 09 09 72 65 67 | 69 73 74 65 72 20 75 6e |;....reg|ister un|
|00000c70| 69 6f 6e 20 72 65 63 6f | 72 64 20 09 2a 73 74 61 |ion reco|rd .*sta|
|00000c80| 72 74 3b 0d 0a 0d 0a 09 | 09 2f 2a 0d 0a 09 09 20 |rt;.....|./*.... |
|00000c90| 2a 20 48 61 6e 64 6c 65 | 20 61 20 72 65 67 75 6c |* Handle| a regul|
|00000ca0| 61 72 20 66 69 6c 65 20 | 77 69 74 68 20 6d 75 6c |ar file |with mul|
|00000cb0| 74 69 70 6c 65 20 6c 69 | 6e 6b 73 2e 0d 0a 09 09 |tiple li|nks.....|
|00000cc0| 20 2a 0d 0a 09 09 20 2a | 20 57 65 20 6d 61 69 6e | *.... *| We main|
|00000cd0| 74 61 69 6e 20 61 20 6c | 69 73 74 20 6f 66 20 61 |tain a l|ist of a|
|00000ce0| 6c 6c 20 73 75 63 68 20 | 66 69 6c 65 73 20 74 68 |ll such |files th|
|00000cf0| 61 74 20 77 65 27 76 65 | 20 77 72 69 74 74 65 6e |at we've| written|
|00000d00| 20 73 6f 0d 0a 09 09 20 | 2a 20 66 61 72 2e 20 20 | so.... |* far. |
|00000d10| 41 6e 79 20 74 69 6d 65 | 20 77 65 20 73 65 65 20 |Any time| we see |
|00000d20| 61 6e 6f 74 68 65 72 2c | 20 77 65 20 63 68 65 63 |another,| we chec|
|00000d30| 6b 20 74 68 65 20 6c 69 | 73 74 20 61 6e 64 0d 0a |k the li|st and..|
|00000d40| 09 09 20 2a 20 61 76 6f | 69 64 20 64 75 6d 70 69 |.. * avo|id dumpi|
|00000d50| 6e 67 20 74 68 65 20 64 | 61 74 61 20 61 67 61 69 |ng the d|ata agai|
|00000d60| 6e 20 69 66 20 77 65 27 | 76 65 20 64 6f 6e 65 20 |n if we'|ve done |
|00000d70| 69 74 20 6f 6e 63 65 20 | 61 6c 72 65 61 64 79 2e |it once |already.|
|00000d80| 0d 0a 09 09 20 2a 2f 0d | 0a 23 69 66 64 65 66 09 |.... */.|.#ifdef.|
|00000d90| 44 55 4d 50 54 49 4d 45 | 0d 0a 09 09 69 66 28 64 |DUMPTIME|....if(d|
|00000da0| 75 6d 70 74 69 6d 65 20 | 26 26 20 73 74 61 74 62 |umptime |&& statb|
|00000db0| 75 66 2d 3e 73 74 5f 6d | 74 69 6d 65 20 3c 20 64 |uf->st_m|time < d|
|00000dc0| 75 6d 70 74 69 6d 65 29 | 0d 0a 09 09 09 62 72 65 |umptime)|.....bre|
|00000dd0| 61 6b 3b 0d 0a 23 65 6e | 64 69 66 0d 0a 09 09 69 |ak;..#en|dif....i|
|00000de0| 66 20 28 73 74 61 74 62 | 75 66 2d 3e 73 74 5f 6e |f (statb|uf->st_n|
|00000df0| 6c 69 6e 6b 20 3e 20 31 | 29 20 7b 0d 0a 09 09 09 |link > 1|) {.....|
|00000e00| 72 65 67 69 73 74 65 72 | 20 73 74 72 75 63 74 20 |register| struct |
|00000e10| 6c 69 6e 6b 09 2a 6c 70 | 3b 0d 0a 0d 0a 09 09 09 |link.*lp|;.......|
|00000e20| 2f 2a 20 46 69 72 73 74 | 20 71 75 69 63 6b 20 61 |/* First| quick a|
|00000e30| 6e 64 20 64 69 72 74 79 | 2e 20 20 48 61 73 68 69 |nd dirty|. Hashi|
|00000e40| 6e 67 2c 20 65 74 63 20 | 6c 61 74 65 72 20 46 49 |ng, etc |later FI|
|00000e50| 58 4d 45 20 2a 2f 0d 0a | 09 09 09 66 6f 72 20 28 |XME */..|...for (|
|00000e60| 6c 70 20 3d 20 6c 69 6e | 6b 6c 69 73 74 3b 20 6c |lp = lin|klist; l|
|00000e70| 70 3b 20 6c 70 20 3d 20 | 6c 70 2d 3e 6e 65 78 74 |p; lp = |lp->next|
|00000e80| 29 20 7b 0d 0a 09 09 09 | 09 69 66 20 28 6c 70 2d |) {.....|.if (lp-|
|00000e90| 3e 69 6e 6f 20 3d 3d 20 | 73 74 61 74 62 75 66 2d |>ino == |statbuf-|
|00000ea0| 3e 73 74 5f 69 6e 6f 20 | 26 26 0d 0a 09 09 09 09 |>st_ino |&&......|
|00000eb0| 20 20 20 20 6c 70 2d 3e | 64 65 76 20 3d 3d 20 73 | lp->|dev == s|
|00000ec0| 74 61 74 62 75 66 2d 3e | 73 74 5f 64 65 76 29 20 |tatbuf->|st_dev) |
|00000ed0| 7b 0d 0a 09 09 09 09 09 | 2f 2a 20 57 65 20 66 6f |{.......|/* We fo|
|00000ee0| 75 6e 64 20 61 20 6c 69 | 6e 6b 2e 20 2a 2f 0d 0a |und a li|nk. */..|
|00000ef0| 09 09 09 09 09 73 74 61 | 74 62 75 66 2d 3e 73 74 |.....sta|tbuf->st|
|00000f00| 5f 73 69 7a 65 20 3d 20 | 30 3b 0d 0a 09 09 09 09 |_size = |0;......|
|00000f10| 09 68 65 61 64 65 72 20 | 3d 20 73 74 61 72 74 5f |.header |= start_|
|00000f20| 68 65 61 64 65 72 28 70 | 2c 20 73 74 61 74 62 75 |header(p|, statbu|
|00000f30| 66 29 3b 0d 0a 09 09 09 | 09 09 69 66 20 28 68 65 |f);.....|..if (he|
|00000f40| 61 64 65 72 20 3d 3d 20 | 4e 55 4c 4c 29 20 67 6f |ader == |NULL) go|
|00000f50| 74 6f 20 62 61 64 66 69 | 6c 65 3b 0d 0a 09 09 09 |to badfi|le;.....|
|00000f60| 09 09 73 74 72 63 70 79 | 28 68 65 61 64 65 72 2d |..strcpy|(header-|
|00000f70| 3e 68 65 61 64 65 72 2e | 6c 69 6e 6b 6e 61 6d 65 |>header.|linkname|
|00000f80| 2c 0d 0a 09 09 09 09 09 | 09 6c 70 2d 3e 6e 61 6d |,.......|.lp->nam|
|00000f90| 65 29 3b 0d 0a 09 09 09 | 09 09 68 65 61 64 65 72 |e);.....|..header|
|00000fa0| 2d 3e 68 65 61 64 65 72 | 2e 6c 69 6e 6b 66 6c 61 |->header|.linkfla|
|00000fb0| 67 20 3d 20 4c 46 5f 4c | 49 4e 4b 3b 0d 0a 09 09 |g = LF_L|INK;....|
|00000fc0| 09 09 09 66 69 6e 69 73 | 68 5f 68 65 61 64 65 72 |...finis|h_header|
|00000fd0| 28 68 65 61 64 65 72 29 | 3b 0d 0a 09 09 09 09 09 |(header)|;.......|
|00000fe0| 69 66 20 28 66 5f 76 65 | 72 62 6f 73 65 29 0d 0a |if (f_ve|rbose)..|
|00000ff0| 09 09 09 09 09 09 61 6e | 6e 6f 72 65 63 28 73 74 |......an|norec(st|
|00001000| 64 6f 75 74 2c 20 28 63 | 68 61 72 20 2a 29 4e 55 |dout, (c|har *)NU|
|00001010| 4c 4c 29 3b 0d 0a 09 09 | 09 09 09 09 70 72 69 6e |LL);....|....prin|
|00001020| 74 66 28 22 25 73 20 6c | 69 6e 6b 20 74 6f 20 25 |tf("%s l|ink to %|
|00001030| 73 5c 6e 22 2c 0d 0a 09 | 09 09 09 09 09 09 70 2c |s\n",...|......p,|
|00001040| 20 6c 70 2d 3e 6e 61 6d | 65 29 3b 0d 0a 09 09 09 | lp->nam|e);.....|
|00001050| 2f 2a 20 4d 61 79 62 65 | 20 72 65 6d 6f 76 65 20 |/* Maybe| remove |
|00001060| 66 72 6f 6d 20 6c 69 73 | 74 20 61 66 74 65 72 20 |from lis|t after |
|00001070| 61 6c 6c 20 6c 69 6e 6b | 73 20 66 6f 75 6e 64 3f |all link|s found?|
|00001080| 20 2a 2f 0d 0a 09 09 2f | 2a 20 49 66 20 73 6f 2c | */..../|* If so,|
|00001090| 20 68 61 76 65 20 74 6f | 20 63 6f 6d 70 61 72 65 | have to| compare|
|000010a0| 20 6e 61 6d 65 73 20 69 | 6e 20 63 61 73 65 20 68 | names i|n case h|
|000010b0| 65 20 64 75 6d 70 73 20 | 74 77 69 63 65 2e 20 2a |e dumps |twice. *|
|000010c0| 2f 0d 0a 09 09 09 2f 2a | 20 4c 61 74 65 72 3a 20 |/...../*| Later: |
|000010d0| 49 20 64 6f 6e 27 74 20 | 75 6e 64 65 72 73 74 61 |I don't |understa|
|000010e0| 6e 64 20 74 68 65 20 61 | 62 6f 76 65 2e 20 20 49 |nd the a|bove. I|
|000010f0| 66 20 73 68 65 0d 0a 09 | 09 09 20 2a 20 64 75 6d |f she...|.. * dum|
|00001100| 70 73 20 74 68 65 20 66 | 69 6c 65 20 74 77 69 63 |ps the f|ile twic|
|00001110| 65 2c 20 69 74 20 77 6f | 75 6c 64 20 62 65 20 42 |e, it wo|uld be B|
|00001120| 41 44 20 74 6f 20 64 75 | 6d 70 0d 0a 09 09 09 20 |AD to du|mp..... |
|00001130| 2a 20 69 74 20 74 68 65 | 20 73 65 63 6f 6e 64 20 |* it the| second |
|00001140| 74 69 6d 65 20 61 73 20 | 61 20 6c 69 6e 6b 2e 2e |time as |a link..|
|00001150| 2e 20 20 67 6e 75 20 32 | 35 4a 75 6c 38 36 0d 0a |. gnu 2|5Jul86..|
|00001160| 09 09 09 20 2a 2f 0d 0a | 09 09 09 09 09 2f 2a 20 |... */..|...../* |
|00001170| 46 49 58 4d 45 20 2a 2f | 0d 0a 09 09 09 09 09 67 |FIXME */|.......g|
|00001180| 6f 74 6f 20 64 6f 6e 65 | 66 69 6c 65 3b 0d 0a 09 |oto done|file;...|
|00001190| 09 09 09 7d 0d 0a 09 09 | 09 7d 0d 0a 0d 0a 09 09 |...}....|.}......|
|000011a0| 09 2f 2a 20 4e 6f 74 20 | 66 6f 75 6e 64 2e 20 20 |./* Not |found. |
|000011b0| 41 64 64 20 69 74 20 74 | 6f 20 74 68 65 20 6c 69 |Add it t|o the li|
|000011c0| 73 74 2e 20 2a 2f 0d 0a | 09 09 09 6c 70 20 3d 20 |st. */..|...lp = |
|000011d0| 28 73 74 72 75 63 74 20 | 6c 69 6e 6b 20 2a 29 20 |(struct |link *) |
|000011e0| 6d 61 6c 6c 6f 63 28 20 | 28 75 6e 73 69 67 6e 65 |malloc( |(unsigne|
|000011f0| 64 29 0d 0a 09 09 09 09 | 28 73 74 72 6c 65 6e 28 |d)......|(strlen(|
|00001200| 70 29 20 2b 20 73 69 7a | 65 6f 66 28 73 74 72 75 |p) + siz|eof(stru|
|00001210| 63 74 20 6c 69 6e 6b 29 | 20 2d 20 4e 41 4d 53 49 |ct link)| - NAMSI|
|00001220| 5a 29 29 3b 0d 0a 09 09 | 09 6c 70 2d 3e 69 6e 6f |Z));....|.lp->ino|
|00001230| 20 3d 20 73 74 61 74 62 | 75 66 2d 3e 73 74 5f 69 | = statb|uf->st_i|
|00001240| 6e 6f 3b 0d 0a 09 09 09 | 6c 70 2d 3e 64 65 76 20 |no;.....|lp->dev |
|00001250| 3d 20 73 74 61 74 62 75 | 66 2d 3e 73 74 5f 64 65 |= statbu|f->st_de|
|00001260| 76 3b 0d 0a 09 09 09 73 | 74 72 63 70 79 28 6c 70 |v;.....s|trcpy(lp|
|00001270| 2d 3e 6e 61 6d 65 2c 20 | 70 29 3b 0d 0a 09 09 09 |->name, |p);.....|
|00001280| 6c 70 2d 3e 6e 65 78 74 | 20 3d 20 6c 69 6e 6b 6c |lp->next| = linkl|
|00001290| 69 73 74 3b 0d 0a 09 09 | 09 6c 69 6e 6b 6c 69 73 |ist;....|.linklis|
|000012a0| 74 20 3d 20 6c 70 3b 0d | 0a 09 09 7d 0d 0a 0d 0a |t = lp;.|...}....|
|000012b0| 09 09 73 69 7a 65 6c 65 | 66 74 20 3d 20 73 74 61 |..sizele|ft = sta|
|000012c0| 74 62 75 66 2d 3e 73 74 | 5f 73 69 7a 65 3b 0d 0a |tbuf->st|_size;..|
|000012d0| 09 09 2f 2a 20 44 6f 6e | 27 74 20 62 6f 74 68 65 |../* Don|'t bothe|
|000012e0| 72 20 6f 70 65 6e 69 6e | 67 20 65 6d 70 74 79 2c |r openin|g empty,|
|000012f0| 20 77 6f 72 6c 64 20 72 | 65 61 64 61 62 6c 65 20 | world r|eadable |
|00001300| 66 69 6c 65 73 2e 20 2a | 2f 0d 0a 09 09 69 66 20 |files. *|/....if |
|00001310| 28 73 69 7a 65 6c 65 66 | 74 20 3e 20 30 20 7c 7c |(sizelef|t > 0 |||
|00001320| 20 30 34 34 34 20 21 3d | 20 28 30 34 34 34 20 26 | 0444 !=| (0444 &|
|00001330| 20 73 74 61 74 62 75 66 | 2d 3e 73 74 5f 6d 6f 64 | statbuf|->st_mod|
|00001340| 65 29 29 20 7b 0d 0a 23 | 69 66 64 65 66 09 4d 53 |e)) {..#|ifdef.MS|
|00001350| 44 4f 53 0d 0a 09 09 09 | 66 20 3d 20 6f 70 65 6e |DOS.....|f = open|
|00001360| 28 70 2c 20 4f 5f 52 44 | 4f 4e 4c 59 7c 4f 5f 42 |(p, O_RD|ONLY|O_B|
|00001370| 49 4e 41 52 59 29 3b 0d | 0a 23 65 6c 73 65 0d 0a |INARY);.|.#else..|
|00001380| 09 09 09 66 20 3d 20 6f | 70 65 6e 28 70 2c 20 4f |...f = o|pen(p, O|
|00001390| 5f 52 44 4f 4e 4c 59 29 | 3b 0d 0a 23 65 6e 64 69 |_RDONLY)|;..#endi|
|000013a0| 66 0d 0a 09 09 09 69 66 | 20 28 66 20 3c 20 30 29 |f.....if| (f < 0)|
|000013b0| 20 67 6f 74 6f 20 62 61 | 64 70 65 72 72 6f 72 3b | goto ba|dperror;|
|000013c0| 0d 0a 09 09 7d 20 65 6c | 73 65 20 7b 0d 0a 09 09 |....} el|se {....|
|000013d0| 09 66 20 3d 20 2d 31 3b | 0d 0a 09 09 7d 0d 0a 09 |.f = -1;|....}...|
|000013e0| 09 68 65 61 64 65 72 20 | 3d 20 73 74 61 72 74 5f |.header |= start_|
|000013f0| 68 65 61 64 65 72 28 70 | 2c 20 73 74 61 74 62 75 |header(p|, statbu|
|00001400| 66 29 3b 0d 0a 09 09 69 | 66 20 28 68 65 61 64 65 |f);....i|f (heade|
|00001410| 72 20 3d 3d 20 4e 55 4c | 4c 29 20 67 6f 74 6f 20 |r == NUL|L) goto |
|00001420| 62 61 64 66 69 6c 65 3b | 0d 0a 09 09 66 69 6e 69 |badfile;|....fini|
|00001430| 73 68 5f 68 65 61 64 65 | 72 28 68 65 61 64 65 72 |sh_heade|r(header|
|00001440| 29 3b 0d 0a 09 09 77 68 | 69 6c 65 20 28 73 69 7a |);....wh|ile (siz|
|00001450| 65 6c 65 66 74 20 3e 20 | 30 29 20 7b 0d 0a 09 09 |eleft > |0) {....|
|00001460| 09 73 74 61 72 74 20 3d | 20 66 69 6e 64 72 65 63 |.start =| findrec|
|00001470| 28 29 3b 0d 0a 09 09 09 | 62 75 66 73 69 7a 65 20 |();.....|bufsize |
|00001480| 3d 20 65 6e 64 6f 66 72 | 65 63 73 28 29 2d 3e 63 |= endofr|ecs()->c|
|00001490| 68 61 72 70 74 72 20 2d | 20 73 74 61 72 74 2d 3e |harptr -| start->|
|000014a0| 63 68 61 72 70 74 72 3b | 0d 0a 09 09 09 69 66 20 |charptr;|.....if |
|000014b0| 28 73 69 7a 65 6c 65 66 | 74 20 3c 20 62 75 66 73 |(sizelef|t < bufs|
|000014c0| 69 7a 65 29 0d 0a 09 09 | 09 09 62 75 66 73 69 7a |ize)....|..bufsiz|
|000014d0| 65 20 3d 20 73 69 7a 65 | 6c 65 66 74 3b 0d 0a 09 |e = size|left;...|
|000014e0| 09 09 63 6f 75 6e 74 20 | 3d 20 72 65 61 64 28 66 |..count |= read(f|
|000014f0| 2c 20 73 74 61 72 74 2d | 3e 63 68 61 72 70 74 72 |, start-|>charptr|
|00001500| 2c 20 62 75 66 73 69 7a | 65 29 3b 0d 0a 09 09 09 |, bufsiz|e);.....|
|00001510| 69 66 20 28 63 6f 75 6e | 74 20 3c 20 30 29 20 7b |if (coun|t < 0) {|
|00001520| 0d 0a 09 09 09 09 61 6e | 6e 6f 72 65 63 28 73 74 |......an|norec(st|
|00001530| 64 65 72 72 2c 20 74 61 | 72 29 3b 0d 0a 09 09 09 |derr, ta|r);.....|
|00001540| 09 66 70 72 69 6e 74 66 | 28 73 74 64 65 72 72 2c |.fprintf|(stderr,|
|00001550| 0d 0a 09 09 09 09 20 20 | 22 72 65 61 64 20 65 72 |...... |"read er|
|00001560| 72 6f 72 20 61 74 20 62 | 79 74 65 20 25 6c 64 2c |ror at b|yte %ld,|
|00001570| 20 72 65 61 64 69 6e 67 | 20 25 64 20 62 79 74 65 | reading| %d byte|
|00001580| 73 2c 20 69 6e 20 66 69 | 6c 65 20 22 2c 0d 0a 09 |s, in fi|le ",...|
|00001590| 09 09 09 09 73 74 61 74 | 62 75 66 2d 3e 73 74 5f |....stat|buf->st_|
|000015a0| 73 69 7a 65 20 2d 20 73 | 69 7a 65 6c 65 66 74 2c |size - s|izeleft,|
|000015b0| 0d 0a 09 09 09 09 09 62 | 75 66 73 69 7a 65 29 3b |.......b|ufsize);|
|000015c0| 0d 0a 09 09 09 09 70 65 | 72 72 6f 72 28 70 29 3b |......pe|rror(p);|
|000015d0| 09 2f 2a 20 46 49 58 4d | 45 20 2a 2f 0d 0a 09 09 |./* FIXM|E */....|
|000015e0| 09 09 67 6f 74 6f 20 70 | 61 64 69 74 3b 0d 0a 09 |..goto p|adit;...|
|000015f0| 09 09 7d 0d 0a 09 09 09 | 73 69 7a 65 6c 65 66 74 |..}.....|sizeleft|
|00001600| 20 2d 3d 20 63 6f 75 6e | 74 3b 0d 0a 09 09 09 75 | -= coun|t;.....u|
|00001610| 73 65 72 65 63 28 73 74 | 61 72 74 2b 28 63 6f 75 |serec(st|art+(cou|
|00001620| 6e 74 2d 31 29 2f 52 45 | 43 4f 52 44 53 49 5a 45 |nt-1)/RE|CORDSIZE|
|00001630| 29 3b 0d 0a 09 09 09 69 | 66 20 28 63 6f 75 6e 74 |);.....i|f (count|
|00001640| 20 3d 3d 20 62 75 66 73 | 69 7a 65 29 20 63 6f 6e | == bufs|ize) con|
|00001650| 74 69 6e 75 65 3b 0d 0a | 09 09 09 61 6e 6e 6f 72 |tinue;..|...annor|
|00001660| 65 63 28 73 74 64 65 72 | 72 2c 20 74 61 72 29 3b |ec(stder|r, tar);|
|00001670| 0d 0a 09 09 09 66 70 72 | 69 6e 74 66 28 73 74 64 |.....fpr|intf(std|
|00001680| 65 72 72 2c 0d 0a 09 22 | 25 73 3a 20 66 69 6c 65 |err,..."|%s: file|
|00001690| 20 73 68 72 75 6e 6b 20 | 62 79 20 25 64 20 62 79 | shrunk |by %d by|
|000016a0| 74 65 73 2c 20 70 61 64 | 64 69 6e 67 20 77 69 74 |tes, pad|ding wit|
|000016b0| 68 20 7a 65 72 6f 73 2e | 5c 6e 22 2c 0d 0a 09 09 |h zeros.|\n",....|
|000016c0| 09 09 70 2c 20 73 69 7a | 65 6c 65 66 74 29 3b 0d |..p, siz|eleft);.|
|000016d0| 0a 09 09 09 67 6f 74 6f | 20 70 61 64 69 74 3b 09 |....goto| padit;.|
|000016e0| 09 2f 2a 20 53 68 6f 72 | 74 20 72 65 61 64 20 2a |./* Shor|t read *|
|000016f0| 2f 0d 0a 09 09 7d 0d 0a | 09 09 69 66 20 28 66 20 |/....}..|..if (f |
|00001700| 3e 3d 20 30 29 0d 0a 09 | 09 09 28 76 6f 69 64 29 |>= 0)...|..(void)|
|00001710| 63 6c 6f 73 65 28 66 29 | 3b 0d 0a 0d 0a 09 09 2f |close(f)|;....../|
|00001720| 2a 20 43 6c 65 61 72 20 | 6c 61 73 74 20 62 6c 6f |* Clear |last blo|
|00001730| 63 6b 20 67 61 72 62 61 | 67 65 20 74 6f 20 7a 65 |ck garba|ge to ze|
|00001740| 72 6f 73 2c 20 46 49 58 | 4d 45 20 2a 2f 0d 0a 0d |ros, FIX|ME */...|
|00001750| 0a 09 09 69 66 20 28 66 | 5f 76 65 72 62 6f 73 65 |...if (f|_verbose|
|00001760| 29 20 7b 0d 0a 09 09 09 | 61 6e 6e 6f 72 65 63 28 |) {.....|annorec(|
|00001770| 73 74 64 6f 75 74 2c 20 | 28 63 68 61 72 20 2a 29 |stdout, |(char *)|
|00001780| 4e 55 4c 4c 29 3b 0d 0a | 09 09 09 70 72 69 6e 74 |NULL);..|...print|
|00001790| 66 28 22 25 73 5c 6e 22 | 2c 20 70 29 3b 0d 0a 09 |f("%s\n"|, p);...|
|000017a0| 09 7d 0d 0a 09 64 6f 6e | 65 66 69 6c 65 3a 0d 0a |.}...don|efile:..|
|000017b0| 09 09 62 72 65 61 6b 3b | 0d 0a 0d 0a 09 09 2f 2a |..break;|....../*|
|000017c0| 0d 0a 09 09 20 2a 20 46 | 69 6c 65 20 73 68 72 75 |.... * F|ile shru|
|000017d0| 6e 6b 20 6f 72 20 67 61 | 76 65 20 65 72 72 6f 72 |nk or ga|ve error|
|000017e0| 2c 20 70 61 64 20 6f 75 | 74 20 74 61 70 65 20 74 |, pad ou|t tape t|
|000017f0| 6f 20 6d 61 74 63 68 0d | 0a 09 09 20 2a 20 74 68 |o match.|... * th|
|00001800| 65 20 73 69 7a 65 20 77 | 65 20 73 70 65 63 69 66 |e size w|e specif|
|00001810| 69 65 64 20 69 6e 20 74 | 68 65 20 68 65 61 64 65 |ied in t|he heade|
|00001820| 72 2e 0d 0a 09 09 20 2a | 2f 0d 0a 09 70 61 64 69 |r..... *|/...padi|
|00001830| 74 3a 0d 0a 09 09 61 62 | 6f 72 74 28 29 3b 0d 0a |t:....ab|ort();..|
|00001840| 09 7d 0d 0a 0d 0a 23 69 | 66 64 65 66 20 53 5f 49 |.}....#i|fdef S_I|
|00001850| 46 4c 4e 4b 0d 0a 09 63 | 61 73 65 20 53 5f 49 46 |FLNK...c|ase S_IF|
|00001860| 4c 4e 4b 3a 09 09 09 2f | 2a 20 53 79 6d 62 6f 6c |LNK:.../|* Symbol|
|00001870| 69 63 20 6c 69 6e 6b 20 | 2a 2f 0d 0a 09 7b 0d 0a |ic link |*/...{..|
|00001880| 09 09 69 6e 74 20 73 69 | 7a 65 3b 0d 0a 0d 0a 09 |..int si|ze;.....|
|00001890| 09 73 74 61 74 62 75 66 | 2d 3e 73 74 5f 73 69 7a |.statbuf|->st_siz|
|000018a0| 65 20 3d 20 30 3b 09 09 | 2f 2a 20 46 6f 72 63 65 |e = 0;..|/* Force|
|000018b0| 20 30 20 73 69 7a 65 20 | 6f 6e 20 73 79 6d 6c 69 | 0 size |on symli|
|000018c0| 6e 6b 20 2a 2f 0d 0a 09 | 09 68 65 61 64 65 72 20 |nk */...|.header |
|000018d0| 3d 20 73 74 61 72 74 5f | 68 65 61 64 65 72 28 70 |= start_|header(p|
|000018e0| 2c 20 73 74 61 74 62 75 | 66 29 3b 0d 0a 09 09 69 |, statbu|f);....i|
|000018f0| 66 20 28 68 65 61 64 65 | 72 20 3d 3d 20 4e 55 4c |f (heade|r == NUL|
|00001900| 4c 29 20 67 6f 74 6f 20 | 62 61 64 66 69 6c 65 3b |L) goto |badfile;|
|00001910| 0d 0a 09 09 73 69 7a 65 | 20 3d 20 72 65 61 64 6c |....size| = readl|
|00001920| 69 6e 6b 28 70 2c 20 68 | 65 61 64 65 72 2d 3e 68 |ink(p, h|eader->h|
|00001930| 65 61 64 65 72 2e 6c 69 | 6e 6b 6e 61 6d 65 2c 20 |eader.li|nkname, |
|00001940| 4e 41 4d 53 49 5a 29 3b | 0d 0a 09 09 69 66 20 28 |NAMSIZ);|....if (|
|00001950| 73 69 7a 65 20 3c 20 30 | 29 20 67 6f 74 6f 20 62 |size < 0|) goto b|
|00001960| 61 64 70 65 72 72 6f 72 | 3b 0d 0a 09 09 69 66 20 |adperror|;....if |
|00001970| 28 73 69 7a 65 20 3d 3d | 20 4e 41 4d 53 49 5a 29 |(size ==| NAMSIZ)|
|00001980| 20 7b 0d 0a 09 09 09 61 | 6e 6e 6f 72 65 63 28 73 | {.....a|nnorec(s|
|00001990| 74 64 65 72 72 2c 20 74 | 61 72 29 3b 0d 0a 09 09 |tderr, t|ar);....|
|000019a0| 09 66 70 72 69 6e 74 66 | 28 73 74 64 65 72 72 2c |.fprintf|(stderr,|
|000019b0| 0d 0a 09 09 09 09 22 25 | 73 3a 20 73 79 6d 62 6f |......"%|s: symbo|
|000019c0| 6c 69 63 20 6c 69 6e 6b | 20 74 6f 6f 20 6c 6f 6e |lic link| too lon|
|000019d0| 67 5c 6e 22 2c 20 70 29 | 3b 0d 0a 09 09 09 62 72 |g\n", p)|;.....br|
|000019e0| 65 61 6b 3b 0d 0a 09 09 | 7d 0d 0a 09 09 68 65 61 |eak;....|}....hea|
|000019f0| 64 65 72 2d 3e 68 65 61 | 64 65 72 2e 6c 69 6e 6b |der->hea|der.link|
|00001a00| 6e 61 6d 65 5b 73 69 7a | 65 5d 20 3d 20 27 5c 30 |name[siz|e] = '\0|
|00001a10| 27 3b 0d 0a 09 09 68 65 | 61 64 65 72 2d 3e 68 65 |';....he|ader->he|
|00001a20| 61 64 65 72 2e 6c 69 6e | 6b 66 6c 61 67 20 3d 20 |ader.lin|kflag = |
|00001a30| 4c 46 5f 53 59 4d 4c 49 | 4e 4b 3b 0d 0a 09 09 66 |LF_SYMLI|NK;....f|
|00001a40| 69 6e 69 73 68 5f 68 65 | 61 64 65 72 28 68 65 61 |inish_he|ader(hea|
|00001a50| 64 65 72 29 3b 09 09 2f | 2a 20 4e 6f 74 68 69 6e |der);../|* Nothin|
|00001a60| 67 20 6d 6f 72 65 20 74 | 6f 20 64 6f 20 74 6f 20 |g more t|o do to |
|00001a70| 69 74 20 2a 2f 0d 0a 09 | 09 69 66 20 28 66 5f 76 |it */...|.if (f_v|
|00001a80| 65 72 62 6f 73 65 29 20 | 7b 0d 0a 09 09 09 61 6e |erbose) |{.....an|
|00001a90| 6e 6f 72 65 63 28 73 74 | 64 6f 75 74 2c 20 28 63 |norec(st|dout, (c|
|00001aa0| 68 61 72 20 2a 29 4e 55 | 4c 4c 29 3b 0d 0a 09 09 |har *)NU|LL);....|
|00001ab0| 09 70 72 69 6e 74 66 28 | 22 25 73 5c 6e 22 2c 20 |.printf(|"%s\n", |
|00001ac0| 70 29 3b 0d 0a 09 09 7d | 0d 0a 09 7d 0d 0a 09 09 |p);....}|...}....|
|00001ad0| 62 72 65 61 6b 3b 0d 0a | 23 65 6e 64 69 66 0d 0a |break;..|#endif..|
|00001ae0| 0d 0a 09 63 61 73 65 20 | 53 5f 49 46 44 49 52 3a |...case |S_IFDIR:|
|00001af0| 09 09 09 2f 2a 20 44 69 | 72 65 63 74 6f 72 79 20 |.../* Di|rectory |
|00001b00| 2a 2f 0d 0a 09 7b 0d 0a | 09 09 72 65 67 69 73 74 |*/...{..|..regist|
|00001b10| 65 72 20 44 49 52 20 2a | 64 69 72 70 3b 0d 0a 09 |er DIR *|dirp;...|
|00001b20| 09 72 65 67 69 73 74 65 | 72 20 73 74 72 75 63 74 |.registe|r struct|
|00001b30| 20 64 69 72 65 63 74 20 | 2a 64 3b 0d 0a 09 09 63 | direct |*d;....c|
|00001b40| 68 61 72 20 6e 61 6d 65 | 62 75 66 5b 4e 41 4d 53 |har name|buf[NAMS|
|00001b50| 49 5a 2b 32 5d 3b 0d 0a | 09 09 72 65 67 69 73 74 |IZ+2];..|..regist|
|00001b60| 65 72 20 69 6e 74 20 6c | 65 6e 3b 0d 0a 0d 0a 09 |er int l|en;.....|
|00001b70| 09 2f 2a 20 42 75 69 6c | 64 20 6e 65 77 20 70 72 |./* Buil|d new pr|
|00001b80| 6f 74 6f 74 79 70 65 20 | 6e 61 6d 65 20 2a 2f 0d |ototype |name */.|
|00001b90| 0a 09 09 73 74 72 6e 63 | 70 79 28 6e 61 6d 65 62 |...strnc|py(nameb|
|00001ba0| 75 66 2c 20 70 2c 20 73 | 69 7a 65 6f 66 20 28 6e |uf, p, s|izeof (n|
|00001bb0| 61 6d 65 62 75 66 29 29 | 3b 0d 0a 09 09 6c 65 6e |amebuf))|;....len|
|00001bc0| 20 3d 20 73 74 72 6c 65 | 6e 28 6e 61 6d 65 62 75 | = strle|n(namebu|
|00001bd0| 66 29 3b 0d 0a 09 09 77 | 68 69 6c 65 20 28 6c 65 |f);....w|hile (le|
|00001be0| 6e 20 3e 3d 20 31 20 26 | 26 20 27 2f 27 20 3d 3d |n >= 1 &|& '/' ==|
|00001bf0| 20 6e 61 6d 65 62 75 66 | 5b 6c 65 6e 2d 31 5d 29 | namebuf|[len-1])|
|00001c00| 20 0d 0a 09 09 09 6c 65 | 6e 2d 2d 3b 09 09 09 2f | .....le|n--;.../|
|00001c10| 2a 20 44 65 6c 65 74 65 | 20 74 72 61 69 6c 69 6e |* Delete| trailin|
|00001c20| 67 20 73 6c 61 73 68 65 | 73 20 2a 2f 0d 0a 09 09 |g slashe|s */....|
|00001c30| 6e 61 6d 65 62 75 66 5b | 6c 65 6e 2b 2b 5d 20 3d |namebuf[|len++] =|
|00001c40| 20 27 2f 27 3b 09 09 2f | 2a 20 4e 6f 77 20 61 64 | '/';../|* Now ad|
|00001c50| 64 20 65 78 61 63 74 6c | 79 20 6f 6e 65 20 62 61 |d exactl|y one ba|
|00001c60| 63 6b 20 2a 2f 0d 0a 0d | 0a 09 09 2f 2a 0d 0a 09 |ck */...|.../*...|
|00001c70| 09 20 2a 20 4f 75 74 70 | 75 74 20 64 69 72 65 63 |. * Outp|ut direc|
|00001c80| 74 6f 72 79 20 68 65 61 | 64 65 72 20 72 65 63 6f |tory hea|der reco|
|00001c90| 72 64 20 77 69 74 68 20 | 70 65 72 6d 69 73 73 69 |rd with |permissi|
|00001ca0| 6f 6e 73 0d 0a 09 09 20 | 2a 20 46 49 58 4d 45 2c |ons.... |* FIXME,|
|00001cb0| 20 64 6f 20 74 68 69 73 | 20 41 46 54 45 52 20 66 | do this| AFTER f|
|00001cc0| 69 6c 65 73 2c 20 74 6f | 20 61 76 6f 69 64 20 52 |iles, to| avoid R|
|00001cd0| 2f 4f 20 64 69 72 20 70 | 72 6f 62 6c 65 6d 73 3f |/O dir p|roblems?|
|00001ce0| 0d 0a 09 09 20 2a 20 49 | 66 20 55 6e 69 78 20 53 |.... * I|f Unix S|
|00001cf0| 74 64 20 66 6f 72 6d 61 | 74 2c 20 64 6f 6e 27 74 |td forma|t, don't|
|00001d00| 20 70 75 74 20 2f 20 6f | 6e 20 65 6e 64 20 6f 66 | put / o|n end of|
|00001d10| 20 64 69 72 20 6e 61 6d | 65 0d 0a 09 09 20 2a 20 | dir nam|e.... * |
|00001d20| 49 66 20 6f 6c 64 20 61 | 72 63 68 69 76 65 20 66 |If old a|rchive f|
|00001d30| 6f 72 6d 61 74 2c 20 64 | 6f 6e 27 74 20 77 72 69 |ormat, d|on't wri|
|00001d40| 74 65 20 72 65 63 6f 72 | 64 20 61 74 20 61 6c 6c |te recor|d at all|
|00001d50| 2e 0d 0a 09 09 20 2a 2f | 0d 0a 09 09 69 66 20 28 |..... */|....if (|
|00001d60| 21 66 5f 6f 6c 64 61 72 | 63 68 29 20 7b 0d 0a 09 |!f_oldar|ch) {...|
|00001d70| 09 09 73 74 61 74 62 75 | 66 2d 3e 73 74 5f 73 69 |..statbu|f->st_si|
|00001d80| 7a 65 20 3d 20 30 3b 09 | 2f 2a 20 46 6f 72 63 65 |ze = 0;.|/* Force|
|00001d90| 20 30 20 73 69 7a 65 20 | 6f 6e 20 64 69 72 20 2a | 0 size |on dir *|
|00001da0| 2f 0d 0a 09 09 09 2f 2a | 0d 0a 09 09 09 20 2a 20 |/...../*|..... * |
|00001db0| 49 66 20 70 65 6f 70 6c | 65 20 63 6f 75 6c 64 20 |If peopl|e could |
|00001dc0| 72 65 61 6c 6c 79 20 72 | 65 61 64 20 73 74 61 6e |really r|ead stan|
|00001dd0| 64 61 72 64 20 61 72 63 | 68 69 76 65 73 2c 0d 0a |dard arc|hives,..|
|00001de0| 09 09 09 20 2a 20 74 68 | 69 73 20 73 68 6f 75 6c |... * th|is shoul|
|00001df0| 64 20 62 65 3a 09 09 28 | 46 49 58 4d 45 29 0d 0a |d be:..(|FIXME)..|
|00001e00| 09 09 09 68 65 61 64 65 | 72 20 3d 20 73 74 61 72 |...heade|r = star|
|00001e10| 74 5f 68 65 61 64 65 72 | 28 66 5f 73 74 61 6e 64 |t_header|(f_stand|
|00001e20| 61 72 64 3f 20 70 3a 20 | 6e 61 6d 65 62 75 66 2c |ard? p: |namebuf,|
|00001e30| 20 73 74 61 74 62 75 66 | 29 3b 0d 0a 09 09 09 20 | statbuf|);..... |
|00001e40| 2a 20 62 75 74 20 73 69 | 6e 63 65 20 74 68 65 79 |* but si|nce they|
|00001e50| 27 64 20 69 6e 74 65 72 | 70 72 65 74 20 4c 46 5f |'d inter|pret LF_|
|00001e60| 44 49 52 20 72 65 63 6f | 72 64 73 20 61 73 0d 0a |DIR reco|rds as..|
|00001e70| 09 09 09 20 2a 20 72 65 | 67 75 6c 61 72 20 66 69 |... * re|gular fi|
|00001e80| 6c 65 73 2c 20 77 65 27 | 64 20 62 65 74 74 65 72 |les, we'|d better|
|00001e90| 20 70 75 74 20 74 68 65 | 20 2f 20 6f 6e 20 74 68 | put the| / on th|
|00001ea0| 65 20 6e 61 6d 65 2e 0d | 0a 09 09 09 20 2a 2f 0d |e name..|.... */.|
|00001eb0| 0a 09 09 09 68 65 61 64 | 65 72 20 3d 20 73 74 61 |....head|er = sta|
|00001ec0| 72 74 5f 68 65 61 64 65 | 72 28 6e 61 6d 65 62 75 |rt_heade|r(namebu|
|00001ed0| 66 2c 20 73 74 61 74 62 | 75 66 29 3b 0d 0a 09 09 |f, statb|uf);....|
|00001ee0| 09 69 66 20 28 68 65 61 | 64 65 72 20 3d 3d 20 4e |.if (hea|der == N|
|00001ef0| 55 4c 4c 29 0d 0a 09 09 | 09 09 67 6f 74 6f 20 62 |ULL)....|..goto b|
|00001f00| 61 64 66 69 6c 65 3b 09 | 2f 2a 20 65 67 20 6e 61 |adfile;.|/* eg na|
|00001f10| 6d 65 20 74 6f 6f 20 6c | 6f 6e 67 20 2a 2f 0d 0a |me too l|ong */..|
|00001f20| 09 09 09 69 66 20 28 66 | 5f 73 74 61 6e 64 61 72 |...if (f|_standar|
|00001f30| 64 29 20 7b 0d 0a 09 09 | 09 09 68 65 61 64 65 72 |d) {....|..header|
|00001f40| 2d 3e 68 65 61 64 65 72 | 2e 6c 69 6e 6b 66 6c 61 |->header|.linkfla|
|00001f50| 67 20 3d 20 4c 46 5f 44 | 49 52 3b 0d 0a 09 09 09 |g = LF_D|IR;.....|
|00001f60| 7d 0d 0a 09 09 09 66 69 | 6e 69 73 68 5f 68 65 61 |}.....fi|nish_hea|
|00001f70| 64 65 72 28 68 65 61 64 | 65 72 29 3b 09 2f 2a 20 |der(head|er);./* |
|00001f80| 44 6f 6e 65 20 77 69 74 | 68 20 64 69 72 65 63 74 |Done wit|h direct|
|00001f90| 6f 72 79 20 68 65 61 64 | 65 72 20 2a 2f 0d 0a 09 |ory head|er */...|
|00001fa0| 09 7d 0d 0a 09 09 69 66 | 20 28 66 5f 76 65 72 62 |.}....if| (f_verb|
|00001fb0| 6f 73 65 29 20 7b 0d 0a | 09 09 09 61 6e 6e 6f 72 |ose) {..|...annor|
|00001fc0| 65 63 28 73 74 64 6f 75 | 74 2c 20 28 63 68 61 72 |ec(stdou|t, (char|
|00001fd0| 20 2a 29 4e 55 4c 4c 29 | 3b 0d 0a 09 09 09 70 72 | *)NULL)|;.....pr|
|00001fe0| 69 6e 74 66 28 22 25 73 | 5c 6e 22 2c 20 70 29 3b |intf("%s|\n", p);|
|00001ff0| 0d 0a 09 09 7d 0d 0a 0d | 0a 09 09 2f 2a 20 48 61 |....}...|.../* Ha|
|00002000| 63 6b 20 74 6f 20 72 65 | 6d 6f 76 65 20 22 2e 2f |ck to re|move "./|
|00002010| 22 20 66 72 6f 6d 20 74 | 68 65 20 66 72 6f 6e 74 |" from t|he front|
|00002020| 20 6f 66 20 61 6c 6c 20 | 74 68 65 20 66 69 6c 65 | of all |the file|
|00002030| 20 6e 61 6d 65 73 20 2a | 2f 0d 0a 09 09 69 66 20 | names *|/....if |
|00002040| 28 6c 65 6e 20 3d 3d 20 | 32 20 26 26 20 6e 61 6d |(len == |2 && nam|
|00002050| 65 62 75 66 5b 30 5d 20 | 3d 3d 20 27 2e 27 29 20 |ebuf[0] |== '.') |
|00002060| 7b 0d 0a 09 09 09 6c 65 | 6e 20 3d 20 30 3b 0d 0a |{.....le|n = 0;..|
|00002070| 09 09 7d 0d 0a 0d 0a 09 | 09 2f 2a 20 4e 6f 77 20 |..}.....|./* Now |
|00002080| 6f 75 74 70 75 74 20 61 | 6c 6c 20 74 68 65 20 66 |output a|ll the f|
|00002090| 69 6c 65 73 20 69 6e 20 | 74 68 65 20 64 69 72 65 |iles in |the dire|
|000020a0| 63 74 6f 72 79 20 2a 2f | 0d 0a 09 09 65 72 72 6e |ctory */|....errn|
|000020b0| 6f 20 3d 20 30 3b 0d 0a | 09 09 64 69 72 70 20 3d |o = 0;..|..dirp =|
|000020c0| 20 6f 70 65 6e 64 69 72 | 28 70 29 3b 0d 0a 09 09 | opendir|(p);....|
|000020d0| 69 66 20 28 21 64 69 72 | 70 29 20 7b 0d 0a 09 09 |if (!dir|p) {....|
|000020e0| 09 69 66 20 28 65 72 72 | 6e 6f 29 20 7b 0d 0a 09 |.if (err|no) {...|
|000020f0| 09 09 09 70 65 72 72 6f | 72 20 28 70 29 3b 0d 0a |...perro|r (p);..|
|00002100| 09 09 09 7d 20 65 6c 73 | 65 20 7b 0d 0a 09 09 09 |...} els|e {.....|
|00002110| 09 61 6e 6e 6f 72 65 63 | 28 73 74 64 65 72 72 2c |.annorec|(stderr,|
|00002120| 20 74 61 72 29 3b 0d 0a | 09 09 09 09 66 70 72 69 | tar);..|....fpri|
|00002130| 6e 74 66 28 73 74 64 65 | 72 72 2c 20 22 25 73 3a |ntf(stde|rr, "%s:|
|00002140| 20 65 72 72 6f 72 20 6f | 70 65 6e 69 6e 67 20 64 | error o|pening d|
|00002150| 69 72 65 63 74 6f 72 79 | 22 2c 0d 0a 09 09 09 09 |irectory|",......|
|00002160| 09 70 29 3b 0d 0a 09 09 | 09 7d 0d 0a 09 09 09 62 |.p);....|.}.....b|
|00002170| 72 65 61 6b 3b 0d 0a 09 | 09 7d 0d 0a 09 09 0d 0a |reak;...|.}......|
|00002180| 09 09 2f 2a 20 53 68 6f | 75 6c 64 20 73 70 65 65 |../* Sho|uld spee|
|00002190| 64 20 74 68 69 73 20 75 | 70 20 62 79 20 63 64 2d |d this u|p by cd-|
|000021a0| 69 6e 67 20 69 6e 74 6f | 20 74 68 65 20 64 69 72 |ing into| the dir|
|000021b0| 2c 20 46 49 58 4d 45 20 | 2a 2f 0d 0a 09 09 77 68 |, FIXME |*/....wh|
|000021c0| 69 6c 65 20 28 4e 55 4c | 4c 20 21 3d 20 28 64 3d |ile (NUL|L != (d=|
|000021d0| 72 65 61 64 64 69 72 28 | 64 69 72 70 29 29 29 20 |readdir(|dirp))) |
|000021e0| 7b 0d 0a 09 09 09 2f 2a | 20 53 6b 69 70 20 2e 20 |{...../*| Skip . |
|000021f0| 61 6e 64 20 2e 2e 20 2a | 2f 0d 0a 09 09 09 69 66 |and .. *|/.....if|
|00002200| 20 28 64 2d 3e 64 5f 6e | 61 6d 65 5b 30 5d 20 3d | (d->d_n|ame[0] =|
|00002210| 3d 20 27 2e 27 29 20 7b | 0d 0a 09 09 09 09 69 66 |= '.') {|......if|
|00002220| 20 28 64 2d 3e 64 5f 6e | 61 6d 65 5b 31 5d 20 3d | (d->d_n|ame[1] =|
|00002230| 3d 20 27 5c 30 27 29 20 | 63 6f 6e 74 69 6e 75 65 |= '\0') |continue|
|00002240| 3b 0d 0a 09 09 09 09 69 | 66 20 28 64 2d 3e 64 5f |;......i|f (d->d_|
|00002250| 6e 61 6d 65 5b 31 5d 20 | 3d 3d 20 27 2e 27 29 20 |name[1] |== '.') |
|00002260| 7b 0d 0a 09 09 09 09 09 | 69 66 20 28 64 2d 3e 64 |{.......|if (d->d|
|00002270| 5f 6e 61 6d 65 5b 32 5d | 20 3d 3d 20 27 5c 30 27 |_name[2]| == '\0'|
|00002280| 29 20 63 6f 6e 74 69 6e | 75 65 3b 0d 0a 09 09 09 |) contin|ue;.....|
|00002290| 09 7d 0d 0a 09 09 09 7d | 0d 0a 09 09 09 69 66 20 |.}.....}|.....if |
|000022a0| 28 64 2d 3e 64 5f 6e 61 | 6d 6c 65 6e 20 2b 20 6c |(d->d_na|mlen + l|
|000022b0| 65 6e 20 3e 3d 20 4e 41 | 4d 53 49 5a 29 20 7b 0d |en >= NA|MSIZ) {.|
|000022c0| 0a 09 09 09 09 61 6e 6e | 6f 72 65 63 28 73 74 64 |.....ann|orec(std|
|000022d0| 65 72 72 2c 20 74 61 72 | 29 3b 0d 0a 09 09 09 09 |err, tar|);......|
|000022e0| 66 70 72 69 6e 74 66 28 | 73 74 64 65 72 72 2c 20 |fprintf(|stderr, |
|000022f0| 22 25 73 25 73 3a 20 6e | 61 6d 65 20 74 6f 6f 20 |"%s%s: n|ame too |
|00002300| 6c 6f 6e 67 5c 6e 22 2c | 20 0d 0a 09 09 09 09 09 |long\n",| .......|
|00002310| 6e 61 6d 65 62 75 66 2c | 20 64 2d 3e 64 5f 6e 61 |namebuf,| d->d_na|
|00002320| 6d 65 29 3b 0d 0a 09 09 | 09 09 63 6f 6e 74 69 6e |me);....|..contin|
|00002330| 75 65 3b 0d 0a 09 09 09 | 7d 0d 0a 09 09 09 73 74 |ue;.....|}.....st|
|00002340| 72 63 70 79 28 6e 61 6d | 65 62 75 66 2b 6c 65 6e |rcpy(nam|ebuf+len|
|00002350| 2c 20 64 2d 3e 64 5f 6e | 61 6d 65 29 3b 0d 0a 09 |, d->d_n|ame);...|
|00002360| 09 09 64 75 6d 70 5f 66 | 69 6c 65 28 6e 61 6d 65 |..dump_f|ile(name|
|00002370| 62 75 66 29 3b 0d 0a 09 | 09 7d 0d 0a 0d 0a 09 09 |buf);...|.}......|
|00002380| 63 6c 6f 73 65 64 69 72 | 28 64 69 72 70 29 3b 0d |closedir|(dirp);.|
|00002390| 0a 09 7d 0d 0a 09 09 62 | 72 65 61 6b 3b 0d 0a 0d |..}....b|reak;...|
|000023a0| 0a 23 69 66 64 65 66 20 | 53 5f 49 46 43 48 52 0d |.#ifdef |S_IFCHR.|
|000023b0| 0a 09 63 61 73 65 20 53 | 5f 49 46 43 48 52 3a 09 |..case S|_IFCHR:.|
|000023c0| 09 09 2f 2a 20 43 68 61 | 72 61 63 74 65 72 20 73 |../* Cha|racter s|
|000023d0| 70 65 63 69 61 6c 20 66 | 69 6c 65 20 2a 2f 0d 0a |pecial f|ile */..|
|000023e0| 09 09 74 79 70 65 20 3d | 20 4c 46 5f 43 48 52 3b |..type =| LF_CHR;|
|000023f0| 0d 0a 09 09 67 6f 74 6f | 20 65 61 73 79 3b 0d 0a |....goto| easy;..|
|00002400| 23 65 6e 64 69 66 0d 0a | 0d 0a 23 69 66 64 65 66 |#endif..|..#ifdef|
|00002410| 20 53 5f 49 46 42 4c 4b | 0d 0a 09 63 61 73 65 20 | S_IFBLK|...case |
|00002420| 53 5f 49 46 42 4c 4b 3a | 09 09 09 2f 2a 20 42 6c |S_IFBLK:|.../* Bl|
|00002430| 6f 63 6b 20 20 20 20 20 | 73 70 65 63 69 61 6c 20 |ock |special |
|00002440| 66 69 6c 65 20 2a 2f 0d | 0a 09 09 74 79 70 65 20 |file */.|...type |
|00002450| 3d 20 4c 46 5f 42 4c 4b | 3b 0d 0a 09 09 67 6f 74 |= LF_BLK|;....got|
|00002460| 6f 20 65 61 73 79 3b 0d | 0a 23 65 6e 64 69 66 0d |o easy;.|.#endif.|
|00002470| 0a 0d 0a 23 69 66 64 65 | 66 20 53 5f 49 46 49 46 |...#ifde|f S_IFIF|
|00002480| 4f 0d 0a 09 63 61 73 65 | 20 53 5f 49 46 49 46 4f |O...case| S_IFIFO|
|00002490| 3a 09 09 09 2f 2a 20 46 | 69 66 6f 20 20 20 20 20 |:.../* F|ifo |
|000024a0| 20 73 70 65 63 69 61 6c | 20 66 69 6c 65 20 2a 2f | special| file */|
|000024b0| 0d 0a 09 09 74 79 70 65 | 20 3d 20 4c 46 5f 46 49 |....type| = LF_FI|
|000024c0| 46 4f 3b 0d 0a 23 65 6e | 64 69 66 0d 0a 0d 0a 09 |FO;..#en|dif.....|
|000024d0| 65 61 73 79 3a 0d 0a 09 | 09 69 66 20 28 21 66 5f |easy:...|.if (!f_|
|000024e0| 73 74 61 6e 64 61 72 64 | 29 20 67 6f 74 6f 20 75 |standard|) goto u|
|000024f0| 6e 6b 6e 6f 77 6e 3b 0d | 0a 0d 0a 09 09 73 74 61 |nknown;.|.....sta|
|00002500| 74 62 75 66 2d 3e 73 74 | 5f 73 69 7a 65 20 3d 20 |tbuf->st|_size = |
|00002510| 30 3b 09 09 2f 2a 20 46 | 6f 72 63 65 20 30 20 73 |0;../* F|orce 0 s|
|00002520| 69 7a 65 20 2a 2f 0d 0a | 09 09 68 65 61 64 65 72 |ize */..|..header|
|00002530| 20 3d 20 73 74 61 72 74 | 5f 68 65 61 64 65 72 28 | = start|_header(|
|00002540| 70 2c 20 73 74 61 74 62 | 75 66 29 3b 0d 0a 09 09 |p, statb|uf);....|
|00002550| 69 66 20 28 68 65 61 64 | 65 72 20 3d 3d 20 4e 55 |if (head|er == NU|
|00002560| 4c 4c 29 20 67 6f 74 6f | 20 62 61 64 66 69 6c 65 |LL) goto| badfile|
|00002570| 3b 09 2f 2a 20 65 67 20 | 6e 61 6d 65 20 74 6f 6f |;./* eg |name too|
|00002580| 20 6c 6f 6e 67 20 2a 2f | 0d 0a 0d 0a 09 09 68 65 | long */|......he|
|00002590| 61 64 65 72 2d 3e 68 65 | 61 64 65 72 2e 6c 69 6e |ader->he|ader.lin|
|000025a0| 6b 66 6c 61 67 20 3d 20 | 74 79 70 65 3b 0d 0a 09 |kflag = |type;...|
|000025b0| 09 69 66 20 28 74 79 70 | 65 20 21 3d 20 4c 46 5f |.if (typ|e != LF_|
|000025c0| 46 49 46 4f 29 20 7b 0d | 0a 09 09 09 74 6f 5f 6f |FIFO) {.|....to_o|
|000025d0| 63 74 28 28 6c 6f 6e 67 | 29 20 6d 61 6a 6f 72 28 |ct((long|) major(|
|000025e0| 73 74 61 74 62 75 66 2d | 3e 73 74 5f 72 64 65 76 |statbuf-|>st_rdev|
|000025f0| 29 2c 20 38 2c 0d 0a 09 | 09 09 09 68 65 61 64 65 |), 8,...|...heade|
|00002600| 72 2d 3e 68 65 61 64 65 | 72 2e 64 65 76 6d 61 6a |r->heade|r.devmaj|
|00002610| 6f 72 29 3b 0d 0a 09 09 | 09 74 6f 5f 6f 63 74 28 |or);....|.to_oct(|
|00002620| 28 6c 6f 6e 67 29 20 6d | 69 6e 6f 72 28 73 74 61 |(long) m|inor(sta|
|00002630| 74 62 75 66 2d 3e 73 74 | 5f 72 64 65 76 29 2c 20 |tbuf->st|_rdev), |
|00002640| 38 2c 0d 0a 09 09 09 09 | 68 65 61 64 65 72 2d 3e |8,......|header->|
|00002650| 68 65 61 64 65 72 2e 64 | 65 76 6d 69 6e 6f 72 29 |header.d|evminor)|
|00002660| 3b 0d 0a 09 09 7d 0d 0a | 0d 0a 09 09 66 69 6e 69 |;....}..|....fini|
|00002670| 73 68 5f 68 65 61 64 65 | 72 28 68 65 61 64 65 72 |sh_heade|r(header|
|00002680| 29 3b 0d 0a 09 09 69 66 | 20 28 66 5f 76 65 72 62 |);....if| (f_verb|
|00002690| 6f 73 65 29 20 7b 0d 0a | 09 09 09 61 6e 6e 6f 72 |ose) {..|...annor|
|000026a0| 65 63 28 73 74 64 6f 75 | 74 2c 20 28 63 68 61 72 |ec(stdou|t, (char|
|000026b0| 20 2a 29 4e 55 4c 4c 29 | 3b 0d 0a 09 09 09 70 72 | *)NULL)|;.....pr|
|000026c0| 69 6e 74 66 28 22 25 73 | 5c 6e 22 2c 20 70 29 3b |intf("%s|\n", p);|
|000026d0| 0d 0a 09 09 7d 0d 0a 09 | 09 62 72 65 61 6b 3b 0d |....}...|.break;.|
|000026e0| 0a 0d 0a 09 64 65 66 61 | 75 6c 74 3a 0d 0a 09 75 |....defa|ult:...u|
|000026f0| 6e 6b 6e 6f 77 6e 3a 0d | 0a 09 09 61 6e 6e 6f 72 |nknown:.|...annor|
|00002700| 65 63 28 73 74 64 65 72 | 72 2c 20 74 61 72 29 3b |ec(stder|r, tar);|
|00002710| 0d 0a 09 09 66 70 72 69 | 6e 74 66 28 73 74 64 65 |....fpri|ntf(stde|
|00002720| 72 72 2c 0d 0a 09 09 09 | 22 25 73 3a 20 55 6e 6b |rr,.....|"%s: Unk|
|00002730| 6e 6f 77 6e 20 66 69 6c | 65 20 74 79 70 65 3b 20 |nown fil|e type; |
|00002740| 66 69 6c 65 20 69 67 6e | 6f 72 65 64 2e 5c 6e 22 |file ign|ored.\n"|
|00002750| 2c 20 70 29 3b 0d 0a 09 | 09 62 72 65 61 6b 3b 0d |, p);...|.break;.|
|00002760| 0a 09 7d 0d 0a 0d 0a 09 | 72 65 74 75 72 6e 20 31 |..}.....|return 1|
|00002770| 3b 09 09 09 2f 2a 20 53 | 75 63 63 65 73 73 20 2a |;.../* S|uccess *|
|00002780| 2f 0d 0a 7d 0d 0a 0d 0a | 0d 0a 2f 2a 0d 0a 20 2a |/..}....|../*.. *|
|00002790| 20 4d 61 6b 65 20 61 20 | 68 65 61 64 65 72 20 62 | Make a |header b|
|000027a0| 6c 6f 63 6b 20 66 6f 72 | 20 74 68 65 20 66 69 6c |lock for| the fil|
|000027b0| 65 20 20 6e 61 6d 65 20 | 20 77 68 6f 73 65 20 73 |e name | whose s|
|000027c0| 74 61 74 20 69 6e 66 6f | 20 69 73 20 20 73 74 20 |tat info| is st |
|000027d0| 2e 0d 0a 20 2a 20 52 65 | 74 75 72 6e 20 68 65 61 |... * Re|turn hea|
|000027e0| 64 65 72 20 70 6f 69 6e | 74 65 72 20 66 6f 72 20 |der poin|ter for |
|000027f0| 73 75 63 63 65 73 73 2c | 20 4e 55 4c 4c 20 69 66 |success,| NULL if|
|00002800| 20 74 68 65 20 6e 61 6d | 65 20 69 73 20 74 6f 6f | the nam|e is too|
|00002810| 20 6c 6f 6e 67 2e 0d 0a | 20 2a 2f 0d 0a 75 6e 69 | long...| */..uni|
|00002820| 6f 6e 20 72 65 63 6f 72 | 64 20 2a 0d 0a 73 74 61 |on recor|d *..sta|
|00002830| 72 74 5f 68 65 61 64 65 | 72 28 6e 61 6d 65 2c 20 |rt_heade|r(name, |
|00002840| 73 74 29 0d 0a 09 63 68 | 61 72 09 2a 6e 61 6d 65 |st)...ch|ar.*name|
|00002850| 3b 0d 0a 09 72 65 67 69 | 73 74 65 72 20 73 74 72 |;...regi|ster str|
|00002860| 75 63 74 20 73 74 61 74 | 20 2a 73 74 3b 0d 0a 7b |uct stat| *st;..{|
|00002870| 0d 0a 09 72 65 67 69 73 | 74 65 72 20 75 6e 69 6f |...regis|ter unio|
|00002880| 6e 20 72 65 63 6f 72 64 | 20 2a 68 65 61 64 65 72 |n record| *header|
|00002890| 3b 0d 0a 0d 0a 09 68 65 | 61 64 65 72 20 3d 20 28 |;.....he|ader = (|
|000028a0| 75 6e 69 6f 6e 20 72 65 | 63 6f 72 64 20 2a 29 20 |union re|cord *) |
|000028b0| 66 69 6e 64 72 65 63 28 | 29 3b 0d 0a 09 62 7a 65 |findrec(|);...bze|
|000028c0| 72 6f 28 68 65 61 64 65 | 72 2d 3e 63 68 61 72 70 |ro(heade|r->charp|
|000028d0| 74 72 2c 20 73 69 7a 65 | 6f 66 28 2a 68 65 61 64 |tr, size|of(*head|
|000028e0| 65 72 29 29 3b 20 2f 2a | 20 58 58 58 20 73 70 65 |er)); /*| XXX spe|
|000028f0| 65 64 20 75 70 20 2a 2f | 0d 0a 09 73 74 72 63 70 |ed up */|...strcp|
|00002900| 79 28 68 65 61 64 65 72 | 2d 3e 68 65 61 64 65 72 |y(header|->header|
|00002910| 2e 6e 61 6d 65 2c 20 6e | 61 6d 65 29 3b 0d 0a 09 |.name, n|ame);...|
|00002920| 69 66 20 28 68 65 61 64 | 65 72 2d 3e 68 65 61 64 |if (head|er->head|
|00002930| 65 72 2e 6e 61 6d 65 5b | 4e 41 4d 53 49 5a 2d 31 |er.name[|NAMSIZ-1|
|00002940| 5d 29 20 7b 0d 0a 09 09 | 61 6e 6e 6f 72 65 63 28 |]) {....|annorec(|
|00002950| 73 74 64 65 72 72 2c 20 | 74 61 72 29 3b 0d 0a 09 |stderr, |tar);...|
|00002960| 09 66 70 72 69 6e 74 66 | 28 73 74 64 65 72 72 2c |.fprintf|(stderr,|
|00002970| 20 22 25 73 3a 20 6e 61 | 6d 65 20 74 6f 6f 20 6c | "%s: na|me too l|
|00002980| 6f 6e 67 5c 6e 22 2c 20 | 6e 61 6d 65 29 3b 0d 0a |ong\n", |name);..|
|00002990| 09 09 72 65 74 75 72 6e | 20 4e 55 4c 4c 3b 0d 0a |..return| NULL;..|
|000029a0| 09 7d 0d 0a 09 74 6f 5f | 6f 63 74 28 28 6c 6f 6e |.}...to_|oct((lon|
|000029b0| 67 29 20 28 73 74 2d 3e | 73 74 5f 6d 6f 64 65 20 |g) (st->|st_mode |
|000029c0| 26 20 7e 53 5f 49 46 4d | 54 29 2c 0d 0a 09 09 09 |& ~S_IFM|T),.....|
|000029d0| 09 09 38 2c 20 20 68 65 | 61 64 65 72 2d 3e 68 65 |..8, he|ader->he|
|000029e0| 61 64 65 72 2e 6d 6f 64 | 65 29 3b 0d 0a 09 74 6f |ader.mod|e);...to|
|000029f0| 5f 6f 63 74 28 28 6c 6f | 6e 67 29 20 73 74 2d 3e |_oct((lo|ng) st->|
|00002a00| 73 74 5f 75 69 64 2c 09 | 38 2c 20 20 68 65 61 64 |st_uid,.|8, head|
|00002a10| 65 72 2d 3e 68 65 61 64 | 65 72 2e 75 69 64 29 3b |er->head|er.uid);|
|00002a20| 0d 0a 09 74 6f 5f 6f 63 | 74 28 28 6c 6f 6e 67 29 |...to_oc|t((long)|
|00002a30| 20 73 74 2d 3e 73 74 5f | 67 69 64 2c 09 38 2c 20 | st->st_|gid,.8, |
|00002a40| 20 68 65 61 64 65 72 2d | 3e 68 65 61 64 65 72 2e | header-|>header.|
|00002a50| 67 69 64 29 3b 0d 0a 09 | 74 6f 5f 6f 63 74 28 28 |gid);...|to_oct((|
|00002a60| 6c 6f 6e 67 29 20 73 74 | 2d 3e 73 74 5f 73 69 7a |long) st|->st_siz|
|00002a70| 65 2c 09 31 2b 31 32 2c | 20 68 65 61 64 65 72 2d |e,.1+12,| header-|
|00002a80| 3e 68 65 61 64 65 72 2e | 73 69 7a 65 29 3b 0d 0a |>header.|size);..|
|00002a90| 09 74 6f 5f 6f 63 74 28 | 28 6c 6f 6e 67 29 20 73 |.to_oct(|(long) s|
|00002aa0| 74 2d 3e 73 74 5f 6d 74 | 69 6d 65 2c 09 31 2b 31 |t->st_mt|ime,.1+1|
|00002ab0| 32 2c 20 68 65 61 64 65 | 72 2d 3e 68 65 61 64 65 |2, heade|r->heade|
|00002ac0| 72 2e 6d 74 69 6d 65 29 | 3b 0d 0a 09 2f 2a 20 68 |r.mtime)|;.../* h|
|00002ad0| 65 61 64 65 72 2d 3e 68 | 65 61 64 65 72 2e 6c 69 |eader->h|eader.li|
|00002ae0| 6e 6b 66 6c 61 67 20 69 | 73 20 6c 65 66 74 20 61 |nkflag i|s left a|
|00002af0| 73 20 6e 75 6c 6c 20 2a | 2f 0d 0a 0d 0a 23 69 66 |s null *|/....#if|
|00002b00| 6e 64 65 66 20 4e 4f 4e | 41 4d 45 53 0d 0a 09 2f |ndef NON|AMES.../|
|00002b10| 2a 20 46 69 6c 6c 20 69 | 6e 20 6e 65 77 20 55 6e |* Fill i|n new Un|
|00002b20| 69 78 20 53 74 61 6e 64 | 61 72 64 20 66 69 65 6c |ix Stand|ard fiel|
|00002b30| 64 73 20 69 66 20 64 65 | 73 69 72 65 64 2e 20 2a |ds if de|sired. *|
|00002b40| 2f 0d 0a 09 69 66 20 28 | 66 5f 73 74 61 6e 64 61 |/...if (|f_standa|
|00002b50| 72 64 29 20 7b 0d 0a 09 | 09 68 65 61 64 65 72 2d |rd) {...|.header-|
|00002b60| 3e 68 65 61 64 65 72 2e | 6c 69 6e 6b 66 6c 61 67 |>header.|linkflag|
|00002b70| 20 3d 20 4c 46 5f 4e 4f | 52 4d 41 4c 3b 09 2f 2a | = LF_NO|RMAL;./*|
|00002b80| 20 4e 65 77 20 64 65 66 | 61 75 6c 74 20 2a 2f 0d | New def|ault */.|
|00002b90| 0a 09 09 73 74 72 63 70 | 79 28 68 65 61 64 65 72 |...strcp|y(header|
|00002ba0| 2d 3e 68 65 61 64 65 72 | 2e 6d 61 67 69 63 2c 20 |->header|.magic, |
|00002bb0| 54 4d 41 47 49 43 29 3b | 09 2f 2a 20 4d 61 72 6b |TMAGIC);|./* Mark|
|00002bc0| 20 61 73 20 55 6e 69 78 | 20 53 74 64 20 2a 2f 0d | as Unix| Std */.|
|00002bd0| 0a 09 09 66 69 6e 64 75 | 6e 61 6d 65 28 68 65 61 |...findu|name(hea|
|00002be0| 64 65 72 2d 3e 68 65 61 | 64 65 72 2e 75 6e 61 6d |der->hea|der.unam|
|00002bf0| 65 2c 20 73 74 2d 3e 73 | 74 5f 75 69 64 29 3b 0d |e, st->s|t_uid);.|
|00002c00| 0a 09 09 66 69 6e 64 67 | 6e 61 6d 65 28 68 65 61 |...findg|name(hea|
|00002c10| 64 65 72 2d 3e 68 65 61 | 64 65 72 2e 67 6e 61 6d |der->hea|der.gnam|
|00002c20| 65 2c 20 73 74 2d 3e 73 | 74 5f 67 69 64 29 3b 0d |e, st->s|t_gid);.|
|00002c30| 0a 09 7d 0d 0a 23 65 6e | 64 69 66 0d 0a 09 72 65 |..}..#en|dif...re|
|00002c40| 74 75 72 6e 20 68 65 61 | 64 65 72 3b 0d 0a 7d 0d |turn hea|der;..}.|
|00002c50| 0a 0d 0a 2f 2a 20 0d 0a | 20 2a 20 46 69 6e 69 73 |.../* ..| * Finis|
|00002c60| 68 20 6f 66 66 20 61 20 | 66 69 6c 6c 65 64 2d 69 |h off a |filled-i|
|00002c70| 6e 20 68 65 61 64 65 72 | 20 62 6c 6f 63 6b 20 61 |n header| block a|
|00002c80| 6e 64 20 77 72 69 74 65 | 20 69 74 20 6f 75 74 2e |nd write| it out.|
|00002c90| 0d 0a 20 2a 2f 0d 0a 76 | 6f 69 64 0d 0a 66 69 6e |.. */..v|oid..fin|
|00002ca0| 69 73 68 5f 68 65 61 64 | 65 72 28 68 65 61 64 65 |ish_head|er(heade|
|00002cb0| 72 29 0d 0a 09 72 65 67 | 69 73 74 65 72 20 75 6e |r)...reg|ister un|
|00002cc0| 69 6f 6e 20 72 65 63 6f | 72 64 20 2a 68 65 61 64 |ion reco|rd *head|
|00002cd0| 65 72 3b 0d 0a 7b 0d 0a | 09 72 65 67 69 73 74 65 |er;..{..|.registe|
|00002ce0| 72 20 69 6e 74 09 69 2c | 20 73 75 6d 3b 0d 0a 09 |r int.i,| sum;...|
|00002cf0| 72 65 67 69 73 74 65 72 | 20 63 68 61 72 09 2a 70 |register| char.*p|
|00002d00| 3b 0d 0a 0d 0a 09 62 63 | 6f 70 79 28 43 48 4b 42 |;.....bc|opy(CHKB|
|00002d10| 4c 41 4e 4b 53 2c 20 68 | 65 61 64 65 72 2d 3e 68 |LANKS, h|eader->h|
|00002d20| 65 61 64 65 72 2e 63 68 | 6b 73 75 6d 2c 20 73 69 |eader.ch|ksum, si|
|00002d30| 7a 65 6f 66 28 68 65 61 | 64 65 72 2d 3e 68 65 61 |zeof(hea|der->hea|
|00002d40| 64 65 72 2e 63 68 6b 73 | 75 6d 29 29 3b 0d 0a 0d |der.chks|um));...|
|00002d50| 0a 09 73 75 6d 20 3d 20 | 30 3b 0d 0a 09 70 20 3d |..sum = |0;...p =|
|00002d60| 20 68 65 61 64 65 72 2d | 3e 63 68 61 72 70 74 72 | header-|>charptr|
|00002d70| 3b 0d 0a 09 66 6f 72 20 | 28 69 20 3d 20 73 69 7a |;...for |(i = siz|
|00002d80| 65 6f 66 28 2a 68 65 61 | 64 65 72 29 3b 20 2d 2d |eof(*hea|der); --|
|00002d90| 69 20 3e 3d 20 30 3b 20 | 29 20 7b 0d 0a 09 09 2f |i >= 0; |) {..../|
|00002da0| 2a 0d 0a 09 09 20 2a 20 | 57 65 20 63 61 6e 27 74 |*.... * |We can't|
|00002db0| 20 75 73 65 20 75 6e 73 | 69 67 6e 65 64 20 63 68 | use uns|igned ch|
|00002dc0| 61 72 20 68 65 72 65 20 | 62 65 63 61 75 73 65 20 |ar here |because |
|00002dd0| 6f 66 20 6f 6c 64 20 63 | 6f 6d 70 69 6c 65 72 73 |of old c|ompilers|
|00002de0| 2c 0d 0a 09 09 20 2a 20 | 65 2e 67 2e 20 56 37 2e |,.... * |e.g. V7.|
|00002df0| 0d 0a 09 09 20 2a 2f 0d | 0a 09 09 73 75 6d 20 2b |.... */.|...sum +|
|00002e00| 3d 20 30 78 46 46 20 26 | 20 2a 70 2b 2b 3b 0d 0a |= 0xFF &| *p++;..|
|00002e10| 09 7d 0d 0a 0d 0a 09 2f | 2a 0d 0a 09 20 2a 20 46 |.}...../|*... * F|
|00002e20| 69 6c 6c 20 69 6e 20 74 | 68 65 20 63 68 65 63 6b |ill in t|he check|
|00002e30| 73 75 6d 20 66 69 65 6c | 64 2e 20 20 49 74 27 73 |sum fiel|d. It's|
|00002e40| 20 66 6f 72 6d 61 74 74 | 65 64 20 64 69 66 66 65 | formatt|ed diffe|
|00002e50| 72 65 6e 74 6c 79 0d 0a | 09 20 2a 20 66 72 6f 6d |rently..|. * from|
|00002e60| 20 74 68 65 20 6f 74 68 | 65 72 20 66 69 65 6c 64 | the oth|er field|
|00002e70| 73 3a 20 20 69 74 20 68 | 61 73 20 5b 36 5d 20 64 |s: it h|as [6] d|
|00002e80| 69 67 69 74 73 2c 20 61 | 20 6e 75 6c 6c 2c 20 74 |igits, a| null, t|
|00002e90| 68 65 6e 20 61 0d 0a 09 | 20 2a 20 73 70 61 63 65 |hen a...| * space|
|00002ea0| 20 2d 2d 20 72 61 74 68 | 65 72 20 74 68 61 6e 20 | -- rath|er than |
|00002eb0| 64 69 67 69 74 73 2c 20 | 61 20 73 70 61 63 65 2c |digits, |a space,|
|00002ec0| 20 74 68 65 6e 20 61 20 | 6e 75 6c 6c 2e 0d 0a 09 | then a |null....|
|00002ed0| 20 2a 20 57 65 20 75 73 | 65 20 74 6f 5f 6f 63 74 | * We us|e to_oct|
|00002ee0| 20 74 68 65 6e 20 77 72 | 69 74 65 20 74 68 65 20 | then wr|ite the |
|00002ef0| 6e 75 6c 6c 20 69 6e 20 | 6f 76 65 72 20 74 6f 5f |null in |over to_|
|00002f00| 6f 63 74 27 73 20 73 70 | 61 63 65 2e 0d 0a 09 20 |oct's sp|ace.... |
|00002f10| 2a 20 54 68 65 20 66 69 | 6e 61 6c 20 73 70 61 63 |* The fi|nal spac|
|00002f20| 65 20 69 73 20 61 6c 72 | 65 61 64 79 20 74 68 65 |e is alr|eady the|
|00002f30| 72 65 2c 20 66 72 6f 6d | 20 63 68 65 63 6b 73 75 |re, from| checksu|
|00002f40| 6d 6d 69 6e 67 2c 20 61 | 6e 64 0d 0a 09 20 2a 20 |mming, a|nd... * |
|00002f50| 74 6f 5f 6f 63 74 20 64 | 6f 65 73 6e 27 74 20 6d |to_oct d|oesn't m|
|00002f60| 6f 64 69 66 79 20 69 74 | 2e 0d 0a 09 20 2a 0d 0a |odify it|.... *..|
|00002f70| 09 20 2a 20 54 68 69 73 | 20 69 73 20 61 20 66 61 |. * This| is a fa|
|00002f80| 73 74 20 77 61 79 20 74 | 6f 20 64 6f 3a 0d 0a 09 |st way t|o do:...|
|00002f90| 20 2a 20 28 76 6f 69 64 | 29 20 73 70 72 69 6e 74 | * (void|) sprint|
|00002fa0| 66 28 68 65 61 64 65 72 | 2d 3e 68 65 61 64 65 72 |f(header|->header|
|00002fb0| 2e 63 68 6b 73 75 6d 2c | 20 22 25 36 6f 22 2c 20 |.chksum,| "%6o", |
|00002fc0| 73 75 6d 29 3b 0d 0a 09 | 20 2a 2f 0d 0a 09 74 6f |sum);...| */...to|
|00002fd0| 5f 6f 63 74 28 28 6c 6f | 6e 67 29 20 73 75 6d 2c |_oct((lo|ng) sum,|
|00002fe0| 09 38 2c 20 20 68 65 61 | 64 65 72 2d 3e 68 65 61 |.8, hea|der->hea|
|00002ff0| 64 65 72 2e 63 68 6b 73 | 75 6d 29 3b 0d 0a 09 68 |der.chks|um);...h|
|00003000| 65 61 64 65 72 2d 3e 68 | 65 61 64 65 72 2e 63 68 |eader->h|eader.ch|
|00003010| 6b 73 75 6d 5b 36 5d 20 | 3d 20 27 5c 30 27 3b 09 |ksum[6] |= '\0';.|
|00003020| 2f 2a 20 5a 61 70 20 74 | 68 65 20 73 70 61 63 65 |/* Zap t|he space|
|00003030| 20 2a 2f 0d 0a 0d 0a 09 | 75 73 65 72 65 63 28 68 | */.....|userec(h|
|00003040| 65 61 64 65 72 29 3b 0d | 0a 09 72 65 74 75 72 6e |eader);.|..return|
|00003050| 3b 0d 0a 7d 0d 0a 0d 0a | 0d 0a 2f 2a 0d 0a 20 2a |;..}....|../*.. *|
|00003060| 20 51 75 69 63 6b 20 61 | 6e 64 20 64 69 72 74 79 | Quick a|nd dirty|
|00003070| 20 6f 63 74 61 6c 20 63 | 6f 6e 76 65 72 73 69 6f | octal c|onversio|
|00003080| 6e 2e 0d 0a 20 2a 20 43 | 6f 6e 76 65 72 74 73 20 |n... * C|onverts |
|00003090| 6c 6f 6e 67 20 22 76 61 | 6c 75 65 22 20 69 6e 74 |long "va|lue" int|
|000030a0| 6f 20 61 20 22 64 69 67 | 73 22 2d 64 69 67 69 74 |o a "dig|s"-digit|
|000030b0| 20 66 69 65 6c 64 20 61 | 74 20 22 77 68 65 72 65 | field a|t "where|
|000030c0| 22 2c 0d 0a 20 2a 20 69 | 6e 63 6c 75 64 69 6e 67 |",.. * i|ncluding|
|000030d0| 20 61 20 74 72 61 69 6c | 69 6e 67 20 73 70 61 63 | a trail|ing spac|
|000030e0| 65 20 61 6e 64 20 72 6f | 6f 6d 20 66 6f 72 20 61 |e and ro|om for a|
|000030f0| 20 6e 75 6c 6c 2e 20 20 | 22 64 69 67 73 22 3d 3d | null. |"digs"==|
|00003100| 33 20 6d 65 61 6e 73 0d | 0a 20 2a 20 31 20 64 69 |3 means.|. * 1 di|
|00003110| 67 69 74 2c 20 61 20 73 | 70 61 63 65 2c 20 61 6e |git, a s|pace, an|
|00003120| 64 20 72 6f 6f 6d 20 66 | 6f 72 20 61 20 6e 75 6c |d room f|or a nul|
|00003130| 6c 2e 0d 0a 20 2a 0d 0a | 20 2a 20 57 65 20 61 73 |l... *..| * We as|
|00003140| 73 75 6d 65 20 74 68 65 | 20 74 72 61 69 6c 69 6e |sume the| trailin|
|00003150| 67 20 6e 75 6c 6c 20 69 | 73 20 61 6c 72 65 61 64 |g null i|s alread|
|00003160| 79 20 74 68 65 72 65 20 | 61 6e 64 20 64 6f 6e 27 |y there |and don'|
|00003170| 74 20 66 69 6c 6c 20 69 | 74 20 69 6e 2e 0d 0a 20 |t fill i|t in... |
|00003180| 2a 20 54 68 69 73 20 66 | 61 63 74 20 69 73 20 75 |* This f|act is u|
|00003190| 73 65 64 20 62 79 20 73 | 74 61 72 74 5f 68 65 61 |sed by s|tart_hea|
|000031a0| 64 65 72 20 61 6e 64 20 | 66 69 6e 69 73 68 5f 68 |der and |finish_h|
|000031b0| 65 61 64 65 72 2c 20 73 | 6f 20 64 6f 6e 27 74 20 |eader, s|o don't |
|000031c0| 63 68 61 6e 67 65 20 69 | 74 21 0d 0a 20 2a 0d 0a |change i|t!.. *..|
|000031d0| 20 2a 20 54 68 69 73 20 | 73 68 6f 75 6c 64 20 62 | * This |should b|
|000031e0| 65 20 65 71 75 69 76 61 | 6c 65 6e 74 20 74 6f 3a |e equiva|lent to:|
|000031f0| 0d 0a 20 2a 09 28 76 6f | 69 64 29 20 73 70 72 69 |.. *.(vo|id) spri|
|00003200| 6e 74 66 28 77 68 65 72 | 65 2c 20 22 25 2a 6c 6f |ntf(wher|e, "%*lo|
|00003210| 20 22 2c 20 64 69 67 73 | 2d 32 2c 20 76 61 6c 75 | ", digs|-2, valu|
|00003220| 65 29 3b 0d 0a 20 2a 20 | 65 78 63 65 70 74 20 74 |e);.. * |except t|
|00003230| 68 61 74 20 73 70 72 69 | 6e 74 66 20 66 69 6c 6c |hat spri|ntf fill|
|00003240| 73 20 69 6e 20 74 68 65 | 20 74 72 61 69 6c 69 6e |s in the| trailin|
|00003250| 67 20 6e 75 6c 6c 20 61 | 6e 64 20 77 65 20 64 6f |g null a|nd we do|
|00003260| 6e 27 74 2e 0d 0a 20 2a | 2f 0d 0a 76 6f 69 64 0d |n't... *|/..void.|
|00003270| 0a 74 6f 5f 6f 63 74 28 | 76 61 6c 75 65 2c 20 64 |.to_oct(|value, d|
|00003280| 69 67 73 2c 20 77 68 65 | 72 65 29 0d 0a 09 72 65 |igs, whe|re)...re|
|00003290| 67 69 73 74 65 72 20 6c | 6f 6e 67 09 76 61 6c 75 |gister l|ong.valu|
|000032a0| 65 3b 0d 0a 09 72 65 67 | 69 73 74 65 72 20 69 6e |e;...reg|ister in|
|000032b0| 74 09 64 69 67 73 3b 0d | 0a 09 72 65 67 69 73 74 |t.digs;.|..regist|
|000032c0| 65 72 20 63 68 61 72 09 | 2a 77 68 65 72 65 3b 0d |er char.|*where;.|
|000032d0| 0a 7b 0d 0a 09 0d 0a 09 | 2d 2d 64 69 67 73 3b 09 |.{......|--digs;.|
|000032e0| 09 09 09 2f 2a 20 54 72 | 61 69 6c 69 6e 67 20 6e |.../* Tr|ailing n|
|000032f0| 75 6c 6c 20 73 6c 6f 74 | 20 69 73 20 6c 65 66 74 |ull slot| is left|
|00003300| 20 61 6c 6f 6e 65 20 2a | 2f 0d 0a 09 77 68 65 72 | alone *|/...wher|
|00003310| 65 5b 2d 2d 64 69 67 73 | 5d 20 3d 20 27 20 27 3b |e[--digs|] = ' ';|
|00003320| 09 09 2f 2a 20 50 75 74 | 20 69 6e 20 74 68 65 20 |../* Put| in the |
|00003330| 73 70 61 63 65 2c 20 74 | 68 6f 75 67 68 20 2a 2f |space, t|hough */|
|00003340| 0d 0a 0d 0a 09 2f 2a 20 | 50 72 6f 64 75 63 65 20 |...../* |Produce |
|00003350| 74 68 65 20 64 69 67 69 | 74 73 20 2d 2d 20 61 74 |the digi|ts -- at|
|00003360| 20 6c 65 61 73 74 20 6f | 6e 65 20 2a 2f 0d 0a 09 | least o|ne */...|
|00003370| 64 6f 20 7b 0d 0a 09 09 | 77 68 65 72 65 5b 2d 2d |do {....|where[--|
|00003380| 64 69 67 73 5d 20 3d 20 | 27 30 27 20 2b 20 28 76 |digs] = |'0' + (v|
|00003390| 61 6c 75 65 20 26 20 37 | 29 3b 09 2f 2a 20 6f 6e |alue & 7|);./* on|
|000033a0| 65 20 6f 63 74 61 6c 20 | 64 69 67 69 74 20 2a 2f |e octal |digit */|
|000033b0| 0d 0a 09 09 76 61 6c 75 | 65 20 3e 3e 3d 20 33 3b |....valu|e >>= 3;|
|000033c0| 0d 0a 09 7d 20 77 68 69 | 6c 65 20 28 64 69 67 73 |...} whi|le (digs|
|000033d0| 20 3e 20 30 20 26 26 20 | 76 61 6c 75 65 20 21 3d | > 0 && |value !=|
|000033e0| 20 30 29 3b 0d 0a 0d 0a | 09 2f 2a 20 4c 65 61 64 | 0);....|./* Lead|
|000033f0| 69 6e 67 20 73 70 61 63 | 65 73 2c 20 69 66 20 6e |ing spac|es, if n|
|00003400| 65 63 65 73 73 61 72 79 | 20 2a 2f 0d 0a 09 77 68 |ecessary| */...wh|
|00003410| 69 6c 65 20 28 64 69 67 | 73 20 3e 20 30 29 0d 0a |ile (dig|s > 0)..|
|00003420| 09 09 77 68 65 72 65 5b | 2d 2d 64 69 67 73 5d 20 |..where[|--digs] |
|00003430| 3d 20 27 20 27 3b 0d 0a | 0d 0a 7d 0d 0a 0d 0a 0d |= ' ';..|..}.....|
|00003440| 0a 2f 2a 0d 0a 20 2a 20 | 57 72 69 74 65 20 74 68 |./*.. * |Write th|
|00003450| 65 20 45 4f 54 20 62 6c | 6f 63 6b 28 73 29 2e 0d |e EOT bl|ock(s)..|
|00003460| 0a 20 2a 2f 0d 0a 77 72 | 69 74 65 5f 65 6f 74 28 |. */..wr|ite_eot(|
|00003470| 29 0d 0a 7b 0d 0a 09 75 | 6e 69 6f 6e 20 72 65 63 |)..{...u|nion rec|
|00003480| 6f 72 64 20 2a 70 3b 0d | 0a 0d 0a 09 70 20 3d 20 |ord *p;.|....p = |
|00003490| 66 69 6e 64 72 65 63 28 | 29 3b 0d 0a 09 62 7a 65 |findrec(|);...bze|
|000034a0| 72 6f 28 70 2d 3e 63 68 | 61 72 70 74 72 2c 20 52 |ro(p->ch|arptr, R|
|000034b0| 45 43 4f 52 44 53 49 5a | 45 29 3b 0d 0a 09 75 73 |ECORDSIZ|E);...us|
|000034c0| 65 72 65 63 28 70 29 3b | 0d 0a 09 2f 2a 20 46 49 |erec(p);|.../* FI|
|000034d0| 58 4d 45 2c 20 6f 6e 6c | 79 20 6f 6e 65 20 45 4f |XME, onl|y one EO|
|000034e0| 54 20 62 6c 6f 63 6b 20 | 73 68 6f 75 6c 64 20 62 |T block |should b|
|000034f0| 65 20 6e 65 65 64 65 64 | 2e 20 2a 2f 0d 0a 09 70 |e needed|. */...p|
|00003500| 20 3d 20 66 69 6e 64 72 | 65 63 28 29 3b 0d 0a 09 | = findr|ec();...|
|00003510| 62 7a 65 72 6f 28 70 2d | 3e 63 68 61 72 70 74 72 |bzero(p-|>charptr|
|00003520| 2c 20 52 45 43 4f 52 44 | 53 49 5a 45 29 3b 0d 0a |, RECORD|SIZE);..|
|00003530| 09 75 73 65 72 65 63 28 | 70 29 3b 0d 0a 7d 0d 0a |.userec(|p);..}..|
|00003540| 09 09 20 2a 20 61 76 6f | 69 64 20 64 75 6d 70 69 |.. * avo|id dumpi|
|00003550| 6e 67 20 74 68 65 20 64 | 61 74 61 20 61 67 61 69 |ng the d|ata agai|
|00003560| 6e 20 69 66 20 77 65 27 | 76 65 20 64 6f 6e 65 20 |n if we'|ve done |
|00003570| 69 74 20 6f 6e 63 65 20 | 61 6c 72 65 61 64 79 2e |it once |already.|
|00003580| 0d 0a 09 09 20 2a 2f 0d | 0a 23 69 66 64 65 66 09 |.... */.|.#ifdef.|
|00003590| 44 55 4d 50 54 49 4d 45 | 0d 0a 09 09 69 66 28 64 |DUMPTIME|....if(d|
|000035a0| 75 6d 70 74 69 6d 65 20 | 26 26 20 73 74 61 74 62 |umptime |&& statb|
|000035b0| 75 66 2d 3e 73 74 5f 6d | 74 69 6d 65 20 3c 20 64 |uf->st_m|time < d|
|000035c0| 75 6d 70 74 69 6d 65 29 | 0d 0a 09 09 09 62 72 65 |umptime)|.....bre|
|000035d0| 61 6b 3b 0d 0a 23 65 6e | 64 69 66 0d 0a 09 09 69 |ak;..#en|dif....i|
|000035e0| 66 20 28 73 74 61 74 62 | 75 66 2d 3e 73 74 5f 6e |f (statb|uf->st_n|
|000035f0| 6c 69 6e 6b 20 3e 20 31 | 29 20 7b 0d 0a 09 09 09 |link > 1|) {.....|
|00003600| 74 61 72 2f 65 78 74 72 | 61 63 74 2e 63 00 00 00 |tar/extr|act.c...|
|00003610| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00003620| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00003630| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00003640| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00003650| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00003660| 00 00 00 00 31 30 30 36 | 34 34 00 00 30 30 30 34 |....1006|44..0004|
|00003670| 32 33 00 00 30 30 30 30 | 30 30 00 00 30 30 30 30 |23..0000|00..0000|
|00003680| 30 30 32 30 32 33 37 00 | 30 35 31 37 31 33 34 34 |0020237.|05171344|
|00003690| 31 30 34 00 30 31 30 34 | 32 30 00 20 30 00 00 00 |104.0104|20. 0...|
|000036a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000036b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000036c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000036d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000036e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000036f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00003700| 00 33 37 37 37 37 37 37 | 37 37 37 37 00 00 00 00 |.3777777|7777....|
|00003710| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00003720| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00003730| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00003740| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00003750| 00 00 00 00 00 00 00 00 | 00 00 20 31 00 20 30 00 |........|.. 1. 0.|
|00003760| 20 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 | .......|........|
|00003770| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00003780| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00003790| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000037a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000037b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000037c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000037d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000037e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000037f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00003800| 2f 2a 0d 0a 20 2a 20 45 | 78 74 72 61 63 74 20 66 |/*.. * E|xtract f|
|00003810| 69 6c 65 73 20 66 72 6f | 6d 20 61 20 74 61 72 20 |iles fro|m a tar |
|00003820| 61 72 63 68 69 76 65 2e | 0d 0a 20 2a 0d 0a 20 2a |archive.|.. *.. *|
|00003830| 20 57 72 69 74 74 65 6e | 20 31 39 20 4e 6f 76 20 | Written| 19 Nov |
|00003840| 31 39 38 35 20 62 79 20 | 4a 6f 68 6e 20 47 69 6c |1985 by |John Gil|
|00003850| 6d 6f 72 65 2c 20 69 68 | 6e 70 34 21 68 6f 70 74 |more, ih|np4!hopt|
|00003860| 6f 61 64 21 67 6e 75 2e | 0d 0a 20 2a 0d 0a 20 2a |oad!gnu.|.. *.. *|
|00003870| 20 40 28 23 29 20 65 78 | 74 72 61 63 74 2e 63 20 | @(#) ex|tract.c |
|00003880| 31 2e 31 37 20 38 36 2f | 31 30 2f 32 39 20 50 75 |1.17 86/|10/29 Pu|
|00003890| 62 6c 69 63 20 44 6f 6d | 61 69 6e 20 2d 20 67 6e |blic Dom|ain - gn|
|000038a0| 75 0d 0a 20 2a 2f 0d 0a | 0d 0a 23 69 6e 63 6c 75 |u.. */..|..#inclu|
|000038b0| 64 65 20 3c 73 74 64 69 | 6f 2e 68 3e 0d 0a 23 69 |de <stdi|o.h>..#i|
|000038c0| 6e 63 6c 75 64 65 20 3c | 65 72 72 6e 6f 2e 68 3e |nclude <|errno.h>|
|000038d0| 0d 0a 23 69 6e 63 6c 75 | 64 65 20 3c 73 79 73 2f |..#inclu|de <sys/|
|000038e0| 74 79 70 65 73 2e 68 3e | 0d 0a 23 69 6e 63 6c 75 |types.h>|..#inclu|
|000038f0| 64 65 20 3c 73 79 73 2f | 73 74 61 74 2e 68 3e 0d |de <sys/|stat.h>.|
|00003900| 0a 23 69 6e 63 6c 75 64 | 65 20 3c 66 63 6e 74 6c |.#includ|e <fcntl|
|00003910| 2e 68 3e 0d 0a 0d 0a 2f | 2a 20 65 78 74 65 72 6e |.h>..../|* extern|
|00003920| 20 69 6e 74 20 65 72 72 | 6e 6f 3b 09 09 09 2f 2a | int err|no;.../*|
|00003930| 20 46 72 6f 6d 20 6c 69 | 62 63 2e 61 20 2a 2f 0d | From li|bc.a */.|
|00003940| 0a 65 78 74 65 72 6e 20 | 63 68 61 72 20 2a 69 6e |.extern |char *in|
|00003950| 64 65 78 28 29 3b 09 09 | 09 2f 2a 20 46 72 6f 6d |dex();..|./* From|
|00003960| 20 6c 69 62 63 2e 61 20 | 6f 72 20 70 6f 72 74 2e | libc.a |or port.|
|00003970| 63 20 2a 2f 0d 0a 0d 0a | 23 69 66 6e 64 65 66 09 |c */....|#ifndef.|
|00003980| 4f 5f 4e 44 45 4c 41 59 | 0d 0a 23 64 65 66 69 6e |O_NDELAY|..#defin|
|00003990| 65 20 4f 5f 4e 44 45 4c | 41 59 20 30 0d 0a 23 65 |e O_NDEL|AY 0..#e|
|000039a0| 6e 64 69 66 0d 0a 0d 0a | 23 69 6e 63 6c 75 64 65 |ndif....|#include|
|000039b0| 20 3c 74 61 72 2e 68 3e | 0d 0a 0d 0a 65 78 74 65 | <tar.h>|....exte|
|000039c0| 72 6e 20 75 6e 69 6f 6e | 20 72 65 63 6f 72 64 20 |rn union| record |
|000039d0| 2a 68 65 61 64 3b 09 09 | 2f 2a 20 50 6f 69 6e 74 |*head;..|/* Point|
|000039e0| 73 20 74 6f 20 63 75 72 | 72 65 6e 74 20 74 61 70 |s to cur|rent tap|
|000039f0| 65 20 68 65 61 64 65 72 | 20 2a 2f 0d 0a 65 78 74 |e header| */..ext|
|00003a00| 65 72 6e 20 73 74 72 75 | 63 74 20 73 74 61 74 20 |ern stru|ct stat |
|00003a10| 68 73 74 61 74 5b 31 5d | 3b 09 09 2f 2a 20 53 74 |hstat[1]|;../* St|
|00003a20| 61 74 20 73 74 72 75 63 | 74 20 63 6f 72 72 65 73 |at struc|t corres|
|00003a30| 70 6f 6e 64 69 6e 67 20 | 2a 2f 0d 0a 0d 0a 65 78 |ponding |*/....ex|
|00003a40| 74 65 72 6e 20 76 6f 69 | 64 20 70 72 69 6e 74 5f |tern voi|d print_|
|00003a50| 68 65 61 64 65 72 28 29 | 3b 0d 0a 65 78 74 65 72 |header()|;..exter|
|00003a60| 6e 20 76 6f 69 64 20 73 | 6b 69 70 5f 66 69 6c 65 |n void s|kip_file|
|00003a70| 28 29 3b 0d 0a 65 78 74 | 65 72 6e 20 76 6f 69 64 |();..ext|ern void|
|00003a80| 20 70 72 5f 6d 6b 64 69 | 72 28 29 3b 0d 0a 0d 0a | pr_mkdi|r();....|
|00003a90| 69 6e 74 20 6d 61 6b 65 | 5f 64 69 72 73 28 29 3b |int make|_dirs();|
|00003aa0| 09 09 09 2f 2a 20 4d 61 | 6b 65 73 20 72 65 71 75 |.../* Ma|kes requ|
|00003ab0| 69 72 65 64 20 64 69 72 | 65 63 74 6f 72 69 65 73 |ired dir|ectories|
|00003ac0| 20 2a 2f 0d 0a 0d 0a 74 | 69 6d 65 5f 74 20 6e 6f | */....t|ime_t no|
|00003ad0| 77 20 3d 20 30 3b 09 09 | 09 09 2f 2a 20 43 75 72 |w = 0;..|../* Cur|
|00003ae0| 72 65 6e 74 20 74 69 6d | 65 20 2a 2f 0d 0a 0d 0a |rent tim|e */....|
|00003af0| 2f 2a 0d 0a 20 2a 20 45 | 78 74 72 61 63 74 20 61 |/*.. * E|xtract a|
|00003b00| 20 66 69 6c 65 20 66 72 | 6f 6d 20 74 68 65 20 61 | file fr|om the a|
|00003b10| 72 63 68 69 76 65 2e 0d | 0a 20 2a 2f 0d 0a 76 6f |rchive..|. */..vo|
|00003b20| 69 64 0d 0a 65 78 74 72 | 61 63 74 5f 61 72 63 68 |id..extr|act_arch|
|00003b30| 69 76 65 28 29 0d 0a 7b | 0d 0a 09 72 65 67 69 73 |ive()..{|...regis|
|00003b40| 74 65 72 20 63 68 61 72 | 20 2a 64 61 74 61 3b 0d |ter char| *data;.|
|00003b50| 0a 09 69 6e 74 20 66 64 | 2c 20 63 68 65 63 6b 2c |..int fd|, check,|
|00003b60| 20 6e 61 6d 65 6c 65 6e | 2c 20 77 72 69 74 74 65 | namelen|, writte|
|00003b70| 6e 3b 0d 0a 09 6c 6f 6e | 67 20 73 69 7a 65 3b 0d |n;...lon|g size;.|
|00003b80| 0a 09 74 69 6d 65 5f 74 | 20 61 63 63 5f 75 70 64 |..time_t| acc_upd|
|00003b90| 5f 74 69 6d 65 73 5b 32 | 5d 3b 0d 0a 09 69 6e 74 |_times[2|];...int|
|00003ba0| 09 73 74 61 6e 64 61 72 | 64 3b 09 09 2f 2a 20 49 |.standar|d;../* I|
|00003bb0| 73 20 68 65 61 64 65 72 | 20 73 74 61 6e 64 61 72 |s header| standar|
|00003bc0| 64 3f 20 2a 2f 0d 0a 0d | 0a 09 73 61 76 65 72 65 |d? */...|..savere|
|00003bd0| 63 28 26 68 65 61 64 29 | 3b 09 09 09 2f 2a 20 4d |c(&head)|;.../* M|
|00003be0| 61 6b 65 20 73 75 72 65 | 20 69 74 20 73 74 69 63 |ake sure| it stic|
|00003bf0| 6b 73 20 61 72 6f 75 6e | 64 20 2a 2f 0d 0a 09 75 |ks aroun|d */...u|
|00003c00| 73 65 72 65 63 28 68 65 | 61 64 29 3b 09 09 09 2f |serec(he|ad);.../|
|00003c10| 2a 20 41 6e 64 20 67 6f | 20 70 61 73 74 20 69 74 |* And go| past it|
|00003c20| 20 69 6e 20 74 68 65 20 | 61 72 63 68 69 76 65 20 | in the |archive |
|00003c30| 2a 2f 0d 0a 09 64 65 63 | 6f 64 65 5f 68 65 61 64 |*/...dec|ode_head|
|00003c40| 65 72 28 68 65 61 64 2c | 20 68 73 74 61 74 2c 20 |er(head,| hstat, |
|00003c50| 26 73 74 61 6e 64 61 72 | 64 2c 20 31 29 3b 09 2f |&standar|d, 1);./|
|00003c60| 2a 20 53 6e 61 72 66 20 | 66 69 65 6c 64 73 20 2a |* Snarf |fields *|
|00003c70| 2f 0d 0a 0d 0a 09 2f 2a | 20 50 72 69 6e 74 20 74 |/...../*| Print t|
|00003c80| 68 65 20 72 65 63 6f 72 | 64 20 66 72 6f 6d 20 27 |he recor|d from '|
|00003c90| 68 65 61 64 27 20 61 6e | 64 20 27 68 73 74 61 74 |head' an|d 'hstat|
|00003ca0| 27 20 2a 2f 0d 0a 09 69 | 66 20 28 66 5f 76 65 72 |' */...i|f (f_ver|
|00003cb0| 62 6f 73 65 29 0d 0a 09 | 09 70 72 69 6e 74 5f 68 |bose)...|.print_h|
|00003cc0| 65 61 64 65 72 28 29 3b | 0d 0a 0d 0a 09 73 77 69 |eader();|.....swi|
|00003cd0| 74 63 68 20 28 68 65 61 | 64 2d 3e 68 65 61 64 65 |tch (hea|d->heade|
|00003ce0| 72 2e 6c 69 6e 6b 66 6c | 61 67 29 20 7b 0d 0a 0d |r.linkfl|ag) {...|
|00003cf0| 0a 09 64 65 66 61 75 6c | 74 3a 0d 0a 09 09 61 6e |..defaul|t:....an|
|00003d00| 6e 6f 66 69 6c 65 28 73 | 74 64 65 72 72 2c 20 74 |nofile(s|tderr, t|
|00003d10| 61 72 29 3b 0d 0a 09 09 | 66 70 72 69 6e 74 66 28 |ar);....|fprintf(|
|00003d20| 73 74 64 65 72 72 2c 20 | 22 55 6e 6b 6e 6f 77 6e |stderr, |"Unknown|
|00003d30| 20 66 69 6c 65 20 74 79 | 70 65 20 25 64 20 66 6f | file ty|pe %d fo|
|00003d40| 72 20 25 73 5c 6e 22 2c | 0d 0a 09 09 09 68 65 61 |r %s\n",|.....hea|
|00003d50| 64 2d 3e 68 65 61 64 65 | 72 2e 6c 69 6e 6b 66 6c |d->heade|r.linkfl|
|00003d60| 61 67 2c 20 68 65 61 64 | 2d 3e 68 65 61 64 65 72 |ag, head|->header|
|00003d70| 2e 6e 61 6d 65 29 3b 0d | 0a 09 09 2f 2a 20 46 41 |.name);.|.../* FA|
|00003d80| 4c 4c 20 54 48 52 55 20 | 2a 2f 0d 0a 0d 0a 09 63 |LL THRU |*/.....c|
|00003d90| 61 73 65 20 4c 46 5f 4f | 4c 44 4e 4f 52 4d 41 4c |ase LF_O|LDNORMAL|
|00003da0| 3a 0d 0a 09 63 61 73 65 | 20 4c 46 5f 4e 4f 52 4d |:...case| LF_NORM|
|00003db0| 41 4c 3a 0d 0a 09 09 2f | 2a 0d 0a 09 09 20 2a 20 |AL:..../|*.... * |
|00003dc0| 41 70 70 65 61 72 73 20 | 74 6f 20 62 65 20 61 20 |Appears |to be a |
|00003dd0| 66 69 6c 65 2e 0d 0a 09 | 09 20 2a 20 53 65 65 20 |file....|. * See |
|00003de0| 69 66 20 69 74 27 73 20 | 72 65 61 6c 6c 79 20 61 |if it's |really a|
|00003df0| 20 64 69 72 65 63 74 6f | 72 79 2e 0d 0a 09 09 20 | directo|ry..... |
|00003e00| 2a 2f 0d 0a 09 09 6e 61 | 6d 65 6c 65 6e 20 3d 20 |*/....na|melen = |
|00003e10| 73 74 72 6c 65 6e 28 68 | 65 61 64 2d 3e 68 65 61 |strlen(h|ead->hea|
|00003e20| 64 65 72 2e 6e 61 6d 65 | 29 2d 31 3b 0d 0a 09 09 |der.name|)-1;....|
|00003e30| 69 66 20 28 68 65 61 64 | 2d 3e 68 65 61 64 65 72 |if (head|->header|
|00003e40| 2e 6e 61 6d 65 5b 6e 61 | 6d 65 6c 65 6e 5d 20 3d |.name[na|melen] =|
|00003e50| 3d 20 27 2f 27 29 0d 0a | 09 09 09 67 6f 74 6f 20 |= '/')..|...goto |
|00003e60| 72 65 61 6c 6c 79 5f 64 | 69 72 3b 0d 0a 0d 0a 09 |really_d|ir;.....|
|00003e70| 09 2f 2a 20 46 49 58 4d | 45 2c 20 64 65 61 6c 20 |./* FIXM|E, deal |
|00003e80| 77 69 74 68 20 70 72 6f | 74 65 63 74 69 6f 6e 20 |with pro|tection |
|00003e90| 69 73 73 75 65 73 20 2a | 2f 0d 0a 09 09 2f 2a 20 |issues *|/..../* |
|00003ea0| 46 49 58 4d 45 2c 20 66 | 5f 6b 65 65 70 20 64 6f |FIXME, f|_keep do|
|00003eb0| 65 73 6e 27 74 20 77 6f | 72 6b 20 6f 6e 20 56 37 |esn't wo|rk on V7|
|00003ec0| 2c 20 73 74 5f 6d 6f 64 | 65 20 6c 6f 73 65 73 20 |, st_mod|e loses |
|00003ed0| 74 6f 6f 20 2a 2f 0d 0a | 09 61 67 61 69 6e 5f 66 |too */..|.again_f|
|00003ee0| 69 6c 65 3a 0d 0a 09 09 | 66 64 20 3d 20 6f 70 65 |ile:....|fd = ope|
|00003ef0| 6e 28 68 65 61 64 2d 3e | 68 65 61 64 65 72 2e 6e |n(head->|header.n|
|00003f00| 61 6d 65 2c 0d 0a 09 09 | 09 66 5f 6b 65 65 70 3f |ame,....|.f_keep?|
|00003f10| 0d 0a 23 69 66 64 65 66 | 09 4d 53 44 4f 53 0d 0a |..#ifdef|.MSDOS..|
|00003f20| 09 09 09 4f 5f 4e 44 45 | 4c 41 59 7c 4f 5f 57 52 |...O_NDE|LAY|O_WR|
|00003f30| 4f 4e 4c 59 7c 4f 5f 41 | 50 50 45 4e 44 7c 4f 5f |ONLY|O_A|PPEND|O_|
|00003f40| 43 52 45 41 54 7c 4f 5f | 45 58 43 4c 7c 4f 5f 42 |CREAT|O_|EXCL|O_B|
|00003f50| 49 4e 41 52 59 3a 0d 0a | 09 09 09 4f 5f 4e 44 45 |INARY:..|...O_NDE|
|00003f60| 4c 41 59 7c 4f 5f 57 52 | 4f 4e 4c 59 7c 4f 5f 41 |LAY|O_WR|ONLY|O_A|
|00003f70| 50 50 45 4e 44 7c 4f 5f | 43 52 45 41 54 7c 4f 5f |PPEND|O_|CREAT|O_|
|00003f80| 54 52 55 4e 43 7c 4f 5f | 42 49 4e 41 52 59 2c 0d |TRUNC|O_|BINARY,.|
|00003f90| 0a 23 65 6c 73 65 0d 0a | 09 09 09 4f 5f 4e 44 45 |.#else..|...O_NDE|
|00003fa0| 4c 41 59 7c 4f 5f 57 52 | 4f 4e 4c 59 7c 4f 5f 41 |LAY|O_WR|ONLY|O_A|
|00003fb0| 50 50 45 4e 44 7c 4f 5f | 43 52 45 41 54 7c 4f 5f |PPEND|O_|CREAT|O_|
|00003fc0| 45 58 43 4c 3a 0d 0a 09 | 09 09 4f 5f 4e 44 45 4c |EXCL:...|..O_NDEL|
|00003fd0| 41 59 7c 4f 5f 57 52 4f | 4e 4c 59 7c 4f 5f 41 50 |AY|O_WRO|NLY|O_AP|
|00003fe0| 50 45 4e 44 7c 4f 5f 43 | 52 45 41 54 7c 4f 5f 54 |PEND|O_C|REAT|O_T|
|00003ff0| 52 55 4e 43 2c 0d 0a 23 | 65 6e 64 69 66 0d 0a 09 |RUNC,..#|endif...|
|00004000| 09 09 68 73 74 61 74 2d | 3e 73 74 5f 6d 6f 64 65 |..hstat-|>st_mode|
|00004010| 29 3b 0d 0a 09 09 69 66 | 20 28 66 64 20 3c 20 30 |);....if| (fd < 0|
|00004020| 29 20 7b 0d 0a 09 09 09 | 69 66 20 28 6d 61 6b 65 |) {.....|if (make|
|00004030| 5f 64 69 72 73 28 68 65 | 61 64 2d 3e 68 65 61 64 |_dirs(he|ad->head|
|00004040| 65 72 2e 6e 61 6d 65 29 | 29 0d 0a 09 09 09 09 67 |er.name)|)......g|
|00004050| 6f 74 6f 20 61 67 61 69 | 6e 5f 66 69 6c 65 3b 0d |oto agai|n_file;.|
|00004060| 0a 09 09 09 61 6e 6e 6f | 66 69 6c 65 28 73 74 64 |....anno|file(std|
|00004070| 65 72 72 2c 20 74 61 72 | 29 3b 0d 0a 09 09 09 66 |err, tar|);.....f|
|00004080| 70 72 69 6e 74 66 28 73 | 74 64 65 72 72 2c 20 22 |printf(s|tderr, "|
|00004090| 43 6f 75 6c 64 20 6e 6f | 74 20 6d 61 6b 65 20 66 |Could no|t make f|
|000040a0| 69 6c 65 20 22 29 3b 0d | 0a 09 09 09 70 65 72 72 |ile ");.|....perr|
|000040b0| 6f 72 28 68 65 61 64 2d | 3e 68 65 61 64 65 72 2e |or(head-|>header.|
|000040c0| 6e 61 6d 65 29 3b 0d 0a | 09 09 09 73 6b 69 70 5f |name);..|...skip_|
|000040d0| 66 69 6c 65 28 28 6c 6f | 6e 67 29 68 73 74 61 74 |file((lo|ng)hstat|
|000040e0| 2d 3e 73 74 5f 73 69 7a | 65 29 3b 0d 0a 09 09 09 |->st_siz|e);.....|
|000040f0| 67 6f 74 6f 20 71 75 69 | 74 3b 0d 0a 09 09 7d 0d |goto qui|t;....}.|
|00004100| 0a 0d 0a 09 09 66 6f 72 | 20 28 73 69 7a 65 20 3d |.....for| (size =|
|00004110| 20 68 73 74 61 74 2d 3e | 73 74 5f 73 69 7a 65 3b | hstat->|st_size;|
|00004120| 0d 0a 09 09 20 20 20 20 | 20 73 69 7a 65 20 3e 20 |.... | size > |
|00004130| 30 3b 0d 0a 09 09 20 20 | 20 20 20 73 69 7a 65 20 |0;.... | size |
|00004140| 2d 3d 20 77 72 69 74 74 | 65 6e 29 20 7b 0d 0a 09 |-= writt|en) {...|
|00004150| 09 09 2f 2a 0d 0a 09 09 | 09 20 2a 20 4c 6f 63 61 |../*....|. * Loca|
|00004160| 74 65 20 64 61 74 61 2c | 20 64 65 74 65 72 6d 69 |te data,| determi|
|00004170| 6e 65 20 6d 61 78 20 6c | 65 6e 67 74 68 0d 0a 09 |ne max l|ength...|
|00004180| 09 09 20 2a 20 77 72 69 | 74 65 61 62 6c 65 2c 20 |.. * wri|teable, |
|00004190| 77 72 69 74 65 20 69 74 | 2c 20 72 65 63 6f 72 64 |write it|, record|
|000041a0| 20 74 68 61 74 0d 0a 09 | 09 09 20 2a 20 77 65 20 | that...|.. * we |
|000041b0| 68 61 76 65 20 75 73 65 | 64 20 74 68 65 20 64 61 |have use|d the da|
|000041c0| 74 61 2c 20 74 68 65 6e | 20 63 68 65 63 6b 0d 0a |ta, then| check..|
|000041d0| 09 09 09 20 2a 20 69 66 | 20 74 68 65 20 77 72 69 |... * if| the wri|
|000041e0| 74 65 20 77 6f 72 6b 65 | 64 2e 0d 0a 09 09 09 20 |te worke|d...... |
|000041f0| 2a 2f 0d 0a 09 09 09 64 | 61 74 61 20 3d 20 66 69 |*/.....d|ata = fi|
|00004200| 6e 64 72 65 63 28 29 2d | 3e 63 68 61 72 70 74 72 |ndrec()-|>charptr|
|00004210| 3b 0d 0a 09 09 09 77 72 | 69 74 74 65 6e 20 3d 20 |;.....wr|itten = |
|00004220| 65 6e 64 6f 66 72 65 63 | 73 28 29 2d 3e 63 68 61 |endofrec|s()->cha|
|00004230| 72 70 74 72 20 2d 20 64 | 61 74 61 3b 0d 0a 09 09 |rptr - d|ata;....|
|00004240| 09 69 66 20 28 77 72 69 | 74 74 65 6e 20 3e 20 73 |.if (wri|tten > s|
|00004250| 69 7a 65 29 20 77 72 69 | 74 74 65 6e 20 3d 20 73 |ize) wri|tten = s|
|00004260| 69 7a 65 3b 0d 0a 09 09 | 09 65 72 72 6e 6f 20 3d |ize;....|.errno =|
|00004270| 20 30 3b 0d 0a 09 09 09 | 63 68 65 63 6b 20 3d 20 | 0;.....|check = |
|00004280| 77 72 69 74 65 28 66 64 | 2c 20 64 61 74 61 2c 20 |write(fd|, data, |
|00004290| 77 72 69 74 74 65 6e 29 | 3b 0d 0a 09 09 09 2f 2a |written)|;...../*|
|000042a0| 0d 0a 09 09 09 20 2a 20 | 54 68 65 20 66 6f 6c 6c |..... * |The foll|
|000042b0| 6f 77 69 6e 67 20 69 73 | 20 69 6e 20 76 69 6f 6c |owing is| in viol|
|000042c0| 61 74 69 6f 6e 20 6f 66 | 20 73 74 72 69 63 74 0d |ation of| strict.|
|000042d0| 0a 09 09 09 20 2a 20 74 | 79 70 69 6e 67 2c 20 73 |.... * t|yping, s|
|000042e0| 69 6e 63 65 20 74 68 65 | 20 61 72 67 20 74 6f 20 |ince the| arg to |
|000042f0| 75 73 65 72 65 63 0d 0a | 09 09 09 20 2a 20 73 68 |userec..|... * sh|
|00004300| 6f 75 6c 64 20 62 65 20 | 61 20 73 74 72 75 63 74 |ould be |a struct|
|00004310| 20 72 65 63 20 2a 2e 20 | 20 46 49 58 4d 45 2e 0d | rec *. | FIXME..|
|00004320| 0a 09 09 09 20 2a 2f 0d | 0a 09 09 09 75 73 65 72 |.... */.|....user|
|00004330| 65 63 28 64 61 74 61 20 | 2b 20 77 72 69 74 74 65 |ec(data |+ writte|
|00004340| 6e 20 2d 20 31 29 3b 0d | 0a 09 09 09 69 66 20 28 |n - 1);.|....if (|
|00004350| 63 68 65 63 6b 20 3d 3d | 20 77 72 69 74 74 65 6e |check ==| written|
|00004360| 29 20 63 6f 6e 74 69 6e | 75 65 3b 0d 0a 09 09 09 |) contin|ue;.....|
|00004370| 2f 2a 0d 0a 09 09 09 20 | 2a 20 45 72 72 6f 72 20 |/*..... |* Error |
|00004380| 69 6e 20 77 72 69 74 69 | 6e 67 20 74 6f 20 66 69 |in writi|ng to fi|
|00004390| 6c 65 2e 0d 0a 09 09 09 | 20 2a 20 50 72 69 6e 74 |le......| * Print|
|000043a0| 20 69 74 2c 20 73 6b 69 | 70 20 74 6f 20 6e 65 78 | it, ski|p to nex|
|000043b0| 74 20 66 69 6c 65 20 69 | 6e 20 61 72 63 68 69 76 |t file i|n archiv|
|000043c0| 65 2e 0d 0a 09 09 09 20 | 2a 2f 0d 0a 09 09 09 61 |e...... |*/.....a|
|000043d0| 6e 6e 6f 66 69 6c 65 28 | 73 74 64 65 72 72 2c 20 |nnofile(|stderr, |
|000043e0| 74 61 72 29 3b 0d 0a 09 | 09 09 66 70 72 69 6e 74 |tar);...|..fprint|
|000043f0| 66 28 73 74 64 65 72 72 | 2c 0d 0a 09 22 54 72 69 |f(stderr|,..."Tri|
|00004400| 65 64 20 74 6f 20 77 72 | 69 74 65 20 25 64 20 62 |ed to wr|ite %d b|
|00004410| 79 74 65 73 20 74 6f 20 | 66 69 6c 65 2c 20 63 6f |ytes to |file, co|
|00004420| 75 6c 64 20 6f 6e 6c 79 | 20 77 72 69 74 65 20 25 |uld only| write %|
|00004430| 64 3a 5c 6e 22 2c 0d 0a | 09 09 09 09 77 72 69 74 |d:\n",..|....writ|
|00004440| 74 65 6e 2c 20 63 68 65 | 63 6b 29 3b 0d 0a 09 09 |ten, che|ck);....|
|00004450| 09 70 65 72 72 6f 72 28 | 68 65 61 64 2d 3e 68 65 |.perror(|head->he|
|00004460| 61 64 65 72 2e 6e 61 6d | 65 29 3b 0d 0a 09 09 09 |ader.nam|e);.....|
|00004470| 28 76 6f 69 64 29 20 63 | 6c 6f 73 65 28 66 64 29 |(void) c|lose(fd)|
|00004480| 3b 0d 0a 09 09 09 73 6b | 69 70 5f 66 69 6c 65 28 |;.....sk|ip_file(|
|00004490| 28 6c 6f 6e 67 29 28 73 | 69 7a 65 20 2d 20 77 72 |(long)(s|ize - wr|
|000044a0| 69 74 74 65 6e 29 29 3b | 0d 0a 09 09 09 67 6f 74 |itten));|.....got|
|000044b0| 6f 20 71 75 69 74 3b 0d | 0a 09 09 7d 0d 0a 0d 0a |o quit;.|...}....|
|000044c0| 09 09 63 68 65 63 6b 20 | 3d 20 63 6c 6f 73 65 28 |..check |= close(|
|000044d0| 66 64 29 3b 0d 0a 09 09 | 69 66 20 28 63 68 65 63 |fd);....|if (chec|
|000044e0| 6b 20 3c 20 30 29 20 7b | 0d 0a 09 09 09 61 6e 6e |k < 0) {|.....ann|
|000044f0| 6f 66 69 6c 65 28 73 74 | 64 65 72 72 2c 20 74 61 |ofile(st|derr, ta|
|00004500| 72 29 3b 0d 0a 09 09 09 | 66 70 72 69 6e 74 66 28 |r);.....|fprintf(|
|00004510| 73 74 64 65 72 72 2c 20 | 22 45 72 72 6f 72 20 77 |stderr, |"Error w|
|00004520| 68 69 6c 65 20 63 6c 6f | 73 69 6e 67 20 22 29 3b |hile clo|sing ");|
|00004530| 0d 0a 09 09 09 70 65 72 | 72 6f 72 28 68 65 61 64 |.....per|ror(head|
|00004540| 2d 3e 68 65 61 64 65 72 | 2e 6e 61 6d 65 29 3b 0d |->header|.name);.|
|00004550| 0a 09 09 7d 0d 0a 09 09 | 0d 0a 09 09 2f 2a 20 46 |...}....|..../* F|
|00004560| 49 58 4d 45 2c 20 64 65 | 61 6c 20 77 69 74 68 20 |IXME, de|al with |
|00004570| 75 69 64 2f 67 69 64 2f | 6d 74 69 6d 65 73 2f 73 |uid/gid/|mtimes/s|
|00004580| 75 69 64 20 2a 2f 0d 0a | 0d 0a 09 09 2f 2a 0d 0a |uid */..|..../*..|
|00004590| 09 09 20 2a 20 53 65 74 | 20 74 68 65 20 6d 6f 64 |.. * Set| the mod|
|000045a0| 69 66 69 65 64 20 74 69 | 6d 65 20 6f 66 20 74 68 |ified ti|me of th|
|000045b0| 65 20 66 69 6c 65 2e 0d | 0a 09 09 20 2a 20 0d 0a |e file..|... * ..|
|000045c0| 09 09 20 2a 20 4e 6f 74 | 65 20 74 68 61 74 20 77 |.. * Not|e that w|
|000045d0| 65 20 73 65 74 20 74 68 | 65 20 61 63 63 65 73 73 |e set th|e access|
|000045e0| 65 64 20 74 69 6d 65 20 | 74 6f 20 22 6e 6f 77 22 |ed time |to "now"|
|000045f0| 2c 20 77 68 69 63 68 0d | 0a 09 09 20 2a 20 69 73 |, which.|... * is|
|00004600| 20 72 65 61 6c 6c 79 20 | 22 74 68 65 20 74 69 6d | really |"the tim|
|00004610| 65 20 77 65 20 73 74 61 | 72 74 65 64 20 65 78 74 |e we sta|rted ext|
|00004620| 72 61 63 74 69 6e 67 20 | 66 69 6c 65 73 22 2e 0d |racting |files"..|
|00004630| 0a 09 09 20 2a 2f 0d 0a | 09 09 69 66 20 28 21 66 |... */..|..if (!f|
|00004640| 5f 6d 6f 64 69 66 69 65 | 64 29 20 7b 0d 0a 09 09 |_modifie|d) {....|
|00004650| 09 69 66 20 28 21 6e 6f | 77 29 0d 0a 09 09 09 09 |.if (!no|w)......|
|00004660| 6e 6f 77 20 3d 20 74 69 | 6d 65 28 28 74 69 6d 65 |now = ti|me((time|
|00004670| 5f 74 20 2a 29 30 29 3b | 20 2f 2a 20 4a 75 73 74 |_t *)0);| /* Just|
|00004680| 20 64 6f 20 69 74 20 6f | 6e 63 65 20 2a 2f 0d 0a | do it o|nce */..|
|00004690| 09 09 09 61 63 63 5f 75 | 70 64 5f 74 69 6d 65 73 |...acc_u|pd_times|
|000046a0| 5b 30 5d 20 3d 20 6e 6f | 77 3b 09 20 20 20 20 20 |[0] = no|w;. |
|000046b0| 20 20 20 20 2f 2a 20 41 | 63 63 65 73 73 65 64 20 | /* A|ccessed |
|000046c0| 6e 6f 77 20 2a 2f 0d 0a | 09 09 09 61 63 63 5f 75 |now */..|...acc_u|
|000046d0| 70 64 5f 74 69 6d 65 73 | 5b 31 5d 20 3d 20 68 73 |pd_times|[1] = hs|
|000046e0| 74 61 74 2d 3e 73 74 5f | 6d 74 69 6d 65 3b 20 2f |tat->st_|mtime; /|
|000046f0| 2a 20 4d 6f 64 27 64 20 | 2a 2f 0d 0a 09 09 09 69 |* Mod'd |*/.....i|
|00004700| 66 20 28 75 74 69 6d 65 | 28 68 65 61 64 2d 3e 68 |f (utime|(head->h|
|00004710| 65 61 64 65 72 2e 6e 61 | 6d 65 2c 20 61 63 63 5f |eader.na|me, acc_|
|00004720| 75 70 64 5f 74 69 6d 65 | 73 29 20 3c 20 30 29 20 |upd_time|s) < 0) |
|00004730| 7b 0d 0a 09 09 09 09 61 | 6e 6e 6f 66 69 6c 65 28 |{......a|nnofile(|
|00004740| 73 74 64 65 72 72 2c 20 | 74 61 72 29 3b 0d 0a 09 |stderr, |tar);...|
|00004750| 09 09 09 70 65 72 72 6f | 72 28 68 65 61 64 2d 3e |...perro|r(head->|
|00004760| 68 65 61 64 65 72 2e 6e | 61 6d 65 29 3b 0d 0a 09 |header.n|ame);...|
|00004770| 09 09 7d 0d 0a 09 09 7d | 0d 0a 0d 0a 09 09 2f 2a |..}....}|....../*|
|00004780| 0d 0a 09 09 20 2a 20 49 | 66 20 27 2d 70 27 20 69 |.... * I|f '-p' i|
|00004790| 73 20 6e 6f 74 20 73 65 | 74 2c 20 4f 52 20 69 66 |s not se|t, OR if|
|000047a0| 20 74 68 65 20 66 69 6c | 65 20 68 61 73 20 70 72 | the fil|e has pr|
|000047b0| 65 74 74 79 20 6e 6f 72 | 6d 61 6c 0d 0a 09 09 20 |etty nor|mal.... |
|000047c0| 2a 20 6d 6f 64 65 20 62 | 69 74 73 2c 20 77 65 20 |* mode b|its, we |
|000047d0| 63 61 6e 20 73 6b 69 70 | 20 74 68 65 20 63 68 6d |can skip| the chm|
|000047e0| 6f 64 20 61 6e 64 20 73 | 61 76 65 20 61 20 73 79 |od and s|ave a sy|
|000047f0| 73 20 63 61 6c 6c 2e 0d | 0a 09 09 20 2a 20 54 68 |s call..|... * Th|
|00004800| 69 73 20 77 6f 72 6b 73 | 20 62 65 63 61 75 73 65 |is works| because|
|00004810| 20 77 65 20 64 69 64 20 | 75 6d 61 73 6b 28 30 29 | we did |umask(0)|
|00004820| 20 69 66 20 2d 70 20 69 | 73 20 73 65 74 2c 20 73 | if -p i|s set, s|
|00004830| 6f 0d 0a 09 09 20 2a 20 | 74 68 65 20 6f 70 65 6e |o.... * |the open|
|00004840| 28 29 20 74 68 61 74 20 | 63 72 65 61 74 65 64 20 |() that |created |
|00004850| 74 68 65 20 66 69 6c 65 | 20 77 69 6c 6c 20 68 61 |the file| will ha|
|00004860| 76 65 20 73 65 74 20 74 | 68 65 20 6d 6f 64 65 73 |ve set t|he modes|
|00004870| 0d 0a 09 09 20 2a 20 70 | 72 6f 70 65 72 6c 79 2e |.... * p|roperly.|
|00004880| 20 20 0d 0a 09 09 20 2a | 20 46 49 58 4d 45 3a 20 | .... *| FIXME: |
|00004890| 49 20 64 6f 6e 27 74 20 | 6b 6e 6f 77 20 77 68 61 |I don't |know wha|
|000048a0| 74 20 6f 70 65 6e 28 29 | 20 64 6f 65 73 20 77 2f |t open()| does w/|
|000048b0| 55 49 44 2f 47 49 44 2f | 53 56 54 58 20 62 69 74 |UID/GID/|SVTX bit|
|000048c0| 73 2e 0d 0a 09 09 20 2a | 20 48 6f 77 65 76 65 72 |s..... *| However|
|000048d0| 2c 20 69 66 20 77 65 27 | 76 65 20 64 6f 6e 65 20 |, if we'|ve done |
|000048e0| 61 20 63 68 6f 77 6e 28 | 29 2c 20 74 68 65 79 20 |a chown(|), they |
|000048f0| 67 6f 74 20 72 65 73 65 | 74 2e 0d 0a 09 09 20 2a |got rese|t..... *|
|00004900| 2f 0d 0a 23 69 66 64 65 | 66 09 53 5f 49 53 55 49 |/..#ifde|f.S_ISUI|
|00004910| 44 0d 0a 09 09 69 66 20 | 28 66 5f 75 73 65 5f 70 |D....if |(f_use_p|
|00004920| 72 6f 74 65 63 74 69 6f | 6e 0d 0a 09 09 20 20 20 |rotectio|n.... |
|00004930| 20 26 26 20 28 68 73 74 | 61 74 2d 3e 73 74 5f 6d | && (hst|at->st_m|
|00004940| 6f 64 65 20 26 20 28 53 | 5f 49 53 55 49 44 7c 53 |ode & (S|_ISUID|S|
|00004950| 5f 49 53 47 49 44 7c 53 | 5f 49 53 56 54 58 29 29 |_ISGID|S|_ISVTX))|
|00004960| 29 20 7b 0d 0a 09 09 09 | 69 66 20 28 63 68 6d 6f |) {.....|if (chmo|
|00004970| 64 28 68 65 61 64 2d 3e | 68 65 61 64 65 72 2e 6e |d(head->|header.n|
|00004980| 61 6d 65 2c 20 28 69 6e | 74 29 68 73 74 61 74 2d |ame, (in|t)hstat-|
|00004990| 3e 73 74 5f 6d 6f 64 65 | 29 20 3c 20 30 29 20 7b |>st_mode|) < 0) {|
|000049a0| 0d 0a 09 09 09 09 61 6e | 6e 6f 66 69 6c 65 28 73 |......an|nofile(s|
|000049b0| 74 64 65 72 72 2c 20 74 | 61 72 29 3b 0d 0a 09 09 |tderr, t|ar);....|
|000049c0| 09 09 70 65 72 72 6f 72 | 28 68 65 61 64 2d 3e 68 |..perror|(head->h|
|000049d0| 65 61 64 65 72 2e 6e 61 | 6d 65 29 3b 0d 0a 09 09 |eader.na|me);....|
|000049e0| 09 7d 0d 0a 09 09 7d 0d | 0a 23 65 6e 64 69 66 0d |.}....}.|.#endif.|
|000049f0| 0a 0d 0a 09 71 75 69 74 | 3a 0d 0a 09 09 62 72 65 |....quit|:....bre|
|00004a00| 61 6b 3b 0d 0a 0d 0a 09 | 63 61 73 65 20 4c 46 5f |ak;.....|case LF_|
|00004a10| 4c 49 4e 4b 3a 0d 0a 23 | 69 66 64 65 66 09 4d 53 |LINK:..#|ifdef.MS|
|00004a20| 44 4f 53 0d 0a 09 09 66 | 70 72 69 6e 74 66 28 73 |DOS....f|printf(s|
|00004a30| 74 64 65 72 72 2c 20 22 | 4c 69 6e 6b 20 25 73 20 |tderr, "|Link %s |
|00004a40| 74 6f 20 25 73 20 69 67 | 6e 6f 72 65 64 5c 6e 22 |to %s ig|nored\n"|
|00004a50| 2c 0d 0a 09 09 09 68 65 | 61 64 2d 3e 68 65 61 64 |,.....he|ad->head|
|00004a60| 65 72 2e 6c 69 6e 6b 6e | 61 6d 65 2c 20 68 65 61 |er.linkn|ame, hea|
|00004a70| 64 2d 3e 68 65 61 64 65 | 72 2e 6e 61 6d 65 29 3b |d->heade|r.name);|
|00004a80| 0d 0a 23 65 6c 73 65 0d | 0a 09 61 67 61 69 6e 5f |..#else.|..again_|
|00004a90| 6c 69 6e 6b 3a 0d 0a 09 | 09 63 68 65 63 6b 20 3d |link:...|.check =|
|00004aa0| 20 6c 69 6e 6b 20 28 68 | 65 61 64 2d 3e 68 65 61 | link (h|ead->hea|
|00004ab0| 64 65 72 2e 6c 69 6e 6b | 6e 61 6d 65 2c 0d 0a 09 |der.link|name,...|
|00004ac0| 09 09 20 20 20 20 20 20 | 68 65 61 64 2d 3e 68 65 |.. |head->he|
|00004ad0| 61 64 65 72 2e 6e 61 6d | 65 29 3b 0d 0a 09 09 2f |ader.nam|e);..../|
|00004ae0| 2a 20 46 49 58 4d 45 2c | 20 64 6f 6e 27 74 20 77 |* FIXME,| don't w|
|00004af0| 6f 72 72 79 20 75 69 64 | 2c 20 67 69 64 2c 20 65 |orry uid|, gid, e|
|00004b00| 74 63 2e 2e 2e 20 2a 2f | 0d 0a 09 09 69 66 20 28 |tc... */|....if (|
|00004b10| 63 68 65 63 6b 20 3d 3d | 20 30 29 0d 0a 09 09 09 |check ==| 0).....|
|00004b20| 62 72 65 61 6b 3b 0d 0a | 09 09 69 66 20 28 6d 61 |break;..|..if (ma|
|00004b30| 6b 65 5f 64 69 72 73 28 | 68 65 61 64 2d 3e 68 65 |ke_dirs(|head->he|
|00004b40| 61 64 65 72 2e 6c 69 6e | 6b 6e 61 6d 65 29 29 0d |ader.lin|kname)).|
|00004b50| 0a 09 09 09 67 6f 74 6f | 20 61 67 61 69 6e 5f 6c |....goto| again_l|
|00004b60| 69 6e 6b 3b 0d 0a 09 09 | 61 6e 6e 6f 66 69 6c 65 |ink;....|annofile|
|00004b70| 28 73 74 64 65 72 72 2c | 20 74 61 72 29 3b 0d 0a |(stderr,| tar);..|
|00004b80| 09 09 66 70 72 69 6e 74 | 66 28 73 74 64 65 72 72 |..fprint|f(stderr|
|00004b90| 2c 20 22 43 6f 75 6c 64 | 20 6e 6f 74 20 6c 69 6e |, "Could| not lin|
|00004ba0| 6b 20 25 73 20 74 6f 20 | 22 2c 0d 0a 09 09 09 68 |k %s to |",.....h|
|00004bb0| 65 61 64 2d 3e 68 65 61 | 64 65 72 2e 6e 61 6d 65 |ead->hea|der.name|
|00004bc0| 29 3b 0d 0a 09 09 70 65 | 72 72 6f 72 28 68 65 61 |);....pe|rror(hea|
|00004bd0| 64 2d 3e 68 65 61 64 65 | 72 2e 6c 69 6e 6b 6e 61 |d->heade|r.linkna|
|00004be0| 6d 65 29 3b 0d 0a 23 65 | 6e 64 69 66 0d 0a 09 09 |me);..#e|ndif....|
|00004bf0| 62 72 65 61 6b 3b 0d 0a | 0d 0a 23 69 66 64 65 66 |break;..|..#ifdef|
|00004c00| 20 53 5f 49 46 4c 4e 4b | 0d 0a 09 63 61 73 65 20 | S_IFLNK|...case |
|00004c10| 4c 46 5f 53 59 4d 4c 49 | 4e 4b 3a 0d 0a 09 61 67 |LF_SYMLI|NK:...ag|
|00004c20| 61 69 6e 5f 73 79 6d 6c | 69 6e 6b 3a 0d 0a 09 09 |ain_syml|ink:....|
|00004c30| 63 68 65 63 6b 20 3d 20 | 73 79 6d 6c 69 6e 6b 28 |check = |symlink(|
|00004c40| 68 65 61 64 2d 3e 68 65 | 61 64 65 72 2e 6c 69 6e |head->he|ader.lin|
|00004c50| 6b 6e 61 6d 65 2c 0d 0a | 09 09 09 20 20 20 20 20 |kname,..|... |
|00004c60| 20 20 20 68 65 61 64 2d | 3e 68 65 61 64 65 72 2e | head-|>header.|
|00004c70| 6e 61 6d 65 29 3b 0d 0a | 09 09 2f 2a 20 46 49 58 |name);..|../* FIX|
|00004c80| 4d 45 2c 20 64 6f 6e 27 | 74 20 77 6f 72 72 79 20 |ME, don'|t worry |
|00004c90| 75 69 64 2c 20 67 69 64 | 2c 20 65 74 63 2e 2e 2e |uid, gid|, etc...|
|00004ca0| 20 2a 2f 0d 0a 09 09 69 | 66 20 28 63 68 65 63 6b | */....i|f (check|
|00004cb0| 20 3d 3d 20 30 29 0d 0a | 09 09 09 62 72 65 61 6b | == 0)..|...break|
|00004cc0| 3b 0d 0a 09 09 69 66 20 | 28 6d 61 6b 65 5f 64 69 |;....if |(make_di|
|00004cd0| 72 73 28 68 65 61 64 2d | 3e 68 65 61 64 65 72 2e |rs(head-|>header.|
|00004ce0| 6c 69 6e 6b 6e 61 6d 65 | 29 29 0d 0a 09 09 09 67 |linkname|)).....g|
|00004cf0| 6f 74 6f 20 61 67 61 69 | 6e 5f 73 79 6d 6c 69 6e |oto agai|n_symlin|
|00004d00| 6b 3b 0d 0a 09 09 61 6e | 6e 6f 66 69 6c 65 28 73 |k;....an|nofile(s|
|00004d10| 74 64 65 72 72 2c 20 74 | 61 72 29 3b 0d 0a 09 09 |tderr, t|ar);....|
|00004d20| 66 70 72 69 6e 74 66 28 | 73 74 64 65 72 72 2c 20 |fprintf(|stderr, |
|00004d30| 22 43 6f 75 6c 64 20 6e | 6f 74 20 63 72 65 61 74 |"Could n|ot creat|
|00004d40| 65 20 73 79 6d 6c 69 6e | 6b 20 22 29 3b 0d 0a 09 |e symlin|k ");...|
|00004d50| 09 70 65 72 72 6f 72 28 | 68 65 61 64 2d 3e 68 65 |.perror(|head->he|
|00004d60| 61 64 65 72 2e 6c 69 6e | 6b 6e 61 6d 65 29 3b 0d |ader.lin|kname);.|
|00004d70| 0a 09 09 62 72 65 61 6b | 3b 0d 0a 23 65 6e 64 69 |...break|;..#endi|
|00004d80| 66 0d 0a 0d 0a 23 69 66 | 64 65 66 20 53 5f 49 46 |f....#if|def S_IF|
|00004d90| 43 48 52 0d 0a 09 63 61 | 73 65 20 4c 46 5f 43 48 |CHR...ca|se LF_CH|
|00004da0| 52 3a 0d 0a 09 09 68 73 | 74 61 74 2d 3e 73 74 5f |R:....hs|tat->st_|
|00004db0| 6d 6f 64 65 20 7c 3d 20 | 53 5f 49 46 43 48 52 3b |mode |= |S_IFCHR;|
|00004dc0| 0d 0a 09 09 67 6f 74 6f | 20 6d 61 6b 65 5f 6e 6f |....goto| make_no|
|00004dd0| 64 65 3b 0d 0a 23 65 6e | 64 69 66 0d 0a 0d 0a 23 |de;..#en|dif....#|
|00004de0| 69 66 64 65 66 20 53 5f | 49 46 42 4c 4b 0d 0a 09 |ifdef S_|IFBLK...|
|00004df0| 63 61 73 65 20 4c 46 5f | 42 4c 4b 3a 0d 0a 09 09 |case LF_|BLK:....|
|00004e00| 68 73 74 61 74 2d 3e 73 | 74 5f 6d 6f 64 65 20 7c |hstat->s|t_mode ||
|00004e10| 3d 20 53 5f 49 46 42 4c | 4b 3b 0d 0a 23 65 6e 64 |= S_IFBL|K;..#end|
|00004e20| 69 66 0d 0a 09 6d 61 6b | 65 5f 6e 6f 64 65 3a 0d |if...mak|e_node:.|
|00004e30| 0a 23 69 66 64 65 66 09 | 4d 53 44 4f 53 0d 0a 09 |.#ifdef.|MSDOS...|
|00004e40| 09 66 70 72 69 6e 74 66 | 28 73 74 64 65 72 72 2c |.fprintf|(stderr,|
|00004e50| 20 22 4e 6f 64 65 20 25 | 73 20 74 79 70 65 20 25 | "Node %|s type %|
|00004e60| 78 20 69 67 6e 6f 72 65 | 64 5c 6e 22 2c 0d 0a 09 |x ignore|d\n",...|
|00004e70| 09 09 68 65 61 64 2d 3e | 68 65 61 64 65 72 2e 6e |..head->|header.n|
|00004e80| 61 6d 65 2c 20 68 73 74 | 61 74 2d 3e 73 74 5f 6d |ame, hst|at->st_m|
|00004e90| 6f 64 65 29 3b 0d 0a 23 | 65 6c 73 65 0d 0a 09 09 |ode);..#|else....|
|00004ea0| 63 68 65 63 6b 20 3d 20 | 6d 6b 6e 6f 64 28 68 65 |check = |mknod(he|
|00004eb0| 61 64 2d 3e 68 65 61 64 | 65 72 2e 6e 61 6d 65 2c |ad->head|er.name,|
|00004ec0| 20 28 69 6e 74 29 20 68 | 73 74 61 74 2d 3e 73 74 | (int) h|stat->st|
|00004ed0| 5f 6d 6f 64 65 2c 0d 0a | 23 69 66 64 65 66 09 4f |_mode,..|#ifdef.O|
|00004ee0| 53 0d 0a 09 09 09 6d 61 | 6a 6f 72 28 68 73 74 61 |S.....ma|jor(hsta|
|00004ef0| 74 2d 3e 73 74 5f 64 65 | 76 29 2c 20 6d 69 6e 6f |t->st_de|v), mino|
|00004f00| 72 28 68 73 74 61 74 2d | 3e 73 74 5f 64 65 76 29 |r(hstat-|>st_dev)|
|00004f10| 29 3b 0d 0a 23 65 6c 73 | 65 0d 0a 09 09 09 28 69 |);..#els|e.....(i|
|00004f20| 6e 74 29 20 68 73 74 61 | 74 2d 3e 73 74 5f 64 65 |nt) hsta|t->st_de|
|00004f30| 76 29 3b 0d 0a 23 65 6e | 64 69 66 0d 0a 09 09 69 |v);..#en|dif....i|
|00004f40| 66 20 28 63 68 65 63 6b | 20 21 3d 20 30 29 20 7b |f (check| != 0) {|
|00004f50| 0d 0a 09 09 09 69 66 20 | 28 6d 61 6b 65 5f 64 69 |.....if |(make_di|
|00004f60| 72 73 28 68 65 61 64 2d | 3e 68 65 61 64 65 72 2e |rs(head-|>header.|
|00004f70| 6e 61 6d 65 29 29 0d 0a | 09 09 09 09 67 6f 74 6f |name))..|....goto|
|00004f80| 20 6d 61 6b 65 5f 6e 6f | 64 65 3b 0d 0a 09 09 09 | make_no|de;.....|
|00004f90| 61 6e 6e 6f 66 69 6c 65 | 28 73 74 64 65 72 72 2c |annofile|(stderr,|
|00004fa0| 20 74 61 72 29 3b 0d 0a | 09 09 09 66 70 72 69 6e | tar);..|...fprin|
|00004fb0| 74 66 28 73 74 64 65 72 | 72 2c 20 22 43 6f 75 6c |tf(stder|r, "Coul|
|00004fc0| 64 20 6e 6f 74 20 6d 61 | 6b 65 20 73 70 65 63 69 |d not ma|ke speci|
|00004fd0| 61 6c 20 66 69 6c 65 20 | 22 29 3b 0d 0a 09 09 09 |al file |");.....|
|00004fe0| 70 65 72 72 6f 72 28 68 | 65 61 64 2d 3e 68 65 61 |perror(h|ead->hea|
|00004ff0| 64 65 72 2e 6e 61 6d 65 | 29 3b 0d 0a 09 09 09 62 |der.name|);.....b|
|00005000| 72 65 61 6b 3b 0d 0a 09 | 09 7d 3b 0d 0a 23 65 6e |reak;...|.};..#en|
|00005010| 64 69 66 0d 0a 09 09 62 | 72 65 61 6b 3b 0d 0a 0d |dif....b|reak;...|
|00005020| 0a 09 63 61 73 65 20 4c | 46 5f 44 49 52 3a 0d 0a |..case L|F_DIR:..|
|00005030| 09 09 2f 2a 20 43 68 65 | 63 6b 20 66 6f 72 20 74 |../* Che|ck for t|
|00005040| 72 61 69 6c 69 6e 67 20 | 2f 20 2a 2f 0d 0a 09 09 |railing |/ */....|
|00005050| 6e 61 6d 65 6c 65 6e 20 | 3d 20 73 74 72 6c 65 6e |namelen |= strlen|
|00005060| 28 68 65 61 64 2d 3e 68 | 65 61 64 65 72 2e 6e 61 |(head->h|eader.na|
|00005070| 6d 65 29 2d 31 3b 0d 0a | 09 72 65 61 6c 6c 79 5f |me)-1;..|.really_|
|00005080| 64 69 72 3a 0d 0a 09 09 | 77 68 69 6c 65 20 28 6e |dir:....|while (n|
|00005090| 61 6d 65 6c 65 6e 20 26 | 26 20 68 65 61 64 2d 3e |amelen &|& head->|
|000050a0| 68 65 61 64 65 72 2e 6e | 61 6d 65 5b 6e 61 6d 65 |header.n|ame[name|
|000050b0| 6c 65 6e 5d 20 3d 3d 20 | 27 2f 27 29 0d 0a 09 09 |len] == |'/')....|
|000050c0| 09 68 65 61 64 2d 3e 68 | 65 61 64 65 72 2e 6e 61 |.head->h|eader.na|
|000050d0| 6d 65 5b 6e 61 6d 65 6c | 65 6e 2d 2d 5d 20 3d 20 |me[namel|en--] = |
|000050e0| 27 5c 30 27 3b 09 2f 2a | 20 5a 61 70 20 2f 20 2a |'\0';./*| Zap / *|
|000050f0| 2f 0d 0a 09 09 0d 0a 09 | 09 2f 2a 20 46 49 58 4d |/.......|./* FIXM|
|00005100| 45 2c 20 64 65 61 6c 20 | 77 69 74 68 20 75 6d 61 |E, deal |with uma|
|00005110| 73 6b 20 2a 2f 0d 0a 09 | 61 67 61 69 6e 5f 64 69 |sk */...|again_di|
|00005120| 72 3a 0d 0a 09 09 63 68 | 65 63 6b 20 3d 20 6d 6b |r:....ch|eck = mk|
|00005130| 64 69 72 28 68 65 61 64 | 2d 3e 68 65 61 64 65 72 |dir(head|->header|
|00005140| 2e 6e 61 6d 65 2c 20 28 | 69 6e 74 29 68 73 74 61 |.name, (|int)hsta|
|00005150| 74 2d 3e 73 74 5f 6d 6f | 64 65 29 3b 0d 0a 09 09 |t->st_mo|de);....|
|00005160| 69 66 20 28 63 68 65 63 | 6b 20 21 3d 20 30 29 20 |if (chec|k != 0) |
|00005170| 7b 0d 0a 09 09 09 69 66 | 20 28 6d 61 6b 65 5f 64 |{.....if| (make_d|
|00005180| 69 72 73 28 68 65 61 64 | 2d 3e 68 65 61 64 65 72 |irs(head|->header|
|00005190| 2e 6e 61 6d 65 29 29 0d | 0a 09 09 09 09 67 6f 74 |.name)).|.....got|
|000051a0| 6f 20 61 67 61 69 6e 5f | 64 69 72 3b 0d 0a 09 09 |o again_|dir;....|
|000051b0| 09 61 6e 6e 6f 66 69 6c | 65 28 73 74 64 65 72 72 |.annofil|e(stderr|
|000051c0| 2c 20 74 61 72 29 3b 0d | 0a 09 09 09 66 70 72 69 |, tar);.|....fpri|
|000051d0| 6e 74 66 28 73 74 64 65 | 72 72 2c 20 22 43 6f 75 |ntf(stde|rr, "Cou|
|000051e0| 6c 64 20 6e 6f 74 20 6d | 61 6b 65 20 64 69 72 65 |ld not m|ake dire|
|000051f0| 63 74 6f 72 79 20 22 29 | 3b 0d 0a 09 09 09 70 65 |ctory ")|;.....pe|
|00005200| 72 72 6f 72 28 68 65 61 | 64 2d 3e 68 65 61 64 65 |rror(hea|d->heade|
|00005210| 72 2e 6e 61 6d 65 29 3b | 0d 0a 09 09 09 62 72 65 |r.name);|.....bre|
|00005220| 61 6b 3b 0d 0a 09 09 7d | 0d 0a 09 09 0d 0a 09 09 |ak;....}|........|
|00005230| 2f 2a 20 46 49 58 4d 45 | 2c 20 64 65 61 6c 20 77 |/* FIXME|, deal w|
|00005240| 69 74 68 20 75 69 64 2f | 67 69 64 20 2a 2f 0d 0a |ith uid/|gid */..|
|00005250| 09 09 2f 2a 20 46 49 58 | 4d 45 2c 20 52 65 6d 65 |../* FIX|ME, Reme|
|00005260| 6d 62 65 72 20 74 69 6d | 65 73 74 61 6d 70 73 20 |mber tim|estamps |
|00005270| 66 6f 72 20 61 66 74 65 | 72 20 66 69 6c 65 73 20 |for afte|r files |
|00005280| 63 72 65 61 74 65 64 3f | 20 2a 2f 0d 0a 09 09 62 |created?| */....b|
|00005290| 72 65 61 6b 3b 0d 0a 0d | 0a 09 63 61 73 65 20 4c |reak;...|..case L|
|000052a0| 46 5f 46 49 46 4f 3a 0d | 0a 09 09 61 62 6f 72 74 |F_FIFO:.|...abort|
|000052b0| 28 29 3b 09 2f 2a 20 46 | 49 58 4d 45 20 2a 2f 0d |();./* F|IXME */.|
|000052c0| 0a 09 09 62 72 65 61 6b | 3b 0d 0a 0d 0a 09 7d 0d |...break|;.....}.|
|000052d0| 0a 0d 0a 09 2f 2a 20 57 | 65 20 64 6f 6e 27 74 20 |..../* W|e don't |
|000052e0| 6e 65 65 64 20 74 6f 20 | 73 61 76 65 20 69 74 20 |need to |save it |
|000052f0| 61 6e 79 20 6c 6f 6e 67 | 65 72 2e 20 2a 2f 0d 0a |any long|er. */..|
|00005300| 09 73 61 76 65 72 65 63 | 28 28 75 6e 69 6f 6e 20 |.saverec|((union |
|00005310| 72 65 63 6f 72 64 20 2a | 2a 29 20 30 29 3b 09 2f |record *|*) 0);./|
|00005320| 2a 20 55 6e 73 61 76 65 | 20 69 74 20 2a 2f 0d 0a |* Unsave| it */..|
|00005330| 7d 0d 0a 0d 0a 2f 2a 0d | 0a 20 2a 20 41 66 74 65 |}..../*.|. * Afte|
|00005340| 72 20 61 20 66 69 6c 65 | 2f 6c 69 6e 6b 2f 73 79 |r a file|/link/sy|
|00005350| 6d 6c 69 6e 6b 2f 64 69 | 72 20 63 72 65 61 74 69 |mlink/di|r creati|
|00005360| 6f 6e 20 68 61 73 20 66 | 61 69 6c 65 64 2c 20 73 |on has f|ailed, s|
|00005370| 65 65 20 69 66 0d 0a 20 | 2a 20 69 74 27 73 20 62 |ee if.. |* it's b|
|00005380| 65 63 61 75 73 65 20 73 | 6f 6d 65 20 72 65 71 75 |ecause s|ome requ|
|00005390| 69 72 65 64 20 64 69 72 | 65 63 74 6f 72 79 20 77 |ired dir|ectory w|
|000053a0| 61 73 20 6e 6f 74 20 70 | 72 65 73 65 6e 74 2c 20 |as not p|resent, |
|000053b0| 61 6e 64 20 69 66 0d 0a | 20 2a 20 73 6f 2c 20 63 |and if..| * so, c|
|000053c0| 72 65 61 74 65 20 61 6c | 6c 20 72 65 71 75 69 72 |reate al|l requir|
|000053d0| 65 64 20 64 69 72 73 2e | 0d 0a 20 2a 2f 0d 0a 69 |ed dirs.|.. */..i|
|000053e0| 6e 74 0d 0a 6d 61 6b 65 | 5f 64 69 72 73 28 70 61 |nt..make|_dirs(pa|
|000053f0| 74 68 6e 61 6d 65 29 0d | 0a 09 63 68 61 72 20 2a |thname).|..char *|
|00005400| 70 61 74 68 6e 61 6d 65 | 3b 0d 0a 7b 0d 0a 09 63 |pathname|;..{...c|
|00005410| 68 61 72 20 2a 70 3b 09 | 09 09 2f 2a 20 50 6f 69 |har *p;.|../* Poi|
|00005420| 6e 74 73 20 69 6e 74 6f | 20 70 61 74 68 20 2a 2f |nts into| path */|
|00005430| 0d 0a 09 69 6e 74 20 6d | 61 64 65 6f 6e 65 20 3d |...int m|adeone =|
|00005440| 20 30 3b 09 09 2f 2a 20 | 44 69 64 20 77 65 20 64 | 0;../* |Did we d|
|00005450| 6f 20 61 6e 79 74 68 69 | 6e 67 20 79 65 74 3f 20 |o anythi|ng yet? |
|00005460| 2a 2f 0d 0a 09 69 6e 74 | 20 73 61 76 65 5f 65 72 |*/...int| save_er|
|00005470| 72 6e 6f 20 3d 20 65 72 | 72 6e 6f 3b 09 09 2f 2a |rno = er|rno;../*|
|00005480| 20 52 65 6d 65 6d 62 65 | 72 20 63 61 6c 6c 65 72 | Remembe|r caller|
|00005490| 27 73 20 65 72 72 6e 6f | 20 2a 2f 0d 0a 09 69 6e |'s errno| */...in|
|000054a0| 74 20 63 68 65 63 6b 3b | 0d 0a 0d 0a 09 69 66 20 |t check;|.....if |
|000054b0| 28 65 72 72 6e 6f 20 21 | 3d 20 45 4e 4f 45 4e 54 |(errno !|= ENOENT|
|000054c0| 29 0d 0a 09 09 72 65 74 | 75 72 6e 20 30 3b 09 09 |)....ret|urn 0;..|
|000054d0| 2f 2a 20 4e 6f 74 20 6f | 75 72 20 70 72 6f 62 6c |/* Not o|ur probl|
|000054e0| 65 6d 20 2a 2f 0d 0a 0d | 0a 09 66 6f 72 20 28 70 |em */...|..for (p|
|000054f0| 20 3d 20 69 6e 64 65 78 | 28 70 61 74 68 6e 61 6d | = index|(pathnam|
|00005500| 65 2c 20 27 2f 27 29 3b | 20 70 20 21 3d 20 4e 55 |e, '/');| p != NU|
|00005510| 4c 4c 3b 20 70 20 3d 20 | 69 6e 64 65 78 28 70 2b |LL; p = |index(p+|
|00005520| 31 2c 20 27 2f 27 29 29 | 20 7b 0d 0a 09 09 2f 2a |1, '/'))| {..../*|
|00005530| 20 41 76 6f 69 64 20 6d | 6b 64 69 72 20 6f 66 20 | Avoid m|kdir of |
|00005540| 65 6d 70 74 79 20 73 74 | 72 69 6e 67 2c 20 69 66 |empty st|ring, if|
|00005550| 20 6c 65 61 64 69 6e 67 | 20 6f 72 20 64 6f 75 62 | leading| or doub|
|00005560| 6c 65 20 27 2f 27 20 2a | 2f 0d 0a 09 09 69 66 20 |le '/' *|/....if |
|00005570| 28 70 20 3d 3d 20 70 61 | 74 68 6e 61 6d 65 20 7c |(p == pa|thname ||
|00005580| 7c 20 70 5b 2d 31 5d 20 | 3d 3d 20 27 2f 27 29 0d || p[-1] |== '/').|
|00005590| 0a 09 09 09 63 6f 6e 74 | 69 6e 75 65 3b 0d 0a 09 |....cont|inue;...|
|000055a0| 09 2f 2a 20 41 76 6f 69 | 64 20 6d 6b 64 69 72 20 |./* Avoi|d mkdir |
|000055b0| 77 68 65 72 65 20 6c 61 | 73 74 20 70 61 72 74 20 |where la|st part |
|000055c0| 6f 66 20 70 61 74 68 20 | 69 73 20 27 2e 27 20 2a |of path |is '.' *|
|000055d0| 2f 0d 0a 09 09 69 66 20 | 28 70 5b 2d 31 5d 20 3d |/....if |(p[-1] =|
|000055e0| 3d 20 27 2e 27 20 26 26 | 20 28 70 20 3d 3d 20 70 |= '.' &&| (p == p|
|000055f0| 61 74 68 6e 61 6d 65 2b | 31 20 7c 7c 20 70 5b 2d |athname+|1 || p[-|
|00005600| 32 5d 20 3d 3d 20 27 2f | 27 29 29 0d 0a 09 09 09 |2] == '/|')).....|
|00005610| 63 6f 6e 74 69 6e 75 65 | 3b 0d 0a 09 09 2a 70 20 |continue|;....*p |
|00005620| 3d 20 30 3b 09 09 09 09 | 2f 2a 20 54 72 75 6e 63 |= 0;....|/* Trunc|
|00005630| 61 74 65 20 74 68 65 20 | 70 61 74 68 20 74 68 65 |ate the |path the|
|00005640| 72 65 20 2a 2f 0d 0a 09 | 09 63 68 65 63 6b 20 3d |re */...|.check =|
|00005650| 20 6d 6b 64 69 72 20 28 | 70 61 74 68 6e 61 6d 65 | mkdir (|pathname|
|00005660| 2c 20 30 37 37 37 29 3b | 09 2f 2a 20 54 72 79 20 |, 0777);|./* Try |
|00005670| 74 6f 20 63 72 65 61 74 | 65 20 69 74 20 61 73 20 |to creat|e it as |
|00005680| 61 20 64 69 72 20 2a 2f | 0d 0a 09 09 2a 70 20 3d |a dir */|....*p =|
|00005690| 20 27 2f 27 3b 0d 0a 09 | 09 69 66 20 28 63 68 65 | '/';...|.if (che|
|000056a0| 63 6b 20 3d 3d 20 30 29 | 20 7b 0d 0a 09 09 09 2f |ck == 0)| {...../|
|000056b0| 2a 20 46 49 58 4d 45 20 | 63 68 6f 77 6e 2c 20 63 |* FIXME |chown, c|
|000056c0| 68 67 72 70 20 69 74 20 | 73 61 6d 65 20 61 73 20 |hgrp it |same as |
|000056d0| 66 69 6c 65 20 62 65 69 | 6e 67 20 63 72 65 61 74 |file bei|ng creat|
|000056e0| 65 64 20 2a 2f 0d 0a 09 | 09 09 2f 2a 20 46 49 58 |ed */...|../* FIX|
|000056f0| 4d 45 2c 20 73 68 6f 77 | 20 6d 6f 64 65 20 61 73 |ME, show| mode as|
|00005700| 20 6d 6f 64 69 66 69 65 | 64 20 62 79 20 63 75 72 | modifie|d by cur|
|00005710| 72 65 6e 74 20 75 6d 61 | 73 6b 20 2a 2f 0d 0a 09 |rent uma|sk */...|
|00005720| 09 09 70 72 5f 6d 6b 64 | 69 72 28 70 61 74 68 6e |..pr_mkd|ir(pathn|
|00005730| 61 6d 65 2c 20 70 2d 70 | 61 74 68 6e 61 6d 65 2c |ame, p-p|athname,|
|00005740| 20 30 37 37 37 29 3b 0d | 0a 09 09 09 6d 61 64 65 | 0777);.|....made|
|00005750| 6f 6e 65 2b 2b 3b 09 09 | 2f 2a 20 52 65 6d 65 6d |one++;..|/* Remem|
|00005760| 62 65 72 20 69 66 20 77 | 65 20 6d 61 64 65 20 6f |ber if w|e made o|
|00005770| 6e 65 20 2a 2f 0d 0a 09 | 09 09 63 6f 6e 74 69 6e |ne */...|..contin|
|00005780| 75 65 3b 0d 0a 09 09 7d | 0d 0a 09 09 69 66 20 28 |ue;....}|....if (|
|00005790| 65 72 72 6e 6f 20 3d 3d | 20 45 45 58 49 53 54 29 |errno ==| EEXIST)|
|000057a0| 09 09 2f 2a 20 44 69 72 | 65 63 74 6f 72 79 20 61 |../* Dir|ectory a|
|000057b0| 6c 72 65 61 64 79 20 65 | 78 69 73 74 73 20 2a 2f |lready e|xists */|
|000057c0| 0d 0a 09 09 09 63 6f 6e | 74 69 6e 75 65 3b 0d 0a |.....con|tinue;..|
|000057d0| 09 09 2f 2a 0d 0a 09 09 | 20 2a 20 53 6f 6d 65 20 |../*....| * Some |
|000057e0| 6f 74 68 65 72 20 65 72 | 72 6f 72 20 69 6e 20 74 |other er|ror in t|
|000057f0| 68 65 20 6d 6b 64 69 72 | 2e 20 20 57 65 20 72 65 |he mkdir|. We re|
|00005800| 74 75 72 6e 20 74 6f 20 | 74 68 65 20 63 61 6c 6c |turn to |the call|
|00005810| 65 72 2e 0d 0a 09 09 20 | 2a 2f 0d 0a 09 09 62 72 |er..... |*/....br|
|00005820| 65 61 6b 3b 0d 0a 09 7d | 0d 0a 0d 0a 09 65 72 72 |eak;...}|.....err|
|00005830| 6e 6f 20 3d 20 73 61 76 | 65 5f 65 72 72 6e 6f 3b |no = sav|e_errno;|
|00005840| 09 09 2f 2a 20 52 65 73 | 74 6f 72 65 20 63 61 6c |../* Res|tore cal|
|00005850| 6c 65 72 27 73 20 65 72 | 72 6e 6f 20 2a 2f 0d 0a |ler's er|rno */..|
|00005860| 09 72 65 74 75 72 6e 20 | 6d 61 64 65 6f 6e 65 3b |.return |madeone;|
|00005870| 09 09 09 2f 2a 20 54 65 | 6c 6c 20 74 68 65 6d 20 |.../* Te|ll them |
|00005880| 74 6f 20 72 65 74 72 79 | 20 69 66 20 77 65 20 6d |to retry| if we m|
|00005890| 61 64 65 20 6f 6e 65 20 | 2a 2f 0d 0a 7d 0d 0a 74 |ade one |*/..}..t|
|000058a0| 6f 20 61 20 22 64 69 67 | 73 22 2d 64 69 67 69 74 |o a "dig|s"-digit|
|000058b0| 20 66 69 65 6c 64 20 61 | 74 20 22 77 68 65 72 65 | field a|t "where|
|000058c0| 22 2c 0d 0a 20 2a 20 69 | 6e 63 6c 75 64 69 6e 67 |",.. * i|ncluding|
|000058d0| 20 61 20 74 72 61 69 6c | 69 6e 67 20 73 70 61 63 | a trail|ing spac|
|000058e0| 65 20 61 6e 64 20 72 6f | 6f 6d 20 66 6f 72 20 61 |e and ro|om for a|
|000058f0| 20 6e 75 6c 6c 2e 20 20 | 22 64 69 67 73 22 3d 3d | null. |"digs"==|
|00005900| 33 20 6d 65 61 6e 73 0d | 0a 20 2a 20 31 20 64 69 |3 means.|. * 1 di|
|00005910| 67 69 74 2c 20 61 20 73 | 70 61 63 65 2c 20 61 6e |git, a s|pace, an|
|00005920| 64 20 72 6f 6f 6d 20 66 | 6f 72 20 61 20 6e 75 6c |d room f|or a nul|
|00005930| 6c 2e 0d 0a 20 2a 0d 0a | 20 2a 20 57 65 20 61 73 |l... *..| * We as|
|00005940| 73 75 6d 65 20 74 68 65 | 20 74 72 61 69 6c 69 6e |sume the| trailin|
|00005950| 67 20 6e 75 6c 6c 20 69 | 73 20 61 6c 72 65 61 64 |g null i|s alread|
|00005960| 79 20 74 68 65 72 65 20 | 61 6e 64 20 64 6f 6e 27 |y there |and don'|
|00005970| 74 20 66 69 6c 6c 20 69 | 74 20 69 6e 2e 0d 0a 20 |t fill i|t in... |
|00005980| 2a 20 54 68 69 73 20 66 | 61 63 74 20 69 73 20 75 |* This f|act is u|
|00005990| 73 65 64 20 62 79 20 73 | 74 61 72 74 5f 68 65 61 |sed by s|tart_hea|
|000059a0| 64 65 72 20 61 6e 64 20 | 66 69 6e 69 73 68 5f 68 |der and |finish_h|
|000059b0| 65 61 64 65 72 2c 20 73 | 6f 20 64 6f 6e 27 74 20 |eader, s|o don't |
|000059c0| 63 68 61 6e 67 65 20 69 | 74 21 0d 0a 20 2a 0d 0a |change i|t!.. *..|
|000059d0| 20 2a 20 54 68 69 73 20 | 73 68 6f 75 6c 64 20 62 | * This |should b|
|000059e0| 65 20 65 71 75 69 76 61 | 6c 65 6e 74 20 74 6f 3a |e equiva|lent to:|
|000059f0| 0d 0a 20 2a 09 28 76 6f | 69 64 29 20 73 70 72 69 |.. *.(vo|id) spri|
|00005a00| 74 61 72 2f 67 65 74 6f | 6c 64 6f 70 2e 63 00 00 |tar/geto|ldop.c..|
|00005a10| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005a20| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005a30| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005a40| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005a50| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005a60| 00 00 00 00 31 30 30 36 | 34 34 00 00 30 30 30 34 |....1006|44..0004|
|00005a70| 32 33 00 00 30 30 30 30 | 30 30 00 00 30 30 30 30 |23..0000|00..0000|
|00005a80| 30 30 30 32 36 34 33 00 | 30 34 34 35 30 37 34 37 |0002643.|04450747|
|00005a90| 30 37 36 00 30 31 30 36 | 30 32 00 20 30 00 00 00 |076.0106|02. 0...|
|00005aa0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005ab0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005ac0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005ad0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005ae0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005af0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005b00| 00 33 37 37 37 37 37 37 | 37 37 37 37 00 00 00 00 |.3777777|7777....|
|00005b10| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005b20| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005b30| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005b40| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005b50| 00 00 00 00 00 00 00 00 | 00 00 20 31 00 20 30 00 |........|.. 1. 0.|
|00005b60| 20 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 | .......|........|
|00005b70| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005b80| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005b90| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005ba0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005bb0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005bc0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005bd0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005be0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005bf0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005c00| 2f 2a 0d 0a 20 2a 20 50 | 6c 75 67 2d 63 6f 6d 70 |/*.. * P|lug-comp|
|00005c10| 61 74 69 62 6c 65 20 72 | 65 70 6c 61 63 65 6d 65 |atible r|eplaceme|
|00005c20| 6e 74 20 66 6f 72 20 67 | 65 74 6f 70 74 28 29 20 |nt for g|etopt() |
|00005c30| 66 6f 72 20 70 61 72 73 | 69 6e 67 20 74 61 72 2d |for pars|ing tar-|
|00005c40| 6c 69 6b 65 0d 0a 20 2a | 20 61 72 67 75 6d 65 6e |like.. *| argumen|
|00005c50| 74 73 2e 20 20 49 66 20 | 74 68 65 20 66 69 72 73 |ts. If |the firs|
|00005c60| 74 20 61 72 67 75 6d 65 | 6e 74 20 62 65 67 69 6e |t argume|nt begin|
|00005c70| 73 20 77 69 74 68 20 22 | 2d 22 2c 20 69 74 20 75 |s with "|-", it u|
|00005c80| 73 65 73 20 67 65 74 6f | 70 74 3b 0d 0a 20 2a 20 |ses geto|pt;.. * |
|00005c90| 6f 74 68 65 72 77 69 73 | 65 2c 20 69 74 20 75 73 |otherwis|e, it us|
|00005ca0| 65 73 20 74 68 65 20 6f | 6c 64 20 72 75 6c 65 73 |es the o|ld rules|
|00005cb0| 20 75 73 65 64 20 62 79 | 20 74 61 72 2c 20 64 75 | used by| tar, du|
|00005cc0| 6d 70 2c 20 61 6e 64 20 | 70 73 2e 0d 0a 20 2a 0d |mp, and |ps... *.|
|00005cd0| 0a 20 2a 20 57 72 69 74 | 74 65 6e 20 32 35 20 41 |. * Writ|ten 25 A|
|00005ce0| 75 67 75 73 74 20 31 39 | 38 35 20 62 79 20 4a 6f |ugust 19|85 by Jo|
|00005cf0| 68 6e 20 47 69 6c 6d 6f | 72 65 20 28 69 68 6e 70 |hn Gilmo|re (ihnp|
|00005d00| 34 21 68 6f 70 74 6f 61 | 64 21 67 6e 75 29 20 61 |4!hoptoa|d!gnu) a|
|00005d10| 6e 64 20 70 6c 61 63 65 | 64 0d 0a 20 2a 20 69 6e |nd place|d.. * in|
|00005d20| 20 74 68 65 20 50 75 62 | 69 63 20 44 6f 6d 61 69 | the Pub|ic Domai|
|00005d30| 6e 20 66 6f 72 20 79 6f | 75 72 20 65 64 69 66 69 |n for yo|ur edifi|
|00005d40| 63 61 74 69 6f 6e 20 61 | 6e 64 20 65 6e 6a 6f 79 |cation a|nd enjoy|
|00005d50| 6d 65 6e 74 2e 0d 0a 20 | 2a 0d 0a 20 2a 20 40 28 |ment... |*.. * @(|
|00005d60| 23 29 67 65 74 6f 6c 64 | 6f 70 74 2e 63 20 31 2e |#)getold|opt.c 1.|
|00005d70| 34 20 32 2f 34 2f 38 36 | 20 50 75 62 6c 69 63 20 |4 2/4/86| Public |
|00005d80| 44 6f 6d 61 69 6e 20 2d | 20 67 6e 75 0d 0a 20 2a |Domain -| gnu.. *|
|00005d90| 2f 0d 0a 0d 0a 23 69 6e | 63 6c 75 64 65 20 3c 73 |/....#in|clude <s|
|00005da0| 74 64 69 6f 2e 68 3e 0d | 0a 0d 0a 0d 0a 69 6e 74 |tdio.h>.|.....int|
|00005db0| 0d 0a 67 65 74 6f 6c 64 | 6f 70 74 28 61 72 67 63 |..getold|opt(argc|
|00005dc0| 2c 20 61 72 67 76 2c 20 | 6f 70 74 73 74 72 69 6e |, argv, |optstrin|
|00005dd0| 67 29 0d 0a 09 69 6e 74 | 09 61 72 67 63 3b 0d 0a |g)...int|.argc;..|
|00005de0| 09 63 68 61 72 09 2a 2a | 61 72 67 76 3b 0d 0a 09 |.char.**|argv;...|
|00005df0| 63 68 61 72 09 2a 6f 70 | 74 73 74 72 69 6e 67 3b |char.*op|tstring;|
|00005e00| 0d 0a 7b 0d 0a 09 65 78 | 74 65 72 6e 20 63 68 61 |..{...ex|tern cha|
|00005e10| 72 09 2a 6f 70 74 61 72 | 67 3b 09 2f 2a 20 50 6f |r.*optar|g;./* Po|
|00005e20| 69 6e 74 73 20 74 6f 20 | 6e 65 78 74 20 61 72 67 |ints to |next arg|
|00005e30| 20 2a 2f 0d 0a 09 65 78 | 74 65 72 6e 20 69 6e 74 | */...ex|tern int|
|00005e40| 09 6f 70 74 69 6e 64 3b | 09 09 2f 2a 20 47 6c 6f |.optind;|../* Glo|
|00005e50| 62 61 6c 20 61 72 67 76 | 20 69 6e 64 65 78 20 2a |bal argv| index *|
|00005e60| 2f 0d 0a 09 73 74 61 74 | 69 63 20 63 68 61 72 09 |/...stat|ic char.|
|00005e70| 2a 6b 65 79 3b 09 09 2f | 2a 20 50 6f 69 6e 74 73 |*key;../|* Points|
|00005e80| 20 74 6f 20 6e 65 78 74 | 20 6b 65 79 6c 65 74 74 | to next| keylett|
|00005e90| 65 72 20 2a 2f 0d 0a 09 | 73 74 61 74 69 63 20 63 |er */...|static c|
|00005ea0| 68 61 72 09 75 73 65 5f | 67 65 74 6f 70 74 3b 09 |har.use_|getopt;.|
|00005eb0| 2f 2a 20 21 3d 30 20 69 | 66 20 61 72 67 76 5b 31 |/* !=0 i|f argv[1|
|00005ec0| 5d 5b 30 5d 20 77 61 73 | 20 27 2d 27 20 2a 2f 0d |][0] was| '-' */.|
|00005ed0| 0a 09 65 78 74 65 72 6e | 20 63 68 61 72 09 2a 69 |..extern| char.*i|
|00005ee0| 6e 64 65 78 28 29 3b 0d | 0a 09 63 68 61 72 09 09 |ndex();.|..char..|
|00005ef0| 63 3b 0d 0a 09 63 68 61 | 72 09 09 2a 70 6c 61 63 |c;...cha|r..*plac|
|00005f00| 65 3b 0d 0a 0d 0a 09 6f | 70 74 61 72 67 20 3d 20 |e;.....o|ptarg = |
|00005f10| 4e 55 4c 4c 3b 0d 0a 09 | 0d 0a 09 69 66 20 28 6b |NULL;...|...if (k|
|00005f20| 65 79 20 3d 3d 20 4e 55 | 4c 4c 29 20 7b 09 09 2f |ey == NU|LL) {../|
|00005f30| 2a 20 46 69 72 73 74 20 | 74 69 6d 65 20 2a 2f 0d |* First |time */.|
|00005f40| 0a 09 09 69 66 20 28 61 | 72 67 63 20 3c 20 32 29 |...if (a|rgc < 2)|
|00005f50| 20 72 65 74 75 72 6e 20 | 45 4f 46 3b 0d 0a 09 09 | return |EOF;....|
|00005f60| 6b 65 79 20 3d 20 61 72 | 67 76 5b 31 5d 3b 0d 0a |key = ar|gv[1];..|
|00005f70| 09 09 69 66 20 28 2a 6b | 65 79 20 3d 3d 20 27 2d |..if (*k|ey == '-|
|00005f80| 27 29 0d 0a 09 09 09 75 | 73 65 5f 67 65 74 6f 70 |').....u|se_getop|
|00005f90| 74 2b 2b 3b 0d 0a 09 09 | 65 6c 73 65 0d 0a 09 09 |t++;....|else....|
|00005fa0| 09 6f 70 74 69 6e 64 20 | 3d 20 32 3b 0d 0a 09 7d |.optind |= 2;...}|
|00005fb0| 0d 0a 0d 0a 09 69 66 20 | 28 75 73 65 5f 67 65 74 |.....if |(use_get|
|00005fc0| 6f 70 74 29 0d 0a 09 09 | 72 65 74 75 72 6e 20 67 |opt)....|return g|
|00005fd0| 65 74 6f 70 74 28 61 72 | 67 63 2c 20 61 72 67 76 |etopt(ar|gc, argv|
|00005fe0| 2c 20 6f 70 74 73 74 72 | 69 6e 67 29 3b 0d 0a 0d |, optstr|ing);...|
|00005ff0| 0a 09 63 20 3d 20 2a 6b | 65 79 2b 2b 3b 0d 0a 09 |..c = *k|ey++;...|
|00006000| 69 66 20 28 63 20 3d 3d | 20 27 5c 30 27 29 20 7b |if (c ==| '\0') {|
|00006010| 0d 0a 09 09 6b 65 79 2d | 2d 3b 0d 0a 09 09 72 65 |....key-|-;....re|
|00006020| 74 75 72 6e 20 45 4f 46 | 3b 0d 0a 09 7d 0d 0a 09 |turn EOF|;...}...|
|00006030| 70 6c 61 63 65 20 3d 20 | 69 6e 64 65 78 28 6f 70 |place = |index(op|
|00006040| 74 73 74 72 69 6e 67 2c | 20 63 29 3b 0d 0a 0d 0a |tstring,| c);....|
|00006050| 09 69 66 20 28 70 6c 61 | 63 65 20 3d 3d 20 4e 55 |.if (pla|ce == NU|
|00006060| 4c 4c 20 7c 7c 20 63 20 | 3d 3d 20 27 3a 27 29 20 |LL || c |== ':') |
|00006070| 7b 0d 0a 09 09 66 70 72 | 69 6e 74 66 28 73 74 64 |{....fpr|intf(std|
|00006080| 65 72 72 2c 20 22 25 73 | 3a 20 75 6e 6b 6e 6f 77 |err, "%s|: unknow|
|00006090| 6e 20 6f 70 74 69 6f 6e | 20 25 63 5c 6e 22 2c 20 |n option| %c\n", |
|000060a0| 61 72 67 76 5b 30 5d 2c | 20 63 29 3b 0d 0a 09 09 |argv[0],| c);....|
|000060b0| 72 65 74 75 72 6e 28 27 | 3f 27 29 3b 0d 0a 09 7d |return('|?');...}|
|000060c0| 0d 0a 0d 0a 09 70 6c 61 | 63 65 2b 2b 3b 0d 0a 09 |.....pla|ce++;...|
|000060d0| 69 66 20 28 2a 70 6c 61 | 63 65 20 3d 3d 20 27 3a |if (*pla|ce == ':|
|000060e0| 27 29 20 7b 0d 0a 09 09 | 69 66 20 28 6f 70 74 69 |') {....|if (opti|
|000060f0| 6e 64 20 3c 20 61 72 67 | 63 29 20 7b 0d 0a 09 09 |nd < arg|c) {....|
|00006100| 09 6f 70 74 61 72 67 20 | 3d 20 61 72 67 76 5b 6f |.optarg |= argv[o|
|00006110| 70 74 69 6e 64 5d 3b 0d | 0a 09 09 09 6f 70 74 69 |ptind];.|....opti|
|00006120| 6e 64 2b 2b 3b 0d 0a 09 | 09 7d 20 65 6c 73 65 20 |nd++;...|.} else |
|00006130| 7b 0d 0a 09 09 09 66 70 | 72 69 6e 74 66 28 73 74 |{.....fp|rintf(st|
|00006140| 64 65 72 72 2c 20 22 25 | 73 3a 20 25 63 20 61 72 |derr, "%|s: %c ar|
|00006150| 67 75 6d 65 6e 74 20 6d | 69 73 73 69 6e 67 5c 6e |gument m|issing\n|
|00006160| 22 2c 0d 0a 09 09 09 09 | 61 72 67 76 5b 30 5d 2c |",......|argv[0],|
|00006170| 20 63 29 3b 0d 0a 09 09 | 09 72 65 74 75 72 6e 28 | c);....|.return(|
|00006180| 27 3f 27 29 3b 0d 0a 09 | 09 7d 0d 0a 09 7d 0d 0a |'?');...|.}...}..|
|00006190| 0d 0a 09 72 65 74 75 72 | 6e 28 63 29 3b 0d 0a 7d |...retur|n(c);..}|
|000061a0| 0d 0a 1a 66 0d 0a 0d 0a | 23 69 6e 63 6c 75 64 65 |...f....|#include|
|000061b0| 20 3c 74 61 72 2e 68 3e | 0d 0a 0d 0a 65 78 74 65 | <tar.h>|....exte|
|000061c0| 72 6e 20 75 6e 69 6f 6e | 20 72 65 63 6f 72 64 20 |rn union| record |
|000061d0| 2a 68 65 61 64 3b 09 09 | 2f 2a 20 50 6f 69 6e 74 |*head;..|/* Point|
|000061e0| 73 20 74 6f 20 63 75 72 | 72 65 6e 74 20 74 61 70 |s to cur|rent tap|
|000061f0| 65 20 68 65 61 64 65 72 | 20 2a 2f 0d 0a 65 78 74 |e header| */..ext|
|00006200| 74 61 72 2f 6c 69 73 74 | 2e 63 00 00 00 00 00 00 |tar/list|.c......|
|00006210| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00006220| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00006230| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00006240| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00006250| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00006260| 00 00 00 00 31 30 30 36 | 34 34 00 00 30 30 30 34 |....1006|44..0004|
|00006270| 32 33 00 00 30 30 30 30 | 30 30 00 00 30 30 30 30 |23..0000|00..0000|
|00006280| 30 30 32 34 30 34 34 00 | 30 35 31 37 31 33 34 34 |0024044.|05171344|
|00006290| 30 34 30 00 30 30 37 37 | 32 30 00 20 30 00 00 00 |040.0077|20. 0...|
|000062a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000062b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000062c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000062d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000062e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000062f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00006300| 00 33 37 37 37 37 37 37 | 37 37 37 37 00 00 00 00 |.3777777|7777....|
|00006310| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00006320| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00006330| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00006340| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00006350| 00 00 00 00 00 00 00 00 | 00 00 20 31 00 20 30 00 |........|.. 1. 0.|
|00006360| 20 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 | .......|........|
|00006370| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00006380| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00006390| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000063a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000063b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000063c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000063d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000063e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000063f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
+--------+-------------------------+-------------------------+--------+--------+
Only 25.0 KB of data is shown above.