Lines Matching defs:ent

236 visit(State_t* state, register FTSENT* ent)
255 if (ent->fts_info == FTS_DC)
257 error(2, "%s: directory causes cycle", ent->fts_path);
258 fts_set(NiL, ent, FTS_SKIP);
261 if (ent->fts_level == 0)
263 base = ent->fts_name;
264 len = ent->fts_namelen;
269 state->presiz = ent->fts_pathlen;
275 state->presiz -= base - ent->fts_name;
276 base = ent->fts_name + len;
277 while (base > ent->fts_name && *(base - 1) == '/')
279 while (base > ent->fts_name && *(base - 1) != '/')
281 len -= base - ent->fts_name;
288 base = ent->fts_path + state->presiz + 1;
289 len = ent->fts_pathlen - state->presiz - 1;
296 if (state->hierarchy && ent->fts_level == 0 && strchr(base, '/'))
314 error(ERROR_SYSTEM|2, "%s: cannot create directory -- %s ignored", state->path, ent->fts_path);
315 fts_set(NiL, ent, FTS_SKIP);
324 switch (ent->fts_info)
327 if (state->preserve && state->op != LN || ent->fts_level > 0 && (ent->fts_statp->st_mode & S_IRWXU) != S_IRWXU)
329 if (len && ent->fts_level > 0)
337 if ((ent->fts_statp->st_mode & S_IPERM) != (st.st_mode & S_IPERM) && chmod(state->path, ent->fts_statp->st_mode & S_IPERM))
340 preserve(state, state->path, &st, ent->fts_statp);
349 fts_set(NiL, ent, FTS_SKIP);
351 error(1, "%s: directory -- copying as plain file", ent->fts_path);
354 error(2, "%s: cannot link directory", ent->fts_path);
358 else switch (ent->fts_info)
361 error(2, "%s: cannot read directory", ent->fts_path);
364 error(2, "%s: cannot search directory", ent->fts_path);
365 fts_set(NiL, ent, FTS_SKIP);
375 error(2, "%s: not a directory -- %s ignored", state->path, ent->fts_path);
379 else if (mkdir(state->path, (ent->fts_statp->st_mode & S_IPERM)|(ent->fts_info == FTS_D ? S_IRWXU : 0)))
381 error(ERROR_SYSTEM|2, "%s: cannot create directory -- %s ignored", state->path, ent->fts_path);
382 fts_set(NiL, ent, FTS_SKIP);
398 error(2, "%s: not found", ent->fts_path);
406 error(2, "%s: cannot copy non-terminal symbolic link", ent->fts_path);
416 else if (state->update && !S_ISDIR(st.st_mode) && (unsigned long)ent->fts_statp->st_mtime < (unsigned long)st.st_mtime)
418 fts_set(NiL, ent, FTS_SKIP);
427 if (state->op != LN && st.st_dev == ent->fts_statp->st_dev && st.st_ino == ent->fts_statp->st_ino)
440 error(2, "%s: identical to %s", state->path, ent->fts_path);
450 rm = state->remove || ent->fts_info == FTS_SL;
558 if (!rename(ent->fts_path, state->path))
567 if (errno != EXDEV && (rm || S_ISDIR(ent->fts_statp->st_mode)))
569 error(ERROR_SYSTEM|2, "%s: cannot rename to %s", ent->fts_path, state->path);
577 if (S_ISLNK(ent->fts_statp->st_mode))
579 if ((n = pathgetlink(ent->fts_path, state->text, sizeof(state->text) - 1)) < 0)
581 error(ERROR_SYSTEM|2, "%s: cannot read symbolic link text", ent->fts_path);
587 error(ERROR_SYSTEM|2, "%s: cannot copy symbolic link to %s", ent->fts_path, state->path);
591 else if (state->op == CP || S_ISREG(ent->fts_statp->st_mode) || S_ISDIR(ent->fts_statp->st_mode))
593 if (ent->fts_statp->st_size > 0 && (rfd = open(ent->fts_path, O_RDONLY|O_BINARY|O_cloexec)) < 0)
595 error(ERROR_SYSTEM|2, "%s: cannot read", ent->fts_path);
598 else if ((wfd = open(state->path, (st.st_mode ? (state->wflags & ~O_EXCL) : state->wflags)|O_cloexec, ent->fts_statp->st_mode & state->perm)) < 0)
601 if (ent->fts_statp->st_size > 0)
605 else if (ent->fts_statp->st_size > 0)
609 error(ERROR_SYSTEM|2, "%s: %s read stream error", ent->fts_path, state->path);
616 error(ERROR_SYSTEM|2, "%s: %s write stream error", ent->fts_path, state->path);
632 error(ERROR_SYSTEM|2, "%s: %s %s error", ent->fts_path, state->path, n == 1 ? ERROR_translate(0, 0, 0, "read") : n == 2 ? ERROR_translate(0, 0, 0, "write") : ERROR_translate(0, 0, 0, "io"));
639 else if (S_ISBLK(ent->fts_statp->st_mode) || S_ISCHR(ent->fts_statp->st_mode) || S_ISFIFO(ent->fts_statp->st_mode))
641 if (mknod(state->path, ent->fts_statp->st_mode, idevice(ent->fts_statp)))
643 error(ERROR_SYSTEM|2, "%s: cannot copy special file to %s", ent->fts_path, state->path);
649 error(2, "%s: cannot copy -- unknown file type 0%o", ent->fts_path, S_ITYPE(ent->fts_statp->st_mode));
654 if (ent->fts_info != FTS_SL)
660 if ((state->preserve & PRESERVE_PERM) && (ent->fts_statp->st_mode & state->perm) != (st.st_mode & state->perm) && chmod(state->path, ent->fts_statp->st_mode & state->perm))
663 preserve(state, state->path, &st, ent->fts_statp);
666 if (state->op == MV && remove(ent->fts_path))
667 error(ERROR_SYSTEM|1, "%s: cannot remove", ent->fts_path);
671 if ((*state->link)(ent->fts_path, state->path))
672 error(ERROR_SYSTEM|2, "%s: cannot link to %s", ent->fts_path, state->path);
686 FTSENT* ent;
988 while (!sh_checksig(context) && (ent = fts_read(fts)) && !visit(state, ent));