Path: utzoo!utgpu!attcan!uunet!mcvax!unido!sbsvax!greim From: greim@sbsvax.UUCP (Michael Greim) Newsgroups: comp.unix.wizards Subject: Re: relative pathname question! Summary: there is a way. Source included Message-ID: <591@sbsvax.UUCP> Date: 10 Aug 88 09:59:38 GMT References: <1670003@hpcilzb.HP.COM> <5762@super.upenn.edu> <5103@rpp386.UUCP> Organization: Universitaet des Saarlandes, Saarbruecken, West Germany Lines: 74 In <5762@super.upenn.edu> Joel Spolsky writes: >In article <1670003@hpcilzb.HP.COM> tedj@hpcilzb.HP.COM (Ted Johnson) writes: >> >>I read the manual (really!), but I still can't figure out how >>to copy everything from a directory onto a tape (with either >>tar or cpio) USING RELATIVE PATHNAMES (as contrasted to absolute >>pathnames). > >Set your default directory using "cd" and just use > >tar cf /dev/whatever * > >This will store all the files in the current directory with relative >pathnames and not absolute ones. >As far as I can tell, there is NO way to extract tar files with >absolute pathnames anywhere except their original positions. There is a way. Here it is: ------- cut here ---------------------------------------------------- static char * sccsid = "@(#) tarfix.c (v1.1 2/8/88)"; /* * this nifty program is by * Phil Hochstetler * Sequent Computer Systems * Beaverton, Oregon * * it prevents tar from using absolute pathnames */ # includemain() { char fixbuf[512]; if (isatty (0)) { fprintf (stderr, "tarfix by Phil Hochstetler\n"); fprintf (stderr, "proposed usage (MX2) :\n"); fprintf (stderr, "tarfix < /dev/fl2 | tar -XXf -\n"); fprintf (stderr, "instead of XX use your own options\n"); exit (0); } 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)); } exit (0); } ------- cut here ----------------------------------- This program should be used in a pipe. It reads the tar blocks and deletes a leading "/" in a pathname so if you have /a/b/c it will be created in ${cwd}/a/b/c. As relativ as you can get. If you want it somewhere else you could then copy it, or indeed you could change the above program to change certain pathnames to certain other pathnames. On my machine (MX2), tar for diskettes is called "far". Absorb, apply and enjoy, -mg -- +------------------------------------------------------------------------------+ | UUCP: ...!uunet!unido!sbsvax!greim | Michael T. Greim | | or greim@sbsvax.UUCP | Universitaet des Saarlandes | | CSNET: greim%sbsvax.uucp@Germany.CSnet| FB 10 - Informatik (Dept. of CS) | | ARPA: greim%sbsvax.uucp@uunet.UU.NET | Bau 36, Im Stadtwald 15 | | Phone: +49 681 302 2434 | D-6600 Saarbruecken 11, West Germany | +------------------------------------------------------------------------------+ | # include | +------------------------------------------------------------------------------+