Changeset 1075


Ignore:
Timestamp:
Jul 15, 2007, 8:22:00 PM (18 years ago)
Author:
bird
Message:

Workaround for readdir on smbfs drive. (FreeBSD)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/dir.c

    r1074 r1075  
    4242# endif /* HAVE_VMSDIR_H */
    4343#endif
     44/* bird: FreeBSD + smbfs -> readdir() + EBADF */
     45#ifdef __FreeBSD__
     46# include <sys/mount.h>
     47#endif
     48/* bird: end */
    4449
    4550/* In GNU systems, <dirent.h> defines this macro for us.  */
     
    679684      if (d == 0)
    680685        {
     686/* bird: Workaround for smbfs mounts returning EBADF at the end of the search.
     687         To exactly determin the cause here, I should probably do some smbfs
     688         tracing, but for now just ignoring the EBADF on seems to work.
     689         (The smb server is 64-bit vista, btw.) */
     690#if defined (__FreeBSD__)
     691          struct statfs stfs;
     692          int saved_errno = errno;
     693          errno = 0;
     694          if (saved_errno == EBADF
     695           && !fstatfs (dirfd (dir->dirstream), &stfs)
     696           && !(stfs.f_flags & MNT_LOCAL)
     697           && !strcmp(stfs.f_fstypename, "smbfs"))
     698            {
     699              /*fprintf (stderr, "EBADF on remote fs! dirfd=%d errno=%d\n",
     700                       dirfd (dir->dirstream), errno);*/
     701              saved_errno = 0;
     702            }
     703          errno = saved_errno;
     704#endif
     705/* bird: end */
    681706          if (errno)
    682707            fatal (NILF, "INTERNAL: readdir(%p): %s (filename=%s)\n", dir, strerror (errno), filename);
Note: See TracChangeset for help on using the changeset viewer.