Lines Matching defs:ent
105 rm(State_t* state, register FTSENT* ent)
112 if (ent->fts_info == FTS_NS || ent->fts_info == FTS_ERR || ent->fts_info == FTS_SLNONE)
115 error(2, "%s: not found", ent->fts_path);
117 else if (state->fs3d && iview(ent->fts_statp))
118 fts_set(NiL, ent, FTS_SKIP);
119 else switch (ent->fts_info)
125 if (!beenhere(ent))
127 if (!chmod(ent->fts_name, (ent->fts_statp->st_mode & S_IPERM)|S_IRWXU))
129 fts_set(NiL, ent, FTS_AGAIN);
135 error(2, "%s: cannot %s directory", ent->fts_path, (ent->fts_info & FTS_NR) ? "read" : "search");
138 fts_set(NiL, ent, FTS_SKIP);
139 nonempty(ent);
143 path = ent->fts_name;
144 if (path[0] == '.' && (!path[1] || path[1] == '.' && !path[2]) && (ent->fts_level > 0 || path[1]))
146 fts_set(NiL, ent, FTS_SKIP);
148 error(2, "%s: cannot remove", ent->fts_path);
155 fts_set(NiL, ent, FTS_SKIP);
156 error(2, "%s: directory", ent->fts_path);
159 if (!beenhere(ent))
161 if (state->unconditional && (ent->fts_statp->st_mode & S_IRWXU) != S_IRWXU)
162 chmod(path, (ent->fts_statp->st_mode & S_IPERM)|S_IRWXU);
163 if (ent->fts_level > 0)
167 if (ent->fts_accpath == ent->fts_name || !(s = strrchr(ent->fts_accpath, '/')))
171 path = ent->fts_accpath;
177 v = st.st_nlink <= 2 || st.st_ino == ent->fts_parent->fts_statp->st_ino && st.st_dev == ent->fts_parent->fts_statp->st_dev || strchr(astconf("PATH_ATTRIBUTES", path, NiL), 'l');
185 if ((v = astquery(-1, "remove directory %s? ", ent->fts_path)) < 0 || sh_checksig(state->context))
189 fts_set(NiL, ent, FTS_SKIP);
190 nonempty(ent);
193 if (ent->fts_info == FTS_D)
198 ent->fts_info = FTS_DC;
199 error(1, "%s: hard link to directory", ent->fts_path);
202 else if (ent->fts_info == FTS_D)
206 if (isempty(ent) || state->directory)
208 path = ent->fts_name;
211 path = ent->fts_accpath;
213 sfputr(sfstdout, ent->fts_path, '\n');
214 if ((ent->fts_info == FTS_DC || state->directory) ? remove(path) : rmdir(path))
223 if (ent->fts_info == FTS_DP && !beenhere(ent))
225 retry(ent);
226 fts_set(NiL, ent, FTS_AGAIN);
231 nonempty(ent);
233 error(ERROR_SYSTEM|2, "%s: directory not removed", ent->fts_path);
240 error(2, "%s: cannot remove", ent->fts_path);
246 nonempty(ent);
248 error(2, "%s: directory not removed", ent->fts_path);
254 path = ent->fts_accpath;
256 sfputr(sfstdout, ent->fts_path, '\n');
259 if ((v = astquery(-1, "remove %s? ", ent->fts_path)) < 0 || sh_checksig(state->context))
263 nonempty(ent);
273 ent->fts_statp->st_uid != state->uid ? "``not owner''" :
274 fmtmode(ent->fts_statp->st_mode & S_IPERM, 0) + 1, ent->fts_path)) < 0 ||
279 nonempty(ent);
284 if (state->clobber && S_ISREG(ent->fts_statp->st_mode) && ent->fts_statp->st_size > 0)
287 error(ERROR_SYSTEM|2, "%s: cannot clear data", ent->fts_path);
290 off_t c = ent->fts_statp->st_size;
296 error(ERROR_SYSTEM|2, "%s: data clear error", ent->fts_path);
310 nonempty(ent);
317 error(ERROR_SYSTEM|2, "%s: not removed", ent->fts_path);
333 FTSENT* ent;
406 while (!sh_checksig(context) && (ent = fts_read(fts)) && !rm(&state, ent));