ã¢ã¼ã«ã¤ãã½ããã§tar.gzãã¡ã¤ã«ã解åããã¨@LongLinkã¨ããååã®ãã¡ã¤ã«ã解åããã¦ãä¸æ¸ããã¾ãããã¨ç¹°ãè¿ãè¨ããã¦ããããã¨ãããã
@LongLinkã¨ããã®ã¯GNU tarã«ããtarãã¡ã¤ã«ã®ç¬èªæ¡å¼µãããããããä¸é¨ã®è§£åã½ããã§ã¯è§£éã§ããªãã¦ãããªãã¡ã¤ã«ãçæããã¦ãã¾ãã
tarã®ãã¡ã¤ã«å½¢å¼ã¯ãããã¨ãã¼ã¿ã«åããããã¡ã¤ã«ãã¨ã«ãããããã¼ã¿ã®ç¹°ãè¿ãã®ãã¼ã¿æ§é ã«ãªã£ã¦ããã
/* POSIX header. */ struct posix_header { /* byte offset */ char name[100]; /* 0 */ char mode[8]; /* 100 */ char uid[8]; /* 108 */ char gid[8]; /* 116 */ char size[12]; /* 124 */ char mtime[12]; /* 136 */ char chksum[8]; /* 148 */ char typeflag; /* 156 */ char linkname[100]; /* 157 */ char magic[6]; /* 257 */ char version[2]; /* 263 */ char uname[32]; /* 265 */ char gname[32]; /* 297 */ char devmajor[8]; /* 329 */ char devminor[8]; /* 337 */ char prefix[155]; /* 345 */ /* 500 */ };
nameã®é¨åããã¡ã¤ã«ã®ãã«ãã¹ãªã®ã§æ大100æåã«ãããªããªãã(æ¬å½ã¯prefixã使ã£ã¦255æåã¾ã§å¯è½ããããã ããprefixã¯ãã¾ã使ããã¦ããªããããã)
ãã¨ãã¨100æåã¾ã§ãããªãã£ãã®ã§GNU tarã¯typeflag(ãã¡ã¤ã«ã¨ããã£ã¬ã¯ããªã¨ããã¡ã¤ã«ã®ç¨®é¡)ãç¬èªã«æ¡å¼µãã¦L(LONGLINK)ã¨K(LONGNAME)ã追å ãã¦ãã
/* Identifies the *next* file on the tape as having a long linkname. */ #define GNUTYPE_LONGLINK 'K' /* Identifies the *next* file on the tape as having a long name. */ #define GNUTYPE_LONGNAME 'L'
ãã®typeflagãåºã¦ããã¨ç¾å¨ã®ã¨ã³ããªã®ãã¼ã¿é¨ããã®ãã¡ã¤ã«ã®ãã«ãã¹ã«ãªãã次ã®ã¨ã³ããªã®ãã¼ã¿é¨ããã®ãã¡ã¤ã«ã®ä¸èº«ã«ãªãã
ãã£ã¦ãGNUå½¢å¼ã®tarãã¡ã¤ã«ããã³ãããã¨ä»¥ä¸ã®ããã«ãªã
$ cat > aaa.....aaa.txt Hello, world $ tar cvf gnu.tar aaa.....aaa.txt aaa.....aaa.txt $ od -c gnu.tar # ã¨ã³ããª1(ããã) 0000000 . / . / @ L o n g L i n k \0 \0 \0 0000020 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 * ... # ã¨ã³ããª1(ãã¼ã¿) 0001000 a a a a a a a a a a a a a a a a * 0001140 . t x t \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 0001160 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 * ... # ã¨ã³ããª2(ããã) 0002000 a a a a a a a a a a a a a a a a * 0002140 . t x t 0 0 0 0 6 4 4 \0 0 0 0 1 .... # ã¨ã³ããª2(ãã¼ã¿) 0003000 H e l l o , W o r l d \n \0 \0 \0 0003020 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 * 0024000
ã§ãPOSIXã§ã¯ã©ããªã£ã¦ãããã¨ããã¨ãpaxæ¡å¼µããããå©ç¨ãã¦ãããtypeflagãxã ã¨ç¾å¨ã®ã¨ã³ããªã®ãã¼ã¿é¨ã¯æ¡å¼µãããã«ãªãããã¡ã¤ã«ã®ä¸èº«ã¯æ¬¡ã®ã¨ã³ããªã®ãã¼ã¿é¨ã«æ¸ãè¾¼ã¾ããã
æ¡å¼µãããã®å½¢å¼ã¯ä»¥ä¸ã®ããã«ãªã£ã¦ãã
"%d %s=%s\n",
, ,
keywordã¯POSIXã§å®ç¾©ããã¦ãããã®ã¨ç¬èªã«è¨å®ã§ãããã®ããããPOSIXã®ãã®ã®ãã¡pathã¯ãã«ãã¹ã表ãã¦ãã
ããããããã§ãPOSIXå½¢å¼ã®tarãã¡ã¤ã«ããã³ãããã¨ä»¥ä¸ã®ããã«ãªããPOSIXå½¢å¼ã®tarãã¡ã¤ã«ãä½æãããå ´åã¯--format=posixãã¤ããã°è¯ãã
$ cat > aaa.....aaa.txt Hello, world $ tar cvf posix.tar --format=posix aaa.....aaa.txt aaa.....aaa.txt $ od -c posix.tar # ã¨ã³ããª1(ããã) 0000000 P a x H e a d e r / a a a a a a 0000020 a a a a a a a a a a a a a a a a * 0000140 a a \0 \0 0 0 0 6 4 4 \0 0 0 0 7 ... # ã¨ã³ããª1(ãã¼ã¿=paxæ¡å¼µããã) 0001000 1 1 1 p a t h = a a a a a a a 0001020 a a a a a a a a a a a a a a a a * 0001140 a a a a a a a a a a . t x t \n 2 0001160 0 c t i m e = 1 2 8 0 2 2 6 0 .... # ã¨ã³ã㪠2(ããã) 0002000 a a a a a a a a a a a a a a a a * 0002140 a . t \0 0 0 0 6 4 4 \0 0 0 0 7 .... # ã¨ã³ã㪠2(ãã¼ã¿) * 0003000 H e l l o , W o r l d \n \0 \0 \0 0003020 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 * 0006000