Bug#759008: libtdb1: FTBFS on hurd-i386
Package: libtdb1
Version: 1.3.0-1.1
Severity: important
Tags: patch
Hello,
tdb fails to build on hurd-i386 (blocking ldb and thus samba) because
it uses two features that are not yet implemented on GNU/Hurd: msync(1)
and partial file locking.
You'll find attached two small patches that make it build.
The first patch adds a configure test for partial file locking and make
tdb use whole file locking when it's not supported.
The second one adds a configure test for msync(1) and correct tdb's
code accordingly.
Please note that this package should be built with 'nocheck' because
some tests do not run well without partial file locking. The tools in
tdbtools/ run fine though.
Please also note that hurd-any should be added to debian/control so it
gets built on hurd-i386.
Thanks!
Manuel Menal
-- System Information:
Debian Release: jessie/sid
APT prefers unreleased
APT policy: (500, 'unreleased'), (500, 'unstable')
Architecture: hurd-i386 (i686-AT386)
Kernel: GNU-Mach 1.4-486/Hurd-0.5
Locale: LANG=fr_FR.utf8, LC_CTYPE=fr_FR.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages libtdb1 depends on:
ii libc0.3 2.19-9
ii multiarch-support 2.19-9
libtdb1 recommends no packages.
libtdb1 suggests no packages.
-- no debconf information
diff -Nurp tdb-1.3.0.orig/common/lock.c tdb-1.3.0/common/lock.c
--- tdb-1.3.0.orig/common/lock.c 2014-08-18 14:59:55.000000000 -0400
+++ tdb-1.3.0/common/lock.c 2014-08-18 15:01:18.000000000 -0400
@@ -49,8 +49,14 @@ static int fcntl_lock(struct tdb_context
fl.l_type = rw;
fl.l_whence = SEEK_SET;
+#ifdef HAVE_FCNTL_LOCK_PARTIAL
fl.l_start = off;
fl.l_len = len;
+#else
+ /* Some platforms (like GNU/Hurd) only support whole file locking */
+ fl.l_start = 0;
+ fl.l_len = 0;
+#endif
fl.l_pid = 0;
cmd = waitflag ? F_SETLKW : F_SETLK;
@@ -130,8 +136,14 @@ static int fcntl_unlock(struct tdb_conte
fl.l_type = F_UNLCK;
fl.l_whence = SEEK_SET;
+#ifdef HAVE_FCNTL_LOCK_PARTIAL
fl.l_start = off;
fl.l_len = len;
+#else
+ /* Some platforms (like GNU/Hurd) only support whole file locking */
+ fl.l_start = 0;
+ fl.l_len = 0;
+#endif
fl.l_pid = 0;
return fcntl(tdb->fd, F_SETLKW, &fl);
diff -Nurp tdb-1.3.0.orig/lib/replace/wscript tdb-1.3.0/lib/replace/wscript
--- tdb-1.3.0.orig/lib/replace/wscript 2014-08-18 14:59:55.000000000 -0400
+++ tdb-1.3.0/lib/replace/wscript 2014-08-18 15:00:32.000000000 -0400
@@ -134,6 +134,23 @@ struct foo bar = { .y = 'X', .x = 1 };
addmain=False,
msg='Checking for O_DIRECT flag to open(2)')
+ if conf.CHECK_HEADERS('fcntl.h'):
+ conf.CHECK_CODE('''
+ #include <fcntl.h>
+ int main (void) { int fd = open("/dev/null", O_RDWR);
+ struct flock fl;
+ fl.l_type = F_WRLCK;
+ fl.l_whence = SEEK_SET;
+ fl.l_start = fl.l_len = 100;
+ fl.l_pid = 0;
+ return fcntl(fd, F_SETLK, &fl); }
+ ''',
+ define='HAVE_FCNTL_LOCK_PARTIAL',
+ addmain=False,
+ execute=True,
+ msg='Checking for partial locking support using fcntl(2)')
+
+
conf.CHECK_TYPES('"long long" intptr_t uintptr_t ptrdiff_t comparison_fn_t')
conf.CHECK_TYPE('_Bool', define='HAVE__Bool')
conf.CHECK_TYPE('bool', define='HAVE_BOOL')
diff -Nurp tdb-1.3.0.orig/common/transaction.c tdb-1.3.0/common/transaction.c
--- tdb-1.3.0.orig/common/transaction.c 2014-08-18 14:59:55.000000000 -0400
+++ tdb-1.3.0/common/transaction.c 2014-08-18 15:21:26.000000000 -0400
@@ -554,7 +554,7 @@ static int transaction_sync(struct tdb_c
TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction: fsync failed\n"));
return -1;
}
-#ifdef HAVE_MMAP
+#ifdef HAVE_MSYNC
if (tdb->map_ptr) {
tdb_off_t moffset = offset & ~(tdb->page_size-1);
if (msync(moffset + (char *)tdb->map_ptr,
diff -Nurp tdb-1.3.0.orig/lib/replace/wscript tdb-1.3.0/lib/replace/wscript
--- tdb-1.3.0.orig/lib/replace/wscript 2014-08-18 14:59:55.000000000 -0400
+++ tdb-1.3.0/lib/replace/wscript 2014-08-18 15:22:53.000000000 -0400
@@ -293,7 +293,7 @@ struct foo bar = { .y = 'X', .x = 1 };
conf.CHECK_FUNCS('if_nametoindex strerror_r')
conf.CHECK_FUNCS('getdirentries getdents syslog')
conf.CHECK_FUNCS('gai_strerror get_current_dir_name')
- conf.CHECK_FUNCS('timegm getifaddrs freeifaddrs mmap setgroups syscall setsid')
+ conf.CHECK_FUNCS('timegm getifaddrs freeifaddrs mmap msync setgroups syscall setsid')
conf.CHECK_FUNCS('getgrent_r getgrgid_r getgrnam_r getgrouplist getpagesize')
conf.CHECK_FUNCS('getpwent_r getpwnam_r getpwuid_r epoll_create')
diff -Nurp tdb-1.3.0.orig/test/run-transaction-expand.c tdb-1.3.0/test/run-transaction-expand.c
--- tdb-1.3.0.orig/test/run-transaction-expand.c 2014-08-18 14:59:55.000000000 -0400
+++ tdb-1.3.0/test/run-transaction-expand.c 2014-08-18 15:21:56.000000000 -0400
@@ -9,7 +9,7 @@ static inline int fake_fsync(int fd)
}
#define fsync fake_fsync
-#ifdef MS_SYNC
+#ifndef HAVE_MSYNC
static inline int fake_msync(void *addr, size_t length, int flags)
{
sync_counts++;
Reply to: