[Buildd-tools-devel] Bug#485637: schroot: does not work on GNU/kFreeBSD
Petr Salinger
Petr.Salinger at seznam.cz
Tue Jun 10 15:56:57 UTC 2008
Package: schroot
Severity: important
Version: 1.2.0-1
Tags: patch
User: glibc-bsd-devel at lists.alioth.debian.org
Usertags: kfreebsd
Hi,
the current version does not work on GNU/kFreeBSD.
It is due to different order of elements in "struct flock"
on Linux and on GNU/kFreeBSD.
The POSIX does not mandate any order of elements, it only lists
mandatory members (l_type, l_whence, l_start, l_len, l_pid).
http://www.opengroup.org/onlinepubs/009695399/basedefs/fcntl.h.html
I tried to use ISO C99 initializer, but it does not work in C++.
http://gcc.gnu.org/onlinedocs/gcc-4.3.0/gcc/Designated-Inits.html
So please, use attached patch or something similar.
Thanks in advance
Petr
-------------- next part --------------
only in patch2:
unchanged:
--- schroot-1.2.0.orig/sbuild/sbuild-lock.cc
+++ schroot-1.2.0/sbuild/sbuild-lock.cc
@@ -163,15 +163,25 @@
// destructor under any circumstances. Any error is logged.
if (locked)
{
+#if 0
struct flock read_lock =
{
- LOCK_NONE,
- SEEK_SET,
- 0,
- 0, // Lock entire file
- 0
+ .l_type = LOCK_NONE,
+ .l_whence = SEEK_SET,
+ .l_start = 0,
+ .l_len = 0, // Lock entire file
+ .l_pid = 0
};
+#else
+ struct flock read_lock;
+
+ read_lock.l_type = LOCK_NONE;
+ read_lock.l_whence = SEEK_SET;
+ read_lock.l_start = 0;
+ read_lock.l_len = 0; // Lock entire file
+ read_lock.l_pid = 0;
+#endif
if (fcntl(this->fd, F_SETLK, &read_lock) == -1)
log_exception_warning(error(UNLOCK, strerror(errno)));
}
@@ -195,14 +205,25 @@
/* Wait on lock until interrupted by a signal if a timeout was set,
otherwise return immediately. */
+#if 0
struct flock read_lock =
{
- lock_type,
- SEEK_SET,
- 0,
- 0, // Lock entire file
- 0
+ .l_type = lock_type,
+ .l_whence = SEEK_SET,
+ .l_start = 0,
+ .l_len = 0, // Lock entire file
+ .l_pid = 0
};
+#else
+ struct flock read_lock;
+
+ read_lock.l_type = lock_type;
+ read_lock.l_whence = SEEK_SET;
+ read_lock.l_start = 0;
+ read_lock.l_len = 0; // Lock entire file
+ read_lock.l_pid = 0;
+#endif
+
if (fcntl(this->fd,
(timeout != 0) ? F_SETLKW : F_SETLK,
More information about the Buildd-tools-devel
mailing list