I'm doing a tar
like in C, and I've got a problem.
I just want to archive and unarchive files and diretories, so I operate this command: tar -cvf NAME.tar FILE1 [FILE2...]
Now I'm trying to get the header POSIX
of this archive :
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 */
};
int main()
{
struct posix_header header;
int fd;
if ((fd = open("./obj.tar", O_RDONLY)) < 2) //open tarball
return (1);
read(fd, &header, 500); //fill struct
printf("%s\n", header.name);
close(fd);
}
but the output is always as ./PaxHeaders.NUMBER/FILE_NAME
.
When I try to open the archive in an editor, it shows a PaxHeader before each file.
What is PaxHeaders
? Is there a header added to be fully compatible with Pax? If there is, is it possible to remove them?
I'm a bit lost, do I have to parse them or jump after these headers?