iphlpapi: Implement find_owning_pid() on FreeBSD.

This commit is contained in:
Charles Davis 2013-08-19 12:07:26 -06:00 committed by Alexandre Julliard
parent e3b9167335
commit 3a2247f7d3
5 changed files with 163 additions and 1 deletions

73
configure vendored
View File

@ -638,6 +638,7 @@ LDPATH
UNWINDFLAGS
BUILTINFLAG
EXTRACFLAGS
LIBPROCSTAT
LIBKSTAT
LIBOPENAL
MPG123_LIBS
@ -6031,6 +6032,7 @@ for ac_header in \
sys/prctl.h \
sys/protosw.h \
sys/ptrace.h \
sys/queue.h \
sys/resource.h \
sys/scsiio.h \
sys/shm.h \
@ -6046,6 +6048,7 @@ for ac_header in \
sys/timeout.h \
sys/times.h \
sys/uio.h \
sys/user.h \
sys/utsname.h \
sys/vm86.h \
sys/wait.h \
@ -6381,6 +6384,28 @@ fi
done
for ac_header in libprocstat.h
do :
ac_fn_c_check_header_compile "$LINENO" "libprocstat.h" "ac_cv_header_libprocstat_h" "#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_SYS_QUEUE_H
#include <sys/queue.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
"
if test "x$ac_cv_header_libprocstat_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBPROCSTAT_H 1
_ACEOF
fi
done
DLLEXT=""
@ -12367,6 +12392,54 @@ fi
fi
if test "$ac_cv_header_libprocstat_h" = "yes"
then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for procstat_open_sysctl in -lprocstat" >&5
$as_echo_n "checking for procstat_open_sysctl in -lprocstat... " >&6; }
if ${ac_cv_lib_procstat_procstat_open_sysctl+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lprocstat $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char procstat_open_sysctl ();
int
main ()
{
return procstat_open_sysctl ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_procstat_procstat_open_sysctl=yes
else
ac_cv_lib_procstat_procstat_open_sysctl=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_procstat_procstat_open_sysctl" >&5
$as_echo "$ac_cv_lib_procstat_procstat_open_sysctl" >&6; }
if test "x$ac_cv_lib_procstat_procstat_open_sysctl" = xyes; then :
$as_echo "#define HAVE_LIBPROCSTAT 1" >>confdefs.h
LIBPROCSTAT="-lprocstat"
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -lodbc" >&5
$as_echo_n "checking for -lodbc... " >&6; }
if ${ac_cv_lib_soname_odbc+:} false; then :

View File

@ -491,6 +491,7 @@ AC_CHECK_HEADERS(\
sys/prctl.h \
sys/protosw.h \
sys/ptrace.h \
sys/queue.h \
sys/resource.h \
sys/scsiio.h \
sys/shm.h \
@ -506,6 +507,7 @@ AC_CHECK_HEADERS(\
sys/timeout.h \
sys/times.h \
sys/uio.h \
sys/user.h \
sys/utsname.h \
sys/vm86.h \
sys/wait.h \
@ -660,6 +662,17 @@ AC_CHECK_HEADERS([linux/videodev.h linux/videodev2.h libv4l1.h],,,
#include <asm/types.h>
#endif])
AC_CHECK_HEADERS([libprocstat.h],,,
[#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_SYS_QUEUE_H
#include <sys/queue.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif])
dnl **** Check for working dll ****
AC_SUBST(DLLEXT,"")
@ -1723,6 +1736,14 @@ then
AC_SUBST(LIBKSTAT,"-lkstat")])
fi
dnl **** Check for libprocstat ****
if test "$ac_cv_header_libprocstat_h" = "yes"
then
AC_CHECK_LIB(procstat,procstat_open_sysctl,
[AC_DEFINE(HAVE_LIBPROCSTAT, 1, [Define to 1 if you have the `procstat' library (-lprocstat).])
AC_SUBST(LIBPROCSTAT,"-lprocstat")])
fi
dnl **** Check for libodbc ****
WINE_CHECK_SONAME(odbc,SQLConnect,,[AC_DEFINE_UNQUOTED(SONAME_LIBODBC,["libodbc.$LIBEXT"])])

View File

@ -1,7 +1,7 @@
MODULE = iphlpapi.dll
IMPORTLIB = iphlpapi
IMPORTS = advapi32
EXTRALIBS = @RESOLVLIBS@ @LIBKSTAT@
EXTRALIBS = @RESOLVLIBS@ @LIBKSTAT@ @LIBPROCSTAT@
C_SRCS = \
icmp.c \

View File

@ -123,6 +123,19 @@
#ifdef HAVE_SYS_TIHDR_H
#include <sys/tihdr.h>
#endif
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_SYS_QUEUE_H
#include <sys/queue.h>
#endif
#ifdef HAVE_SYS_USER_H
/* Make sure the definitions of struct kinfo_proc are the same. */
#include <sys/user.h>
#endif
#ifdef HAVE_LIBPROCSTAT_H
#include <libprocstat.h>
#endif
#ifdef HAVE_LIBPROC_H
#include <libproc.h>
#endif
@ -1987,6 +2000,52 @@ static unsigned int find_owning_pid( struct pid_map *map, unsigned int num_entri
}
}
return 0;
#elif defined(HAVE_LIBPROCSTAT)
struct procstat *pstat;
struct kinfo_proc *proc;
struct filestat_list *fds;
struct filestat *fd;
struct sockstat sock;
unsigned int i, proc_count;
pstat = procstat_open_sysctl();
if (!pstat) return 0;
for (i = 0; i < num_entries; i++)
{
proc = procstat_getprocs( pstat, KERN_PROC_PID, map[i].unix_pid, &proc_count );
if (!proc || proc_count < 1) continue;
fds = procstat_getfiles( pstat, proc, 0 );
if (!fds)
{
procstat_freeprocs( pstat, proc );
continue;
}
STAILQ_FOREACH( fd, fds, next )
{
char errbuf[_POSIX2_LINE_MAX];
if (fd->fs_type != PS_FST_TYPE_SOCKET) continue;
procstat_get_socket_info( pstat, fd, &sock, errbuf );
if (sock.so_pcb == inode)
{
procstat_freefiles( pstat, fds );
procstat_freeprocs( pstat, proc );
procstat_close( pstat );
return map[i].pid;
}
}
procstat_freefiles( pstat, fds );
procstat_freeprocs( pstat, proc );
}
procstat_close( pstat );
return 0;
#elif defined(HAVE_LIBPROC_H)
struct proc_fdinfo *fds;
struct socket_fdinfo sock;

View File

@ -351,6 +351,12 @@
/* Define to 1 if you have the `ossaudio' library (-lossaudio). */
#undef HAVE_LIBOSSAUDIO
/* Define to 1 if you have the `procstat' library (-lprocstat). */
#undef HAVE_LIBPROCSTAT
/* Define to 1 if you have the <libprocstat.h> header file. */
#undef HAVE_LIBPROCSTAT_H
/* Define to 1 if you have the <libproc.h> header file. */
#undef HAVE_LIBPROC_H
@ -978,6 +984,9 @@
/* Define to 1 if you have the <sys/ptrace.h> header file. */
#undef HAVE_SYS_PTRACE_H
/* Define to 1 if you have the <sys/queue.h> header file. */
#undef HAVE_SYS_QUEUE_H
/* Define to 1 if you have the <sys/resource.h> header file. */
#undef HAVE_SYS_RESOURCE_H