Lines Matching defs:arcn

110 file_creat(ARCHD *arcn, int write_to_hardlink)
121 if (arcn->nlen != 0 && arcn->name[arcn->nlen - 1] == '/') {
125 arcn->name);
141 return (open(arcn->name, O_TRUNC | O_EXCL | O_RDWR, 0));
147 arcn->tmp_name = malloc(arcn->nlen + 8);
148 if (arcn->tmp_name == NULL) {
149 syswarn(1, errno, "Cannot malloc %d bytes", arcn->nlen + 8);
154 xtmp_name = arcn->tmp_name;
163 (void)snprintf(arcn->tmp_name, arcn->nlen + 8, "%s.XXXXXX",
164 arcn->name);
165 fd = mkstemp(arcn->tmp_name);
169 if (nodirs || chk_path(arcn->name,arcn->sb.st_uid,arcn->sb.st_gid) < 0) {
171 syswarn(1, oerrno, "Cannot create %s", arcn->tmp_name);
173 free(arcn->tmp_name);
174 arcn->tmp_name = NULL;
188 file_cleanup(ARCHD *arcn, int fd)
195 tmp_name = (arcn->tmp_name != NULL) ? arcn->tmp_name : arcn->name;
202 if (arcn->tmp_name == NULL)
206 if (unlink(arcn->tmp_name) < 0) {
207 syswarn(0, errno, "Cannot unlink %s", arcn->tmp_name);
210 free(arcn->tmp_name);
211 arcn->tmp_name = NULL;
222 file_close(ARCHD *arcn, int fd)
230 tmp_name = (arcn->tmp_name != NULL) ? arcn->tmp_name : arcn->name;
242 res = set_ids(tmp_name, arcn->sb.st_uid, arcn->sb.st_gid);
252 arcn->sb.st_mode &= ~SETBITS(0);
254 set_pmode(tmp_name, arcn->sb.st_mode);
257 apply_umask((arcn->sb.st_mode & FILEBITS(0))));
259 set_ftime(tmp_name, arcn->sb.st_mtime,
260 arcn->sb.st_atime, 0, 0);
263 if (arcn->tmp_name == NULL)
270 if (rename(tmp_name, arcn->name) < 0) {
272 tmp_name, arcn->name);
277 if (pfflags && arcn->type != PAX_SLK)
278 set_chflags(arcn->name, arcn->sb.st_flags);
281 free(arcn->tmp_name);
282 arcn->tmp_name = NULL;
288 * Create a hard link to arcn->ln_name from arcn->name. arcn->ln_name
295 lnk_creat(ARCHD *arcn, int *payload)
305 *payload = S_ISREG(arcn->sb.st_mode) &&
306 (arcn->sb.st_size > 0) && (arcn->sb.st_size <= arcn->skip);
312 if (lstat(arcn->ln_name, &sb) != -1 && S_ISDIR(sb.st_mode)) {
314 arcn->ln_name);
318 return mk_link(arcn->ln_name, &sb, arcn->name, 0);
323 * Create a hard link to arcn->org_name from arcn->name. Only used in copy
332 cross_lnk(ARCHD *arcn)
339 if (arcn->type == PAX_DIR)
341 return mk_link(arcn->org_name, &(arcn->sb), arcn->name, 1);
356 chk_same(ARCHD *arcn)
364 if (lstat(arcn->name, &sb) < 0)
372 if ((arcn->sb.st_dev == sb.st_dev) && (arcn->sb.st_ino == sb.st_ino)) {
374 arcn->name);
465 node_creat(ARCHD *arcn)
474 char *nm = arcn->name;
483 file_mode = arcn->sb.st_mode & FILEBITS(arcn->type == PAX_DIR);
486 switch (arcn->type) {
502 nm, arcn->name);
517 res = mknod(nm, file_mode, arcn->sb.st_rdev);
521 res = mknod(nm, file_mode, arcn->sb.st_rdev);
535 res = symlink(arcn->ln_name, nm);
564 if ((ign = unlnk_exist(nm, arcn->type)) < 0)
570 chk_path(nm, arcn->sb.st_uid,
571 arcn->sb.st_gid) < 0) {
589 res = set_ids(nm, arcn->sb.st_uid, arcn->sb.st_gid);
599 arcn->sb.st_mode &= ~SETBITS(arcn->type == PAX_DIR);
601 set_pmode(arcn->name, arcn->sb.st_mode);
603 if (arcn->type == PAX_DIR && strcmp(NM_CPIO, argv0) != 0) {
616 arcn->name);
626 FILEBITS(arcn->type == PAX_DIR)) |
629 arcn->sb.st_mode = sb.st_mode;
636 add_dir(nm, arcn->nlen, &(arcn->sb), 1);
638 add_dir(nm, arcn->nlen, &(arcn->sb), 0);
642 set_ftime(arcn->name, arcn->sb.st_mtime,
643 arcn->sb.st_atime, 0, (arcn->type == PAX_SLK) ? 1 : 0);
646 if (pfflags && arcn->type != PAX_SLK)
647 set_chflags(arcn->name, arcn->sb.st_flags);
1108 * reset access time (tflag) do so (the times are stored in arcn).
1112 rdfile_close(ARCHD *arcn, int *fd)
1128 set_ftime(arcn->org_name, arcn->sb.st_mtime, arcn->sb.st_atime, 1, 0);
1142 set_crc(ARCHD *arcn, int fd)
1156 arcn->crc = 0L;
1160 if ((size = (u_long)arcn->sb.st_blksize) > (u_long)sizeof(tbuf))
1179 if (cpcnt != arcn->sb.st_size)
1180 tty_warn(1, "File changed size %s", arcn->org_name);
1182 syswarn(1, errno, "Failed stat on %s", arcn->org_name);
1183 else if (arcn->sb.st_mtime != sb.st_mtime)
1184 tty_warn(1, "File %s was modified during read", arcn->org_name);
1186 syswarn(1, errno, "File rewind failed on: %s", arcn->org_name);
1188 arcn->crc = crc;