summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2004-03-19 19:29:17 -0500
committerTheodore Ts'o <tytso@mit.edu>2004-03-19 19:29:17 -0500
commit84ea6e70b77090c8a35702b265039d58c2efd6ad (patch)
tree6f7bc46bf1150664dd4fc7c04ecb636d8460c402
parent39595ce86c1567461ef699995f659c4c7721e2a3 (diff)
downloade2fsprogs-84ea6e70b77090c8a35702b265039d58c2efd6ad.tar.gz
Fix Darwin/Mac OS X support to fetch the ethernet address in the uuid library.
-rw-r--r--configure65
-rw-r--r--configure.in18
-rw-r--r--lib/uuid/gen_uuid.c17
3 files changed, 82 insertions, 18 deletions
diff --git a/configure b/configure
index 5315b2c5..9ef11801 100644
--- a/configure
+++ b/configure
@@ -5272,7 +5272,7 @@ test -n "$BUILD_CC" && break
done
fi
-for ac_hdr in stdlib.h unistd.h stdarg.h errno.h malloc.h mntent.h paths.h dirent.h getopt.h setjmp.h signal.h termios.h linux/fd.h linux/major.h sys/disk.h sys/disklabel.h sys/ioctl.h sys/mkdev.h sys/mount.h sys/sockio.h sys/socket.h sys/sysmacros.h sys/time.h sys/stat.h sys/types.h sys/wait.h sys/resource.h net/if.h netinet/in.h
+for ac_hdr in stdlib.h unistd.h stdarg.h errno.h malloc.h mntent.h paths.h dirent.h getopt.h setjmp.h signal.h termios.h linux/fd.h linux/major.h sys/disk.h sys/disklabel.h sys/ioctl.h sys/mkdev.h sys/mount.h sys/sockio.h sys/socket.h sys/sysmacros.h sys/time.h sys/stat.h sys/types.h sys/wait.h sys/resource.h net/if.h net/if_dl.h netinet/in.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
@@ -5946,15 +5946,50 @@ EOF
fi
fi
+echo $ac_n "checking whether struct sockaddr contains sa_len""... $ac_c" 1>&6
+echo "configure:5951: checking whether struct sockaddr contains sa_len" >&5
+if eval "test \"`echo '$''{'e2fsprogs_cv_sockaddr_sa_len'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 5956 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <sys/socket.h>
+
+int main() {
+struct sockaddr sa;
+sa.sa_len;
+; return 0; }
+EOF
+if { (eval echo configure:5966: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ e2fsprogs_cv_sockaddr_sa_len=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ e2fsprogs_cv_sockaddr_sa_len=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$e2fsprogs_cv_sockaddr_sa_len" 1>&6
+if test $e2fsprogs_cv_sockaddr_sa_len = yes; then
+ cat >> confdefs.h <<EOF
+#define HAVE_SA_LEN 1
+EOF
+
+fi
for ac_func in chflags getrusage llseek lseek64 open64 getmntinfo strtoull strcasecmp srandom fchown mallinfo fdatasync strnlen strptime sysconf pathconf posix_memalign memalign valloc
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:5953: checking for $ac_func" >&5
+echo "configure:5988: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 5958 "configure"
+#line 5993 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -5977,7 +6012,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:5981: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6016: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -6003,7 +6038,7 @@ done
SOCKET_LIB=''
echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6
-echo "configure:6007: checking for socket in -lsocket" >&5
+echo "configure:6042: checking for socket in -lsocket" >&5
ac_lib_var=`echo socket'_'socket | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -6011,7 +6046,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lsocket $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 6015 "configure"
+#line 6050 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -6022,7 +6057,7 @@ int main() {
socket()
; return 0; }
EOF
-if { (eval echo configure:6026: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6061: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -6045,7 +6080,7 @@ fi
DLOPEN_LIB=''
echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
-echo "configure:6049: checking for dlopen in -ldl" >&5
+echo "configure:6084: checking for dlopen in -ldl" >&5
ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -6053,7 +6088,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-ldl $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 6057 "configure"
+#line 6092 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -6064,7 +6099,7 @@ int main() {
dlopen()
; return 0; }
EOF
-if { (eval echo configure:6068: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6103: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -6090,12 +6125,12 @@ fi
echo $ac_n "checking for optreset""... $ac_c" 1>&6
-echo "configure:6094: checking for optreset" >&5
+echo "configure:6129: checking for optreset" >&5
if eval "test \"`echo '$''{'ac_cv_have_optreset'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6099 "configure"
+#line 6134 "configure"
#include "confdefs.h"
#include <unistd.h>
EOF
@@ -6186,20 +6221,20 @@ fi
echo $ac_n "checking whether linker accepts -static""... $ac_c" 1>&6
-echo "configure:6190: checking whether linker accepts -static" >&5
+echo "configure:6225: checking whether linker accepts -static" >&5
if eval "test \"`echo '$''{'ac_cv_e2fsprogs_use_static'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
SAVE_LDFLAGS=$LDFLAGS; LDFLAGS="$LDFLAGS -static"
cat > conftest.$ac_ext <<EOF
-#line 6196 "configure"
+#line 6231 "configure"
#include "confdefs.h"
#include <stdio.h>
int main() {
fflush(stdout);
; return 0; }
EOF
-if { (eval echo configure:6203: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6238: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
ac_cv_e2fsprogs_use_static=yes
else
diff --git a/configure.in b/configure.in
index 6b2d2e98..4d05a1b7 100644
--- a/configure.in
+++ b/configure.in
@@ -586,7 +586,7 @@ if test $cross_compiling = no; then
else
AC_CHECK_PROGS(BUILD_CC, gcc cc)
fi
-AC_CHECK_HEADERS(stdlib.h unistd.h stdarg.h errno.h malloc.h mntent.h paths.h dirent.h getopt.h setjmp.h signal.h termios.h linux/fd.h linux/major.h sys/disk.h sys/disklabel.h sys/ioctl.h sys/mkdev.h sys/mount.h sys/sockio.h sys/socket.h sys/sysmacros.h sys/time.h sys/stat.h sys/types.h sys/wait.h sys/resource.h net/if.h netinet/in.h)
+AC_CHECK_HEADERS(stdlib.h unistd.h stdarg.h errno.h malloc.h mntent.h paths.h dirent.h getopt.h setjmp.h signal.h termios.h linux/fd.h linux/major.h sys/disk.h sys/disklabel.h sys/ioctl.h sys/mkdev.h sys/mount.h sys/sockio.h sys/socket.h sys/sysmacros.h sys/time.h sys/stat.h sys/types.h sys/wait.h sys/resource.h net/if.h net/if_dl.h netinet/in.h)
AC_FUNC_VPRINTF
dnl Check to see if dirent has member d_reclen. On cygwin those d_reclen
dnl is not decleared.
@@ -701,6 +701,22 @@ if test "$e2fsprogs_cv_struct_st_flags" = yes; then
AC_DEFINE(HAVE_STAT_FLAGS)
fi
fi
+dnl
+dnl Check for the presence of SA_LEN
+dnl
+AC_MSG_CHECKING(whether struct sockaddr contains sa_len)
+AC_CACHE_VAL(e2fsprogs_cv_sockaddr_sa_len,
+[AC_TRY_COMPILE([#include <sys/types.h>
+#include <sys/socket.h>
+],
+[struct sockaddr sa;
+sa.sa_len;],
+e2fsprogs_cv_sockaddr_sa_len=yes,e2fsprogs_cv_sockaddr_sa_len=no)])
+AC_MSG_RESULT([$]e2fsprogs_cv_sockaddr_sa_len)
+if test $e2fsprogs_cv_sockaddr_sa_len = yes; then
+ AC_DEFINE_UNQUOTED(HAVE_SA_LEN,1,[Define if struct sockaddr contains sa_len])
+fi
+dnl
AC_CHECK_FUNCS(chflags getrusage llseek lseek64 open64 getmntinfo strtoull strcasecmp srandom fchown mallinfo fdatasync strnlen strptime sysconf pathconf posix_memalign memalign valloc)
dnl
dnl Check to see if -lsocket is required (solaris) to make something
diff --git a/lib/uuid/gen_uuid.c b/lib/uuid/gen_uuid.c
index c7e62a60..931d7c1b 100644
--- a/lib/uuid/gen_uuid.c
+++ b/lib/uuid/gen_uuid.c
@@ -43,6 +43,9 @@
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
+#ifdef HAVE_NET_IF_DL_H
+#include <net/if_dl.h>
+#endif
#include "uuidP.h"
@@ -117,7 +120,10 @@ static int get_node_id(unsigned char *node_id)
char buf[1024];
int n, i;
unsigned char *a;
-
+#if defined(HAVE_NET_IF_DL_H) && defined(AF_LINK)
+ struct sockaddr_dl *sdlp;
+#endif
+
/*
* BSD 4.4 defines the size of an ifreq to be
* max(sizeof(ifreq), sizeof(ifreq.ifr_name)+ifreq.ifr_addr.sa_len
@@ -146,7 +152,7 @@ static int get_node_id(unsigned char *node_id)
return -1;
}
n = ifc.ifc_len;
- for (i = 0; i < n; i+= ifreq_size(*ifr) ) {
+ for (i = 0; i < n; i+= ifreq_size(*ifrp) ) {
ifrp = (struct ifreq *)((char *) ifc.ifc_buf+i);
strncpy(ifr.ifr_name, ifrp->ifr_name, IFNAMSIZ);
#ifdef SIOCGIFHWADDR
@@ -159,12 +165,19 @@ static int get_node_id(unsigned char *node_id)
continue;
a = (unsigned char *) ifr.ifr_enaddr;
#else
+#if defined(HAVE_NET_IF_DL_H) && defined(AF_LINK)
+ sdlp = (struct sockaddr_dl *) &ifrp->ifr_addr;
+ if ((sdlp->sdl_family != AF_LINK) || (sdlp->sdl_alen < 6))
+ continue;
+ a = (unsigned char *) &sdlp->sdl_data[sdlp->sdl_nlen];
+#else
/*
* XXX we don't have a way of getting the hardware
* address
*/
close(sd);
return 0;
+#endif /* HAVE_NET_IF_DL_H && AF_LINK */
#endif /* SIOCGENADDR */
#endif /* SIOCGIFHWADDR */
if (!a[0] && !a[1] && !a[2] && !a[3] && !a[4] && !a[5])