Author: mjg
Date: Fri Jan 17 14:40:09 2020
New Revision: 356829
URL: https://svnweb.freebsd.org/changeset/base/356829

Log:
  libc: assume no union stack if fstatfs fails in readdir
  
  The failure is not really expected, but should it happen it's better to
  get some data.
  
  Suggested by: kib

Modified:
  head/lib/libc/gen/opendir.c

Modified: head/lib/libc/gen/opendir.c
==============================================================================
--- head/lib/libc/gen/opendir.c Fri Jan 17 14:39:00 2020        (r356828)
+++ head/lib/libc/gen/opendir.c Fri Jan 17 14:40:09 2020        (r356829)
@@ -283,7 +283,7 @@ __opendir_common(int fd, int flags, bool use_current_p
        DIR *dirp;
        int incr;
        int saved_errno;
-       int unionstack;
+       bool unionstack;
 
        if ((dirp = malloc(sizeof(DIR) + sizeof(struct _telldir))) == NULL)
                return (NULL);
@@ -310,15 +310,14 @@ __opendir_common(int fd, int flags, bool use_current_p
        /*
         * Determine whether this directory is the top of a union stack.
         */
+       unionstack = false;
        if (flags & DTF_NODUP) {
                struct statfs sfb;
 
-               if (_fstatfs(fd, &sfb) < 0)
-                       goto fail;
-               unionstack = !strcmp(sfb.f_fstypename, "unionfs")
-                   || (sfb.f_flags & MNT_UNION);
-       } else {
-               unionstack = 0;
+               if (_fstatfs(fd, &sfb) == 0) {
+                       unionstack = strcmp(sfb.f_fstypename, "unionfs") == 0 ||
+                           (sfb.f_flags & MNT_UNION);
+               }
        }
 
        if (unionstack) {
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to