Page MenuHomeFreeBSD

Fix bug 200942 - Don't squash fts_children errors
ClosedPublic

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

Details

Summary

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

Diff Detail

Repository
rS FreeBSD src repository
Lint
Lint OK
Unit
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.

cse_cem_gmail_com edited the test plan for this revision. (Show Details)Jun 19 2015, 12:28 AM
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.
lib/libc/gen/fts.c
574–577

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.

cse_cem_gmail_com marked an inline comment as done.Jun 19 2015, 10:22 PM

Thanks!

lib/libc/gen/fts.c
574–581

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 accepted this revision.Jun 20 2015, 10:20 AM
jilles edited edge metadata.

Looks good to me.

This revision is now accepted and ready to land.Jun 20 2015, 10:20 AM
cse_cem_gmail_com marked an inline comment as done.Jun 20 2015, 3:50 PM

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

jilles closed this revision.Jun 20 2015, 10:17 PM

Committed to head.