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

Function process_file

src/du.c:537–717  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

535 the depth of the current entry. It returns true on success. */
536
537static bool
538process_file (FTS *fts, FTSENT *ent)
539{
540 bool ok = true;
541 struct duinfo dui;
542 struct duinfo dui_to_print;
543 static idx_t n_alloc;
544 /* First element of the structure contains:
545 The sum of the sizes of all entries in the single directory
546 at the corresponding level. Although this does include the sizes
547 corresponding to each subdirectory, it does not include the size of
548 any file in a subdirectory. Also corresponding last modified date.
549 Second element of the structure contains:
550 The sum of the sizes of all entries in the hierarchy at or below the
551 directory at the specified level. */
552 static struct dulevel *dulvl;
553
554 char const *file = ent->fts_path;
555 const struct stat *sb = ent->fts_statp;
556 int info = ent->fts_info;
557
558 if (info == FTS_DNR)
559 {
560 /* An error occurred, but the size is known, so count it. */
561 error (0, ent->fts_errno, _("cannot read directory %s"), quoteaf (file));
562 ok = false;
563 }
564 else if (info != FTS_DP)
565 {
566 bool excluded = excluded_file_name (exclude, file);
567 if (! excluded)
568 {
569 /* Make the stat buffer *SB valid, or fail noisily. */
570
571 if (info == FTS_NSOK)
572 {
573 fts_set (fts, ent, FTS_AGAIN);
574 MAYBE_UNUSED FTSENT const *e = fts_read (fts);
575 affirm (e == ent);
576 info = ent->fts_info;
577 }
578
579 if (info == FTS_NS || info == FTS_SLNONE)
580 {
581 error (0, ent->fts_errno, _("cannot access %s"), quoteaf (file));
582 return false;
583 }
584
585 /* The --one-file-system (-x) option cannot exclude anything
586 specified on the command-line. By definition, it can exclude
587 a file or directory only when its device number is different
588 from that of its just-processed parent directory, and du does
589 not process the parent of a command-line argument. */
590 if (fts->fts_options & FTS_XDEV
591 && FTS_ROOTLEVEL < ent->fts_level
592 && fts->fts_dev != sb->st_dev)
593 excluded = true;
594 }

Callers 1

du_filesFunction · 0.70

Calls 8

hash_insFunction · 0.85
cycle_warning_requiredFunction · 0.85
mount_point_in_fts_cycleFunction · 0.85
duinfo_setFunction · 0.85
usable_st_sizeFunction · 0.85
duinfo_initFunction · 0.85
duinfo_addFunction · 0.85
print_sizeFunction · 0.85

Tested by

no test coverage detected