MCPcopy Create free account
hub / github.com/coreutils/coreutils / process_file

Function process_file

src/chmod.c:209–364  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207 once for every file system object that fts encounters. */
208
209static bool
210process_file (FTS *fts, FTSENT *ent)
211{
212 char const *file_full_name = ent->fts_path;
213 char const *file = ent->fts_accpath;
214 const struct stat *file_stats = ent->fts_statp;
215 struct change_status ch = {0};
216 ch.status = CH_NO_STAT;
217 struct stat stat_buf;
218
219 switch (ent->fts_info)
220 {
221 case FTS_DP:
222 return true;
223
224 case FTS_NS:
225 /* For a top-level file or directory, this FTS_NS (stat failed)
226 indicator is determined at the time of the initial fts_open call.
227 With programs like chmod, chown, and chgrp, that modify
228 permissions, it is possible that the file in question is
229 accessible when control reaches this point. So, if this is
230 the first time we've seen the FTS_NS for this file, tell
231 fts_read to stat it "again". */
232 if (ent->fts_level == FTS_ROOTLEVEL && ent->fts_number == 0)
233 {
234 ent->fts_number = 1;
235 fts_set (fts, ent, FTS_AGAIN);
236 return true;
237 }
238 if (! force_silent)
239 error (0, ent->fts_errno, _("cannot access %s"),
240 quoteaf (file_full_name));
241 break;
242
243 case FTS_ERR:
244 if (! force_silent)
245 error (0, ent->fts_errno, "%s", quotef (file_full_name));
246 break;
247
248 case FTS_DNR:
249 if (! force_silent)
250 error (0, ent->fts_errno, _("cannot read directory %s"),
251 quoteaf (file_full_name));
252 break;
253
254 case FTS_SLNONE:
255 if (dereference)
256 {
257 if (! force_silent)
258 error (0, 0, _("cannot operate on dangling symlink %s"),
259 quoteaf (file_full_name));
260 break;
261 }
262 ch.status = CH_NOT_APPLIED;
263 break;
264
265 case FTS_SL:
266 if (dereference == 1)

Callers 1

process_filesFunction · 0.70

Calls 4

cycle_warning_requiredFunction · 0.85
is_ENOTSUPFunction · 0.85
mode_changedFunction · 0.85
describe_changeFunction · 0.70

Tested by

no test coverage detected