lvm2: update to 2.02.114 and unbreak musl builds.

This commit is contained in:
Juan RP 2014-12-28 08:35:54 +01:00
parent 16a8baf04a
commit af5039f21b
3 changed files with 164 additions and 4 deletions

View file

@ -0,0 +1,111 @@
--- lib/commands/toolcontext.c
+++ lib/commands/toolcontext.c
@@ -1336,7 +1336,10 @@
/*
* Close and reopen stream on file descriptor fd.
*/
-static int _reopen_stream(FILE *stream, int fd, const char *mode, const char *name, FILE **new_stream)
+#ifdef __GLIBC__
+#define _reopen_stream(stream, fd, mode, name) __reopen_stream(stream, fd, mode, name, &stream)
+
+static int __reopen_stream(FILE *stream, int fd, const char *mode, const char *name, FILE **new_stream)
{
int fd_copy, new_fd;
@@ -1363,6 +1366,9 @@
return 1;
}
+#else
+#define _reopen_stream(stream, fd, mode, name) (freopen(NULL, mode, stream) != NULL)
+#endif
/* Entry point */
struct cmd_context *create_toolcontext(unsigned is_long_lived,
@@ -1371,7 +1377,6 @@
unsigned threaded)
{
struct cmd_context *cmd;
- FILE *new_stream;
int flags;
#ifdef M_MMAP_MAX
@@ -1421,9 +1426,8 @@
if (is_valid_fd(STDIN_FILENO) &&
((flags = fcntl(STDIN_FILENO, F_GETFL)) > 0) &&
(flags & O_ACCMODE) != O_WRONLY) {
- if (!_reopen_stream(stdin, STDIN_FILENO, "r", "stdin", &new_stream))
+ if (!_reopen_stream(stdin, STDIN_FILENO, "r", "stdin"))
goto_out;
- stdin = new_stream;
if (setvbuf(stdin, cmd->linebuffer, _IOLBF, linebuffer_size)) {
log_sys_error("setvbuf", "");
goto out;
@@ -1433,9 +1437,8 @@
if (is_valid_fd(STDOUT_FILENO) &&
((flags = fcntl(STDOUT_FILENO, F_GETFL)) > 0) &&
(flags & O_ACCMODE) != O_RDONLY) {
- if (!_reopen_stream(stdout, STDOUT_FILENO, "w", "stdout", &new_stream))
+ if (!_reopen_stream(stdout, STDOUT_FILENO, "w", "stdout"))
goto_out;
- stdout = new_stream;
if (setvbuf(stdout, cmd->linebuffer + linebuffer_size,
_IOLBF, linebuffer_size)) {
log_sys_error("setvbuf", "");
@@ -1715,7 +1718,6 @@
void destroy_toolcontext(struct cmd_context *cmd)
{
struct dm_config_tree *cft_cmdline;
- FILE *new_stream;
int flags;
if (cmd->dump_filter && cmd->filter && cmd->filter->dump &&
@@ -1752,8 +1754,7 @@
if (is_valid_fd(STDIN_FILENO) &&
((flags = fcntl(STDIN_FILENO, F_GETFL)) > 0) &&
(flags & O_ACCMODE) != O_WRONLY) {
- if (_reopen_stream(stdin, STDIN_FILENO, "r", "stdin", &new_stream)) {
- stdin = new_stream;
+ if (_reopen_stream(stdin, STDIN_FILENO, "r", "stdin")) {
setlinebuf(stdin);
} else
cmd->linebuffer = NULL; /* Leave buffer in place (deliberate leak) */
@@ -1762,8 +1763,7 @@
if (is_valid_fd(STDOUT_FILENO) &&
((flags = fcntl(STDOUT_FILENO, F_GETFL)) > 0) &&
(flags & O_ACCMODE) != O_RDONLY) {
- if (_reopen_stream(stdout, STDOUT_FILENO, "w", "stdout", &new_stream)) {
- stdout = new_stream;
+ if (_reopen_stream(stdout, STDOUT_FILENO, "w", "stdout")) {
setlinebuf(stdout);
} else
cmd->linebuffer = NULL; /* Leave buffer in place (deliberate leak) */
--- tools/lvmcmdline.c
+++ tools/lvmcmdline.c
@@ -1252,7 +1252,7 @@
int err = is_valid_fd(STDERR_FILENO);
if (!is_valid_fd(STDIN_FILENO) &&
- !(stdin = fopen(_PATH_DEVNULL, "r"))) {
+ !freopen(_PATH_DEVNULL, "r", stdin)) {
if (err)
perror("stdin stream open");
else
@@ -1262,7 +1262,7 @@
}
if (!is_valid_fd(STDOUT_FILENO) &&
- !(stdout = fopen(_PATH_DEVNULL, "w"))) {
+ !freopen(_PATH_DEVNULL, "w", stdout)) {
if (err)
perror("stdout stream open");
/* else no stdout */
@@ -1270,7 +1270,7 @@
}
if (!is_valid_fd(STDERR_FILENO) &&
- !(stderr = fopen(_PATH_DEVNULL, "w"))) {
+ !freopen(_PATH_DEVNULL, "w", stderr)) {
printf("stderr stream open: %s\n",
strerror(errno));
return 0;

View file

@ -0,0 +1,49 @@
Portability fixes:
- Use fcntl.h for O_RDONLY and friends.
- Only use mallinfo with glibc.
- Use PTHREAD_MUTEX_RECURSIVE rather than the _NP (non portable) variants.
--- lib/mm/memlock.c 2014-11-29 00:07:42.000000000 +0100
+++ lib/mm/memlock.c 2014-12-28 08:25:12.424935165 +0100
@@ -133,7 +133,7 @@ static void _touch_memory(void *mem, siz
static void _allocate_memory(void)
{
-#ifndef VALGRIND_POOL
+#if !defined(VALGRIND_POOL) && defined(__GLIBC__)
void *stack_mem;
struct rlimit limit;
int i, area = 0, missing = _size_malloc_tmp, max_areas = 32, hblks;
--- daemons/lvmetad/lvmetad-core.c 2014-11-29 00:07:42.000000000 +0100
+++ daemons/lvmetad/lvmetad-core.c 2014-12-28 08:29:16.406946052 +0100
@@ -124,7 +124,7 @@ static struct dm_config_tree *lock_vg(lv
if (!(vg = dm_hash_lookup(s->lock.vg, id))) {
if (!(vg = malloc(sizeof(pthread_mutex_t))) ||
pthread_mutexattr_init(&rec) ||
- pthread_mutexattr_settype(&rec, PTHREAD_MUTEX_RECURSIVE_NP) ||
+ pthread_mutexattr_settype(&rec, PTHREAD_MUTEX_RECURSIVE) ||
pthread_mutex_init(vg, &rec))
goto bad;
if (!dm_hash_insert(s->lock.vg, id, vg)) {
@@ -1152,7 +1152,7 @@ static int init(daemon_state *s)
ls->log = s->log;
pthread_mutexattr_init(&rec);
- pthread_mutexattr_settype(&rec, PTHREAD_MUTEX_RECURSIVE_NP);
+ pthread_mutexattr_settype(&rec, PTHREAD_MUTEX_RECURSIVE);
pthread_mutex_init(&ls->lock.pvid_to_pvmeta, &rec);
pthread_mutex_init(&ls->lock.vgid_to_metadata, &rec);
pthread_mutex_init(&ls->lock.pvid_to_vgid, NULL);
--- libdaemon/server/daemon-server.c 2014-11-29 00:07:42.000000000 +0100
+++ libdaemon/server/daemon-server.c 2014-12-28 08:22:40.985928408 +0100
@@ -14,6 +14,7 @@
#include "daemon-server.h"
#include "daemon-log.h"
+#include <fcntl.h>
#include <dlfcn.h>
#include <errno.h>
#include <pthread.h>

View file

@ -1,7 +1,7 @@
# Template file for 'lvm2'
pkgname=lvm2
version=2.02.112
revision=2
version=2.02.114
revision=1
wrksrc=LVM2.${version}
build_style=gnu-configure
configure_args="--disable-selinux --enable-readline --enable-pkgconfig
@ -24,8 +24,9 @@ short_desc="Logical Volume Manager 2 utilities"
maintainer="Juan RP <xtraeme@gmail.com>"
homepage="http://sourceware.org/lvm2/"
license="GPL-2, LGPL-2.1"
update_pkgname="LVM2."
distfiles="ftp://sources.redhat.com/pub/lvm2/LVM2.${version}.tgz"
checksum=495fced8ec1a8b14912359f4eb97299e0b2d2bc0dfc9a50820daf7bbb3ff67e5
checksum=de9cb0acfb9c5a6afa6184160c9e066f19043677f91a72c741d153efcd2874a5
post_install() {
if [ "$build_option_systemd" ]; then
@ -52,7 +53,6 @@ device-mapper-devel_package() {
}
device-mapper_package() {
short_desc="Device Mapper userspace library and tools"
replaces="lvm2<2.02.95_3"
pkg_install() {
vmove "usr/sbin/dm*"
vmove "usr/lib/libdevmapper*.so.*"