Lines Matching refs:hd

311 	HD_TAR *hd;  in tar_id()  local
316 hd = (HD_TAR *)blk; in tar_id()
326 if (hd->name[0] == '\0') in tar_id()
330 if (asc_ul(hd->chksum,sizeof(hd->chksum),OCT) != tar_chksm(blk,BLKMULT)) in tar_id()
383 HD_TAR *hd; in tar_rd() local
398 hd = (HD_TAR *)buf; in tar_rd()
399 if (hd->linkflag != LONGLINKTYPE && hd->linkflag != LONGNAMETYPE) { in tar_rd()
401 &gnu_name_string, hd->name, sizeof(hd->name)); in tar_rd()
403 &gnu_link_string, hd->linkname, sizeof(hd->linkname)); in tar_rd()
405 arcn->sb.st_mode = (mode_t)(asc_ul(hd->mode,sizeof(hd->mode),OCT) & in tar_rd()
407 arcn->sb.st_uid = (uid_t)asc_ul(hd->uid, sizeof(hd->uid), OCT); in tar_rd()
408 arcn->sb.st_gid = (gid_t)asc_ul(hd->gid, sizeof(hd->gid), OCT); in tar_rd()
409 arcn->sb.st_size = (off_t)asc_ot(hd->size, sizeof(hd->size), OCT); in tar_rd()
410 arcn->sb.st_mtime = (time_t)asc_ul(hd->mtime, sizeof(hd->mtime), OCT); in tar_rd()
420 switch (hd->linkflag) { in tar_rd()
450 hd->linkflag == LONGLINKTYPE ? PAX_GLL : PAX_GLF; in tar_rd()
516 HD_TAR *hd; in tar_wr() local
547 if ((size_t)arcn->ln_nlen > sizeof(hd->linkname)) { in tar_wr()
565 if ((size_t)len > sizeof(hd->name)) { in tar_wr()
579 hd = (HD_TAR *)hdblk; in tar_wr()
580 fieldcpy(hd->name, sizeof(hd->name), arcn->name, sizeof(arcn->name)); in tar_wr()
589 hd->linkflag = AREGTYPE; in tar_wr()
590 hd->name[len-1] = '/'; in tar_wr()
591 if (ul_oct((u_long)0L, hd->size, sizeof(hd->size), 1)) in tar_wr()
597 hd->linkflag = SYMTYPE; in tar_wr()
598 fieldcpy(hd->linkname, sizeof(hd->linkname), arcn->ln_name, in tar_wr()
600 if (ul_oct((u_long)0L, hd->size, sizeof(hd->size), 1)) in tar_wr()
606 hd->linkflag = LNKTYPE; in tar_wr()
607 fieldcpy(hd->linkname, sizeof(hd->linkname), arcn->ln_name, in tar_wr()
609 if (ul_oct((u_long)0L, hd->size, sizeof(hd->size), 1)) in tar_wr()
615 hd->linkflag = AREGTYPE; in tar_wr()
616 if (ot_oct(arcn->sb.st_size, hd->size, sizeof(hd->size), 1)) { in tar_wr()
626 if (ul_oct((u_long)arcn->sb.st_mode, hd->mode, sizeof(hd->mode), 0) || in tar_wr()
627 ul_oct((u_long)arcn->sb.st_uid, hd->uid, sizeof(hd->uid), 0) || in tar_wr()
628 ul_oct((u_long)arcn->sb.st_gid, hd->gid, sizeof(hd->gid), 0) || in tar_wr()
629 ul_oct((u_long)(u_int)arcn->sb.st_mtime, hd->mtime, sizeof(hd->mtime), 1)) in tar_wr()
637 if (ul_oct(tar_chksm(hdblk, sizeof(HD_TAR)), hd->chksum, in tar_wr()
638 sizeof(hd->chksum), 3)) in tar_wr()
701 HD_USTAR *hd; in ustar_id() local
705 hd = (HD_USTAR *)blk; in ustar_id()
713 if (hd->prefix[0] == '\0' && hd->name[0] == '\0') in ustar_id()
715 if (strncmp(hd->magic, TMAGIC, TMAGLEN - 1) != 0) in ustar_id()
717 if (asc_ul(hd->chksum,sizeof(hd->chksum),OCT) != tar_chksm(blk,BLKMULT)) in ustar_id()
733 HD_USTAR *hd; in ustar_rd() local
747 hd = (HD_USTAR *)buf; in ustar_rd()
754 if (*(hd->prefix) != '\0') { in ustar_rd()
755 cnt = fieldcpy(dest, sizeof(arcn->name) - 1, hd->prefix, in ustar_rd()
756 sizeof(hd->prefix)); in ustar_rd()
764 if (hd->typeflag != LONGLINKTYPE && hd->typeflag != LONGNAMETYPE) { in ustar_rd()
766 &gnu_name_string, hd->name, sizeof(hd->name)); in ustar_rd()
768 &gnu_link_string, hd->linkname, sizeof(hd->linkname)); in ustar_rd()
775 arcn->sb.st_mode = (mode_t)(asc_ul(hd->mode, sizeof(hd->mode), OCT) & in ustar_rd()
777 arcn->sb.st_size = (off_t)asc_ot(hd->size, sizeof(hd->size), OCT); in ustar_rd()
778 arcn->sb.st_mtime = (time_t)asc_ul(hd->mtime, sizeof(hd->mtime), OCT); in ustar_rd()
787 hd->gname[sizeof(hd->gname) - 1] = '\0'; in ustar_rd()
789 (gid_name(hd->gname, &(arcn->sb.st_gid)) < 0)) in ustar_rd()
790 arcn->sb.st_gid = (gid_t)asc_ul(hd->gid, sizeof(hd->gid), OCT); in ustar_rd()
791 hd->uname[sizeof(hd->uname) - 1] = '\0'; in ustar_rd()
793 (uid_name(hd->uname, &(arcn->sb.st_uid)) < 0)) in ustar_rd()
794 arcn->sb.st_uid = (uid_t)asc_ul(hd->uid, sizeof(hd->uid), OCT); in ustar_rd()
806 switch (hd->typeflag) { in ustar_rd()
829 if (hd->typeflag == BLKTYPE) { in ustar_rd()
836 devmajor = (dev_t)asc_ul(hd->devmajor,sizeof(hd->devmajor),OCT); in ustar_rd()
837 devminor = (dev_t)asc_ul(hd->devminor,sizeof(hd->devminor),OCT); in ustar_rd()
842 if (hd->typeflag == SYMTYPE) { in ustar_rd()
861 hd->typeflag == LONGLINKTYPE ? PAX_GLL : PAX_GLF; in ustar_rd()
897 HD_USTAR *hd; in ustar_wr() local
918 ((size_t)arcn->ln_nlen > sizeof(hd->linkname))) { in ustar_wr()
945 hd = (HD_USTAR *)hdblk; in ustar_wr()
957 fieldcpy(hd->prefix, sizeof(hd->prefix), arcn->name, in ustar_wr()
966 fieldcpy(hd->name, sizeof(hd->name), pt, in ustar_wr()
978 hd->typeflag = DIRTYPE; in ustar_wr()
979 if (ul_oct((u_long)0L, hd->size, sizeof(hd->size), 3)) in ustar_wr()
985 hd->typeflag = CHRTYPE; in ustar_wr()
987 hd->typeflag = BLKTYPE; in ustar_wr()
988 if (ul_oct((u_long)MAJOR(arcn->sb.st_rdev), hd->devmajor, in ustar_wr()
989 sizeof(hd->devmajor), 3) || in ustar_wr()
990 ul_oct((u_long)MINOR(arcn->sb.st_rdev), hd->devminor, in ustar_wr()
991 sizeof(hd->devminor), 3) || in ustar_wr()
992 ul_oct((u_long)0L, hd->size, sizeof(hd->size), 3)) in ustar_wr()
996 hd->typeflag = FIFOTYPE; in ustar_wr()
997 if (ul_oct((u_long)0L, hd->size, sizeof(hd->size), 3)) in ustar_wr()
1004 hd->typeflag = SYMTYPE; in ustar_wr()
1006 hd->typeflag = LNKTYPE; in ustar_wr()
1007 fieldcpy(hd->linkname, sizeof(hd->linkname), arcn->ln_name, in ustar_wr()
1009 if (ul_oct((u_long)0L, hd->size, sizeof(hd->size), 3)) in ustar_wr()
1019 hd->typeflag = CONTTYPE; in ustar_wr()
1021 hd->typeflag = REGTYPE; in ustar_wr()
1023 if (ot_oct(arcn->sb.st_size, hd->size, sizeof(hd->size), 3)) { in ustar_wr()
1030 strncpy(hd->magic, TMAGIC, TMAGLEN); in ustar_wr()
1031 strncpy(hd->version, TVERSION, TVERSLEN); in ustar_wr()
1037 if (ul_oct(t_uid, hd->uid, sizeof(hd->uid), 3)) { in ustar_wr()
1048 if (ul_oct((u_long)uid_nobody, hd->uid, sizeof(hd->uid), 3)) in ustar_wr()
1051 if (ul_oct(t_gid, hd->gid, sizeof(hd->gid), 3)) { in ustar_wr()
1062 if (ul_oct((u_long)gid_nobody, hd->gid, sizeof(hd->gid), 3)) in ustar_wr()
1065 if (ul_oct((u_long)arcn->sb.st_mode, hd->mode, sizeof(hd->mode), 3) || in ustar_wr()
1066 ul_oct(t_mtime,hd->mtime,sizeof(hd->mtime),3)) in ustar_wr()
1069 strncpy(hd->uname, name_id(name_uid(t_uid, 0)), sizeof(hd->uname)); in ustar_wr()
1070 strncpy(hd->gname, name_id(name_gid(t_gid, 0)), sizeof(hd->gname)); in ustar_wr()
1078 if (ul_oct(tar_chksm(hdblk, sizeof(HD_USTAR)), hd->chksum, in ustar_wr()
1079 sizeof(hd->chksum), 3)) in ustar_wr()
1084 tar_dbgfld("writing name '", hd->name, TNMSZ); in ustar_wr()
1085 tar_dbgfld("' mode ", hd->mode, 8); in ustar_wr()
1086 tar_dbgfld(" uid ", hd->uid, 8); in ustar_wr()
1087 tar_dbgfld(" (", hd->uname, 32); in ustar_wr()
1088 tar_dbgfld(") gid ", hd->gid, 8); in ustar_wr()
1089 tar_dbgfld(" (", hd->gname, 32); in ustar_wr()
1090 tar_dbgfld(") size ", hd->size, 12); in ustar_wr()
1091 tar_dbgfld(" mtime ", hd->mtime, 12); in ustar_wr()
1092 tar_dbgfld(" type ", &(hd->typeflag), 1); in ustar_wr()
1093 tar_dbgfld(" linked to '", hd->linkname, TNMSZ); in ustar_wr()
1094 tar_dbgfld("' magic '", hd->magic, TMAGLEN); in ustar_wr()
1095 tar_dbgfld("' v", hd->version, TVERSLEN); in ustar_wr()
1096 tar_dbgfld(" device '", hd->devmajor, 8); in ustar_wr()
1097 tar_dbgfld(":", hd->devminor, 8); in ustar_wr()
1098 tar_dbgfld("' prefix '", hd->prefix, TPFSZ); in ustar_wr()
1099 tar_dbgfld("' checksum ", hd->chksum, CHK_LEN); in ustar_wr()