GNOME Bugzilla – Bug 776213
metadata build/link failures on Solaris for major()/minor()
Last modified: 2017-01-06 15:26:48 UTC
Building on Solaris fails with: metatree.c: In function ‘get_tree_for_device’: metatree.c:2854:55: warning: implicit declaration of function ‘major’ [-Wimplicit-function-declaration] major (device), ^ metatree.c:2855:55: warning: implicit declaration of function ‘minor’ [-Wimplicit-function-declaration] minor (device), ^ Undefined first referenced symbol in file major ./.libs/libmetadata.a(metatree.o) minor ./.libs/libmetadata.a(metatree.o) ld: fatal: symbol referencing errors collect2: error: ld returned 1 exit status On Solaris, you need to #include <sys/mkdev.h> to define the major() and minor() macros for device nodes.
Created attachment 342125 [details] [review] Patch currently used in Solaris builds
Review of attachment 342125 [details] [review]: Thanks for the patch, can you please update the patch per my review? ::: configure.ac @@ +761,3 @@ dnl Look for various fs info getters +AC_CHECK_HEADERS([sys/statfs.h sys/statvfs.h sys/vfs.h sys/mount.h sys/param.h sys/mkdev.h]) We should rather use AC_HEADER_MAJOR for this, see: https://www.gnu.org/software/autoconf/manual/autoconf.html#index-AC_005fHEADER_005fMAJOR-616 ::: metadata/metatree.c @@ +12,3 @@ +#if HAVE_SYS_MKDEV_H +#include <sys/mkdev.h> /* needed for major() & minor() on Solaris */ +#endif Hmm, we should probably include "sys/sysmacros.h" also in other cases for sure, so something like the following: #if MAJOR_IN_MKDEV #include <sys/mkdev.h> #elif MAJOR_IN_SYSMACROS #include <sys/sysmacros.h> #endif
*** Bug 776532 has been marked as a duplicate of this bug. ***
The header files need to be included also in meta-daemon.c because of makedev(). See the duplicated bug.
Created attachment 342708 [details] [review] metadata: Include headers for device number functionality The implicit sys/sysmacros.h (resp. sys/mkdev.h) includes via sys/types.h is being deprecated. Use AC_HEADER_MAJOR and include necessary header files for major(), minor(), and makedev() functions.
Guys, can you please check that this fixes your problems?
(In reply to Ondrej Holy from comment #6) > Guys, can you please check that this fixes your problems? Thanks - this solves the problem on Solaris and looks better than my patch.
Thanks for testing! Attachment 342708 [details] pushed as 3424bef - metadata: Include headers for device number functionality