+ tomodes(&stbuf);
+ if (strlen(longname) >= NAMSIZ) {
+ fprintf(stderr, "tar: %s: file name too long\n",
+ longname);
+ return;
+ }
+ strcpy(dblock.dbuf.name, longname);
+ if (stbuf.st_nlink > 1) {
+ struct linkbuf *lp;
+ int found = 0;
+
+ for (lp = ihead; lp != NULL; lp = lp->nextp)
+ if (lp->inum == stbuf.st_ino &&
+ lp->devnum == stbuf.st_dev) {
+ found++;
+ break;
+ }
+ if (found) {
+ strcpy(dblock.dbuf.linkname, lp->pathname);
+ dblock.dbuf.linkflag = '1';
+ sprintf(dblock.dbuf.chksum, "%6o", checksum());
+ writetape( (char *) &dblock);
+ if (vflag) {
+ fprintf(stderr, "a %s ", longname);
+ fprintf(stderr, "link to %s\n",
+ lp->pathname);
+ }
+ lp->count--;
+ close(infile);
+ return;
+ }
+ lp = (struct linkbuf *) malloc(sizeof(*lp));
+ if (lp == NULL) {
+ if (freemem) {
+ fprintf(stderr,
+ "tar: out of memory, link information lost\n");
+ freemem = 0;
+ }
+ } else {
+ lp->nextp = ihead;
+ ihead = lp;
+ lp->inum = stbuf.st_ino;
+ lp->devnum = stbuf.st_dev;
+ lp->count = stbuf.st_nlink - 1;
+ strcpy(lp->pathname, longname);