mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-02 01:18:26 +03:00
Add timestamp functions with --disable-realtime configure option. [AJ]
This commit is contained in:
parent
34fadac485
commit
8b1a3214b5
@ -1,5 +1,6 @@
|
||||
Version 2.02.11 -
|
||||
=====================================
|
||||
Add timestamp functions with --disable-realtime configure option.
|
||||
Add %VG, %LV and %FREE suffices to lvcreate/lvresize --extents arg.
|
||||
Fix two potential NULL pointer derefs in error cases in vg_read().
|
||||
Separate --enable-cluster from locking lib options in lvmconf.sh.
|
||||
|
108
configure
vendored
108
configure
vendored
@ -310,7 +310,7 @@ ac_includes_default="\
|
||||
#endif"
|
||||
|
||||
ac_default_prefix=/usr
|
||||
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os AWK CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LN_S SET_MAKE RANLIB ac_ct_RANLIB CFLOW_CMD CSCOPE_CMD CPP EGREP ALLOCA LIBOBJS POW_LIB MSGFMT MODPROBE_CMD JOBS STATIC_LINK LVM1 POOL SNAPSHOTS MIRRORS OWNER GROUP COPTIMISE_FLAG CLDFLAGS CLDWHOLEARCHIVE CLDNOWHOLEARCHIVE LDDEPS LIB_SUFFIX LVM_VERSION LVM1_FALLBACK DEBUG DEVMAPPER HAVE_LIBDL HAVE_SELINUX CMDLIB LOCALEDIR CONFDIR STATICDIR INTL_PACKAGE INTL CLVMD CLUSTER FSADM DMEVENTD LTLIBOBJS'
|
||||
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os AWK CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LN_S SET_MAKE RANLIB ac_ct_RANLIB CFLOW_CMD CSCOPE_CMD CPP EGREP ALLOCA LIBOBJS POW_LIB MSGFMT MODPROBE_CMD JOBS STATIC_LINK LVM1 POOL SNAPSHOTS MIRRORS OWNER GROUP COPTIMISE_FLAG CLDFLAGS CLDWHOLEARCHIVE CLDNOWHOLEARCHIVE LDDEPS LIB_SUFFIX LVM_VERSION LVM1_FALLBACK DEBUG DEVMAPPER HAVE_LIBDL HAVE_SELINUX HAVE_REALTIME CMDLIB LOCALEDIR CONFDIR STATICDIR INTL_PACKAGE INTL CLVMD CLUSTER FSADM DMEVENTD LTLIBOBJS'
|
||||
ac_subst_files=''
|
||||
|
||||
# Initialize some variables set by options.
|
||||
@ -853,6 +853,7 @@ Optional Features:
|
||||
statically. Default is dynamic linking
|
||||
--enable-readline Enable readline support
|
||||
--disable-selinux Disable selinux support
|
||||
--disable-realtime Disable realtime clock support
|
||||
--enable-debug Enable debugging
|
||||
--disable-devmapper Disable device-mapper interaction
|
||||
--disable-o_direct Disable O_DIRECT
|
||||
@ -1459,6 +1460,7 @@ case "$host_os" in
|
||||
DEVMAPPER=yes
|
||||
ODIRECT=yes
|
||||
SELINUX=yes
|
||||
REALTIME=yes
|
||||
CLUSTER=internal
|
||||
FSADM=no ;;
|
||||
darwin*)
|
||||
@ -1473,6 +1475,7 @@ case "$host_os" in
|
||||
DEVMAPPER=yes
|
||||
ODIRECT=no
|
||||
SELINUX=no
|
||||
REALTIME=no
|
||||
CLUSTER=none
|
||||
FSADM=no ;;
|
||||
esac
|
||||
@ -7431,6 +7434,17 @@ fi;
|
||||
echo "$as_me:$LINENO: result: $SELINUX" >&5
|
||||
echo "${ECHO_T}$SELINUX" >&6
|
||||
|
||||
################################################################################
|
||||
echo "$as_me:$LINENO: checking whether to enable realtime support" >&5
|
||||
echo $ECHO_N "checking whether to enable realtime support... $ECHO_C" >&6
|
||||
# Check whether --enable-realtime or --disable-realtime was given.
|
||||
if test "${enable_realtime+set}" = set; then
|
||||
enableval="$enable_realtime"
|
||||
REALTIME=$enableval
|
||||
fi;
|
||||
echo "$as_me:$LINENO: result: $REALTIME" >&5
|
||||
echo "${ECHO_T}$REALTIME" >&6
|
||||
|
||||
################################################################################
|
||||
echo "$as_me:$LINENO: checking whether to build cluster LVM daemon" >&5
|
||||
echo $ECHO_N "checking whether to build cluster LVM daemon... $ECHO_C" >&6
|
||||
@ -8420,6 +8434,96 @@ echo "$as_me: WARNING: Disabling selinux" >&2;}
|
||||
fi
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
if test x$REALTIME = xyes; then
|
||||
echo "$as_me:$LINENO: checking for clock_gettime function" >&5
|
||||
echo $ECHO_N "checking for clock_gettime function... $ECHO_C" >&6
|
||||
echo "$as_me:$LINENO: checking for clock_gettime in -lrt" >&5
|
||||
echo $ECHO_N "checking for clock_gettime in -lrt... $ECHO_C" >&6
|
||||
if test "${ac_cv_lib_rt_clock_gettime+set}" = set; then
|
||||
echo $ECHO_N "(cached) $ECHO_C" >&6
|
||||
else
|
||||
ac_check_lib_save_LIBS=$LIBS
|
||||
LIBS="-lrt $LIBS"
|
||||
cat >conftest.$ac_ext <<_ACEOF
|
||||
/* confdefs.h. */
|
||||
_ACEOF
|
||||
cat confdefs.h >>conftest.$ac_ext
|
||||
cat >>conftest.$ac_ext <<_ACEOF
|
||||
/* end confdefs.h. */
|
||||
|
||||
/* Override any gcc2 internal prototype to avoid an error. */
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
/* We use char because int might match the return type of a gcc2
|
||||
builtin and then its argument prototype would still apply. */
|
||||
char clock_gettime ();
|
||||
int
|
||||
main ()
|
||||
{
|
||||
clock_gettime ();
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
rm -f conftest.$ac_objext conftest$ac_exeext
|
||||
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
|
||||
(eval $ac_link) 2>conftest.er1
|
||||
ac_status=$?
|
||||
grep -v '^ *+' conftest.er1 >conftest.err
|
||||
rm -f conftest.er1
|
||||
cat conftest.err >&5
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); } &&
|
||||
{ ac_try='test -z "$ac_c_werror_flag"
|
||||
|| test ! -s conftest.err'
|
||||
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||
(eval $ac_try) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; } &&
|
||||
{ ac_try='test -s conftest$ac_exeext'
|
||||
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||
(eval $ac_try) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; }; then
|
||||
ac_cv_lib_rt_clock_gettime=yes
|
||||
else
|
||||
echo "$as_me: failed program was:" >&5
|
||||
sed 's/^/| /' conftest.$ac_ext >&5
|
||||
|
||||
ac_cv_lib_rt_clock_gettime=no
|
||||
fi
|
||||
rm -f conftest.err conftest.$ac_objext \
|
||||
conftest$ac_exeext conftest.$ac_ext
|
||||
LIBS=$ac_check_lib_save_LIBS
|
||||
fi
|
||||
echo "$as_me:$LINENO: result: $ac_cv_lib_rt_clock_gettime" >&5
|
||||
echo "${ECHO_T}$ac_cv_lib_rt_clock_gettime" >&6
|
||||
if test $ac_cv_lib_rt_clock_gettime = yes; then
|
||||
HAVE_REALTIME=yes
|
||||
else
|
||||
HAVE_REALTIME=no
|
||||
fi
|
||||
|
||||
echo "$as_me:$LINENO: result: $HAVE_REALTIME" >&5
|
||||
echo "${ECHO_T}$HAVE_REALTIME" >&6
|
||||
|
||||
if test x$HAVE_REALTIME = xyes; then
|
||||
|
||||
cat >>confdefs.h <<\_ACEOF
|
||||
#define HAVE_REALTIME 1
|
||||
_ACEOF
|
||||
|
||||
LIBS="-lrt $LIBS"
|
||||
else
|
||||
{ echo "$as_me:$LINENO: WARNING: Disabling realtime clock" >&5
|
||||
echo "$as_me: WARNING: Disabling realtime clock" >&2;}
|
||||
fi
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
|
||||
for ac_header in getopt.h
|
||||
@ -11095,6 +11199,7 @@ fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
################################################################################
|
||||
@ -11789,6 +11894,7 @@ s,@DEBUG@,$DEBUG,;t t
|
||||
s,@DEVMAPPER@,$DEVMAPPER,;t t
|
||||
s,@HAVE_LIBDL@,$HAVE_LIBDL,;t t
|
||||
s,@HAVE_SELINUX@,$HAVE_SELINUX,;t t
|
||||
s,@HAVE_REALTIME@,$HAVE_REALTIME,;t t
|
||||
s,@CMDLIB@,$CMDLIB,;t t
|
||||
s,@LOCALEDIR@,$LOCALEDIR,;t t
|
||||
s,@CONFDIR@,$CONFDIR,;t t
|
||||
|
25
configure.in
25
configure.in
@ -42,6 +42,7 @@ case "$host_os" in
|
||||
DEVMAPPER=yes
|
||||
ODIRECT=yes
|
||||
SELINUX=yes
|
||||
REALTIME=yes
|
||||
CLUSTER=internal
|
||||
FSADM=no ;;
|
||||
darwin*)
|
||||
@ -56,6 +57,7 @@ case "$host_os" in
|
||||
DEVMAPPER=yes
|
||||
ODIRECT=no
|
||||
SELINUX=no
|
||||
REALTIME=no
|
||||
CLUSTER=none
|
||||
FSADM=no ;;
|
||||
esac
|
||||
@ -282,6 +284,13 @@ AC_ARG_ENABLE(selinux, [ --disable-selinux Disable selinux support],
|
||||
SELINUX=$enableval)
|
||||
AC_MSG_RESULT($SELINUX)
|
||||
|
||||
################################################################################
|
||||
dnl -- Disable realtime clock support
|
||||
AC_MSG_CHECKING(whether to enable realtime support)
|
||||
AC_ARG_ENABLE(realtime, [ --disable-realtime Disable realtime clock support],
|
||||
REALTIME=$enableval)
|
||||
AC_MSG_RESULT($REALTIME)
|
||||
|
||||
################################################################################
|
||||
dnl -- Build cluster LVM daemon
|
||||
AC_MSG_CHECKING(whether to build cluster LVM daemon)
|
||||
@ -449,6 +458,21 @@ if test x$SELINUX = xyes; then
|
||||
fi
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
dnl -- Check for realtime clock support
|
||||
if test x$REALTIME = xyes; then
|
||||
AC_MSG_CHECKING(for clock_gettime function)
|
||||
AC_CHECK_LIB(rt, clock_gettime, HAVE_REALTIME=yes, HAVE_REALTIME=no)
|
||||
AC_MSG_RESULT($HAVE_REALTIME)
|
||||
|
||||
if test x$HAVE_REALTIME = xyes; then
|
||||
AC_DEFINE([HAVE_REALTIME], 1, [Define to 1 to include support for realtime clock.])
|
||||
LIBS="-lrt $LIBS"
|
||||
else
|
||||
AC_MSG_WARN(Disabling realtime clock)
|
||||
fi
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
dnl -- Check for getopt
|
||||
AC_CHECK_HEADERS(getopt.h, AC_DEFINE([HAVE_GETOPTLONG], 1, [Define to 1 to if getopt_long is available.]))
|
||||
@ -578,6 +602,7 @@ AC_SUBST(DEBUG)
|
||||
AC_SUBST(DEVMAPPER)
|
||||
AC_SUBST(HAVE_LIBDL)
|
||||
AC_SUBST(HAVE_SELINUX)
|
||||
AC_SUBST(HAVE_REALTIME)
|
||||
AC_SUBST(CMDLIB)
|
||||
AC_SUBST(MSGFMT)
|
||||
AC_SUBST(LOCALEDIR)
|
||||
|
@ -79,6 +79,7 @@ SOURCES =\
|
||||
misc/lvm-file.c \
|
||||
misc/lvm-string.c \
|
||||
misc/lvm-wrappers.c \
|
||||
misc/timestamp.c \
|
||||
mm/memlock.c \
|
||||
regex/matcher.c \
|
||||
regex/parse_rx.c \
|
||||
|
@ -174,6 +174,9 @@
|
||||
/* Define to 1 if you have the <selinux/selinux.h> header file. */
|
||||
#undef HAVE_SELINUX_SELINUX_H
|
||||
|
||||
/* define to 1 to include support for realtime clock */
|
||||
#undef HAVE_REALTIME
|
||||
|
||||
/* Define to 1 if you have the `setlocale' function. */
|
||||
#undef HAVE_SETLOCALE
|
||||
|
||||
|
132
lib/misc/timestamp.c
Normal file
132
lib/misc/timestamp.c
Normal file
@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Copyright (C) 2006 Rackable Systems All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU General Public License v.2.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
* Abstract out the time methods used so they can be adjusted later -
|
||||
* the results of these routines should stay in-core. This implementation
|
||||
* requires librt.
|
||||
*/
|
||||
|
||||
#include "lib.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "timestamp.h"
|
||||
|
||||
/*
|
||||
* The realtime section uses clock_gettime with the CLOCK_MONOTONIC
|
||||
* parameter to prevent issues with time warps
|
||||
*/
|
||||
#ifdef HAVE_REALTIME
|
||||
|
||||
#include <time.h>
|
||||
#include <bits/time.h>
|
||||
|
||||
struct timestamp {
|
||||
struct timespec t;
|
||||
};
|
||||
|
||||
struct timestamp *get_timestamp(void)
|
||||
{
|
||||
struct timestamp *ts = NULL;
|
||||
int err = 0;
|
||||
|
||||
if (!(ts = dm_malloc(sizeof(*ts))))
|
||||
return_NULL;
|
||||
|
||||
if (clock_gettime(CLOCK_MONOTONIC, &ts->t)) {
|
||||
log_sys_error("clock_gettime", "get_timestamp");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return ts;
|
||||
}
|
||||
|
||||
/* cmp_timestamp: Compare two timestamps
|
||||
*
|
||||
* Return: -1 if t1 is less than t2
|
||||
* 0 if t1 is equal to t2
|
||||
* 1 if t1 is greater than t2
|
||||
*/
|
||||
int cmp_timestamp(struct timestamp *t1, struct timestamp *t2)
|
||||
{
|
||||
if(t1->t.tv_sec < t2->t.tv_sec)
|
||||
return -1;
|
||||
if(t1->t.tv_sec > t2->t.tv_sec)
|
||||
return 1;
|
||||
|
||||
if(t1->t.tv_nsec < t2->t.tv_nsec)
|
||||
return -1;
|
||||
if(t1->t.tv_nsec > t2->t.tv_nsec)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else /* ! HAVE_REALTIME */
|
||||
|
||||
/*
|
||||
* The !realtime section just uses gettimeofday and is therefore subject
|
||||
* to ntp-type time warps - not sure if should allow that.
|
||||
*/
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
struct timestamp {
|
||||
struct timeval t;
|
||||
};
|
||||
|
||||
struct timestamp *get_timestamp(void)
|
||||
{
|
||||
struct timestamp *ts = NULL;
|
||||
int err = 0;
|
||||
|
||||
if (!(ts = dm_malloc(sizeof(*ts))))
|
||||
return_NULL;
|
||||
|
||||
if ((err = gettimeofday(&ts->t, NULL))) {
|
||||
log_sys_error("gettimeofday", "get_timestamp");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return ts;
|
||||
}
|
||||
|
||||
/* cmp_timestamp: Compare two timestamps
|
||||
*
|
||||
* Return: -1 if t1 is less than t2
|
||||
* 0 if t1 is equal to t2
|
||||
* 1 if t1 is greater than t2
|
||||
*/
|
||||
int cmp_timestamp(struct timestamp *t1, struct timestamp *t2)
|
||||
{
|
||||
if(t1->t.tv_sec < t2->t.tv_sec)
|
||||
return -1;
|
||||
if(t1->t.tv_sec > t2->t.tv_sec)
|
||||
return 1;
|
||||
|
||||
if(t1->t.tv_usec < t2->t.tv_usec)
|
||||
return -1;
|
||||
if(t1->t.tv_usec > t2->t.tv_usec)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* HAVE_REALTIME */
|
||||
|
||||
void destroy_timestamp(struct timestamp *t)
|
||||
{
|
||||
if (t)
|
||||
dm_free(t);
|
||||
}
|
33
lib/misc/timestamp.h
Normal file
33
lib/misc/timestamp.h
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (C) 2006 Rackable Systems All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU General Public License v.2.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef _LVM_TIMESTAMP_H
|
||||
#define _LVM_TIMESTAMP_H
|
||||
|
||||
struct timestamp;
|
||||
|
||||
struct timestamp *get_timestamp(void);
|
||||
|
||||
/* cmp_timestamp: Compare two timestamps
|
||||
*
|
||||
* Return: -1 if t1 is less than t2
|
||||
* 0 if t1 is equal to t2
|
||||
* 1 if t1 is greater than t2
|
||||
*/
|
||||
int cmp_timestamp(struct timestamp *t1, struct timestamp *t2);
|
||||
|
||||
void destroy_timestamp(struct timestamp *t);
|
||||
|
||||
#endif /* _LVM_TIMESTAMP_H */
|
||||
|
Loading…
Reference in New Issue
Block a user