Lines Matching refs:arcn
100 cpio_subtrail(ARCHD *arcn)
105 if ((strcmp(arcn->name, TRAILER) == 0) && (arcn->sb.st_size == 0))
118 com_rd(ARCHD *arcn)
120 arcn->skip = 0;
121 arcn->pat = NULL;
122 arcn->org_name = arcn->name;
123 switch(arcn->sb.st_mode & C_IFMT) {
125 arcn->type = PAX_FIF;
128 arcn->type = PAX_DIR;
131 arcn->type = PAX_BLK;
134 arcn->type = PAX_CHR;
137 arcn->type = PAX_SLK;
140 arcn->type = PAX_SCK;
149 arcn->sb.st_mode = (arcn->sb.st_mode & 0xfff) | C_ISREG;
150 arcn->type = PAX_REG;
151 arcn->skip = arcn->sb.st_size;
154 if (chk_lnk(arcn) < 0)
190 rd_nm(ARCHD *arcn, int nsz)
195 if ((nsz <= 0) || (nsz > (int)sizeof(arcn->name))) {
203 if ((rd_wrbuf(arcn->name,nsz) != nsz) || (arcn->name[nsz-1] != '\0') ||
204 (arcn->name[0] == '\0')) {
220 rd_ln_nm(ARCHD *arcn)
225 if ((arcn->sb.st_size == 0) ||
226 (arcn->sb.st_size >= (off_t)sizeof(arcn->ln_name))) {
228 (OFFT_T) arcn->sb.st_size);
235 if (rd_wrbuf(arcn->ln_name, (int)arcn->sb.st_size) !=
236 (int)arcn->sb.st_size) {
240 arcn->ln_nlen = arcn->sb.st_size;
241 arcn->ln_name[arcn->ln_nlen] = '\0';
246 if (arcn->ln_name[0] == '\0') {
283 cpio_rd(ARCHD *arcn, char *buf)
299 arcn->pad = 0L;
300 arcn->sb.st_dev = (dev_t)asc_u32(hd->c_dev, sizeof(hd->c_dev), OCT);
301 arcn->sb.st_ino = (ino_t)asc_u32(hd->c_ino, sizeof(hd->c_ino), OCT);
302 arcn->sb.st_mode = (mode_t)asc_u32(hd->c_mode, sizeof(hd->c_mode), OCT);
303 arcn->sb.st_uid = (uid_t)asc_u32(hd->c_uid, sizeof(hd->c_uid), OCT);
304 arcn->sb.st_gid = (gid_t)asc_u32(hd->c_gid, sizeof(hd->c_gid), OCT);
305 arcn->sb.st_nlink = (nlink_t)asc_u32(hd->c_nlink, sizeof(hd->c_nlink),
307 arcn->sb.st_rdev = (dev_t)asc_u32(hd->c_rdev, sizeof(hd->c_rdev), OCT);
308 arcn->sb.st_mtime = (time_t)(int32_t)asc_u32(hd->c_mtime, sizeof(hd->c_mtime),
310 arcn->sb.st_ctime = arcn->sb.st_atime = arcn->sb.st_mtime;
311 arcn->sb.st_size = (off_t)ASC_OFFT(hd->c_filesize,
320 arcn->nlen = nsz - 1;
321 if (rd_nm(arcn, nsz) < 0)
324 if (((arcn->sb.st_mode&C_IFMT) != C_ISLNK)||(arcn->sb.st_size == 0)) {
328 arcn->ln_nlen = 0;
329 arcn->ln_name[0] = '\0';
330 return com_rd(arcn);
337 if (rd_ln_nm(arcn) < 0)
343 return com_rd(arcn);
382 cpio_wr(ARCHD *arcn)
391 if (map_dev(arcn, (u_long)CPIO_MASK, (u_long)CPIO_MASK) < 0)
394 arcn->pad = 0L;
395 nsz = arcn->nlen + 1;
397 if ((arcn->type != PAX_BLK) && (arcn->type != PAX_CHR))
398 arcn->sb.st_rdev = 0;
400 switch(arcn->type) {
407 if (OFFT_ASC(arcn->sb.st_size, hd->c_filesize,
410 arcn->org_name);
418 if (u32_asc((uintmax_t)arcn->ln_nlen, hd->c_filesize,
436 u32_asc((uintmax_t)arcn->sb.st_dev, hd->c_dev, sizeof(hd->c_dev),
438 u32_asc((uintmax_t)arcn->sb.st_ino, hd->c_ino, sizeof(hd->c_ino),
440 u32_asc((uintmax_t)arcn->sb.st_mode, hd->c_mode, sizeof(hd->c_mode),
442 u32_asc((uintmax_t)arcn->sb.st_uid, hd->c_uid, sizeof(hd->c_uid),
444 u32_asc((uintmax_t)arcn->sb.st_gid, hd->c_gid, sizeof(hd->c_gid),
446 u32_asc((uintmax_t)arcn->sb.st_nlink, hd->c_nlink, sizeof(hd->c_nlink),
448 u32_asc((uintmax_t)arcn->sb.st_rdev, hd->c_rdev, sizeof(hd->c_rdev),
450 u32_asc((uintmax_t)arcn->sb.st_mtime,hd->c_mtime,sizeof(hd->c_mtime),
459 (wr_rdbuf(arcn->name, nsz) < 0)) {
461 arcn->org_name);
469 if ((arcn->type == PAX_CTG) || (arcn->type == PAX_REG))
471 if (arcn->type != PAX_SLK)
478 if (wr_rdbuf(arcn->ln_name, arcn->ln_nlen) < 0) {
480 arcn->org_name);
490 arcn->org_name);
556 vcpio_rd(ARCHD *arcn, char *buf)
576 arcn->pad = 0L;
581 arcn->sb.st_ino = (ino_t)asc_u32(hd->c_ino, sizeof(hd->c_ino), HEX);
582 arcn->sb.st_mode = (mode_t)asc_u32(hd->c_mode, sizeof(hd->c_mode), HEX);
583 arcn->sb.st_uid = (uid_t)asc_u32(hd->c_uid, sizeof(hd->c_uid), HEX);
584 arcn->sb.st_gid = (gid_t)asc_u32(hd->c_gid, sizeof(hd->c_gid), HEX);
585 arcn->sb.st_mtime = (time_t)(int32_t)asc_u32(hd->c_mtime,sizeof(hd->c_mtime),HEX);
586 arcn->sb.st_ctime = arcn->sb.st_atime = arcn->sb.st_mtime;
587 arcn->sb.st_size = (off_t)ASC_OFFT(hd->c_filesize,
589 arcn->sb.st_nlink = (nlink_t)asc_u32(hd->c_nlink, sizeof(hd->c_nlink),
593 arcn->sb.st_dev = TODEV(devmajor, devminor);
596 arcn->sb.st_rdev = TODEV(devmajor, devminor);
597 arcn->crc = asc_u32(hd->c_chksum, sizeof(hd->c_chksum), HEX);
605 arcn->nlen = nsz - 1;
606 if (rd_nm(arcn, nsz) < 0)
619 if (((arcn->sb.st_mode&C_IFMT) != C_ISLNK)||(arcn->sb.st_size == 0)) {
623 arcn->ln_nlen = 0;
624 arcn->ln_name[0] = '\0';
625 arcn->pad = VCPIO_PAD(arcn->sb.st_size);
626 return com_rd(arcn);
632 if ((rd_ln_nm(arcn) < 0) ||
633 (rd_skip((off_t)(VCPIO_PAD(arcn->sb.st_size))) < 0))
639 return com_rd(arcn);
680 vcpio_wr(ARCHD *arcn)
690 if (map_dev(arcn, (u_long)VCPIO_MASK, (u_long)VCPIO_MASK) < 0)
692 nsz = arcn->nlen + 1;
694 if ((arcn->type != PAX_BLK) && (arcn->type != PAX_CHR))
695 arcn->sb.st_rdev = 0;
704 u32_asc((uintmax_t)arcn->crc,hd->c_chksum,sizeof(hd->c_chksum),
714 switch(arcn->type) {
722 arcn->pad = VCPIO_PAD(arcn->sb.st_size);
723 if (OFFT_ASC(arcn->sb.st_size, hd->c_filesize,
726 arcn->org_name);
735 arcn->pad = 0L;
736 if (u32_asc((uintmax_t)arcn->ln_nlen, hd->c_filesize,
744 arcn->pad = 0L;
754 if (u32_asc((uintmax_t)arcn->sb.st_ino, hd->c_ino, sizeof(hd->c_ino),
756 u32_asc((uintmax_t)arcn->sb.st_mode, hd->c_mode, sizeof(hd->c_mode),
758 u32_asc((uintmax_t)arcn->sb.st_uid, hd->c_uid, sizeof(hd->c_uid),
760 u32_asc((uintmax_t)arcn->sb.st_gid, hd->c_gid, sizeof(hd->c_gid),
762 u32_asc((uintmax_t)arcn->sb.st_mtime, hd->c_mtime, sizeof(hd->c_mtime),
764 u32_asc((uintmax_t)arcn->sb.st_nlink, hd->c_nlink, sizeof(hd->c_nlink),
766 u32_asc((uintmax_t)MAJOR(arcn->sb.st_dev),hd->c_maj, sizeof(hd->c_maj),
768 u32_asc((uintmax_t)MINOR(arcn->sb.st_dev),hd->c_min, sizeof(hd->c_min),
770 u32_asc((uintmax_t)MAJOR(arcn->sb.st_rdev),hd->c_rmaj,sizeof(hd->c_maj),
772 u32_asc((uintmax_t)MINOR(arcn->sb.st_rdev),hd->c_rmin,sizeof(hd->c_min),
781 (wr_rdbuf(arcn->name, (int)nsz) < 0) ||
784 arcn->org_name);
791 if ((arcn->type == PAX_CTG) || (arcn->type == PAX_REG) ||
792 (arcn->type == PAX_HRG))
798 if (arcn->type != PAX_SLK)
804 if ((wr_rdbuf(arcn->ln_name, arcn->ln_nlen) < 0) ||
805 (wr_skip((off_t)(VCPIO_PAD(arcn->ln_nlen))) < 0)) {
807 arcn->org_name);
817 arcn->org_name);
862 bcpio_rd(ARCHD *arcn, char *buf)
873 arcn->pad = 0L;
879 arcn->sb.st_dev = (dev_t)(RSHRT_EXT(hd->h_dev));
880 arcn->sb.st_ino = (ino_t)(RSHRT_EXT(hd->h_ino));
881 arcn->sb.st_mode = (mode_t)(RSHRT_EXT(hd->h_mode));
882 arcn->sb.st_uid = (uid_t)(RSHRT_EXT(hd->h_uid));
883 arcn->sb.st_gid = (gid_t)(RSHRT_EXT(hd->h_gid));
884 arcn->sb.st_nlink = (nlink_t)(RSHRT_EXT(hd->h_nlink));
885 arcn->sb.st_rdev = (dev_t)(RSHRT_EXT(hd->h_rdev));
886 arcn->sb.st_mtime = (time_t)(RSHRT_EXT(hd->h_mtime_1));
887 arcn->sb.st_mtime = (arcn->sb.st_mtime << 16) |
889 arcn->sb.st_size = (off_t)(RSHRT_EXT(hd->h_filesize_1));
890 arcn->sb.st_size = (arcn->sb.st_size << 16) |
894 arcn->sb.st_dev = (dev_t)(SHRT_EXT(hd->h_dev));
895 arcn->sb.st_ino = (ino_t)(SHRT_EXT(hd->h_ino));
896 arcn->sb.st_mode = (mode_t)(SHRT_EXT(hd->h_mode));
897 arcn->sb.st_uid = (uid_t)(SHRT_EXT(hd->h_uid));
898 arcn->sb.st_gid = (gid_t)(SHRT_EXT(hd->h_gid));
899 arcn->sb.st_nlink = (nlink_t)(SHRT_EXT(hd->h_nlink));
900 arcn->sb.st_rdev = (dev_t)(SHRT_EXT(hd->h_rdev));
901 arcn->sb.st_mtime = (time_t)(SHRT_EXT(hd->h_mtime_1));
902 arcn->sb.st_mtime = (arcn->sb.st_mtime << 16) |
904 arcn->sb.st_size = (off_t)(SHRT_EXT(hd->h_filesize_1));
905 arcn->sb.st_size = (arcn->sb.st_size << 16) |
909 arcn->sb.st_ctime = arcn->sb.st_atime = arcn->sb.st_mtime;
917 arcn->nlen = nsz - 1;
918 if (rd_nm(arcn, nsz) < 0)
931 if (((arcn->sb.st_mode & C_IFMT) != C_ISLNK)||(arcn->sb.st_size == 0)){
935 arcn->ln_nlen = 0;
936 arcn->ln_name[0] = '\0';
937 arcn->pad = BCPIO_PAD(arcn->sb.st_size);
938 return com_rd(arcn);
941 if ((rd_ln_nm(arcn) < 0) ||
942 (rd_skip((off_t)(BCPIO_PAD(arcn->sb.st_size))) < 0))
948 return com_rd(arcn);
977 bcpio_wr(ARCHD *arcn)
990 if (map_dev(arcn, (u_long)BCPIO_MASK, (u_long)BCPIO_MASK) < 0)
993 if ((arcn->type != PAX_BLK) && (arcn->type != PAX_CHR))
994 arcn->sb.st_rdev = 0;
997 switch(arcn->type) {
1005 arcn->pad = BCPIO_PAD(arcn->sb.st_size);
1006 hd->h_filesize_1[0] = CHR_WR_0(arcn->sb.st_size);
1007 hd->h_filesize_1[1] = CHR_WR_1(arcn->sb.st_size);
1008 hd->h_filesize_2[0] = CHR_WR_2(arcn->sb.st_size);
1009 hd->h_filesize_2[1] = CHR_WR_3(arcn->sb.st_size);
1012 if (arcn->sb.st_size != t_offt) {
1014 arcn->org_name);
1023 arcn->pad = 0L;
1024 hd->h_filesize_1[0] = CHR_WR_0(arcn->ln_nlen);
1025 hd->h_filesize_1[1] = CHR_WR_1(arcn->ln_nlen);
1026 hd->h_filesize_2[0] = CHR_WR_2(arcn->ln_nlen);
1027 hd->h_filesize_2[1] = CHR_WR_3(arcn->ln_nlen);
1030 if (arcn->ln_nlen != t_int)
1037 arcn->pad = 0L;
1050 hd->h_dev[0] = CHR_WR_2(arcn->sb.st_dev);
1051 hd->h_dev[1] = CHR_WR_3(arcn->sb.st_dev);
1052 if (arcn->sb.st_dev != (dev_t)(SHRT_EXT(hd->h_dev)))
1054 hd->h_ino[0] = CHR_WR_2(arcn->sb.st_ino);
1055 hd->h_ino[1] = CHR_WR_3(arcn->sb.st_ino);
1056 if (arcn->sb.st_ino != (ino_t)(SHRT_EXT(hd->h_ino)))
1058 hd->h_mode[0] = CHR_WR_2(arcn->sb.st_mode);
1059 hd->h_mode[1] = CHR_WR_3(arcn->sb.st_mode);
1060 if (arcn->sb.st_mode != (mode_t)(SHRT_EXT(hd->h_mode)))
1062 hd->h_uid[0] = CHR_WR_2(arcn->sb.st_uid);
1063 hd->h_uid[1] = CHR_WR_3(arcn->sb.st_uid);
1064 if (arcn->sb.st_uid != (uid_t)(SHRT_EXT(hd->h_uid)))
1066 hd->h_gid[0] = CHR_WR_2(arcn->sb.st_gid);
1067 hd->h_gid[1] = CHR_WR_3(arcn->sb.st_gid);
1068 if (arcn->sb.st_gid != (gid_t)(SHRT_EXT(hd->h_gid)))
1070 hd->h_nlink[0] = CHR_WR_2(arcn->sb.st_nlink);
1071 hd->h_nlink[1] = CHR_WR_3(arcn->sb.st_nlink);
1072 if (arcn->sb.st_nlink != (nlink_t)(SHRT_EXT(hd->h_nlink)))
1074 hd->h_rdev[0] = CHR_WR_2(arcn->sb.st_rdev);
1075 hd->h_rdev[1] = CHR_WR_3(arcn->sb.st_rdev);
1076 if (arcn->sb.st_rdev != (dev_t)(SHRT_EXT(hd->h_rdev)))
1078 hd->h_mtime_1[0] = CHR_WR_0(arcn->sb.st_mtime);
1079 hd->h_mtime_1[1] = CHR_WR_1(arcn->sb.st_mtime);
1080 hd->h_mtime_2[0] = CHR_WR_2(arcn->sb.st_mtime);
1081 hd->h_mtime_2[1] = CHR_WR_3(arcn->sb.st_mtime);
1084 if (arcn->sb.st_mtime != t_timet)
1086 nsz = arcn->nlen + 1;
1096 (wr_rdbuf(arcn->name, nsz) < 0) ||
1099 arcn->org_name);
1106 if ((arcn->type == PAX_CTG) || (arcn->type == PAX_REG) ||
1107 (arcn->type == PAX_HRG))
1113 if (arcn->type != PAX_SLK)
1119 if ((wr_rdbuf(arcn->ln_name, arcn->ln_nlen) < 0) ||
1120 (wr_skip((off_t)(BCPIO_PAD(arcn->ln_nlen))) < 0)) {
1122 arcn->org_name);
1132 arcn->org_name);