SCCS-vsn: old/tar/tar.c 4.12
-static char *sccsid = "@(#)tar.c 4.11 (Berkeley) 82/10/20";
+static char *sccsid = "@(#)tar.c 4.12 (Berkeley) 82/12/09";
/*
* Tape Archival Program
/*
* Tape Archival Program
char *argv[];
{
register char *cp, *cp2;
char *argv[];
{
register char *cp, *cp2;
+ char wdir[MAXPATHLEN], tempdir[MAXPATHLEN], *parent;
for (cp = *argv; *cp; cp++)
if (*cp == '/')
cp2 = cp;
if (cp2 != *argv) {
*cp2 = '\0';
for (cp = *argv; *cp; cp++)
if (*cp == '/')
cp2 = cp;
if (cp2 != *argv) {
*cp2 = '\0';
+ if (chdir(*argv) < 0) {
+ perror(*argv);
+ continue;
+ }
+ getwdir(tempdir);
+ parent = tempdir;
+ putfile(*argv++, cp2, parent);
chdir(wdir);
}
putempty();
chdir(wdir);
}
putempty();
-putfile(longname, shortname)
+putfile(longname, shortname, parent)
char *longname;
char *shortname;
char *longname;
char *shortname;
{
int infile;
long blocks;
{
int infile;
long blocks;
struct direct *dp;
DIR *dirp;
int i, j;
struct direct *dp;
DIR *dirp;
int i, j;
+ char newparent[NAMSIZ+64];
infile = open(shortname, 0);
if (infile < 0) {
fprintf(stderr, "tar: %s: cannot open file\n", longname);
return;
}
infile = open(shortname, 0);
if (infile < 0) {
fprintf(stderr, "tar: %s: cannot open file\n", longname);
return;
}
- lstat(shortname, &stbuf);
+ if (!hflag)
+ lstat(shortname, &stbuf);
+ else if (stat(shortname, &stbuf) < 0) {
+ perror(longname);
+ close(infile);
+ return;
+ }
if (tfile != NULL && checkupdate(longname) == 0) {
close(infile);
return;
if (tfile != NULL && checkupdate(longname) == 0) {
close(infile);
return;
sprintf(dblock.dbuf.chksum, "%6o", checksum());
writetape((char *)&dblock);
}
sprintf(dblock.dbuf.chksum, "%6o", checksum());
writetape((char *)&dblock);
}
+ sprintf(newparent, "%s/%s", parent, shortname);
chdir(shortname);
close(infile);
if ((dirp = opendir(".")) == NULL) {
fprintf(stderr, "%s: directory read error\n", longname);
chdir(shortname);
close(infile);
if ((dirp = opendir(".")) == NULL) {
fprintf(stderr, "%s: directory read error\n", longname);
return;
}
while ((dp = readdir(dirp)) != NULL && !term) {
return;
}
while ((dp = readdir(dirp)) != NULL && !term) {
strcpy(cp, dp->d_name);
i = telldir(dirp);
closedir(dirp);
strcpy(cp, dp->d_name);
i = telldir(dirp);
closedir(dirp);
+ putfile(buf, cp, newparent);
dirp = opendir(".");
seekdir(dirp, i);
}
closedir(dirp);
dirp = opendir(".");
seekdir(dirp, i);
}
closedir(dirp);
return;
}
i = stbuf.st_mode & S_IFMT;
return;
}
i = stbuf.st_mode & S_IFMT;
- i = readlink(longname, dblock.dbuf.linkname, NAMSIZ - 1);
+ i = readlink(shortname, dblock.dbuf.linkname, NAMSIZ - 1);
while (wait((int *)NULL) != -1)
;
read(pipdes[0], s, 50);
while (wait((int *)NULL) != -1)
;
read(pipdes[0], s, 50);
+ read(pipdes[0], s, 50);
while (*s != '\n')
s++;
*s = '\0';
while (*s != '\n')
s++;
*s = '\0';