Lines Matching refs:arcn
457 tar_rd(ARCHD *arcn, char *buf)
467 memset(arcn, 0, sizeof(*arcn));
468 arcn->org_name = arcn->name;
469 arcn->pat = NULL;
470 arcn->sb.st_nlink = 1;
477 arcn->nlen = expandname(arcn->name, sizeof(arcn->name),
480 arcn->ln_nlen = expandname(arcn->ln_name, sizeof(arcn->ln_name),
484 arcn->sb.st_mode = (mode_t)(asc_u32(hd->mode,sizeof(hd->mode),OCT) &
486 arcn->sb.st_uid = (uid_t)asc_u32(hd->uid, sizeof(hd->uid), OCT);
487 arcn->sb.st_gid = (gid_t)asc_u32(hd->gid, sizeof(hd->gid), OCT);
488 arcn->sb.st_size = (off_t)ASC_OFFT(hd->size, sizeof(hd->size), OCT);
489 if (arcn->sb.st_size == -1)
491 arcn->sb.st_mtime = (time_t)(int32_t)asc_u32(hd->mtime, sizeof(hd->mtime), OCT);
492 arcn->sb.st_ctime = arcn->sb.st_atime = arcn->sb.st_mtime;
498 pt = &(arcn->name[arcn->nlen - 1]);
499 arcn->pad = 0;
500 arcn->skip = 0;
507 arcn->type = PAX_SLK;
508 arcn->sb.st_mode |= S_IFLNK;
515 arcn->type = PAX_HLK;
516 arcn->sb.st_nlink = 2;
522 arcn->sb.st_mode |= S_IFREG;
531 arcn->type = PAX_GLF;
533 arcn->type = PAX_GLL;
534 arcn->pad = TAR_PAD(arcn->sb.st_size);
535 arcn->skip = arcn->sb.st_size;
550 arcn->type = PAX_DIR;
551 arcn->sb.st_mode |= S_IFDIR;
552 arcn->sb.st_nlink = 2;
559 arcn->type = PAX_REG;
560 arcn->sb.st_mode |= S_IFREG;
561 arcn->pad = TAR_PAD(arcn->sb.st_size);
562 arcn->skip = arcn->sb.st_size;
572 --arcn->nlen;
590 tar_wr(ARCHD *arcn)
600 switch(arcn->type) {
610 arcn->org_name);
614 "Tar cannot archive a block device %s", arcn->org_name);
617 tty_warn(1, "Tar cannot archive a socket %s", arcn->org_name);
620 tty_warn(1, "Tar cannot archive a fifo %s", arcn->org_name);
625 if (arcn->ln_nlen > (int)sizeof(hd->linkname)) {
627 arcn->ln_name);
640 len = arcn->nlen;
641 if (arcn->type == PAX_DIR)
644 tty_warn(1, "File name too long for tar %s", arcn->name);
658 strlcpy(hd->name, arcn->name, sizeof(hd->name));
659 arcn->pad = 0;
661 if (arcn->type == PAX_DIR) {
671 } else if (arcn->type == PAX_SLK) {
676 strlcpy(hd->linkname, arcn->ln_name, sizeof(hd->linkname));
679 } else if ((arcn->type == PAX_HLK) || (arcn->type == PAX_HRG)) {
684 strlcpy(hd->linkname, arcn->ln_name, sizeof(hd->linkname));
692 if (OFFT_OCT(arcn->sb.st_size, hd->size, sizeof(hd->size), 1)) {
694 arcn->org_name);
697 arcn->pad = TAR_PAD(arcn->sb.st_size);
703 mtime = tst.st_ino ? tst.st_mtime : arcn->sb.st_mtime;
704 if (u32_oct((uintmax_t)arcn->sb.st_mode, hd->mode, sizeof(hd->mode), 0) ||
705 u32_oct((uintmax_t)arcn->sb.st_uid, hd->uid, sizeof(hd->uid), 0) ||
706 u32_oct((uintmax_t)arcn->sb.st_gid, hd->gid, sizeof(hd->gid), 0) ||
727 if ((arcn->type == PAX_CTG) || (arcn->type == PAX_REG))
735 tty_warn(1, "Tar header field is too small for %s", arcn->org_name);
815 ustar_rd(ARCHD *arcn, char *buf)
829 memset(arcn, 0, sizeof(*arcn));
830 arcn->org_name = arcn->name;
831 arcn->pat = NULL;
832 arcn->sb.st_nlink = 1;
839 dest = arcn->name;
841 cnt = strlcpy(arcn->name, hd->prefix, sizeof(arcn->name));
850 arcn->nlen = expandname(dest, sizeof(arcn->name) - cnt,
853 arcn->ln_nlen = expandname(arcn->ln_name,
854 sizeof(arcn->ln_name), &gnu_link_string, &gnu_link_length,
862 arcn->sb.st_mode = (mode_t)(asc_u32(hd->mode, sizeof(hd->mode), OCT) &
864 arcn->sb.st_size = (off_t)ASC_OFFT(hd->size, sizeof(hd->size), OCT);
865 if (arcn->sb.st_size == -1)
867 arcn->sb.st_mtime = (time_t)(int32_t)asc_u32(hd->mtime, sizeof(hd->mtime), OCT);
868 arcn->sb.st_ctime = arcn->sb.st_atime = arcn->sb.st_mtime;
877 if (gid_from_group(hd->gname, &(arcn->sb.st_gid)) < 0)
878 arcn->sb.st_gid = (gid_t)asc_u32(hd->gid, sizeof(hd->gid), OCT);
880 if (uid_from_user(hd->uname, &(arcn->sb.st_uid)) < 0)
881 arcn->sb.st_uid = (uid_t)asc_u32(hd->uid, sizeof(hd->uid), OCT);
886 arcn->pad = 0;
887 arcn->skip = 0;
888 arcn->sb.st_rdev = (dev_t)0;
895 arcn->type = PAX_FIF;
896 arcn->sb.st_mode |= S_IFIFO;
899 arcn->type = PAX_DIR;
900 arcn->sb.st_mode |= S_IFDIR;
901 arcn->sb.st_nlink = 2;
908 if (arcn->name[arcn->nlen - 1] == '/')
909 arcn->name[--arcn->nlen] = '\0';
917 arcn->type = PAX_BLK;
918 arcn->sb.st_mode |= S_IFBLK;
920 arcn->type = PAX_CHR;
921 arcn->sb.st_mode |= S_IFCHR;
925 arcn->sb.st_rdev = TODEV(devmajor, devminor);
930 arcn->type = PAX_SLK;
931 arcn->sb.st_mode |= S_IFLNK;
933 arcn->type = PAX_HLK;
937 arcn->sb.st_mode |= S_IFREG;
938 arcn->sb.st_nlink = 2;
949 arcn->type = PAX_GLF;
951 arcn->type = PAX_GLL;
952 arcn->pad = TAR_PAD(arcn->sb.st_size);
953 arcn->skip = arcn->sb.st_size;
974 arcn->type = PAX_REG;
975 arcn->pad = TAR_PAD(arcn->sb.st_size);
976 arcn->skip = arcn->sb.st_size;
977 arcn->sb.st_mode |= S_IFREG;
1001 longlink(ARCHD *arcn, int type)
1012 gnu_hack_string = arcn->ln_name;
1013 gnu_hack_len = arcn->ln_nlen + 1;
1016 gnu_hack_string = arcn->name;
1017 gnu_hack_len = arcn->nlen + 1;
1042 size_err(const char *what, ARCHD *arcn)
1048 what, arcn->org_name);
1053 ustar_wr(ARCHD *arcn)
1061 switch (arcn->type) {
1068 arcn->org_name);
1077 if (arcn->ln_nlen >= (int)sizeof(hd->linkname)) {
1079 longlink(arcn, PAX_GLL);
1082 arcn->ln_name);
1093 * pt != arcn->name, the name has to be split
1095 if ((pt = name_split(arcn->name, arcn->nlen)) == NULL) {
1097 longlink(arcn, PAX_GLF);
1098 pt = arcn->name;
1101 arcn->name);
1111 arcn->pad = 0L;
1116 if (pt != arcn->name) {
1122 strlcpy(hd->prefix, arcn->name, sizeof(hd->prefix));
1135 switch(arcn->type) {
1139 return size_err("DIRTYPE", arcn);
1143 if (arcn->type == PAX_CHR)
1147 if (u32_oct((uintmax_t)MAJOR(arcn->sb.st_rdev), hd->devmajor,
1149 u32_oct((uintmax_t)MINOR(arcn->sb.st_rdev), hd->devminor,
1152 return size_err("DEVTYPE", arcn);
1157 return size_err("FIFOTYPE", arcn);
1163 if (arcn->type == PAX_SLK)
1165 else if (arcn->type == PAX_GLL)
1169 strlcpy(hd->linkname, arcn->ln_name, sizeof(hd->linkname));
1172 return size_err("LINKTYPE", arcn);
1181 if (arcn->type == PAX_GLF) {
1183 arcn->pad = TAR_PAD(gnu_hack_len);
1187 arcn->org_name);
1191 if (arcn->type == PAX_CTG)
1195 arcn->pad = TAR_PAD(arcn->sb.st_size);
1196 if (OFFT_OCT(arcn->sb.st_size, hd->size,
1199 arcn->org_name);
1216 if (u32_oct((uintmax_t)arcn->sb.st_mode, hd->mode, sizeof(hd->mode), 3))
1217 return size_err("MODE", arcn);
1218 if (u32_oct((uintmax_t)arcn->sb.st_uid, hd->uid, sizeof(hd->uid), 3))
1219 return size_err("UID", arcn);
1220 if (u32_oct((uintmax_t)arcn->sb.st_gid, hd->gid, sizeof(hd->gid), 3))
1221 return size_err("GID", arcn);
1222 mtime = tst.st_ino ? tst.st_mtime : arcn->sb.st_mtime;
1224 return size_err("MTIME", arcn);
1225 user = user_from_uid(arcn->sb.st_uid, 1);
1226 group = group_from_gid(arcn->sb.st_gid, 1);
1237 return size_err("CHKSUM", arcn);
1252 if ((arcn->type == PAX_CTG) || (arcn->type == PAX_REG))