There are some variations in how the ustar format is supported. Please refer to these two sites:Wikipedia: http://en.wikipedia.org/wiki/Tar_(file_format)
Mkssoftware: http://www.mkssoftware.com/docs/man4/tar.4.asp
The best test of your code is to use the version of tar on the system to list the contents of your archive and to extract the contents of your archive. If both these operations work, your program is likely to be correct.