What exactly is the GNU tar ././@LongLink “trick”?

跟風遠走 提交于 2019-12-03 02:10:35

Just by observation of a single archive here's what I surmised about the 'L' entry type in tar archives, and the "././@LongLink" name:

The 'L' entry is present in a header for a series of 1 or more 512-byte blocks that hold just the filename for a file or directory with a name over 100 chars. For example, if the filename is 1200 chars long, then the size in the header block will be 1200, and there will be 3 additional blocks with filename data; the last block is partially filled.

Following that series is another header block, in the traditional form - a header with type '0' (regular file) or '5' (directory), followed by the appropriate number of data blocks with the entry data. In the header for this series, the name will be truncated to the first 100 characters of the actual name.

EDIT
See my implementation here: http://cheesoexamples.codeplex.com/SourceControl/changeset/view/99885#1868643

Note that the information about all of that can be found in the libtar project:

http://www.feep.net/libtar/

The proposed header is libtar.h (opposed to the POSIX tar.h) which clearly includes a long filename, and long symbolic link.

Get the "fake" headers + data for the long filenames/links then the "real" header (except for the actual filename and symbolic link) after that.

HEADER type 'L'
BLOCKS of data with the real long filename
HEADER type 'K'
BLOCKS of data with the real symbolic link
HEADER type '0' (or '5' for directory, etc.)
BLOCKS of data with the actual file contents

Of course, under MS-Windows, you probably won't handle symbolic links, although with Win7 it is said that symbolic links under MS-Windows are working (finally.)

Pertinent definition from libtar.h:

/* GNU extensions for typeflag */
#define GNU_LONGNAME_TYPE   'L'
#define GNU_LONGLINK_TYPE   'K'
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!