From nobody@FreeBSD.org  Tue Jul 27 23:28:46 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 654F81065677
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 27 Jul 2010 23:28:46 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 53F2E8FC08
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 27 Jul 2010 23:28:46 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o6RNSkSw024640
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 27 Jul 2010 23:28:46 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o6RNSkYR024639;
	Tue, 27 Jul 2010 23:28:46 GMT
	(envelope-from nobody)
Message-Id: <201007272328.o6RNSkYR024639@www.freebsd.org>
Date: Tue, 27 Jul 2010 23:28:46 GMT
From: Tuco <tuco.xyz@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: make ZFS makefiles use the libraries from build directory
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         149014
>Category:       kern
>Synopsis:       [zfs] [patch] declarations in ZFS libraries/utilities collide with glibc namespace
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-fs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jul 27 23:30:01 UTC 2010
>Closed-Date:    
>Last-Modified:  Wed Jul 28 02:15:45 UTC 2010
>Originator:     Tuco
>Release:        Debian GNU/kFreeBSD
>Organization:
>Environment:
>Description:

Hello

A few declarations in ZFS libraries/utilities collide with Glibc namespace,
making it impossible to compile on GNU environment.

Here is a patch that either renames them or avoids the conflict with
preprocessor checks.

>How-To-Repeat:

>Fix:


Patch attached with submission follows:

diff -ur cddl/compat/opensolaris/include/solaris.h cddl/compat/opensolaris/include/solaris.h
--- cddl/compat/opensolaris/include/solaris.h	2008-04-22 03:43:00.000000000 -0400
+++ cddl/compat/opensolaris/include/solaris.h	2010-07-26 19:18:00.428981335 -0400
@@ -5,6 +5,9 @@
 
 #include <sys/ccompile.h>
 
+/* GNU libc has its own dirent64 declaration */
+#ifndef __GLIBC__
 #define	dirent64	dirent
+#endif
 
 #endif	/* !_SOLARIS_H_ */
diff -ur cddl/compat/opensolaris/misc/fsshare.c cddl/compat/opensolaris/misc/fsshare.c
--- cddl/compat/opensolaris/misc/fsshare.c	2008-03-28 18:16:18.000000000 -0400
+++ cddl/compat/opensolaris/misc/fsshare.c	2010-07-26 19:48:58.456848324 -0400
@@ -67,7 +70,7 @@
  * mountpoint specified in the 'skip' argument.
  */
 static char *
