Page MenuHomeFreeBSD

Fix bug 200942 - Don't squash fts_children errors

Authored by cse_cem_gmail_com on Jun 17 2015, 10:58 PM.



Preserve errors from fts_* via fts_children by saving errno over
fchdir(2) and close(2).

Diff Detail

rS FreeBSD src repository - subversion
Lint OK
No Unit Test Coverage

Event Timeline

cse_cem_gmail_com retitled this revision from to Fix bug 200942 - Don't squash fts_children errors.
cse_cem_gmail_com updated this object.
cse_cem_gmail_com edited the test plan for this revision. (Show Details)
cse_cem_gmail_com added reviewers: imp, jilles.
cse_cem_gmail_com added subscribers: benno, markj, ngie.

Don't preserve errno from close(2)

We don't return NULL to the caller on close(2) errors, so they have no reason
to check errno anyway.

This revision is now accepted and ready to land.Jun 19 2015, 9:58 PM
jilles requested changes to this revision.Jun 19 2015, 10:08 PM
jilles edited edge metadata.
jilles added inline comments.

This should probably be

serrno = sp->fts_child == NULL ? errno : 0;

since fts_build() may set errno to a non-zero value even if it does not fail (e.g. if symlinks are being followed and there is a dangling symlink (FTS_SLNONE)).

This revision now requires changes to proceed.Jun 19 2015, 10:08 PM
cse_cem_gmail_com edited edge metadata.

Per Jilles' feedback, only set serrno value if fts_build actually fails.


This is maybe now bogus. In particular, the sequence:

  1. fts_build() succeeds but sets errno (symlink case);
  2. fchdir() succeeds and doesn't clear errno
  3. serrno gets the symlink error that we were trying to avoid
cse_cem_gmail_com edited edge metadata.

Address the concern I brought up re: using stale errno value after fchdir(2).

jilles edited edge metadata.

Looks good to me.

This revision is now accepted and ready to land.Jun 20 2015, 10:20 AM

Thanks. Can you commit this for me? I don't have a src bit yet.