On 01/08/14 15:43, Samuli Suominen wrote:
> Please, #include "missing.h" in src/shared/util.h to fix the build for
> old systems w/ no system header defining
> the struct

I ran into the same thing on a slightly odd system (Debian 7 with a
backported kernel, so it has Linux 3.14 but only glibc 2.13) and
initially tried an identical patch, but it turned out to break the
build, because missing.h redefines a bunch of stuff from <linux/btrfs.h>
if HAVE_LINUX_BTRFS_H is not defined, and if you don't include config.h,
that symbol will never be defined.

The attached patch is what I'm using, and might be closer to correct,
although I think to be fully portable (e.g. to Debian 7 with its
original Linux 3.2) the inclusion of <linux/btrfs.h> might need to be
wrapped in #ifdef HAVE_LINUX_BTRFS_H too. I haven't tried that
configuration.

Best-practice in Autotools projects seems to be to include config.h at
the very top of every .c file, whether it is currently needed or not.

Thanks for reminding me to upstream this!

    S

>From 669af691816ee56dbf097ae7f0e4f207af5929f5 Mon Sep 17 00:00:00 2001
From: Simon McVittie <simon.mcvit...@collabora.co.uk>
Date: Tue, 29 Jul 2014 14:40:18 +0100
Subject: [PATCH] util.h: include missing.h, for struct file_handle

This breaks udev-builtin-btrfs.c, which reinvents some of missing.h,
so use missing.h there too.
---
 src/shared/util.h             |  1 +
 src/udev/udev-builtin-btrfs.c | 10 ++++------
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/shared/util.h b/src/shared/util.h
index b00395c..e40687e 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -43,6 +43,7 @@
 #include <mntent.h>
 
 #include "macro.h"
+#include "missing.h"
 #include "time-util.h"
 
 union dirent_storage {
diff --git a/src/udev/udev-builtin-btrfs.c b/src/udev/udev-builtin-btrfs.c
index f7bea69..5e1e262 100644
--- a/src/udev/udev-builtin-btrfs.c
+++ b/src/udev/udev-builtin-btrfs.c
@@ -17,6 +17,8 @@
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
+#include "config.h"
+
 #include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
@@ -24,15 +26,11 @@
 #include <fcntl.h>
 #include <errno.h>
 #include <sys/ioctl.h>
+#include <linux/btrfs.h>
 
+#include "missing.h"
 #include "udev.h"
 
-#define BTRFS_PATH_NAME_MAX 4087
-struct btrfs_ioctl_vol_args {
-        int64_t fd;
-        char name[BTRFS_PATH_NAME_MAX + 1];
-};
-#define BTRFS_IOCTL_MAGIC 0x94
 #define BTRFS_IOC_DEVICES_READY _IOR(BTRFS_IOCTL_MAGIC, 39, struct btrfs_ioctl_vol_args)
 
 static int builtin_btrfs(struct udev_device *dev, int argc, char *argv[], bool test)
-- 
2.0.1

_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to