s4/pvfs: handle non-POSIX compliant Tru64, NetBSD and FreeBSD errno on O_NOFOLLOW...
authorBjörn Jacke <bj@sernet.de>
Sun, 10 Jun 2012 18:17:44 +0000 (20:17 +0200)
committerBjoern Jacke <bj@sernet.de>
Sun, 10 Jun 2012 19:38:08 +0000 (21:38 +0200)
see also f75f1d62339f0accb4e574645b1d265c75a01b5b

source4/ntvfs/posix/pvfs_sys.c

index 9112848bfef32380091ab3dbef88e542da6f7846..5775d0bb7790a7e93358deed8d70f1d57567b62d 100644 (file)
@@ -405,11 +405,32 @@ int pvfs_sys_unlink(struct pvfs_state *pvfs, const char *filename, bool allow_ov
 static bool contains_symlink(const char *path)
 {
        int fd = open(path, PVFS_NOFOLLOW | O_RDONLY);
+       int posix_errno = errno;
        if (fd != -1) {
                close(fd);
                return false;
        }
-       return (errno == ELOOP);
+
+#if defined(ENOTSUP) && defined(OSF1)
+       /* handle special Tru64 errno */
+       if (errno == ENOTSUP) {
+               posix_errno = ELOOP;
+       }
+#endif /* ENOTSUP */
+
+#ifdef EFTYPE
+       /* fix broken NetBSD errno */
+       if (errno == EFTYPE) {
+               posix_errno = ELOOP;
+       }
+#endif /* EFTYPE */
+
+       /* fix broken FreeBSD errno */
+       if (errno == EMLINK) {
+               posix_errno = ELOOP;
+       }
+
+       return (posix_errno == ELOOP);
 }
 
 /*