Hi I needed cpio to extract files and support GNU tar's way of holding long file names so I wrote it. The new code is only used if a tar archive includes a file named "././@LongLink". All code has been tested and found to work on Gentoo Linux. The only issues that I know of is that it leaves an un-freed block of memory holding the name of the last long file name and it doesn't have an option to turn the feature off though the comments point out where it could be placed. Enjoy.
~Mad Scientist
Note: The .diff was generated with WinMerge if there are any issues with it send an email and I'll upload another version of your choosing.
[cpio_tar.c.diff]
265a266,270
>
> // @LongLink addition
> static char *long_name = NULL;
> int use_long_name = false;
> long long_link_size = 0;
267a273,291
>
> // \todo and an option to use @LongLink
> if ( strcmp(tar_hdr->name, "././@LongLink") == 0 /* && @LongLink option == true */)
> {
> // get length of data
> long_link_size = FROM_OCTAL (tar_hdr->size);
> // free the old memory and grab some fresh stuff
> if (long_name != NULL) free (long_name);
> long_name = (char *) xmalloc (long_link_size);
> // read the file name from the data section of the archive
> tape_buffered_read ((char*)long_name, in_des, long_link_size);
> // since we now have the file name read out the remaining bytes to get an even 512 ( i used tar_rec to hold the data as I am not sure if i can send the output to /dev/null, and it gets overwriten int he next step anyway)
> tape_buffered_read((char*) &tar_rec, in_des, 512 - long_link_size % 512);
> // tell the if function down below to use the long name instead of the normal name given by the header
> use_long_name = true;
> // load header to real file
> tape_buffered_read((char*) &tar_rec, in_des, TARRECORDSIZE);
> }
>
318a343,344
> else if ( use_long_name == true )
> file_hdr->c_name = &long_name;
_______________________________________________
Bug-cpio mailing list
Bug-cpio@...
http://lists.gnu.org/mailman/listinfo/bug-cpio