LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   [TAR] file format (https://www.linuxquestions.org/questions/programming-9/%5Btar%5D-file-format-786478/)

fguihot 02-02-2010 11:56 AM

[TAR] file format
 
Hi everybody.

I'm trying to build my own untar program, and I am unable to gather the file size from the tar.
I'm working on linux 2.6.11, with gcc.
According to http://en.wikipedia.org/wiki/Tar_(file_format), the file size should be ascii encoded, and at offset d124 from the header.
But when I tar a file of 34 bytes, I read a file size of 42 bytes, which is incorrect.

Here is the hexa code (read with ghex2)
0x30 0x30 0x30 0x30 0x30 0x30 0x30 0x30 0x30 0x34 0x32 0x00
which stand for (Ascii) 00000000042\0
And I have check with ls -l the size of my untared file, which is 34 bytes.


Does anybody has an idea ?
Thanks !

mjones490 02-02-2010 12:04 PM

On the wikipedia page you mentioned, in the File Header section, the fourth paragraph begins:

Quote:

Numeric values are encoded in octal numbers using ASCII digits, with leading zeroes.
Decimal 34 = octal 42. :)

fguihot 02-03-2010 02:01 AM

Umpf!!!


I should have read the entire text..:o
Thanks a lot...


All times are GMT -5. The time now is 04:55 AM.