relative pathname question!

Steve Hayman sahayman at watmath.waterloo.edu
Fri Aug 19 12:16:28 AEST 1988


Sorry to leap into this discussion so late.  Anyway, in 
article <591 at sbsvax.UUCP> greim at sbsvax.UUCP suggests
using a little filter program to remove leading /'s from
tar pathnames: (i.e.  filter <the-tape | tar xf -)

	
	main()
	{
		char fixbuf[512];
	
		while (read(0, fixbuf, sizeof (fixbuf)) == sizeof (fixbuf)) {
			if (fixbuf[0] == '/' && fixbuf[99] == 0) {
				strcpy(fixbuf, &fixbuf[1]);
				fixbuf[99] = '/';
			}
			write(1, fixbuf, sizeof (fixbuf));
		}


Good idea, but isn't that kind of dangerous?  What happens when you have
a data file that happens to have a '/' and a '\0' in those
positions?    You don't want those moved around, you only
want to diddle tar header blocks.

A program to do this safely really needs to know a little more
about tar-format - fiddle the header blocks only, not the
data blocks.   I think I have a version that will do that,
I'll send it off to comp.sources.misc.

..Steve Hayman



More information about the Comp.unix.wizards mailing list