Lines Matching refs:ent

218 visit(State_t* state, register FTSENT* ent)
237 if (ent->fts_info == FTS_DC)
239 error(2, "%s: directory causes cycle", ent->fts_path);
240 fts_set(NiL, ent, FTS_SKIP);
243 if (ent->fts_level == 0)
245 base = ent->fts_name;
246 len = ent->fts_namelen;
251 state->presiz = ent->fts_pathlen;
257 state->presiz -= base - ent->fts_name;
258 base = ent->fts_name + len;
259 while (base > ent->fts_name && *(base - 1) == '/')
261 while (base > ent->fts_name && *(base - 1) != '/')
263 len -= base - ent->fts_name;
270 base = ent->fts_path + state->presiz + 1;
271 len = ent->fts_pathlen - state->presiz - 1;
278 if (state->hierarchy && ent->fts_level == 0 && strchr(base, '/'))
296 error(ERROR_SYSTEM|2, "%s: cannot create directory -- %s ignored", state->path, ent->fts_path);
297 fts_set(NiL, ent, FTS_SKIP);
306 switch (ent->fts_info)
309 if (state->preserve && state->op != LN || ent->fts_level > 0 && (ent->fts_statp->st_mode & S_IRWXU) != S_IRWXU)
311 if (len && ent->fts_level > 0)
319 if ((ent->fts_statp->st_mode & S_IPERM) != (st.st_mode & S_IPERM) && chmod(state->path, ent->fts_statp->st_mode & S_IPERM))
322 preserve(state, state->path, &st, ent->fts_statp);
331 fts_set(NiL, ent, FTS_SKIP);
333 error(1, "%s: directory -- copying as plain file", ent->fts_path);
336 error(2, "%s: cannot link directory", ent->fts_path);
340 else switch (ent->fts_info)
343 error(2, "%s: cannot read directory", ent->fts_path);
346 error(2, "%s: cannot search directory", ent->fts_path);
347 fts_set(NiL, ent, FTS_SKIP);
357 error(2, "%s: not a directory -- %s ignored", state->path, ent->fts_path);
361 else if (mkdir(state->path, (ent->fts_statp->st_mode & S_IPERM)|(ent->fts_info == FTS_D ? S_IRWXU : 0)))
363 error(ERROR_SYSTEM|2, "%s: cannot create directory -- %s ignored", state->path, ent->fts_path);
364 fts_set(NiL, ent, FTS_SKIP);
380 error(2, "%s: not found", ent->fts_path);
388 error(2, "%s: cannot copy non-terminal symbolic link", ent->fts_path);
398 else if (state->update && !S_ISDIR(st.st_mode) && (unsigned long)ent->fts_statp->st_mtime < (unsigned long)st.st_mtime)
400 fts_set(NiL, ent, FTS_SKIP);
409 if (st.st_dev == ent->fts_statp->st_dev && st.st_ino == ent->fts_statp->st_ino)
422 error(2, "%s: identical to %s", state->path, ent->fts_path);
432 rm = state->op == LN || ent->fts_info == FTS_SL;
535 if (!rename(ent->fts_path, state->path))
544 if (errno != EXDEV && (rm || S_ISDIR(ent->fts_statp->st_mode)))
546 error(ERROR_SYSTEM|2, "%s: cannot rename to %s", ent->fts_path, state->path);
554 if (S_ISLNK(ent->fts_statp->st_mode))
556 if ((n = pathgetlink(ent->fts_path, state->text, sizeof(state->text) - 1)) < 0)
558 error(ERROR_SYSTEM|2, "%s: cannot read symbolic link text", ent->fts_path);
564 error(ERROR_SYSTEM|2, "%s: cannot copy symbolic link to %s", ent->fts_path, state->path);
568 else if (state->op == CP || S_ISREG(ent->fts_statp->st_mode) || S_ISDIR(ent->fts_statp->st_mode))
570 if (ent->fts_statp->st_size > 0 && (rfd = open(ent->fts_path, O_RDONLY|O_BINARY)) < 0)
572 error(ERROR_SYSTEM|2, "%s: cannot read", ent->fts_path);
575 else if ((wfd = open(state->path, st.st_mode ? (state->wflags & ~O_EXCL) : state->wflags, ent->fts_statp->st_mode & state->perm)) < 0)
578 if (ent->fts_statp->st_size > 0)
582 else if (ent->fts_statp->st_size > 0)
586 error(ERROR_SYSTEM|2, "%s: %s read stream error", ent->fts_path, state->path);
595 error(ERROR_SYSTEM|2, "%s: %s write stream error", ent->fts_path, state->path);
610 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"));
617 else if (S_ISBLK(ent->fts_statp->st_mode) || S_ISCHR(ent->fts_statp->st_mode) || S_ISFIFO(ent->fts_statp->st_mode))
619 if (mknod(state->path, ent->fts_statp->st_mode, idevice(ent->fts_statp)))
621 error(ERROR_SYSTEM|2, "%s: cannot copy special file to %s", ent->fts_path, state->path);
627 error(2, "%s: cannot copy -- unknown file type 0%o", ent->fts_path, S_ITYPE(ent->fts_statp->st_mode));
632 if (ent->fts_info != FTS_SL)
638 if ((ent->fts_statp->st_mode & state->perm) != (st.st_mode & state->perm) && chmod(state->path, ent->fts_statp->st_mode & state->perm))
640 preserve(state, state->path, &st, ent->fts_statp);
643 if (state->op == MV && remove(ent->fts_path))
644 error(ERROR_SYSTEM|1, "%s: cannot remove", ent->fts_path);
648 if ((*state->link)(ent->fts_path, state->path))
649 error(ERROR_SYSTEM|2, "%s: cannot link to %s", ent->fts_path, state->path);
663 FTSENT* ent;
925 while (!sh_checksig(context) && (ent = fts_read(fts)) && !visit(state, ent));