-getline(FILE *fd, const char *skip)
+xgetline(FILE *fd, const char *skip)
 {
 	static char line[MAXLINESIZE];
 	size_t len, skiplen;
@@ -198,7 +201,7 @@
 
 	/* Place big, fat warning at the begining of the file. */
 	fprintf(newfd, "%s", FILE_HEADER);
-	while (oldfd != NULL && (line = getline(oldfd, mountpoint)) != NULL)
+	while (oldfd != NULL && (line = xgetline(oldfd, mountpoint)) != NULL)
 		fprintf(newfd, "%s\n", line);
 	if (oldfd != NULL && ferror(oldfd) != 0) {
 		error = ferror(oldfd);
diff -ur cddl/compat/opensolaris/misc/mnttab.c cddl/compat/opensolaris/misc/mnttab.c
--- cddl/compat/opensolaris/misc/mnttab.c	2008-11-17 15:49:29.000000000 -0500
+++ cddl/compat/opensolaris/misc/mnttab.c	2010-07-26 18:46:46.354168277 -0400
@@ -63,7 +63,7 @@
 }
 
 char *
-hasmntopt(struct mnttab *mnt, char *opt)
+solaris_hasmntopt(struct mnttab *mnt, char *opt)
 {
 	char tmpopts[MNT_LINE_MAX];
 	char *f, *opts = tmpopts;
diff -ur cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c
--- cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c	2008-11-17 15:49:29.000000000 -0500
+++ cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c	2010-07-26 18:46:46.353151407 -0400
@@ -2166,11 +2166,11 @@
 	case ZFS_PROP_NBMAND:
 		*val = getprop_uint64(zhp, prop, source);
 
-		if (hasmntopt(&mnt, mntopt_on) && !*val) {
+		if (solaris_hasmntopt(&mnt, mntopt_on) && !*val) {
 			*val = B_TRUE;
 			if (src)
 				*src = ZPROP_SRC_TEMPORARY;
-		} else if (hasmntopt(&mnt, mntopt_off) && *val) {
+		} else if (solaris_hasmntopt(&mnt, mntopt_off) && *val) {
 			*val = B_FALSE;
 			if (src)
 				*src = ZPROP_SRC_TEMPORARY;
diff -ur cddl/contrib/opensolaris/lib/libzpool/common/kernel.c cddl/contrib/opensolaris/lib/libzpool/common/kernel.c
--- cddl/contrib/opensolaris/lib/libzpool/common/kernel.c	2009-07-09 16:22:05.000000000 -0400
+++ cddl/contrib/opensolaris/lib/libzpool/common/kernel.c	2010-07-26 18:46:46.363308187 -0400
@@ -463,7 +463,7 @@
 /*ARGSUSED*/
 int
 vn_rdwr(int uio, vnode_t *vp, void *addr, ssize_t len, offset_t offset,
-	int x1, int x2, rlim64_t x3, void *x4, ssize_t *residp)
+	int x1, int x2, solaris_rlim64_t x3, void *x4, ssize_t *residp)
 {
 	ssize_t iolen, split;
 
diff -ur cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h
--- cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h	2009-07-09 16:22:05.000000000 -0400
+++ cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h	2010-07-26 18:46:46.368459207 -0400
@@ -105,8 +105,8 @@
 
 #define	ZFS_LOG(...)	do {  } while (0)
 
-typedef u_longlong_t      rlim64_t;
-#define	RLIM64_INFINITY	((rlim64_t)-3)
+typedef u_longlong_t      solaris_rlim64_t;
+#define	RLIM64_INFINITY	((solaris_rlim64_t)-3)
 
 #ifdef ZFS_DEBUG
 extern void dprintf_setup(int *argc, char **argv);
@@ -438,7 +438,7 @@
 extern int vn_openat(char *path, int x1, int oflags, int mode, vnode_t **vpp,
     int x2, int x3, vnode_t *vp, int fd);
 extern int vn_rdwr(int uio, vnode_t *vp, void *addr, ssize_t len,
-    offset_t offset, int x1, int x2, rlim64_t x3, void *x4, ssize_t *residp);
+    offset_t offset, int x1, int x2, solaris_rlim64_t x3, void *x4, ssize_t *residp);
 extern void vn_close(vnode_t *vp, int openflag, cred_t *cr, kthread_t *td);
 
 #define	vn_remove(path, x1, x2)		remove(path)
diff -ur sys/cddl/compat/opensolaris/sys/dirent.h sys/cddl/compat/opensolaris/sys/dirent.h
--- sys/cddl/compat/opensolaris/sys/dirent.h	2008-03-28 18:16:18.000000000 -0400
+++ sys/cddl/compat/opensolaris/sys/dirent.h	2010-07-26 19:18:26.928512005 -0400
@@ -32,7 +32,10 @@
 #include_next <sys/dirent.h>
 
 typedef	struct dirent	dirent64_t;
+/* GNU libc has its own dirent64 declaration */
+#ifndef __GLIBC__
 #define	dirent64	dirent
+#endif
 #define	ino64_t		ino_t
 
 #define	d_ino	d_fileno
diff -ur sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
--- sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c	2009-10-12 16:36:55.000000000 -0400
+++ sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c	2010-07-26 18:46:46.380558137 -0400
@@ -677,7 +677,7 @@
 zfs_write(vnode_t *vp, uio_t *uio, int ioflag, cred_t *cr, caller_context_t *ct)
 {
 	znode_t		*zp = VTOZ(vp);
-	rlim64_t	limit = MAXOFFSET_T;
+	solaris_rlim64_t	limit = MAXOFFSET_T;
 	ssize_t		start_resid = uio->uio_resid;
 	ssize_t		tx_bytes;
 	uint64_t	end_size;


>Release-Note:
>Audit-Trail:

From: Tuco <tuco.xyz@gmail.com>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: misc/149014: make ZFS makefiles use the libraries from build 
	directory
Date: Wed, 28 Jul 2010 01:39:33 +0200

 Ops, I typed the wrong subject. This PR is about namespace collisions
 with Glibc (see description).
 
 Sorry!
Responsible-Changed-From-To: freebsd-bugs->freebsd-fs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Wed Jul 28 02:15:10 UTC 2010 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=149014 
>Unformatted:
