[dm-crypt] [PATCH] include sys/sysmacros.h for major/minor/makedev

Mike Frysinger vapier at gentoo.org
Tue Apr 19 08:53:44 CEST 2016


On 19 Apr 2016 08:34, Milan Broz wrote:
> On 04/19/2016 08:16 AM, Mike Frysinger wrote:
> > These functions are defined in that header, so include it when needed.
> > Otherwise we can get build failures like:
> > veritysetup-utils_loop.o: In function '_sysfs_backing_file':
> > utils_loop.c:(.text+0x50): undefined reference to 'minor'
> > utils_loop.c:(.text+0x5e): undefined reference to 'major'
> > veritysetup-utils_loop.o: In function 'crypt_loop_device':
> > utils_loop.c:(.text+0x638): undefined reference to 'major'
> > ../lib/.libs/libcryptsetup.so: undefined reference to 'makedev'
> > ---
> >  lib/utils_devpath.c | 1 +
> >  lib/utils_loop.c    | 1 +
> >  lib/utils_wipe.c    | 1 +
> >  3 files changed, 3 insertions(+)
> > 
> > diff --git a/lib/utils_devpath.c b/lib/utils_devpath.c
> > index 963785a..0bc0563 100644
> > --- a/lib/utils_devpath.c
> > +++ b/lib/utils_devpath.c
> > @@ -30,6 +30,7 @@
> >  #include <errno.h>
> >  #include <limits.h>
> >  #include <sys/stat.h>
> > +#include <sys/sysmacros.h>
> 
> Shouldn't we also check for existence of this header in autoconf?
> I do not think it is present on all systems (FreeBSD?).

i couldn't tell how portable this code base was trying to be or if it
was assuming Linux.  if you want to be portable w/autoconf, should be
easy to do:
(1) call AC_HEADER_MAJOR in configure.ac
(2) use the idiom:
#ifdef MAJOR_IN_MKDEV
# include <sys/mkdev.h>
#elif defined(MAJOR_IN_SYSMACROS)
# include <sys/sysmacros.h>
#endif
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://www.saout.de/pipermail/dm-crypt/attachments/20160419/1a93fb79/attachment.asc>


More information about the dm-crypt mailing list