Lines Matching refs: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 (!chmod(ent->fts_name, (ent->fts_statp->st_mode & S_IPERM)|S_IRWXU))
127 fts_set(NiL, ent, FTS_AGAIN);
133 error(2, "%s: cannot %s directory", ent->fts_path, (ent->fts_info & FTS_NR) ? "read" : "search");
136 fts_set(NiL, ent, FTS_SKIP);
137 nonempty(ent);
141 path = ent->fts_name;
142 if (path[0] == '.' && (!path[1] || path[1] == '.' && !path[2]) && (ent->fts_level > 0 || path[1]))
144 fts_set(NiL, ent, FTS_SKIP);
146 error(2, "%s: cannot remove", ent->fts_path);
153 fts_set(NiL, ent, FTS_SKIP);
154 error(2, "%s: directory", ent->fts_path);
157 if (!beenhere(ent))
159 if (state->unconditional && (ent->fts_statp->st_mode ^ S_IRWXU))
160 chmod(path, (ent->fts_statp->st_mode & S_IPERM)|S_IRWXU);
161 if (ent->fts_level > 0)
165 if (ent->fts_accpath == ent->fts_name || !(s = strrchr(ent->fts_accpath, '/')))
169 path = ent->fts_accpath;
175 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');
183 if ((v = astquery(-1, "remove directory %s? ", ent->fts_path)) < 0 || sh_checksig(state->context))
187 fts_set(NiL, ent, FTS_SKIP);
188 nonempty(ent);
191 if (ent->fts_info == FTS_D)
196 ent->fts_info = FTS_DC;
197 error(1, "%s: hard link to directory", ent->fts_path);
200 else if (ent->fts_info == FTS_D)
204 if (isempty(ent) || state->directory)
206 path = ent->fts_name;
209 path = ent->fts_accpath;
211 sfputr(sfstdout, ent->fts_path, '\n');
212 if ((ent->fts_info == FTS_DC || state->directory) ? remove(path) : rmdir(path))
221 if (ent->fts_info == FTS_DP && !beenhere(ent))
223 retry(ent);
224 fts_set(NiL, ent, FTS_AGAIN);
229 nonempty(ent);
231 error(ERROR_SYSTEM|2, "%s: directory not removed", ent->fts_path);
238 error(2, "%s: cannot remove", ent->fts_path);
244 nonempty(ent);
246 error(2, "%s: directory not removed", ent->fts_path);
252 path = ent->fts_accpath;
254 sfputr(sfstdout, ent->fts_path, '\n');
257 if ((v = astquery(-1, "remove %s? ", ent->fts_path)) < 0 || sh_checksig(state->context))
261 nonempty(ent);
265 else if (!state->force && state->terminal && S_ISREG(ent->fts_statp->st_mode))
280 ent->fts_statp->st_uid != state->uid ? "``not owner''" :
281 fmtmode(ent->fts_statp->st_mode & S_IPERM, 0) + 1, ent->fts_path)) < 0 ||
286 nonempty(ent);
294 if (state->clobber && S_ISREG(ent->fts_statp->st_mode) && ent->fts_statp->st_size > 0)
297 error(ERROR_SYSTEM|2, "%s: cannot clear data", ent->fts_path);
300 off_t c = ent->fts_statp->st_size;
306 error(ERROR_SYSTEM|2, "%s: data clear error", ent->fts_path);
320 nonempty(ent);
327 error(ERROR_SYSTEM|2, "%s: not removed", ent->fts_path);
343 FTSENT* ent;
416 while (!sh_checksig(context) && (ent = fts_read(fts)) && !rm(&state, ent));